|
GeneticAlgoithm
Implementation of the genetic algorithm
|
Abstract class describing a population of models. More...
#include <IPopulation.h>


Public Member Functions | |
| 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) |
| IFigureOfMerit * | getFigureOfMerit () |
| IModel * | getBestFitted (int rank=0) |
| int | size () |
| double | getScoreMean () |
| double | getScoreRMS () |
| void | clear () |
Protected Member Functions | |
| virtual void | doInitialize (int n)=0 |
| virtual void | doCrossOver (const std::vector< std::vector< IModel *> > &parents)=0 |
| virtual void | doMutate (IModel *model)=0 |
| virtual void | selectParents (int &p1, int &p2) |
| void | sort () |
| void | checkFigureOfMerit () |
Protected Attributes | |
| 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. | |
| IFigureOfMerit * | m_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. | |
Abstract class describing a population of models.
This class should implement the following functionalities:
Derive from this class by implementing at least these three methods:
Definition at line 27 of file IPopulation.h.
| IPopulation::IPopulation | ( | ) |
Default Constructor
Definition at line 10 of file IPopulation.cxx.
|
virtual |
Destructor
Definition at line 20 of file IPopulation.cxx.
| void IPopulation::initialize | ( | int | n | ) |
Initialize a population of a given size.
| n | Desired size of the population. |
Definition at line 28 of file IPopulation.cxx.
| void IPopulation::crossOver | ( | ) |
Performs population cross-over.
Definition at line 34 of file IPopulation.cxx.
| void IPopulation::mutate | ( | ) |
Performs individual mutations.
Definition at line 56 of file IPopulation.cxx.
| void IPopulation::score | ( | ) |
Compute the scores for the members of the population.
This function also calculates the mean and RMS for the scores of this population.
Definition at line 93 of file IPopulation.cxx.
| void IPopulation::setRandomSeed | ( | int | seed | ) |
Sets the random seed for the random number generator.
| seed | Random number generator seed. |
Definition at line 70 of file IPopulation.cxx.
| void IPopulation::setMutateRate | ( | double | rate | ) |
Sets the mutation rate.
| rate | Desired mutation rate. |
Definition at line 79 of file IPopulation.cxx.
| void IPopulation::setFigureOfMerit | ( | IFigureOfMerit * | fom | ) |
Sets the figure of merit to be used to calculate scores and perform the ranking.
| fom | Pointer to a figure of merit object to be used to calculate scores and perform the ranking. |
Definition at line 120 of file IPopulation.cxx.
| IFigureOfMerit * IPopulation::getFigureOfMerit | ( | ) |
Returns the figure of merit that is used to calculate scores and perform the ranking.
Definition at line 128 of file IPopulation.cxx.
| IModel * IPopulation::getBestFitted | ( | int | rank = 0 | ) |
Returns the method at a given rank.
| rank | Rank. |
Definition at line 137 of file IPopulation.cxx.
| int IPopulation::size | ( | ) |
Returns the size of the population.
Definition at line 154 of file IPopulation.cxx.
| double IPopulation::getScoreMean | ( | ) |
Returns the mean score for the population.
Definition at line 162 of file IPopulation.cxx.
| double IPopulation::getScoreRMS | ( | ) |
Returns the RMS of the scores for the population.
Definition at line 170 of file IPopulation.cxx.
| void IPopulation::clear | ( | ) |
Resets the population.
Definition at line 175 of file IPopulation.cxx.
|
protectedpure virtual |
Should implement the actual initialization.
Implemented in ParametricModelPopulation.
|
protectedpure virtual |
Should implement the cross-over.
Implemented in ParametricModelPopulation.
|
protectedpure virtual |
Should implement the mutation of a model.
Implemented in ParametricModelPopulation.
|
protectedvirtual |
Selects parents to be crossed-over
| p1 | Returns the index of the first parent. |
| p2 | Returns the index of the second parent. |
Definition at line 221 of file IPopulation.cxx.
|
protected |
Performs the ranking from the best to the least fitted.
Definition at line 183 of file IPopulation.cxx.
|
protected |
Makes sure an IFigureOfMerit object is assigned to this population.
Definition at line 209 of file IPopulation.cxx.
1.8.13