STK++ 0.9.13
STK_MixtureFacade.cpp
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._DOT_I..._AT_stkpp.org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::Clustering
27 * created on: 4 sept. 2013
28 * Author: iovleff, serge.iovleff@stkpp.org
29 **/
30
42
43namespace STK
44{
45
47
56
57/* create a FullStrategy */
69
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}
102
104
110
111/* create a FullStrategy */
117
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 {
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}
155
156} // namespace STK
157
158
159
160
In this file we define the abstract base class for mixture models.
In this file we define the interface base class for learners.
#define STKERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:49
In this file we define learning mixture algorithms.
In this file we define mixture algorithms.
In this file we define the StrategyFacade and LearnFacade which construct properly a way to estimate/...
In this file we define the interface base class for initialization methods.
In this file we define the strategies to use in order to estimate a mixture model.
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
void setModel(IMixtureLearner *p_model)
set model
Interface base class for the algorithms.
virtual void finalizeStep()
Finalize the estimation of the model.
Interface base class for the initializations.
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 algorithm
void createImputeAlgo(Clust::algoLearnType algo, int nbIter, Real epsilon)
create an imputation algorithm
IMixtureLearner * p_model_
the mixture model to learn
void createSimulAlgo(Clust::algoLearnType algo, int nblongIter)
create a simulation algorithm
IMixtureAlgoLearn * p_algo_
the algorithm to use for learning
virtual ~LearnFacade()
destructor.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
IMixtureComposer *& p_model_
the mixture model to estimate
IMixtureStrategy * p_strategy_
the strategy to use in order to estimate the mixture model
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
virtual bool run()
run the strategy
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 ~StrategyFacade()
destructor.
initType
initialization type.
algoType
Estimation algorithms.
algoLearnType
Learning estimation algorithms.
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 * createSimpleStrategy(IMixtureComposer *&p_composer, int nbTry, IMixtureInit *const &p_init, IMixtureAlgo *const &algo)
Utility function for creating a SimpleStrategy.
IMixtureAlgoLearn * createLearnAlgo(Clust::algoLearnType algo, int nbIterMax, Real epsilon)
utility function for creating a learning 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.
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.