43using std::vector, std::ostream;
60 for (
unsigned int i = 0; i < ranges.size(); ++i )
63 vector<Double_t> newEntry(
fRanges.size() );
64 for (
int i = 0; i <
size; ++i )
66 for (
unsigned int rIt = 0; rIt <
fRanges.size(); ++rIt )
67 newEntry[rIt] =
fRanges[rIt]->Random();
81 std::vector<GeneticRange*>::iterator it =
fRanges.begin();
82 for (;it!=
fRanges.end(); ++it)
delete *it;
106 for (std::vector<TMVA::GeneticGenes>::iterator it =
fGenePool.begin();
109 GiveHint( it->GetFactors(), it->GetFitness() );
120#ifdef _GLIBCXX_PARALLEL
124 for (
int it = 0; it < (
int) (
fGenePool.size() / 2); ++it )
138 vector< Double_t > child(
fRanges.size());
139 for (
unsigned int i = 0; i <
fRanges.size(); ++i) {
170 vector< Double_t>::iterator
vec;
171 vector< TMVA::GeneticRange* >::iterator vecRange;
178 for (
int it = startIndex; it < (
int)
fGenePool.size(); ++it) {
182 (*vec) = (*vecRange)->Random( near, (*
vec), spread, mirror );
204 for (
unsigned int it = 0; it <
fGenePool.size(); ++it )
207 if (untilIndex >= -1 ) {
208 if (untilIndex == -1 )
return;
211 Log() <<
"fitness: " <<
fGenePool[it].GetFitness() <<
" ";
212 for (vector< Double_t >::iterator
vec =
fGenePool[it].GetFactors().begin();
214 Log() <<
"f_" <<
n++ <<
": " << (*vec) <<
" ";
226 for (
unsigned int it = 0; it <
fGenePool.size(); ++it ) {
228 if (untilIndex >= -1 ) {
229 if (untilIndex == -1 )
return;
232 out <<
"fitness: " <<
fGenePool[it].GetFitness() <<
" ";
233 for (vector< Double_t >::iterator
vec =
fGenePool[it].GetFactors().begin();
235 out <<
"f_" <<
n++ <<
": " << (*vec) <<
" ";
253 std::cout <<
"FAILED! TMVA::GeneticPopulation::VariableDistribution" << std::endl;
255 std::stringstream histName;
258 histName << varNumber;
259 TH1F *hist =
new TH1F( histName.str().c_str(),histName.str().c_str(), bins,min,max );
269 std::cout <<
"FAILED! TMVA::GeneticPopulation::VariableDistribution" << std::endl;
271 vector< Double_t > varDist;
281 for (std::vector<TMVA::GeneticGenes>::iterator it = strangers->
fGenePool.begin();
282 it != strangers->
fGenePool.end(); ++it ) {
283 GiveHint( it->GetFactors(), it->GetFitness() );
312 g.SetFitness(fitness);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
1-D histogram with a float per channel (see TH1 documentation)
Cut optimisation interface class for genetic algorithm.
std::vector< Double_t > & GetFactors()
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 ~GeneticPopulation()
destructor
Int_t fPopulationSizeLimit
std::vector< TMVA::GeneticRange * > fRanges
contains the ranges in between the values of the coefficients have to be
TRandom3 * fRandomGenerator
random Generator for this population
void Sort()
sort the genepool according to the fitness of the individuals
void MakeCopies(int number)
Produces offspring which is are copies of their parents.
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.
GeneticPopulation(const std::vector< TMVA::Interval * > &ranges, Int_t size, UInt_t seed=0)
Constructor.
MsgLogger * fLogger
! message logger
void Print(Int_t untilIndex=-1)
make a little printout of the individuals up to index "untilIndex" this means, .
void MakeChildren()
Creates children out of members of the current generation.
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...
std::vector< TMVA::GeneticGenes > fGenePool
the "genePool" where the individuals of the current generation are stored
void AddPopulation(GeneticPopulation *strangers)
add another population (strangers) to the one of this GeneticPopulation
void SetRandomSeed(UInt_t seed=0)
the random seed of the random generator
GeneticGenes MakeSex(GeneticGenes male, GeneticGenes female)
this function takes two individuals and produces offspring by mixing (recombining) their coefficients...
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.
ostringstream derivative to redirect and format output
Random number generator class based on M.
MsgLogger & Endl(MsgLogger &ml)