Population of < Gep::Individual, std::binary_function<cGEP::Individual &, GEP::Individual &, bool> >. Holds population of individuals - instances of derrivates of GEP::Individual class. Genetic operators are applied through _operators. More...
#include <Population.h>

Public Types | |
| typedef IndividualType | ind_type |
| typedef Comparator < IndividualType > | comparator |
Public Member Functions | |
| Population (const std::string &path) | |
| Population (const ConfigArgs &cfg) | |
| virtual | ~Population () |
| IndividualType & | operator[] (const u_short &idx) |
| IndividualType | operator[] (const u_short &idx) const |
| virtual void | clear () |
| virtual void | generatePopulation () |
| virtual void | generatePopulation (const std::string &path) |
| virtual void | generate (IndividualType &generate) |
| virtual void | generateAt (u_short idx=0) |
| virtual void | runGeneration () |
| virtual void | runBasicGEPGeneration () |
| virtual void | evaluate (const typename IndividualType::eval_type &user_param=typename IndividualType::eval_type(0), const bool &elite=false) |
| virtual void | fitness (const bool &elite=false) |
| virtual void | reset (std::vector< IndividualType > &vec) |
| virtual void | readConfig (const std::string &path) |
| virtual void | readConfig (const ConfigArgs &cfg) |
| u_short | countViable () |
| std::vector< u_short > | getUnviablesIdx () |
| IndividualType & | findCurrentBest () |
| virtual const IndividualType & | getBest () const |
| virtual IndividualType & | getBest () |
| virtual const IndividualType & | getWorst () const |
| virtual IndividualType & | getWorst () |
| u_short | getPopSize () const |
| size_t | getAge () const |
| std::vector< short > | getInitLinks () const |
| double | getMutationProbability () const |
| double | getLinkMutationProbability () const |
| double | getInversionProbability () const |
| double | getTranspositionISProbability () const |
| double | getTranspositionRISProbability () const |
| double | getTranspositionGeneProbability () const |
| double | getOnePointCrossoverProbability () const |
| double | getTwoPointCrossoverProbability () const |
| double | getGenePointCrossoverProbability () const |
| u_short | getInversionLength () const |
| u_short | getTransposonLength () const |
| std::vector< IndividualType > & | getIndividuals () |
| const std::vector < IndividualType > & | getIndividuals () const |
| std::vector< IndividualType > & | getElite () |
| const std::vector < IndividualType > & | getElite () const |
| const Operators< IndividualType > & | getOperators () const |
| Operators< IndividualType > & | getOperators () |
| void | setInitLinks (const std::vector< short > &initLinks) |
| void | setMutationProbability (const double fpMutation) |
| void | setLinkMutationProbability (const double fpLinkMutation) |
| void | setInversionProbability (const double fpInversion) |
| void | setTranspositionISProbability (const double fpTranspositionIS) |
| void | setTranspositionRISProbability (const double fpTranspositionRIS) |
| void | setTranspositionGeneProbability (const double fpTranspositionGene) |
| void | setOnePointCrossoverProbability (const double fpOnePointCrossover) |
| void | setTwoPointCrossoverProbability (const double fpTwoPointCrossover) |
| void | setGenePointCrossoverProbability (const double fpGeneCrossover) |
| void | setInversionLength (const u_short finversionLength) |
| void | setTransposonLength (const u_short ftransposonLength) |
Protected Member Functions | |
| virtual void | init () |
| virtual void | tournamentSelection () |
| virtual void | elitism () |
| virtual void | findWorst () |
| virtual void | smartElite () |
| virtual void | simpleElite () |
| virtual void | singleIndividualOperators () |
| virtual void | twoIndividualOperators () |
Protected Attributes | |
| u_short | _popSize |
| size_t | _age |
| u_short | _eliteSize |
| std::vector< IndividualType > | _individuals |
| std::vector< IndividualType > | _tmp_pop |
| std::vector< IndividualType > | _elite |
| IndividualType | _bestInPop |
| IndividualType | _worstInPop |
| Operators< IndividualType > | _operators |
| RandomConstants < IndividualType, Comparator > | _rcpop |
| Comparator< IndividualType > | _comparator |
| std::vector< u_short > | _initLinks |
| double | _pMutation |
| double | _pLinkMutation |
| double | _pInversion |
| double | _pTranspositionIS |
| double | _pTranspositionRIS |
| double | _pTranspositionGene |
| double | _pOnePointCrossover |
| double | _pTwoPointCrossover |
| double | _pGeneCrossover |
Static Protected Attributes | |
| static smallGen | _rng_select |
Private Types | |
| typedef IndividualType::chromo_type | IChromoType |
| typedef IndividualType::ret_type | IReturnType |
Population of < Gep::Individual, std::binary_function<cGEP::Individual &, GEP::Individual &, bool> >. Holds population of individuals - instances of derrivates of GEP::Individual class. Genetic operators are applied through _operators.
| typedef Comparator<IndividualType> GEP::Population< IndividualType, Comparator >::comparator |
typedef IndividualType::chromo_type GEP::Population< IndividualType, Comparator >::IChromoType [private] |
| typedef IndividualType GEP::Population< IndividualType, Comparator >::ind_type |
typedef IndividualType::ret_type GEP::Population< IndividualType, Comparator >::IReturnType [private] |
Reimplemented in GEP::MOPopulation< IndividualType, Comparator >.
| GEP::Population< IndividualType, Comparator >::Population | ( | const std::string & | path | ) | [inline] |
Constructor
| path | - path to configure file |
| GEP::Population< IndividualType, Comparator >::Population | ( | const ConfigArgs & | cfg | ) | [inline] |
Constructor
| cfg | - ConfigArgs structure containing the setup |
| GEP::Population< IndividualType, Comparator >::~Population | ( | ) | [inline, virtual] |
| void GEP::Population< IndividualType, Comparator >::clear | ( | ) | [inline, virtual] |
Reimplemented in GEP::MOPopulation< IndividualType, Comparator >.
| u_short GEP::Population< IndividualType, Comparator >::countViable | ( | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::elitism | ( | ) | [inline, protected, virtual] |
Choses _eliteSize individuals of the highest fitness of the population, places them in _elite Assumes, that individuals are evaluated, and their fitness - calculated.
Reimplemented in GEP::MOPopulation< IndividualType, Comparator >.
| void GEP::Population< IndividualType, Comparator >::evaluate | ( | const typename IndividualType::eval_type & | user_param = typename IndividualType::eval_type(0), |
|
| const bool & | elite = false | |||
| ) | [inline, virtual] |
Runs evaluation for all elements in population, with user_param as target case
| user_param | - desired output | |
| elite | - if true, elite will be evaluated |
Reimplemented in GEP::CellPopulation< IndividualType, Comparator >, and GEP::MergePopulation< IndividualType, Comparator >.
| IndividualType & GEP::Population< IndividualType, Comparator >::findCurrentBest | ( | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::findWorst | ( | ) | [inline, protected, virtual] |
Replaces _worstInPop individual with the one having the lowest fitness in current population.
| void GEP::Population< IndividualType, Comparator >::fitness | ( | const bool & | elite = false |
) | [inline, virtual] |
Calcualtes fitness for all elements in population.
| elite | - if true, fitness of the elite will be calculated |
Reimplemented in GEP::CellPopulation< IndividualType, Comparator >, and GEP::MergePopulation< IndividualType, Comparator >.
| void GEP::Population< IndividualType, Comparator >::generate | ( | IndividualType & | generate | ) | [inline, virtual] |
Generates an Individuals with random Chromosomes.
| generate | - pointer to the individual that will be generated |
| void GEP::Population< IndividualType, Comparator >::generateAt | ( | u_short | idx = 0 |
) | [inline, virtual] |
Generates an Individual with random Chromosome.
| idx | - position at which the individual will be generated |
| void GEP::Population< IndividualType, Comparator >::generatePopulation | ( | const std::string & | path | ) | [inline, virtual] |
Generates population of Individuals with Chromosomes defined file indicated by
| path |
| void GEP::Population< IndividualType, Comparator >::generatePopulation | ( | ) | [inline, virtual] |
Generates population of Individuals with random Chromosomes.
| size_t GEP::Population< IndividualType, Comparator >::getAge | ( | ) | const [inline] |
| virtual IndividualType& GEP::Population< IndividualType, Comparator >::getBest | ( | ) | [inline, virtual] |
| virtual const IndividualType& GEP::Population< IndividualType, Comparator >::getBest | ( | ) | const [inline, virtual] |
| const std::vector<IndividualType>& GEP::Population< IndividualType, Comparator >::getElite | ( | ) | const [inline] |
| std::vector<IndividualType>& GEP::Population< IndividualType, Comparator >::getElite | ( | ) | [inline] |
| double GEP::Population< IndividualType, Comparator >::getGenePointCrossoverProbability | ( | ) | const [inline] |
| const std::vector<IndividualType>& GEP::Population< IndividualType, Comparator >::getIndividuals | ( | ) | const [inline] |
| std::vector<IndividualType>& GEP::Population< IndividualType, Comparator >::getIndividuals | ( | ) | [inline] |
| std::vector<short> GEP::Population< IndividualType, Comparator >::getInitLinks | ( | ) | const [inline] |
| u_short GEP::Population< IndividualType, Comparator >::getInversionLength | ( | ) | const [inline] |
| double GEP::Population< IndividualType, Comparator >::getInversionProbability | ( | ) | const [inline] |
| double GEP::Population< IndividualType, Comparator >::getLinkMutationProbability | ( | ) | const [inline] |
| double GEP::Population< IndividualType, Comparator >::getMutationProbability | ( | ) | const [inline] |
| double GEP::Population< IndividualType, Comparator >::getOnePointCrossoverProbability | ( | ) | const [inline] |
| Operators<IndividualType>& GEP::Population< IndividualType, Comparator >::getOperators | ( | ) | [inline] |
| const Operators<IndividualType>& GEP::Population< IndividualType, Comparator >::getOperators | ( | ) | const [inline] |
| u_short GEP::Population< IndividualType, Comparator >::getPopSize | ( | ) | const [inline] |
| double GEP::Population< IndividualType, Comparator >::getTranspositionGeneProbability | ( | ) | const [inline] |
| double GEP::Population< IndividualType, Comparator >::getTranspositionISProbability | ( | ) | const [inline] |
| double GEP::Population< IndividualType, Comparator >::getTranspositionRISProbability | ( | ) | const [inline] |
| u_short GEP::Population< IndividualType, Comparator >::getTransposonLength | ( | ) | const [inline] |
| double GEP::Population< IndividualType, Comparator >::getTwoPointCrossoverProbability | ( | ) | const [inline] |
| std::vector< u_short > GEP::Population< IndividualType, Comparator >::getUnviablesIdx | ( | ) | [inline] |
| virtual IndividualType& GEP::Population< IndividualType, Comparator >::getWorst | ( | ) | [inline, virtual] |
| virtual const IndividualType& GEP::Population< IndividualType, Comparator >::getWorst | ( | ) | const [inline, virtual] |
| void GEP::Population< IndividualType, Comparator >::init | ( | ) | [inline, protected, virtual] |
Handles the initialization of the population.
| IndividualType GEP::Population< IndividualType, Comparator >::operator[] | ( | const u_short & | idx | ) | const [inline] |
| IndividualType& GEP::Population< IndividualType, Comparator >::operator[] | ( | const u_short & | idx | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::readConfig | ( | const ConfigArgs & | cfg | ) | [inline, virtual] |
Reimplemented in GEP::MOPopulation< IndividualType, Comparator >.
| void GEP::Population< IndividualType, Comparator >::readConfig | ( | const std::string & | path | ) | [inline, virtual] |
Parses config file for fields specific to the Population
Reimplemented in GEP::CellPopulation< IndividualType, Comparator >, GEP::MergePopulation< IndividualType, Comparator >, and GEP::MOPopulation< IndividualType, Comparator >.
| void GEP::Population< IndividualType, Comparator >::reset | ( | std::vector< IndividualType > & | vec | ) | [inline, virtual] |
Invokes 'reset' for a whole population. Used for fitness calculation.
| void GEP::Population< IndividualType, Comparator >::runBasicGEPGeneration | ( | ) | [inline, virtual] |
Performs operators on the population in the following sequence:
> elitism (choose _eliteSize best individuals; for Ferreira _eliteSize = 1)
1) Create temporary population through:
> selection
2) Apply individual operators
> one individual operators (mutation and IS, RIS, Gene transpositions)
> two individual operators (one point, two point and gene crossovers)
> elitism, continued - replace _eliteSize first individuals with the elite ones.
3) Replace the population with temporary one
4) Replace _eliteSize first individuals with _elite
Reimplemented in GEP::CellPopulation< IndividualType, Comparator >, and GEP::MergePopulation< IndividualType, Comparator >.
| void GEP::Population< IndividualType, Comparator >::runGeneration | ( | ) | [inline, virtual] |
Performs operators on the population in the following sequence:
1) Update population
> elitism - replacement of the worst, (if any) with the best of previous gen (_elite)
(This is clearly different than approach of Ferreira - see runBasicGEPGeneration)
2) Create temporary population through:
> selection
3) Apply individual operators
> one individual operators (mutation and IS, RIS, Gene transpositions)
> two individual operators (one point, two point and gene crossovers)
4) Replace the population with temporary one
Reimplemented in GEP::CellPopulation< IndividualType, Comparator >, and GEP::MergePopulation< IndividualType, Comparator >.
| void GEP::Population< IndividualType, Comparator >::setGenePointCrossoverProbability | ( | const double | fpGeneCrossover | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setInitLinks | ( | const std::vector< short > & | initLinks | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setInversionLength | ( | const u_short | finversionLength | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setInversionProbability | ( | const double | fpInversion | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setLinkMutationProbability | ( | const double | fpLinkMutation | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setMutationProbability | ( | const double | fpMutation | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setOnePointCrossoverProbability | ( | const double | fpOnePointCrossover | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setTranspositionGeneProbability | ( | const double | fpTranspositionGene | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setTranspositionISProbability | ( | const double | fpTranspositionIS | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setTranspositionRISProbability | ( | const double | fpTranspositionRIS | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setTransposonLength | ( | const u_short | ftransposonLength | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::setTwoPointCrossoverProbability | ( | const double | fpTwoPointCrossover | ) | [inline] |
| void GEP::Population< IndividualType, Comparator >::simpleElite | ( | ) | [inline, protected, virtual] |
Replaces _eliteSize firts individuals of temporary population with elite ones.
Reimplemented in GEP::MOPopulation< IndividualType, Comparator >.
| void GEP::Population< IndividualType, Comparator >::singleIndividualOperators | ( | ) | [inline, protected, virtual] |
Reimplemented in GEP::MergePopulation< IndividualType, Comparator >.
| void GEP::Population< IndividualType, Comparator >::smartElite | ( | ) | [inline, protected, virtual] |
Replaces worst population individuals (if any) with elite ones. Comparison is made on the basis of fitness. Operates on populations (uses evaluated individuals!). Assumes, that individuals are evaluated, and their fitness - calculated.
Reimplemented in GEP::MOPopulation< IndividualType, Comparator >.
| void GEP::Population< IndividualType, Comparator >::tournamentSelection | ( | ) | [inline, protected, virtual] |
Tournament Selection mechanism (instead of Roulette Wheel by Ferreira). Results are placed in temporary population. Assumes, that individuals are evaluated, and their fitness - calculated.
Reimplemented in GEP::MergePopulation< IndividualType, Comparator >, and GEP::MOPopulation< IndividualType, Comparator >.
| void GEP::Population< IndividualType, Comparator >::twoIndividualOperators | ( | ) | [inline, protected, virtual] |
Reimplemented in GEP::MergePopulation< IndividualType, Comparator >.
size_t GEP::Population< IndividualType, Comparator >::_age [protected] |
current id of the generation i.e the age of the population
IndividualType GEP::Population< IndividualType, Comparator >::_bestInPop [protected] |
The best individual in population (after evaluation)
Comparator<IndividualType> GEP::Population< IndividualType, Comparator >::_comparator [protected] |
Comparator returns true if the first individual is better in the terms of fitness than the other.
std::vector<IndividualType> GEP::Population< IndividualType, Comparator >::_elite [protected] |
The elite (vector of template objects)
u_short GEP::Population< IndividualType, Comparator >::_eliteSize [protected] |
The size of the elite
std::vector<IndividualType> GEP::Population< IndividualType, Comparator >::_individuals [protected] |
The population (vector of template objects)
std::vector<u_short> GEP::Population< IndividualType, Comparator >::_initLinks [protected] |
Initial links for all chromosomes of individuals in the population.
Operators<IndividualType> GEP::Population< IndividualType, Comparator >::_operators [protected] |
Instance of GEP::Operators, reponsible for generating and modifying individuals.
double GEP::Population< IndividualType, Comparator >::_pGeneCrossover [protected] |
Probability of Gene crossover
double GEP::Population< IndividualType, Comparator >::_pInversion [protected] |
Probability of inversion
double GEP::Population< IndividualType, Comparator >::_pLinkMutation [protected] |
Probability of link mutation
double GEP::Population< IndividualType, Comparator >::_pMutation [protected] |
Probability of mutation
double GEP::Population< IndividualType, Comparator >::_pOnePointCrossover [protected] |
Probability of one point crossover
u_short GEP::Population< IndividualType, Comparator >::_popSize [protected] |
The size of the population
double GEP::Population< IndividualType, Comparator >::_pTranspositionGene [protected] |
Probability of Gene transposition
double GEP::Population< IndividualType, Comparator >::_pTranspositionIS [protected] |
Probability of Insert Sequence transposition
double GEP::Population< IndividualType, Comparator >::_pTranspositionRIS [protected] |
Probability of Root Insert Sequence transposition
double GEP::Population< IndividualType, Comparator >::_pTwoPointCrossover [protected] |
Probability of two point crossover
RandomConstants<IndividualType,Comparator> GEP::Population< IndividualType, Comparator >::_rcpop [protected] |
Instance of GEP::RandomConstants, reponsible for generating and modifying random constants of individuals.
smallGen GEP::Population< IndividualType, Comparator >::_rng_select [inline, static, protected] |
Random number generator for the sake of population operators
std::vector<IndividualType> GEP::Population< IndividualType, Comparator >::_tmp_pop [protected] |
Temporary population (vector of template objects)
IndividualType GEP::Population< IndividualType, Comparator >::_worstInPop [protected] |
The worst individual in population (for you, Seb;) )
1.6.1