STK++ 0.9.13
STK::LearnFacade Class Reference

facade design pattern. More...

#include <STK_MixtureFacade.h>

Inheritance diagram for STK::LearnFacade:
Inheritance graph

Public Member Functions

 LearnFacade (IMixtureLearner *p_model)
 constructor.
 
virtual ~LearnFacade ()
 destructor.
 
void setModel (IMixtureLearner *p_model)
 set model in case we want to use the strategy again
 
void createImputeAlgo (Clust::algoLearnType algo, int nbIter, Real epsilon)
 create an imputation algorithm
 
void createSimulAlgo (Clust::algoLearnType algo, int nblongIter)
 create a simulation algorithm
 
virtual bool run ()
 run algorithm
 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 

Protected Attributes

IMixtureLearnerp_model_
 the mixture model to learn
 
IMixtureAlgoLearnp_algo_
 the algorithm to use for learning
 
- Protected Attributes inherited from STK::IRunnerBase
String msg_error_
 String with the last error message.
 
bool hasRun_
 true if run has been used, false otherwise
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IRunnerBase
 IRunnerBase ()
 default constructor
 
 IRunnerBase (IRunnerBase const &runner)
 copy constructor
 
virtual ~IRunnerBase ()
 destructor
 
virtual void update ()
 update the runner.
 

Detailed Description

facade design pattern.

LearnFacade allows to create the algorithms for learning a mixture model with less effort

Definition at line 95 of file STK_MixtureFacade.h.

Constructor & Destructor Documentation

◆ LearnFacade()

STK::LearnFacade::LearnFacade ( IMixtureLearner p_model)
inline

constructor.

Parameters
p_modela reference on the current model

Definition at line 101 of file STK_MixtureFacade.h.

102 : IRunnerBase(), p_model_(p_model), p_algo_(0)
103 {}
IRunnerBase()
default constructor
Definition STK_IRunner.h:68
IMixtureLearner * p_model_
the mixture model to learn
IMixtureAlgoLearn * p_algo_
the algorithm to use for learning

◆ ~LearnFacade()

STK::LearnFacade::~LearnFacade ( )
virtual

destructor.

Definition at line 103 of file STK_MixtureFacade.cpp.

103{ if (p_algo_) delete p_algo_;}

References p_algo_.

Member Function Documentation

◆ createImputeAlgo()

void STK::LearnFacade::createImputeAlgo ( Clust::algoLearnType  algo,
int  nbIter,
Real  epsilon 
)

create an imputation algorithm

Definition at line 105 of file STK_MixtureFacade.cpp.

106{
107 p_algo_ = Clust::createLearnAlgo(algo, nbIter, epsilon);
109}
void setModel(IMixtureLearner *p_model)
set model
IMixtureAlgoLearn * createLearnAlgo(Clust::algoLearnType algo, int nbIterMax, Real epsilon)
utility function for creating a learning algorithm.

References STK::Clust::createLearnAlgo(), p_algo_, p_model_, and STK::IMixtureAlgoLearn::setModel().

◆ createSimulAlgo()

void STK::LearnFacade::createSimulAlgo ( Clust::algoLearnType  algo,
int  nblongIter 
)

create a simulation algorithm

Definition at line 112 of file STK_MixtureFacade.cpp.

113{
114 p_algo_ = Clust::createLearnAlgo(algo, nbIter, 0.);
116}

References STK::Clust::createLearnAlgo(), p_algo_, p_model_, and STK::IMixtureAlgoLearn::setModel().

◆ run()

bool STK::LearnFacade::run ( )
virtual

run algorithm

Implements STK::IRunnerBase.

Definition at line 118 of file STK_MixtureFacade.cpp.

119{
120#ifdef STK_MIXTURE_VERBOSE
121 stk_cout << _T("------------------------------\n")
122 << _T("Entering LearnFacade::run() \n");
123#endif
124 // initialize model
126 // start algorithm
127 bool flag = false;
128 if (p_algo_)
129 {
130 if (p_algo_->run()) { flag = true;}
131 else
132 {
133 msg_error_ += STKERROR_NO_ARG(StrategyFacade::run,strategy failed\n);
135#ifdef STK_MIXTURE_VERBOSE
136 stk_cout << _T("LearnFacade:run() terminated without success. \n")
137 << msg_error_ << _T("\n")
138 << _T("------------------------------------------------\n");
139#endif
140 }
141 // finalize any
143 }
144 else
145 {
146 msg_error_ = STKERROR_NO_ARG(MixtureFacade::run(),algo is not created);
147 }
148#ifdef STK_MIXTURE_VERBOSE
149 stk_cout << _T("StrategyFacade:run() terminated.\n")
150 << _T("p_model->lnLikelihood() =") << p_model_->lnLikelihood() << _T("\n")
151 << _T("--------------------------------\n");
152#endif
153 return flag;
154}
#define STKERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:49
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
virtual void initializeStep()
Initialize the model before at its first use.
virtual void finalizeStep()
Finalize the estimation of the model.
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96
virtual bool run()=0
run the computations.
String const & error() const
get the last error message.
Definition STK_IRunner.h:82
virtual bool run()
run the strategy

References _T, STK::IRunnerBase::error(), STK::IMixtureStatModel::finalizeStep(), STK::IMixtureStatModel::initializeStep(), STK::IStatModelBase::lnLikelihood(), STK::IRunnerBase::msg_error_, p_algo_, p_model_, STK::StrategyFacade::run(), STK::IRunnerBase::run(), stk_cout, and STKERROR_NO_ARG.

◆ setModel()

void STK::LearnFacade::setModel ( IMixtureLearner p_model)
inline

set model in case we want to use the strategy again

Parameters
p_modelthe model to set

Definition at line 109 of file STK_MixtureFacade.h.

109{p_model_ = p_model;};

References p_model_.

Member Data Documentation

◆ p_algo_

IMixtureAlgoLearn* STK::LearnFacade::p_algo_
protected

the algorithm to use for learning

Definition at line 121 of file STK_MixtureFacade.h.

Referenced by createImputeAlgo(), createSimulAlgo(), run(), and ~LearnFacade().

◆ p_model_

IMixtureLearner* STK::LearnFacade::p_model_
protected

the mixture model to learn

Definition at line 119 of file STK_MixtureFacade.h.

Referenced by createImputeAlgo(), createSimulAlgo(), run(), and setModel().


The documentation for this class was generated from the following files: