STK++ 0.9.13
STK::RandomInit Class Reference

Implementation of the random initialization. More...

#include <STK_MixtureInit.h>

Inheritance diagram for STK::RandomInit:
Inheritance graph

Public Member Functions

 RandomInit ()
 default constructor
 
 RandomInit (RandomInit const &init)
 copy constructor
 
virtual ~RandomInit ()
 destructor
 
virtual RandomInitclone () const
 clone pattern
 
virtual bool run ()
 run the initialization by calling the randomInit method of the model.
 
- Public Member Functions inherited from STK::IMixtureInit
virtual ~IMixtureInit ()
 destructor
 
IMixtureAlgo const *const p_initAlgo () const
 set a the number of try
 
int nbTry () const
 
void setNbTry (int nbTry)
 set a the number of try
 
void setModel (IMixtureComposer *p_model)
 set a new model
 
void setInitAlgo (IMixtureAlgo *p_initAlgo)
 set the initial algorithm

 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IMixtureInit
 IMixtureInit ()
 default constructor
 
 IMixtureInit (IMixtureInit const &init)
 copy constructor.
 
bool runInitAlgo ()
 launch the initialization algorithm.
 
- 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.
 
- Protected Attributes inherited from STK::IMixtureInit
int nbTry_
 number of retry in initialization
 
IMixtureComposerp_model_
 pointer on the mixture model
 
IMixtureAlgop_initAlgo_
 algorithm to use in the initialization
 
- 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
 

Detailed Description

Implementation of the random initialization.

This class will initialize the parameter by calling the randomInit() method of the model.

Definition at line 47 of file STK_MixtureInit.h.

Constructor & Destructor Documentation

◆ RandomInit() [1/2]

STK::RandomInit::RandomInit ( )
inline

default constructor

Definition at line 51 of file STK_MixtureInit.h.

51: IMixtureInit() {}
IMixtureInit()
default constructor

Referenced by clone().

◆ RandomInit() [2/2]

STK::RandomInit::RandomInit ( RandomInit const init)
inline

copy constructor

Parameters
initthe initialization to copy

Definition at line 55 of file STK_MixtureInit.h.

55: IMixtureInit(init) {}

◆ ~RandomInit()

virtual STK::RandomInit::~RandomInit ( )
inlinevirtual

destructor

Definition at line 57 of file STK_MixtureInit.h.

57{}

Member Function Documentation

◆ clone()

virtual RandomInit * STK::RandomInit::clone ( ) const
inlinevirtual

clone pattern

Implements STK::IMixtureInit.

Definition at line 59 of file STK_MixtureInit.h.

59{ return new RandomInit(*this);}
RandomInit()
default constructor

References RandomInit().

◆ run()

bool STK::RandomInit::run ( )
virtual

run the initialization by calling the randomInit method of the model.

Returns
true if no error occur, false otherwise

Implements STK::IRunnerBase.

Definition at line 66 of file STK_MixtureInit.cpp.

67{
68#ifdef STK_MIXTURE_VERY_VERBOSE
69 stk_cout << _T("--------------------------\n")
70 << _T("Entering RandomInit::run()\n")
71 << _T("nbTry = ") << nbTry_ << _T("\n");
72#endif
73 bool result = false;
74 int iTry;
75 for (iTry= 0; iTry < nbTry_; ++iTry)
76 {
77 try
78 {
81 if (runInitAlgo()) { result = true; break;}
82#ifdef STK_MIXTURE_VERBOSE
83 stk_cout << _T("In RandomInit::run(), try number") << iTry << " runInitAlgo() failed.\n";
84#endif
85 msg_error_ = STKERROR_NO_ARG(ClassInit::run,Init algo failed\n);
87 }
88 catch (Clust::exceptions const& error)
89 {
92#ifdef STK_MIXTURE_VERBOSE
93 stk_cout << _T("In RandomInit::run(), try number") << iTry << " generate an exception.\n";
94 stk_cout << _T("In RandomInit::run(), error") << msg_error_ << _T("\n");
95#endif
96 }
97 catch (Exception const& error)
98 {
99 String msg = error.error();
101#ifdef STK_MIXTURE_VERBOSE
102 stk_cout << _T("In RandomInit::run(), try number") << iTry << " generate an exception.\n";
103 stk_cout << _T("In RandomInit::run(), error") << msg_error_ << _T("\n");
104#endif
105 }
106 } // iTry
107#ifdef STK_MIXTURE_VERY_VERBOSE
108 stk_cout << _T("RandomInit::run() done\n")
109 << _T("----------------------\n");
110#endif
111 return result;
112}
#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 bool run()
run the initialization by calling the randomClassInit method of the model.
virtual void initializeStep()
Initialize the model before its first use.
virtual void randomInit()=0
initialize randomly the parameters of the components of the model
IMixtureComposer * p_model_
pointer on the mixture model
IMixtureAlgo * p_initAlgo_
algorithm to use in the initialization
bool runInitAlgo()
launch the initialization algorithm.
int nbTry_
number of retry in initialization
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96
String const & error() const
get the last error message.
Definition STK_IRunner.h:82
String exceptionToString(exceptions const &type)
convert a Clust::exceptions to a String.
exceptions
Specific exceptions allowing to handle the erroros that can occur in the estimation process.
std::basic_string< Char > String
STK fundamental type of a String.

References _T, STK::IRunnerBase::error(), STK::Clust::exceptionToString(), STK::IMixtureComposer::initializeStep(), STK::IRunnerBase::msg_error_, STK::IMixtureInit::nbTry_, STK::IMixtureInit::p_initAlgo_, STK::IMixtureInit::p_model_, STK::IMixtureComposer::randomInit(), STK::ClassInit::run(), STK::IMixtureInit::runInitAlgo(), stk_cout, and STKERROR_NO_ARG.


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