STK++ 0.9.13
STK::StrategyFacade Class Reference

facade design pattern. More...

#include <STK_MixtureFacade.h>

Inheritance diagram for STK::StrategyFacade:
Inheritance graph

Public Member Functions

 StrategyFacade (IMixtureComposer *&p_model)
 constructor.
 
virtual ~StrategyFacade ()
 destructor.
 
void setModel (IMixtureComposer *&p_model)
 set model in case we want to use the strategy again
 
void createSimpleStrategy (Clust::initType init, int nbTrialInInit, Clust::algoType initAlgo, int nbInitIter, Real initEpsilon, int nbTry, Clust::algoType algo, int nbIter, Real epsilon)
 create a SimpleStrategy
 
void createFullStrategy (Clust::initType init, int nbTryInInit, Clust::algoType initAlgo, int nbInitIter, Real initEpsilon, int nbTry, int nbInitRun, int nbShortRun, Clust::algoType shortAlgo, int nbShortIter, Real shortEpsilon, Clust::algoType longAlgo, int nblongIter, Real longEpsilon)
 create a FullStrategy
 
virtual bool run ()
 run the strategy
 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 

Protected Attributes

IMixtureComposer *& p_model_
 the mixture model to estimate
 
IMixtureStrategyp_strategy_
 the strategy to use in order to estimate the mixture model
 
- 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.

StrategyFacade allows to create the strategy for estimating a mixture model with less effort

Definition at line 56 of file STK_MixtureFacade.h.

Constructor & Destructor Documentation

◆ StrategyFacade()

STK::StrategyFacade::StrategyFacade ( IMixtureComposer *&  p_model)
inline

constructor.

Parameters
p_modela reference on the current model

Definition at line 62 of file STK_MixtureFacade.h.

63 : IRunnerBase(), p_model_(p_model), p_strategy_(0)
64 {}
IRunnerBase()
default constructor
Definition STK_IRunner.h:68
IMixtureComposer *& p_model_
the mixture model to estimate
IMixtureStrategy * p_strategy_
the strategy to use in order to estimate the mixture model

◆ ~StrategyFacade()

STK::StrategyFacade::~StrategyFacade ( )
virtual

destructor.

Definition at line 46 of file STK_MixtureFacade.cpp.

46{ if (p_strategy_) delete p_strategy_;}

References p_strategy_.

Member Function Documentation

◆ createFullStrategy()

void STK::StrategyFacade::createFullStrategy ( Clust::initType  init,
int  nbTryInInit,
Clust::algoType  initAlgo,
int  nbInitIter,
Real  initEpsilon,
int  nbTry,
int  nbInitRun,
int  nbShortRun,
Clust::algoType  shortAlgo,
int  nbShortIter,
Real  shortEpsilon,
Clust::algoType  longAlgo,
int  nblongIter,
Real  longEpsilon 
)

create a FullStrategy

Definition at line 58 of file STK_MixtureFacade.cpp.

62{
63 IMixtureInit* p_init = Clust::createInit(init, nbTryInInit, initAlgo, nbInitIter, initEpsilon);
64 IMixtureAlgo* p_shortAlgo = Clust::createAlgo(shortAlgo, nbShortIter, shortEpsilon);
65 IMixtureAlgo* p_longAlgo = Clust::createAlgo(longAlgo, nblongIter, longEpsilon);
66
67 p_strategy_ = Clust::createFullStrategy(p_model_, nbTry, nbInitRun, p_init, nbShortRun, p_shortAlgo, p_longAlgo);
68}
IMixtureInit * createInit(Clust::initType init=defaultInitType, int nbInits=defaultNbInit, Clust::algoType algo=defaultAlgoInInit, int nbIterMax=defaultNbIterMaxInInit, Real epsilon=defaultEpsilonInInit)
Utility function for creating a model initializer.
IMixtureAlgo * createAlgo(Clust::algoType algo, int nbIterMax, Real epsilon)
utility function for creating an estimation algorithm.
IMixtureStrategy * createFullStrategy(IMixtureComposer *&p_composer, int nbTry, int nbInitRun, IMixtureInit *const &p_init, int nbShortRun, IMixtureAlgo *const &shortRunAlgo, IMixtureAlgo *const &longRunAlgo)
Utility function for creating a FullStrategy.

