GeneticAlgoithm
Implementation of the genetic algorithm
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ParametricModelPopulation Class Reference

Implements a population of parametric models. More...

#include <ParametricModelPopulation.h>

Inheritance diagram for ParametricModelPopulation:
Inheritance graph
[legend]
Collaboration diagram for ParametricModelPopulation:
Collaboration graph
[legend]

Public Member Functions

 ParametricModelPopulation ()
 
 ~ParametricModelPopulation ()
 
void setFormula (TF1 *formula)
 
void setMutationSize (double relativeSize)
 
- Public Member Functions inherited from IPopulation
 IPopulation ()
 
virtual ~IPopulation ()
 
void initialize (int n)
 
void crossOver ()
 
void mutate ()
 
void score ()
 
void setRandomSeed (int seed)
 
void setMutateRate (double rate)
 
void setFigureOfMerit (IFigureOfMerit *fom)
 
IFigureOfMeritgetFigureOfMerit ()
 
IModelgetBestFitted (int rank=0)
 
int size ()
 
double getScoreMean ()
 
double getScoreRMS ()
 
void clear ()
 

Protected Member Functions

virtual void doInitialize (int n)
 
virtual void doCrossOver (const std::vector< std::vector< IModel *> > &parents)
 
virtual void doMutate (IModel *model)
 
- Protected Member Functions inherited from IPopulation
virtual void selectParents (int &p1, int &p2)
 
void sort ()
 
void checkFigureOfMerit ()
 

Protected Attributes

TF1 * m_formula
 Stores the formula for this population.
 
double m_mutationSize
 Stores the relative size (sigma) of the gaussian noise applied during mutation.
 
- Protected Attributes inherited from IPopulation
double m_mutateRate
 Stores the mutate rate.
 
bool m_sorted
 Stores whether the ranking is valid or needs to be redone.
 
std::vector< IModel * > m_individuals
 Stores the individuals of this population.
 
IFigureOfMeritm_fom
 Stores the figure of merit to be used to calculate scores and perform the ranking.
 
TRandom3 * m_random
 Stores a random number generator.
 
double m_scoreMean
 Stores the mean score for the population.
 
double m_scoreRMS
 Stores the score RMS for the population.
 
std::vector< std::vector< IModel * > > m_parents
 Stores the list of parents about to be crossed-over.
 

Detailed Description

Implements a population of parametric models.

The following behavior is implemented:

Definition at line 16 of file ParametricModelPopulation.h.

Constructor & Destructor Documentation

◆ ParametricModelPopulation()

ParametricModelPopulation::ParametricModelPopulation ( )

Default Constructor.

Definition at line 5 of file ParametricModelPopulation.cxx.

◆ ~ParametricModelPopulation()

ParametricModelPopulation::~ParametricModelPopulation ( )

Destructor.

Definition at line 12 of file ParametricModelPopulation.cxx.

Member Function Documentation

◆ setFormula()

void ParametricModelPopulation::setFormula ( TF1 *  formula)

Sets the formula for this population.

Parameters
formulaFormula to be used for this population.

Definition at line 19 of file ParametricModelPopulation.cxx.

◆ setMutationSize()

void ParametricModelPopulation::setMutationSize ( double  relativeSize)

Sets the relative size (sigma) of the gaussian noise applied during mutation.

Parameters
relativeSizeThe relative size (sigma) of the gaussian noise applied during mutation.

Definition at line 27 of file ParametricModelPopulation.cxx.

◆ doInitialize()

void ParametricModelPopulation::doInitialize ( int  n)
protectedvirtual

Implements initialization.

Parameters for the individual models are randomly initialized following uniform distribution in the allowed range as defined in the population's formula.

Parameters
Thedesired size of the population.

Implements IPopulation.

Definition at line 38 of file ParametricModelPopulation.cxx.

◆ doCrossOver()

void ParametricModelPopulation::doCrossOver ( const std::vector< std::vector< IModel *> > &  parents)
protectedvirtual

Implements cross-over.

Cross-over is implemented such that each parameter is passed from either parents chosen at random.

Parameters
parentsList of parents to be crossed-over.

Implements IPopulation.

Definition at line 62 of file ParametricModelPopulation.cxx.

◆ doMutate()

void ParametricModelPopulation::doMutate ( IModel imodel)
protectedvirtual

Implements mutation.

Mutation is implemented such that a random parameter is chosen and then modified by adding a gaussian noise component. The size of the gaussian noise is controlled via setMutationSize().

Parameters
imodelModel to be mutated.

Implements IPopulation.

Definition at line 110 of file ParametricModelPopulation.cxx.


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