Logo ROOT  
Reference Guide
TMVA::GeneticAlgorithm Class Reference

Base definition for genetic algorithm.

Definition at line 50 of file GeneticAlgorithm.h.

Public Member Functions

 GeneticAlgorithm (IFitterTarget &target, Int_t populationSize, const std::vector< TMVA::Interval * > &ranges, UInt_t seed=0)
 Constructor. More...
virtual ~GeneticAlgorithm ()
virtual Double_t CalculateFitness ()
 starts the evaluation of the fitness of all different individuals of the population. More...
virtual void Evolution ()
 this function is called from "init" and controls the evolution of the individuals. More...
GeneticPopulationGetGeneticPopulation ()
Bool_t GetMakeCopies ()
Double_t GetSpread () const
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 "individuals" of at least "improvement" More...
void Init ()
 calls evolution, but if it is not the first time. More...
virtual TClassIsA () const
virtual Double_t NewFitness (Double_t oldValue, Double_t newValue)
 if the "fitnessFunction" is called multiple times for one set of factors (because i.e. More...
void SetMakeCopies (Bool_t s)
void SetSpread (Double_t s)
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 the last generations. More...
virtual void Streamer (TBuffer &)
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)

Static Public Member Functions

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

Public Attributes

Int_t fConvCounter

Protected Member Functions

MsgLoggerLog () const

Protected Attributes

Double_t fBestFitness
Double_t fConvValue
Bool_t fFirstTime
Double_t fLastResult
Bool_t fMakeCopies
Bool_t fMirror
GeneticPopulation fPopulation
Int_t fPopulationSize
const std::vector< TMVA::Interval * > & fRanges
Double_t fSpread
std::deque< Int_tfSuccessList

#include <TMVA/GeneticAlgorithm.h>

Constructor & Destructor Documentation

◆ GeneticAlgorithm()