References STK::Clust::createAlgo(), STK::Clust::createFullStrategy(), STK::Clust::createInit(), p_model_, and p_strategy_.

◆ createSimpleStrategy()

void STK::StrategyFacade::createSimpleStrategy ( Clust::initType  init,
int  nbTrialInInit,
Clust::algoType  initAlgo,
int  nbInitIter,
Real  initEpsilon,
int  nbTry,
Clust::algoType  algo,
int  nbIter,
Real  epsilon 
)

create a SimpleStrategy

Definition at line 48 of file STK_MixtureFacade.cpp.

50{
51 IMixtureInit* p_init = Clust::createInit(init, nbTryInInit, initAlgo, nbInitIter, initEpsilon);
52 IMixtureAlgo* p_algo = Clust::createAlgo(algo, nbIter, epsilon);
53
54 p_strategy_ = Clust::createSimpleStrategy(p_model_, nbTry, p_init, p_algo);
55}
IMixtureStrategy * createSimpleStrategy(IMixtureComposer *&p_composer, int nbTry, IMixtureInit *const &p_init, IMixtureAlgo *const &algo)
Utility function for creating a SimpleStrategy.

References STK::Clust::createAlgo(), STK::Clust::createInit(), STK::Clust::createSimpleStrategy(), p_model_, and p_strategy_.

◆ run()

bool STK::StrategyFacade::run ( )
virtual

run the strategy

Implements STK::IRunnerBase.

Definition at line 70 of file STK_MixtureFacade.cpp.

71{
72#ifdef STK_MIXTURE_VERBOSE
73 stk_cout << _T("------------------------------\n")
74 << _T("Entering StrategyFacade::run()\n");
75#endif
76 bool flag = false;
77 if (p_strategy_)
78 {
79 if (p_strategy_->run()) { flag = true;}
80 else
81 {
84#ifdef STK_MIXTURE_VERBOSE
85 stk_cout << _T("StrategyFacade:run() terminated without success.\n")
86 << msg_error_ << _T("\n")
87 << _T("------------------------------------------------\n");
88#endif
89 }
90 // p_model_->imputationStep();
92 }
93 else
94 { msg_error_ = STKERROR_NO_ARG(MixtureFacade::run(),strategy is not created);}
95#ifdef STK_MIXTURE_VERBOSE
96 stk_cout << _T("StrategyFacade:run() terminated.\np_model->lnLikelihood() =")
97 << p_model_->lnLikelihood() << _T("\n")
98 << _T("--------------------------------\n");
99#endif
100 return flag;
101}
#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 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::IMixtureComposer::finalizeStep(), STK::IStatModelBase::lnLikelihood(), STK::IRunnerBase::msg_error_, p_model_, p_strategy_, run(), STK::IRunnerBase::run(), stk_cout, and STKERROR_NO_ARG.

Referenced by run(), and STK::LearnFacade::run().

◆ setModel()

void STK::StrategyFacade::setModel ( IMixtureComposer *&  p_model)
inline

set model in case we want to use the strategy again

Parameters
p_modelthe model to set

Definition at line 70 of file STK_MixtureFacade.h.

70{p_model_ = p_model;};

References p_model_.

Member Data Documentation

◆ p_model_

IMixtureComposer*& STK::StrategyFacade::p_model_
protected

the mixture model to estimate

Definition at line 85 of file STK_MixtureFacade.h.

Referenced by createFullStrategy(), createSimpleStrategy(), run(), and setModel().

◆ p_strategy_

IMixtureStrategy* STK::StrategyFacade::p_strategy_
protected

the strategy to use in order to estimate the mixture model

Definition at line 87 of file STK_MixtureFacade.h.

Referenced by createFullStrategy(), createSimpleStrategy(), run(), and ~StrategyFacade().


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