54 const std::vector<TMVA::Interval*>& ranges,
68 DeclareOptionRef( fPopSize=300,
"PopSize",
"Population size for GA" );
69 DeclareOptionRef( fNsteps=40,
"Steps",
"Number of steps for convergence" );
70 DeclareOptionRef( fCycles=3,
"Cycles",
"Independent cycles of GA fitting" );
71 DeclareOptionRef( fSC_steps=10,
"SC_steps",
"Spread control, steps" );
72 DeclareOptionRef( fSC_rate=5,
"SC_rate",
"Spread control, rate: factor is changed depending on the rate" );
73 DeclareOptionRef( fSC_factor=0.95,
"SC_factor",
"Spread control, factor" );
74 DeclareOptionRef( fConvCrit=0.001,
"ConvCrit",
"Convergence criteria" );
76 DeclareOptionRef( fSaveBestFromGeneration=1,
"SaveBestGen",
77 "Saves the best n results from each generation. They are included in the last cycle" );
78 DeclareOptionRef( fSaveBestFromCycle=10,
"SaveBestCycle",
79 "Saves the best n results from each cycle. They are included in the last cycle. The value should be set to at least 1.0" );
81 DeclareOptionRef( fTrim=
kFALSE,
"Trim",
82 "Trim the population to PopSize after assessing the fitness of each individual" );
83 DeclareOptionRef( fSeed=100,
"Seed",
"Set seed of random generator (0 gives random seeds)" );
100 fSC_steps = SC_steps;
102 fSC_factor = SC_factor;
103 fConvCrit = convCrit;
111 Log() << kHEADER <<
"<GeneticFitter> Optimisation, please be patient "
112 <<
"... (inaccurate progress timing for GA)" <<
Endl;
114 GetFitterTarget().ProgressNotifier(
"GA",
"init" );
121 if (fIPyMaxIter) *fIPyMaxIter = 100*(fCycles);
126 for (
Int_t cycle = 0; cycle < fCycles; cycle++) {
127 if (fIPyCurrentIter) *fIPyCurrentIter = 100*(cycle);
128 if (fExitFromTraining && *fExitFromTraining)
break;
129 GetFitterTarget().ProgressNotifier(
"GA",
"cycle" );
136 if ( pars.size() == fRanges.size() ){
139 if (cycle==fCycles-1) {
140 GetFitterTarget().ProgressNotifier(
"GA",
"last" );
144 GetFitterTarget().ProgressNotifier(
"GA",
"iteration" );
151 GetFitterTarget().ProgressNotifier(
"GA",
"iteration" );
165 for (
Int_t i = 0; i<fSaveBestFromGeneration && i<fPopSize; i++ ) {
174 for (
Int_t i = 0; i<fSaveBestFromGeneration && i<fPopSize; i++ ) {
188 GetFitterTarget().ProgressNotifier(
"GA",
"stop" );
virtual void ParseOptions()
options parser
Base class for TMVA fitters.
Double_t Run()
estimator function interface for fitting
Base definition for genetic algorithm.
virtual Double_t SpreadControl(Int_t steps, Int_t ofSteps, Double_t factor)
this function provides the ability to change the stepSize of a mutation according to the success of t...
virtual Bool_t HasConverged(Int_t steps=10, Double_t ratio=0.1)
gives back true if the last "steps" steps have lead to an improvement of the "fitness" of the "indivi...
GeneticPopulation & GetGeneticPopulation()
void Init()
calls evolution, but if it is not the first time.
virtual Double_t CalculateFitness()
starts the evaluation of the fitness of all different individuals of the population.
Fitter using a Genetic Algorithm.
void DeclareOptions()
declare GA options
void SetParameters(Int_t cycles, Int_t nsteps, Int_t popSize, Int_t SC_steps, Int_t SC_rate, Double_t SC_factor, Double_t convCrit)
set GA configuration parameters
GeneticFitter(IFitterTarget &target, const TString &name, const std::vector< TMVA::Interval * > &ranges, const TString &theOption)
constructor
std::vector< Double_t > & GetFactors()
Double_t GetFitness() const
void Sort()
sort the genepool according to the fitness of the individuals
void TrimPopulation()
trim the population to the predefined size
GeneticGenes * GetGenes(Int_t index)
gives back the "Genes" of the population with the given index.
void GiveHint(std::vector< Double_t > &hint, Double_t fitness=0)
add an individual (a set of variables) to the population if there is a set of variables which is know...
void AddPopulation(GeneticPopulation *strangers)
add another population (strangers) to the one of this GeneticPopulation
Interface for a fitter 'target'.
Timing information for training and evaluation of MVA methods.
TString GetElapsedTime(Bool_t Scientific=kTRUE)
returns pretty string with elapsed time
void DrawProgressBar(Int_t, const TString &comment="")
draws progress bar in color or B&W caution:
std::string GetName(const std::string &scope_name)
MsgLogger & Endl(MsgLogger &ml)