TMVA::GeneticAlgorithm::GeneticAlgorithm ( IFitterTarget target,
Int_t  populationSize,
const std::vector< TMVA::Interval * > &  ranges,
UInt_t  seed = 0 



  • int populationSize : defines the number of "Individuals" which are created and tested within one Generation (Iteration of the Evolution)
  • std::vector<TMVA::Interval*> ranges : Interval holds the information of an interval, where the GetMin gets the low and GetMax gets the high constraint of the variable the size of "ranges" is the number of coefficients which are optimised Purpose:

    Creates a random population with individuals of the size ranges.size()

Definition at line 69 of file GeneticAlgorithm.cxx.

◆ ~GeneticAlgorithm()

TMVA::GeneticAlgorithm::~GeneticAlgorithm ( )

Definition at line 88 of file GeneticAlgorithm.cxx.

Member Function Documentation

◆ CalculateFitness()

Double_t TMVA::GeneticAlgorithm::CalculateFitness ( )

starts the evaluation of the fitness of all different individuals of the population.

this function calls implicitly (many times) the "fitnessFunction" which has been overridden by the user.

Definition at line 135 of file GeneticAlgorithm.cxx.

◆ Class()

static TClass * TMVA::GeneticAlgorithm::Class ( )
TClass describing this class

◆ Class_Name()

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

◆ Class_Version()

static Version_t TMVA::GeneticAlgorithm::Class_Version ( )
Version of this class

Definition at line 104 of file GeneticAlgorithm.h.

◆ DeclFileName()

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

Definition at line 104 of file GeneticAlgorithm.h.

◆ Evolution()

void TMVA::GeneticAlgorithm::Evolution ( )

this function is called from "init" and controls the evolution of the individuals.

The function can be overridden to change the parameters for mutation rate sexual reproduction and so on.

Definition at line 190 of file GeneticAlgorithm.cxx.

◆ GetGeneticPopulation()

GeneticPopulation & TMVA::GeneticAlgorithm::GetGeneticPopulation ( )

Definition at line 67 of file GeneticAlgorithm.h.

◆ GetMakeCopies()

Bool_t TMVA::GeneticAlgorithm::GetMakeCopies ( )

Definition at line 73 of file GeneticAlgorithm.h.

◆ GetSpread()

Double_t TMVA::GeneticAlgorithm::GetSpread ( ) const

Definition at line 69 of file GeneticAlgorithm.h.

◆ HasConverged()

Bool_t TMVA::GeneticAlgorithm::HasConverged ( Int_t  steps = 10,
Double_t  improvement = 0.1 

gives back true if the last "steps" steps have lead to an improvement of the "fitness" of the "individuals" of at least "improvement"

this gives a simple measure of if the fitness of the individuals is converging and no major improvement is to be expected soon.

Definition at line 260 of file GeneticAlgorithm.cxx.

◆ Init()

void TMVA::GeneticAlgorithm::Init ( void  )

calls evolution, but if it is not the first time.

If it's the first time, the random population created by the constructor is still not evaluated, .. therefore we wait for the second time init is called.

Definition at line 101 of file GeneticAlgorithm.cxx.

◆ IsA()

virtual TClass * TMVA::GeneticAlgorithm::IsA ( ) const
TClass describing current object

Definition at line 104 of file GeneticAlgorithm.h.

◆ Log()

MsgLogger & TMVA::GeneticAlgorithm::Log ( ) const

Definition at line 102 of file GeneticAlgorithm.h.

◆ NewFitness()

Double_t TMVA::GeneticAlgorithm::NewFitness ( Double_t  oldValue,
Double_t  newValue 

if the "fitnessFunction" is called multiple times for one set of factors (because i.e.

each event of a TTree has to be assessed with each set of Factors proposed by the Genetic Algorithm) the value of the current calculation has to be added(? or else) to the value obtained up to now. example: some chi-square is calculated for every event, after every event the new chi-square (newValue) has to be simply added to the oldValue.

this function has to be overridden eventually it might contain only the following return statement. return oldValue + newValue;

Definition at line 123 of file GeneticAlgorithm.cxx.

◆ SetMakeCopies()

void TMVA::GeneticAlgorithm::SetMakeCopies ( Bool_t  s)

Definition at line 72 of file GeneticAlgorithm.h.

◆ SetSpread()

void TMVA::GeneticAlgorithm::SetSpread ( Double_t  s)

Definition at line 70 of file GeneticAlgorithm.h.

◆ SpreadControl()

Double_t TMVA::GeneticAlgorithm::SpreadControl ( Int_t  ofSteps,
Int_t  successSteps,
Double_t  factor 

this function provides the ability to change the stepSize of a mutation according to the success of the last generations.


  • int ofSteps : = if OF the number of STEPS given in this variable (ofSteps)
  • int successSteps : >sucessSteps Generations could improve the result
  • double factor : than multiply the stepSize ( spread ) by this factor

(if ofSteps == successSteps nothing is changed, if ofSteps < successSteps, the spread is divided by the factor)

using this function one can increase the stepSize of the mutation when we have good success (to pass fast through the easy phase-space) and reduce the stepSize if we are in a difficult "territory" of the phase-space.

Definition at line 217 of file GeneticAlgorithm.cxx.

◆ Streamer()

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

◆ StreamerNVirtual()

void TMVA::GeneticAlgorithm::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)

Definition at line 104 of file GeneticAlgorithm.h.

Member Data Documentation

◆ fBestFitness

Double_t TMVA::GeneticAlgorithm::fBestFitness

Definition at line 99 of file GeneticAlgorithm.h.

◆ fConvCounter

Int_t TMVA::GeneticAlgorithm::fConvCounter

Definition at line 75 of file GeneticAlgorithm.h.

◆ fConvValue

Double_t TMVA::GeneticAlgorithm::fConvValue

Definition at line 81 of file GeneticAlgorithm.h.

◆ fFirstTime

Bool_t TMVA::GeneticAlgorithm::fFirstTime

Definition at line 91 of file GeneticAlgorithm.h.

◆ fFitterTarget

IFitterTarget& TMVA::GeneticAlgorithm::fFitterTarget

Definition at line 79 of file GeneticAlgorithm.h.

◆ fLastResult

Double_t TMVA::GeneticAlgorithm::fLastResult

Definition at line 87 of file GeneticAlgorithm.h.

◆ fLogger

MsgLogger* TMVA::GeneticAlgorithm::fLogger

Definition at line 101 of file GeneticAlgorithm.h.

◆ fMakeCopies

Bool_t TMVA::GeneticAlgorithm::fMakeCopies

Definition at line 92 of file GeneticAlgorithm.h.

◆ fMirror

Bool_t TMVA::GeneticAlgorithm::fMirror

Definition at line 90 of file GeneticAlgorithm.h.

◆ fPopulation

GeneticPopulation TMVA::GeneticAlgorithm::fPopulation

Definition at line 98 of file GeneticAlgorithm.h.

◆ fPopulationSize

Int_t TMVA::GeneticAlgorithm::fPopulationSize

Definition at line 94 of file GeneticAlgorithm.h.

◆ fRanges

const std::vector<TMVA::Interval*>& TMVA::GeneticAlgorithm::fRanges

Definition at line 96 of file GeneticAlgorithm.h.

◆ fSpread

Double_t TMVA::GeneticAlgorithm::fSpread

Definition at line 89 of file GeneticAlgorithm.h.

◆ fSuccessList

std::deque<Int_t> TMVA::GeneticAlgorithm::fSuccessList

Definition at line 86 of file GeneticAlgorithm.h.

Libraries for TMVA::GeneticAlgorithm:

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