Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMVA::GeneticPopulation Class Reference

Population definition for genetic algorithm.

Definition at line 48 of file GeneticPopulation.h.

Public Member Functions

 GeneticPopulation (const std::vector< TMVA::Interval * > &ranges, Int_t size, UInt_t seed=0)
 Constructor.
 
virtual ~GeneticPopulation ()
 destructor
 
void AddPopulation (GeneticPopulation &strangers)
 add another population (strangers) to the one of this GeneticPopulation
 
void AddPopulation (GeneticPopulation *strangers)
 add another population (strangers) to the one of this GeneticPopulation
 
Double_t GetFitness () const
 
std::vector< TMVA::GeneticGenes > & GetGenePool ()
 
const std::vector< TMVA::GeneticGenes > & GetGenePool () const
 
GeneticGenesGetGenes (Int_t index)
 gives back the "Genes" of the population with the given index.
 
Int_t GetPopulationSize () const
 
std::vector< TMVA::GeneticRange * > & GetRanges ()
 
const std::vector< TMVA::GeneticRange * > & GetRanges () const
 
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 known to perform good, they can be given as a hint to the population
 
virtual TClassIsA () const
 
void MakeChildren ()
 Creates children out of members of the current generation.
 
void MakeCopies (int number)
 Produces offspring which is are copies of their parents.
 
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.
 
void NextGeneration ()
 
void Print (Int_t untilIndex=-1)
 make a little printout of the individuals up to index "untilIndex" this means, .
 
void Print (std::ostream &out, Int_t utilIndex=-1)
 make a little printout to the stream "out" of the individuals up to index "untilIndex" this means, .
 
void SetRandomSeed (UInt_t seed=0)
 the random seed of the random generator
 
void Sort ()
 sort the genepool according to the fitness of the individuals
 
virtual void Streamer (TBuffer &)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
void TrimPopulation ()
 trim the population to the predefined size
 
std::vector< Double_tVariableDistribution (Int_t varNumber)
 gives back all the values of coefficient "varNumber" of the current generation
 
TH1FVariableDistribution (Int_t varNumber, Int_t bins, Int_t min, Int_t max)
 give back a histogram with the distribution of the coefficients.
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 

Private Member Functions

MsgLoggerLog () const
 
GeneticGenes MakeSex (GeneticGenes male, GeneticGenes female)
 this function takes two individuals and produces offspring by mixing (recombining) their coefficients.
 

Private Attributes

std::vector< TMVA::GeneticGenesfGenePool
 the "genePool" where the individuals of the current generation are stored
 
MsgLoggerfLogger
 message logger
 
Int_t fPopulationSizeLimit
 
TRandom3fRandomGenerator
 random Generator for this population
 
std::vector< TMVA::GeneticRange * > fRanges
 contains the ranges in between the values of the coefficients have to be
 

#include <TMVA/GeneticPopulation.h>

Constructor & Destructor Documentation

◆ GeneticPopulation()

TMVA::GeneticPopulation::GeneticPopulation ( const std::vector< TMVA::Interval * > &  ranges,
Int_t  size,
UInt_t  seed = 0 
)

Constructor.

Definition at line 49 of file GeneticPopulation.cxx.

◆ ~GeneticPopulation()

TMVA::GeneticPopulation::~GeneticPopulation ( )
virtual

destructor

Definition at line 78 of file GeneticPopulation.cxx.

Member Function Documentation

◆ AddPopulation() [1/2]

void TMVA::GeneticPopulation::AddPopulation ( GeneticPopulation strangers)

add another population (strangers) to the one of this GeneticPopulation

Definition at line 291 of file GeneticPopulation.cxx.

◆ AddPopulation() [2/2]

void TMVA::GeneticPopulation::AddPopulation ( GeneticPopulation strangers)

add another population (strangers) to the one of this GeneticPopulation

Definition at line 280 of file GeneticPopulation.cxx.

◆ Class()

static TClass * TMVA::GeneticPopulation::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TMVA::GeneticPopulation::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TMVA::GeneticPopulation::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 104 of file GeneticPopulation.h.

◆ DeclFileName()

static const char * TMVA::GeneticPopulation::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 104 of file GeneticPopulation.h.

◆ GetFitness()

Double_t TMVA::GeneticPopulation::GetFitness ( ) const
inline

Definition at line 63 of file GeneticPopulation.h.

◆ GetGenePool() [1/2]

std::vector< TMVA::GeneticGenes > & TMVA::GeneticPopulation::GetGenePool ( )
inline

Definition at line 68 of file GeneticPopulation.h.

◆ GetGenePool() [2/2]

const std::vector< TMVA::GeneticGenes > & TMVA::GeneticPopulation::GetGenePool ( ) const
inline

Definition at line 65 of file GeneticPopulation.h.

◆ GetGenes()

TMVA::GeneticGenes * TMVA::GeneticPopulation::GetGenes ( Int_t  index)

gives back the "Genes" of the population with the given index.

Definition at line 194 of file GeneticPopulation.cxx.

◆ GetPopulationSize()

Int_t TMVA::GeneticPopulation::GetPopulationSize ( ) const
inline

Definition at line 62 of file GeneticPopulation.h.

◆ GetRanges() [1/2]

std::vector< TMVA::GeneticRange * > & TMVA::GeneticPopulation::GetRanges ( )
inline

Definition at line 69 of file GeneticPopulation.h.

◆ GetRanges() [2/2]

const std::vector< TMVA::GeneticRange * > & TMVA::GeneticPopulation::GetRanges ( ) const
inline

Definition at line 66 of file GeneticPopulation.h.

