ROOT logo
ROOT » TMVA » TMVA::GeneticAlgorithm

class TMVA::GeneticAlgorithm


 Base definition for genetic algorithm

Function Members (Methods)

public:
virtual~GeneticAlgorithm()
virtual Double_tCalculateFitness()
static TClass*Class()
virtual voidEvolution()
TMVA::GeneticAlgorithmGeneticAlgorithm(const TMVA::GeneticAlgorithm&)
TMVA::GeneticAlgorithmGeneticAlgorithm(TMVA::IFitterTarget& target, Int_t populationSize, const vector<TMVA::Interval*>& ranges, UInt_t seed = 0)
TMVA::GeneticPopulation&GetGeneticPopulation()
Bool_tGetMakeCopies()
Double_tGetSpread() const
virtual Bool_tHasConverged(Int_t steps = 10, Double_t ratio = 0.1)
voidInit()
virtual TClass*IsA() const
virtual Double_tNewFitness(Double_t oldValue, Double_t newValue)
voidSetMakeCopies(Bool_t s)
voidSetSpread(Double_t s)
virtual voidShowMembers(TMemberInspector& insp)
virtual Double_tSpreadControl(Int_t steps, Int_t ofSteps, Double_t factor)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
protected:
TMVA::MsgLogger&Log() const

Data Members

public:
Int_tfConvCounterconverging? ... keeps track of the number of improvements
protected:
Double_tfBestFitness
Double_tfConvValuekeeps track of the quantity of improvement
Bool_tfFirstTimeif true its the first time, so no evolution yet
TMVA::IFitterTarget&fFitterTargetthe fitter target
Double_tfLastResultremembers the last obtained result (for internal use)
TMVA::MsgLogger*fLoggermessage logger
Bool_tfMakeCopiesif true, the population will make copies of the first individuals
Bool_tfMirrornew values for mutation are mirror-mapped if outside of constraints
TMVA::GeneticPopulationfPopulationcontains and controls the "individual"
Int_tfPopulationSizethe size of the population
const vector<TMVA::Interval*>&fRangesparameter ranges
Double_tfSpreadregulates the spread of the value change at mutation (sigma)
deque<Int_t>fSuccessListto adjust the stepSize

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

GeneticAlgorithm(TMVA::IFitterTarget& target, Int_t populationSize, const vector<TMVA::Interval*>& ranges, UInt_t seed = 0)
 Constructor
 Parameters:
     int populationSize : defines the number of "Individuals" which are created and tested
                          within one Generation (Iteration of the Evolution)
     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()
~GeneticAlgorithm()
 destructor; deletes fLogger
void Init()
 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.
Double_t 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;
Double_t 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.
void 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.
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.

 Parameters:
      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.

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"

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

GeneticAlgorithm(TMVA::IFitterTarget& target, Int_t populationSize, const vector<TMVA::Interval*>& ranges, UInt_t seed = 0)
GeneticPopulation& GetGeneticPopulation()
{ return fPopulation; }
Double_t GetSpread() const
{ return fSpread; }
void SetSpread(Double_t s)
{ fSpread = s; }
void SetMakeCopies(Bool_t s)
{ fMakeCopies = s; }
Bool_t GetMakeCopies()
{ return fMakeCopies; }