56{
57#ifdef STK_MIXTURE_VERY_VERBOSE
58 stk_cout <<
_T(
"Entering XemStrategy::run() with:\n")
61#endif
62
65
68
69 try
70 {
71 for (
int iTry = 0; iTry <
nbTry_; ++iTry)
72 {
73#ifdef STK_MIXTURE_VERY_VERBOSE
74 stk_cout <<
_T(
"-------------------------------\n")
75 <<
_T(
"try number = ") << iTry <<
_T(
"\n");
76#endif
77
79 {
80
83 {
84
87
88 if( p_currentBestModel->lnLikelihood()<p_currentModel->lnLikelihood())
89 { std::swap(p_currentModel, p_currentBestModel);}
90 }
91 }
92
93
95 {
96
99 { continue; }
100 }
101#ifdef STK_MIXTURE_VERBOSE
103 <<
_T(
". In XemStrategy::run(), short run terminated. best model:\n");
104 p_currentBestModel->writeParameters(
stk_cout);
106#endif
107
110#ifdef STK_MIXTURE_VERBOSE
111 stk_cout <<
"In FullStrategy::run(), Long run Failed.\n";
112#endif
113 }
114 delete p_currentBestModel;
115 delete p_currentModel;
116 } catch (Exception const& e)
117 {
119 return false;
120 }
121#ifdef STK_MIXTURE_VERBOSE
122 stk_cout <<
"XemStrategy::run() terminated.\n";
123 stk_cout <<
"-------------------------------\n";
124#endif
126 {
128 return false;
129 }
130 return true;
131}
#define STKERROR_NO_ARG(Where, Error)
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
void setModel(IMixtureComposer *p_model)
set model
void randomFuzzyInit()
Initialize randomly the posterior probabilities tik of the model, then compute the zi values with map...
virtual IMixtureComposer * create() const =0
create pattern
Clust::modelState state() const
void setModel(IMixtureComposer *p_model)
set a new model
int nbTry_
number of tries of each strategies (1 by default)
void storeModel(IMixtureComposer *&p_otherModel)
store a model in p_model_ if it is better.
IMixtureInit * p_init_
initialization method
IMixtureComposer *& p_model_
reference on the main model
String msg_error_
String with the last error message.
virtual bool run()=0
run the computations.
Real lnLikelihood() const
virtual bool run()
run the strategy
double Real
STK fundamental type of Real values.
IMixtureAlgo * p_shortAlgo_
algorithm to use in short runs
IMixtureAlgo * p_longAlgo_
algorithm to use in long run
int nbShortRun_
number of short run to perform