◆ GiveHint()

void TMVA::GeneticPopulation::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 known to perform good, they can be given as a hint to the population

Definition at line 310 of file GeneticPopulation.cxx.

◆ IsA()

virtual TClass * TMVA::GeneticPopulation::IsA ( ) const
inlinevirtual
Returns
TClass describing current object

Definition at line 104 of file GeneticPopulation.h.

◆ Log()

MsgLogger & TMVA::GeneticPopulation::Log ( ) const
inlineprivate

Definition at line 100 of file GeneticPopulation.h.

◆ MakeChildren()

void TMVA::GeneticPopulation::MakeChildren ( )

Creates children out of members of the current generation.

Children have a combination of the coefficients of their parents

Definition at line 119 of file GeneticPopulation.cxx.

◆ MakeCopies()

void TMVA::GeneticPopulation::MakeCopies ( int  number)

Produces offspring which is are copies of their parents.

Parameters:

  • int number : the number of the last individual to be copied

Definition at line 104 of file GeneticPopulation.cxx.

◆ MakeSex()

TMVA::GeneticGenes TMVA::GeneticPopulation::MakeSex ( TMVA::GeneticGenes  male,
TMVA::GeneticGenes  female 
)
private

this function takes two individuals and produces offspring by mixing (recombining) their coefficients.

Definition at line 136 of file GeneticPopulation.cxx.

◆ Mutate()

void TMVA::GeneticPopulation::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.

Parameters:

  • double probability : gives the probability (in percent) of a mutation of a coefficient
  • int startIndex : leaves unchanged (without mutation) the individuals which are better ranked than indicated by "startIndex". This means: if "startIndex==3", the first (and best) three individuals are not mutated. This allows to preserve the best result of the current Generation for the next generation.
  • Bool_t near : if true, the mutation will produce a new coefficient which is "near" the old one (gaussian around the current value)
  • double spread : if near==true, spread gives the sigma of the gaussian
  • Bool_t mirror : if the new value obtained would be outside of the given constraints the value is mapped between the constraints again. This can be done either by a kind of periodic boundary conditions or mirrored at the boundary. (mirror = true seems more "natural")

Definition at line 168 of file GeneticPopulation.cxx.

◆ NextGeneration()

void TMVA::GeneticPopulation::NextGeneration ( )
inline

Definition at line 82 of file GeneticPopulation.h.

◆ Print() [1/2]

void TMVA::GeneticPopulation::Print ( Int_t  untilIndex = -1)

make a little printout of the individuals up to index "untilIndex" this means, .

. write out the best "untilIndex" individuals.

Definition at line 203 of file GeneticPopulation.cxx.

◆ Print() [2/2]

void TMVA::GeneticPopulation::Print ( std::ostream &  out,
Int_t  untilIndex = -1 
)

make a little printout to the stream "out" of the individuals up to index "untilIndex" this means, .

. write out the best "untilIndex" individuals.

Definition at line 225 of file GeneticPopulation.cxx.

◆ SetRandomSeed()

void TMVA::GeneticPopulation::SetRandomSeed ( UInt_t  seed = 0)

the random seed of the random generator

Definition at line 93 of file GeneticPopulation.cxx.

◆ Sort()

void TMVA::GeneticPopulation::Sort ( )

sort the genepool according to the fitness of the individuals

Definition at line 321 of file GeneticPopulation.cxx.

◆ Streamer()

virtual void TMVA::GeneticPopulation::Streamer ( TBuffer )
virtual

◆ StreamerNVirtual()

void TMVA::GeneticPopulation::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 104 of file GeneticPopulation.h.

◆ TrimPopulation()

void TMVA::GeneticPopulation::TrimPopulation ( )

trim the population to the predefined size

Definition at line 299 of file GeneticPopulation.cxx.

◆ VariableDistribution() [1/2]

vector< Double_t > TMVA::GeneticPopulation::VariableDistribution ( Int_t  varNumber)

gives back all the values of coefficient "varNumber" of the current generation

Definition at line 268 of file GeneticPopulation.cxx.

◆ VariableDistribution() [2/2]

TH1F * TMVA::GeneticPopulation::VariableDistribution ( Int_t  varNumber,
Int_t  bins,
Int_t  min,
Int_t  max 
)

give back a histogram with the distribution of the coefficients.

Parameters:

  • int bins : number of bins of the histogram
  • int min : histogram minimum
  • int max : maximum value of the histogram

Definition at line 251 of file GeneticPopulation.cxx.

Member Data Documentation

◆ fGenePool

std::vector<TMVA::GeneticGenes> TMVA::GeneticPopulation::fGenePool
private

the "genePool" where the individuals of the current generation are stored

Definition at line 94 of file GeneticPopulation.h.

◆ fLogger

MsgLogger* TMVA::GeneticPopulation::fLogger
mutableprivate

message logger

Definition at line 99 of file GeneticPopulation.h.

◆ fPopulationSizeLimit

Int_t TMVA::GeneticPopulation::fPopulationSizeLimit
private

Definition at line 102 of file GeneticPopulation.h.

◆ fRandomGenerator

TRandom3* TMVA::GeneticPopulation::fRandomGenerator
private

random Generator for this population

Definition at line 97 of file GeneticPopulation.h.

◆ fRanges

std::vector<TMVA::GeneticRange*> TMVA::GeneticPopulation::fRanges
private

contains the ranges in between the values of the coefficients have to be

Definition at line 95 of file GeneticPopulation.h.

Libraries for TMVA::GeneticPopulation:

The documentation for this class was generated from the following files: