66 DeclareOptionRef( fPopSize=300,
"PopSize",
"Population size for GA" );
67 DeclareOptionRef( fNsteps=40,
"Steps",
"Number of steps for convergence" );
68 DeclareOptionRef( fCycles=3,
"Cycles",
"Independent cycles of GA fitting" );
69 DeclareOptionRef( fSC_steps=10,
"SC_steps",
"Spread control, steps" );
70 DeclareOptionRef( fSC_rate=5,
"SC_rate",
"Spread control, rate: factor is changed depending on the rate" );
71 DeclareOptionRef( fSC_factor=0.95,
"SC_factor",
"Spread control, factor" );
72 DeclareOptionRef( fConvCrit=0.001,
"ConvCrit",
"Convergence criteria" );
74 DeclareOptionRef( fSaveBestFromGeneration=1,
"SaveBestGen",
75 "Saves the best n results from each generation. They are included in the last cycle" );
76 DeclareOptionRef( fSaveBestFromCycle=10,
"SaveBestCycle",
77 "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" );
79 DeclareOptionRef( fTrim=
kFALSE,
"Trim",
80 "Trim the population to PopSize after assessing the fitness of each individual" );
81 DeclareOptionRef( fSeed=100,
"Seed",
"Set seed of random generator (0 gives random seeds)" );
109 Log() << kHEADER <<
"<GeneticFitter> Optimisation, please be patient "
110 <<
"... (inaccurate progress timing for GA)" <<
Endl;
112 GetFitterTarget().ProgressNotifier(
"GA",
"init" );
119 if (fIPyMaxIter) *fIPyMaxIter = 100*(fCycles);
120 timer.DrawProgressBar( 0 );
124 for (
Int_t cycle = 0; cycle < fCycles; cycle++) {
125 if (fIPyCurrentIter) *fIPyCurrentIter = 100*(cycle);
126 if (fExitFromTraining && *fExitFromTraining)
break;
127 GetFitterTarget().ProgressNotifier(
"GA",
"cycle" );
134 if ( pars.size() == fRanges.size() ){
135 ga.GetGeneticPopulation().GiveHint( pars, 0.0 );
137 if (cycle==fCycles-1) {
138 GetFitterTarget().ProgressNotifier(
"GA",
"last" );
139 ga.GetGeneticPopulation().AddPopulation(
gstore.GetGeneticPopulation() );
142 GetFitterTarget().ProgressNotifier(
"GA",
"iteration" );
144 ga.CalculateFitness();
145 ga.GetGeneticPopulation().TrimPopulation();
149 GetFitterTarget().ProgressNotifier(
"GA",
"iteration" );
151 ga.CalculateFitness();
152 if ( fTrim )
ga.GetGeneticPopulation().TrimPopulation();
153 ga.SpreadControl( fSC_steps, fSC_rate, fSC_factor );
162 ga.GetGeneticPopulation().Sort();
163 for (
Int_t i = 0; i<fSaveBestFromGeneration && i<fPopSize; i++ ) {
164 gstore.GetGeneticPopulation().GiveHint(
ga.GetGeneticPopulation().GetGenes(i)->GetFactors(),
165 ga.GetGeneticPopulation().GetGenes(i)->GetFitness() );
167 }
while (!
ga.HasConverged( fNsteps, fConvCrit ));
169 timer.DrawProgressBar( 100*(cycle+1) );
171 ga.GetGeneticPopulation().Sort();
172 for (
Int_t i = 0; i<fSaveBestFromGeneration && i<fPopSize; i++ ) {
173 gstore.GetGeneticPopulation().GiveHint(
ga.GetGeneticPopulation().GetGenes(i)->GetFactors(),
174 ga.GetGeneticPopulation().GetGenes(i)->GetFitness() );
179 Log() << kINFO <<
"Elapsed time: " <<
timer.GetElapsedTime()
183 gstore.GetGeneticPopulation().Sort();
184 pars.swap(
gstore.GetGeneticPopulation().GetGenes(0)->GetFactors() );
186 GetFitterTarget().ProgressNotifier(
"GA",
"stop" );
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