54 fRanges(ranges.size()),
55 fLogger( new
MsgLogger(
"GeneticPopulation") )
64 for (
unsigned int i = 0; i < ranges.size(); ++i )
67 vector<Double_t> newEntry(
fRanges.size() );
68 for (
int i = 0; i < size; ++i )
70 for (
unsigned int rIt = 0; rIt <
fRanges.size(); ++rIt )
71 newEntry[rIt] =
fRanges[rIt]->Random();
85 std::vector<GeneticRange*>::iterator it =
fRanges.begin();
86 for (;it!=
fRanges.end(); ++it)
delete *it;
110 for (std::vector<TMVA::GeneticGenes>::iterator it =
fGenePool.begin();
113 GiveHint( it->GetFactors(), it->GetFitness() );
124 #ifdef _GLIBCXX_PARALLEL 128 for (
int it = 0; it < (int) (
fGenePool.size() / 2); ++it )
142 vector< Double_t > child(
fRanges.size());
143 for (
unsigned int i = 0; i <
fRanges.size(); ++i) {
174 vector< Double_t>::iterator vec;
175 vector< TMVA::GeneticRange* >::iterator vecRange;
182 for (
int it = startIndex; it < (int)
fGenePool.size(); ++it) {
184 for (vec = (
fGenePool[it].GetFactors()).begin(); vec < (
fGenePool[it].GetFactors()).end(); ++vec) {
186 (*vec) = (*vecRange)->Random( near, (*vec), spread, mirror );
208 for (
unsigned int it = 0; it <
fGenePool.size(); ++it )
211 if (untilIndex >= -1 ) {
212 if (untilIndex == -1 )
return;
215 Log() <<
"fitness: " <<
fGenePool[it].GetFitness() <<
" ";
216 for (vector< Double_t >::iterator vec =
fGenePool[it].GetFactors().begin();
217 vec <
fGenePool[it].GetFactors().end(); ++vec ) {
218 Log() <<
"f_" << n++ <<
": " << (*vec) <<
" ";
230 for (
unsigned int it = 0; it <
fGenePool.size(); ++it ) {
232 if (untilIndex >= -1 ) {
233 if (untilIndex == -1 )
return;
236 out <<
"fitness: " <<
fGenePool[it].GetFitness() <<
" ";
237 for (vector< Double_t >::iterator vec =
fGenePool[it].GetFactors().begin();
238 vec <
fGenePool[it].GetFactors().end(); ++vec ) {
239 out <<
"f_" << n++ <<
": " << (*vec) <<
" ";
257 std::cout <<
"FAILED! TMVA::GeneticPopulation::VariableDistribution" << std::endl;
259 std::stringstream histName;
262 histName << varNumber;
263 TH1F *hist =
new TH1F( histName.str().c_str(),histName.str().c_str(), bins,min,max );
273 std::cout <<
"FAILED! TMVA::GeneticPopulation::VariableDistribution" << std::endl;
275 vector< Double_t > varDist;
285 for (std::vector<TMVA::GeneticGenes>::iterator it = strangers->
fGenePool.begin();
286 it != strangers->
fGenePool.end(); ++it ) {
287 GiveHint( it->GetFactors(), it->GetFitness() );
Random number generator class based on M.
MsgLogger & Endl(MsgLogger &ml)
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...
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
virtual void SetSeed(ULong_t seed=0)
Set the random generator sequence if seed is 0 (default value) a TUUID is generated and used to fill ...
void MakeChildren()
Creates children out of members of the current generation.
1-D histogram with a float per channel (see TH1 documentation)}
void MakeCopies(int number)
Produces offspring which is are copies of their parents.
void AddPopulation(GeneticPopulation *strangers)
add another population (strangers) to the one of this GeneticPopulation
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.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer on [ 0, imax-1 ].
std::vector< TMVA::GeneticRange * > fRanges
Cut optimisation interface class for genetic algorithm.
virtual ~GeneticPopulation()
destructor
void SetFitness(Double_t fitness)
GeneticPopulation(const std::vector< TMVA::Interval *> &ranges, Int_t size, UInt_t seed=0)
Constructor.
void TrimPopulation()
trim the population to the predefined size
void SetRandomSeed(UInt_t seed=0)
the random seed of the random generator
GeneticGenes * GetGenes(Int_t index)
gives back the "Genes" of the population with the given index.
void Print(Int_t untilIndex=-1)
make a little printout of the individuals up to index "untilIndex" this means, .
std::vector< TMVA::GeneticGenes > fGenePool
void Sort()
sort the genepool according to the fitness of the individuals
GeneticGenes MakeSex(GeneticGenes male, GeneticGenes female)
this function takes two individuals and produces offspring by mixing (recombining) their coefficients...
std::vector< Double_t > & GetFactors()
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
ostringstream derivative to redirect and format output
Int_t fPopulationSizeLimit
Population definition for genetic algorithm.
TRandom3 * fRandomGenerator
TH1F * VariableDistribution(Int_t varNumber, Int_t bins, Int_t min, Int_t max)
give back a histogram with the distribution of the coefficients.
Range definition for genetic algorithm.