36 #ifdef _GLIBCXX_PARALLEL 71 const std::vector<Interval*>& ranges,
UInt_t seed )
73 fFitterTarget( target ),
80 fPopulationSize(populationSize),
82 fPopulation(ranges, populationSize, seed),
83 fBestFitness(DBL_MAX),
84 fLogger( new
MsgLogger(
"GeneticAlgorithm") )
139 #ifdef _GLIBCXX_PARALLEL 141 const int nt = omp_get_num_threads();
143 for (
int i =0; i < nt; ++i )
148 int thread_number = omp_get_thread_num();
157 if ( bests[thread_number] > fitness )
158 bests[thread_number] = fitness;
236 if ( n >= ofSteps ) {
238 if ( sum > successSteps ) {
240 if (GeneticAlgorithm__DEBUG__)
Log() << kINFO <<
">" << std::flush;
242 else if ( sum == successSteps ) {
243 if (GeneticAlgorithm__DEBUG__)
Log() <<
"=" << std::flush;
247 if (GeneticAlgorithm__DEBUG__)
Log() <<
"<" << std::flush;
273 if (GeneticAlgorithm__DEBUG__)
Log() <<
"." << std::flush;
static long int sum(long int i)
virtual Double_t EstimatorFunction(std::vector< Double_t > ¶meters)=0
Int_t GetPopulationSize() const
virtual Double_t CalculateFitness()
starts the evaluation of the fitness of all different individuals of the population.
GeneticAlgorithm(IFitterTarget &target, Int_t populationSize, const std::vector< TMVA::Interval *> &ranges, UInt_t seed=0)
Constructor.
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...
void MakeChildren()
Creates children out of members of the current generation.
void MakeCopies(int number)
Produces offspring which is are copies of their parents.
GeneticPopulation fPopulation
void Mutate(Double_t probability=20, Int_t startIndex=0, Bool_t near=kFALSE, Double_t spread=0.1, Bool_t mirror=kFALSE)
Mutates the individuals in the genePool.
Cut optimisation interface class for genetic algorithm.
void SetFitness(Double_t fitness)
IFitterTarget & fFitterTarget
void SetRandomSeed(UInt_t seed=0)
the random seed of the random generator
Base definition for genetic algorithm.
GeneticGenes * GetGenes(Int_t index)
gives back the "Genes" of the population with the given index.
Double_t GetFitness() const
void Sort()
sort the genepool according to the fitness of the individuals
virtual ~GeneticAlgorithm()
std::deque< Int_t > fSuccessList
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...
std::vector< Double_t > & GetFactors()
ostringstream derivative to redirect and format output
virtual void Evolution()
this function is called from "init" and controls the evolution of the individuals.
Abstract ClassifierFactory template that handles arbitrary types.
virtual Double_t NewFitness(Double_t oldValue, Double_t newValue)
if the "fitnessFunction" is called multiple times for one set of factors (because i...
Interface for a fitter 'target'.
void Init()
calls evolution, but if it is not the first time.