65 DeclareOptionRef( fPopSize=300,
"PopSize",
"Population size for GA" );
66 DeclareOptionRef( fNsteps=40,
"Steps",
"Number of steps for convergence" );
67 DeclareOptionRef( fCycles=3,
"Cycles",
"Independent cycles of GA fitting" );
68 DeclareOptionRef( fSC_steps=10,
"SC_steps",
"Spread control, steps" );
69 DeclareOptionRef( fSC_rate=5,
"SC_rate",
"Spread control, rate: factor is changed depending on the rate" );
70 DeclareOptionRef( fSC_factor=0.95,
"SC_factor",
"Spread control, factor" );
71 DeclareOptionRef( fConvCrit=0.001,
"ConvCrit",
"Convergence criteria" );
73 DeclareOptionRef( fSaveBestFromGeneration=1,
"SaveBestGen",
74 "Saves the best n results from each generation. They are included in the last cycle" );
75 DeclareOptionRef( fSaveBestFromCycle=10,
"SaveBestCycle",
76 "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" );
78 DeclareOptionRef( fTrim=
kFALSE,
"Trim",
79 "Trim the population to PopSize after assessing the fitness of each individual" );
80 DeclareOptionRef( fSeed=100,
"Seed",
"Set seed of random generator (0 gives random seeds)" );
108 Log() << kHEADER <<
"<GeneticFitter> Optimisation, please be patient "
109 <<
"... (inaccurate progress timing for GA)" <<
Endl;
111 GetFitterTarget().ProgressNotifier(
"GA",
"init" );
118 timer.DrawProgressBar( 0 );
122 for (
Int_t cycle = 0; cycle < fCycles; cycle++) {
123 GetFitterTarget().ProgressNotifier(
"GA",
"cycle" );
130 if ( pars.size() == fRanges.size() ){
131 ga.GetGeneticPopulation().GiveHint( pars, 0.0 );
133 if (cycle==fCycles-1) {
134 GetFitterTarget().ProgressNotifier(
"GA",
"last" );
135 ga.GetGeneticPopulation().AddPopulation(
gstore.GetGeneticPopulation() );
138 GetFitterTarget().ProgressNotifier(
"GA",
"iteration" );
140 ga.CalculateFitness();
141 ga.GetGeneticPopulation().TrimPopulation();
145 GetFitterTarget().ProgressNotifier(
"GA",
"iteration" );
147 ga.CalculateFitness();
148 if ( fTrim )
ga.GetGeneticPopulation().TrimPopulation();
149 ga.SpreadControl( fSC_steps, fSC_rate, fSC_factor );
158 ga.GetGeneticPopulation().Sort();
159 for (
Int_t i = 0; i<fSaveBestFromGeneration && i<fPopSize; i++ ) {
160 gstore.GetGeneticPopulation().GiveHint(
ga.GetGeneticPopulation().GetGenes(i)->GetFactors(),
161 ga.GetGeneticPopulation().GetGenes(i)->GetFitness() );
163 }
while (!
ga.HasConverged( fNsteps, fConvCrit ));
165 timer.DrawProgressBar( 100*(cycle+1) );
167 ga.GetGeneticPopulation().Sort();
168 for (
Int_t i = 0; i<fSaveBestFromGeneration && i<fPopSize; i++ ) {
169 gstore.GetGeneticPopulation().GiveHint(
ga.GetGeneticPopulation().GetGenes(i)->GetFactors(),
170 ga.GetGeneticPopulation().GetGenes(i)->GetFitness() );
175 Log() << kINFO <<
"Elapsed time: " <<
timer.GetElapsedTime()
179 gstore.GetGeneticPopulation().Sort();
180 pars.swap(
gstore.GetGeneticPopulation().GetGenes(0)->GetFactors() );
182 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