Set of genetic operations for GEP::SChromosome. It is used to perform modifications to Individuals during evolution of population. Operations here are performed on single (or pairs of) GEP::Chromosome<CType> instances. More...
#include <Operators.h>
Public Member Functions | |
| Operators () | |
| ~Operators () | |
| void | seedTheGenerator () |
| CElement | generateElement () |
| CElement | generateElement (short type) |
| void | generate (Chromosome< CType > &chromosome, bool generateLink, const size_t pop_age=0) |
| void | mutateGene (Chromosome< CType > &mutant, u_short gene, u_short index) |
| void | mutate (Chromosome< CType > &mutant, const size_t pop_age=0) |
| void | mutateLink (Chromosome< CType > &mutant, const size_t pop_age=0) |
| void | mutateAll (Chromosome< CType > &mutant) |
| void | invert (Chromosome< CType > &inverted, u_short gene, u_short index, u_short length, const size_t pop_age=0) |
| void | invert (Chromosome< CType > &inverted, const size_t pop_age=0) |
| void | swapGenes (Chromosome< CType > &toSwap, u_short gene1, u_short gene2, const size_t pop_age=0) |
| void | swapGenes (Chromosome< CType > &toSwap1, Chromosome< CType > &toSwap2, u_short gene1, u_short gene2, const size_t pop_age=0) |
| void | swapElementsDown (Chromosome< CType > &toSwap1, Chromosome< CType > &toSwap2, u_short gene, u_short index) |
| void | swapElementsUp (Chromosome< CType > &toSwap1, Chromosome< CType > &toSwap2, u_short gene, u_short index) |
| void | transposeIS (Chromosome< CType > &toTranspose, u_short length, u_short src, u_short srcPos, u_short dst, u_short dstPos, bool head, const size_t pop_age=0) |
| void | transposeIS (Chromosome< CType > &toTranspose, u_short length, const size_t pop_age=0) |
| void | transposeIS (Chromosome< CType > &toTranspose, bool fixed, const size_t pop_age=0) |
| void | transposeRIS (Chromosome< CType > &toTranspose, u_short length, const size_t pop_age=0) |
| void | transposeRIS (Chromosome< CType > &toTranspose, bool fixed, const size_t pop_age=0) |
| void | transposeGene (Chromosome< CType > &toTranspose, const size_t pop_age=0) |
| void | onePointCross (Chromosome< CType > &p1, Chromosome< CType > &p2, u_short gene, u_short pos, const size_t pop_age=0) |
| void | onePointCross (Chromosome< CType > &p1, Chromosome< CType > &p2, const size_t pop_age=0) |
| void | twoPointCross (Chromosome< CType > &p1, Chromosome< CType > &p2, u_short gene1, u_short pos1, u_short gene2, u_short pos2, const size_t pop_age=0) |
| void | twoPointCross (Chromosome< CType > &p1, Chromosome< CType > &p2, const size_t pop_age=0) |
| void | geneCross (Chromosome< CType > &p1, Chromosome< CType > &p2, const size_t pop_age=0) |
| bool | p_transposeIS (const double &prob, IndividualType &toTranspose, bool fixed, const size_t pop_age=0) |
| bool | p_transposeRIS (const double &prob, IndividualType &toTranspose, bool fixed, const size_t pop_age=0) |
| bool | p_transposeGene (const double &prob, IndividualType &toTranspose, const size_t pop_age=0) |
| bool | p_mutate (const double &prob, IndividualType &mutant, const size_t pop_age=0) |
| bool | p_mutateLink (const double &prob, IndividualType &mutant, const size_t pop_age=0) |
| bool | p_invert (const double &prob, IndividualType &inverted, const size_t pop_age=0) |
| bool | p_onePointCross (const double &prob, IndividualType &p1, IndividualType &p2, const size_t pop_age=0) |
| bool | p_twoPointCross (const double &prob, IndividualType &p1, IndividualType &p2, const size_t pop_age=0) |
| bool | p_geneCross (const double &prob, IndividualType &p1, IndividualType &p2, const size_t pop_age=0) |
| u_short | getInversionLength () const |
| u_short | getTransposonLength () const |
| void | setInversionLength (u_short finversionLength) |
| void | setTransposonLength (u_short ftransposonLength) |
| void | setFunctionProbability (const double &fpb) |
| void | setOneArgFunctionProbability (const double &oafpb) |
Static Public Attributes | |
| static boost::mt19937 | _mersenne = boost::mt19937(42u) |
| static boost::uniform_01 < boost::mt19937 > | _rng_uni_real = boost::uniform_01<boost::mt19937>(_mersenne) |
Private Types | |
| typedef IndividualType::chromo_type | CType |
Private Attributes | |
| smallGen | _rng_oneArg |
| smallGen | _rng_twoArg |
| smallGen | _rng_linkPool |
| smallGen | _rng_terms |
| smallGen | _rng_head |
| smallGen | _rng_tail |
| smallGen | _rng_total |
| smallGen | _rng_links |
| smallGen | _rng_genes |
| smallGen | _rng_is |
| double | _functionProbability |
| double | _oneArgFunctionProbability |
| double | _rcProbability |
| u_short | _inversionLength |
| u_short | _transposonLength |
Set of genetic operations for GEP::SChromosome. It is used to perform modifications to Individuals during evolution of population. Operations here are performed on single (or pairs of) GEP::Chromosome<CType> instances.
typedef IndividualType::chromo_type GEP::Operators< IndividualType >::CType [private] |
| GEP::Operators< IndividualType >::Operators | ( | ) | [inline] |
Seeds the engine with time of microseconds resolution. Since engine is the same for all random generators, one invocation seeds all of them. Constructor
| GEP::Operators< IndividualType >::~Operators | ( | ) | [inline] |
Default destructor. Do not touch ChromosomeFactory pointer - it will be cleaned.
| void GEP::Operators< IndividualType >::geneCross | ( | Chromosome< CType > & | p1, | |
| Chromosome< CType > & | p2, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
Gene crossover. The point of crossover is between positions of ORFs, and it is randomly generated. The result will be two modified Chromosome<CType>s.
| p1 | - first parent | |
| p2 | - second parent | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::generate | ( | Chromosome< CType > & | chromosome, | |
| bool | generateLink, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
Genereates new Chromosome and places it under chromosome
| chromosome | - Chromosome pointer, after invocation it should point to a newly created Chromosome. | |
| generateLink | - if true, a set of linking functions vector will be generated for this Chromosome. | |
| pop_age | - age of the population -- used by cheaters (a variable, perhaps, set by Population?) |
| CElement GEP::Operators< IndividualType >::generateElement | ( | short | type | ) | [inline] |
Generates random element of
| type |
| CElement GEP::Operators< IndividualType >::generateElement | ( | ) | [inline] |
Generates random element of random type
| u_short GEP::Operators< IndividualType >::getInversionLength | ( | ) | const [inline] |
| u_short GEP::Operators< IndividualType >::getTransposonLength | ( | ) | const [inline] |
| void GEP::Operators< IndividualType >::invert | ( | Chromosome< CType > & | inverted, | |
| const size_t | pop_age = 0 | |||
| ) | [inline] |
Inversion with randomly generated position (gene and index) The result will be modified Chromosome<CType>.
| inverted | - a Chromosome<CType> to be mutated | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::invert | ( | Chromosome< CType > & | inverted, | |
| u_short | gene, | |||
| u_short | index, | |||
| u_short | length, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
Inversion of Chromosome<CType>. The result will be modified Chromosome<CType>.
| inverted | - a Chromosome<CType> to be inverted | |
| gene | - ORF to be inverted | |
| index | - position of inversion | |
| length | - number of inverted elements | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::mutate | ( | Chromosome< CType > & | mutant, | |
| const size_t | pop_age = 0 | |||
| ) | [inline] |
The result will be modified Chromosome<CType>.
| mutant | - a Chromosome<CType> to be mutated | |
| pop_age | - age of the population -- used by cheaters (a variable, perhaps, set by Population?) |
| void GEP::Operators< IndividualType >::mutateAll | ( | Chromosome< CType > & | mutant | ) | [inline] |
Mutation of _links vector with randomly generated position of target (in _links) and source (in _linksPool) The result will be modified Chromosome<CType>.
| mutant | - a Chromosome<CType> to be mutated |
| void GEP::Operators< IndividualType >::mutateGene | ( | Chromosome< CType > & | mutant, | |
| u_short | gene, | |||
| u_short | index | |||
| ) | [inline] |
The result will be modified Chromosome<CType>.
| mutant | - a Chromosome<CType> to be mutated | |
| gene | - an ORF to be mutated | |
| index | - position in ORF to be mutated |
| void GEP::Operators< IndividualType >::mutateLink | ( | Chromosome< CType > & | mutant, | |
| const size_t | pop_age = 0 | |||
| ) | [inline] |
Mutation performed on linking functions of the Chromosome<CType> with randomly generated index for target (position in _links) and source (position in _linkPool) The result will be modified Chromosome<CType>.
| mutant | - a Chromosome<CType> to be mutated | |
| pop_age | - age of the population -- used by cheaters (a variable, perhaps, set by Population?) |
| void GEP::Operators< IndividualType >::onePointCross | ( | Chromosome< CType > & | p1, | |
| Chromosome< CType > & | p2, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
One point crossover. The point of crossover is randomly generated. The result will be two modified Chromosome<CType>s.
| p1 | - first parent | |
| p2 | - second parent | |
| pop_age | the age of the current population |
| void GEP::Operators< IndividualType >::onePointCross | ( | Chromosome< CType > & | p1, | |
| Chromosome< CType > & | p2, | |||
| u_short | gene, | |||
| u_short | pos, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
One point crossover. An ORF and position in it are chosen as a point of cross. Every Node down that position is exchanged. The result will be two modified Chromosome<CType>s.
| p1 | - first parent | |
| p2 | - second parent | |
| gene | - index of ORF | |
| pos | - index of Node | |
| pop_age | the age of the current population - for cheater use only |
| bool GEP::Operators< IndividualType >::p_geneCross | ( | const double & | prob, | |
| IndividualType & | p1, | |||
| IndividualType & | p2, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
| bool GEP::Operators< IndividualType >::p_invert | ( | const double & | prob, | |
| IndividualType & | inverted, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
| bool GEP::Operators< IndividualType >::p_mutate | ( | const double & | prob, | |
| IndividualType & | mutant, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
| bool GEP::Operators< IndividualType >::p_mutateLink | ( | const double & | prob, | |
| IndividualType & | mutant, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
| bool GEP::Operators< IndividualType >::p_onePointCross | ( | const double & | prob, | |
| IndividualType & | p1, | |||
| IndividualType & | p2, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
| bool GEP::Operators< IndividualType >::p_transposeGene | ( | const double & | prob, | |
| IndividualType & | toTranspose, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
| bool GEP::Operators< IndividualType >::p_transposeIS | ( | const double & | prob, | |
| IndividualType & | toTranspose, | |||
| bool | fixed, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
| bool GEP::Operators< IndividualType >::p_transposeRIS | ( | const double & | prob, | |
| IndividualType & | toTranspose, | |||
| bool | fixed, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
| bool GEP::Operators< IndividualType >::p_twoPointCross | ( | const double & | prob, | |
| IndividualType & | p1, | |||
| IndividualType & | p2, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
| void GEP::Operators< IndividualType >::seedTheGenerator | ( | ) | [inline] |
| void GEP::Operators< IndividualType >::setFunctionProbability | ( | const double & | fpb | ) | [inline] |
| void GEP::Operators< IndividualType >::setInversionLength | ( | u_short | finversionLength | ) | [inline] |
| void GEP::Operators< IndividualType >::setOneArgFunctionProbability | ( | const double & | oafpb | ) | [inline] |
| void GEP::Operators< IndividualType >::setTransposonLength | ( | u_short | ftransposonLength | ) | [inline] |
| void GEP::Operators< IndividualType >::swapElementsDown | ( | Chromosome< CType > & | toSwap1, | |
| Chromosome< CType > & | toSwap2, | |||
| u_short | gene, | |||
| u_short | index | |||
| ) | [inline] |
Elements in two Chromosome<CType>s exchange place down from chosen point The result will be modified Chromosome<CType>s.
| toSwap1 | - first chromosome to swap | |
| toSwap2 | - second chromosome to swap | |
| gene | - ORF of swap point | |
| index | - index of chosen point |
| void GEP::Operators< IndividualType >::swapElementsUp | ( | Chromosome< CType > & | toSwap1, | |
| Chromosome< CType > & | toSwap2, | |||
| u_short | gene, | |||
| u_short | index | |||
| ) | [inline] |
Elements in two Chromosome<CType>s exchange place up to chosen point The result will be modified Chromosome<CType>s.
| toSwap1 | - first chromosome to swap | |
| toSwap2 | - second chromosome to swap | |
| gene | - ORF of swap point | |
| index | - index of chosen point |
| void GEP::Operators< IndividualType >::swapGenes | ( | Chromosome< CType > & | toSwap1, | |
| Chromosome< CType > & | toSwap2, | |||
| u_short | gene1, | |||
| u_short | gene2, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
Two chosen ORFs in two Chromosome<CType>s exchange place The result will be modified Chromosome<CType>.
| toSwap1 | - first chromosome to swap | |
| toSwap2 | - second chromosome to swap | |
| gene1 | - first gene to swap | |
| gene2 | - second gene to swap | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::swapGenes | ( | Chromosome< CType > & | toSwap, | |
| u_short | gene1, | |||
| u_short | gene2, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
Two chosen ORFs in the Chromosome<CType> exchange place The result will be modified Chromosome<CType>.
| toSwap | - chromosome to be modified | |
| gene1 | - first gene to swap | |
| gene2 | - second gene to swap | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::transposeGene | ( | Chromosome< CType > & | toTranspose, | |
| const size_t | pop_age = 0 | |||
| ) | [inline] |
A whole ORF is treated as transposon (sequence to exchange). The difference from previous is that ORFs are exchanged, target is not copied to the source.
| void GEP::Operators< IndividualType >::transposeIS | ( | Chromosome< CType > & | toTranspose, | |
| bool | fixed, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
IS transposition with randomly generated src, srcPos, dst and dstPos, head = false. The result will be modified Chromosome<CType>. length is eq. to _transposeISLength.
| toTranspose | - Chromosome<CType> under trasposition | |
| fixed | - if to use maximum, or randomly generated value of transposon | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::transposeIS | ( | Chromosome< CType > & | toTranspose, | |
| u_short | length, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
IS transposition with randomly generated src, srcPos, dst and dstPos, head = false. The result will be modified Chromosome<CType>.
| toTranspose | - Chromosome<CType> under trasposition | |
| length | - length of the transposon | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::transposeIS | ( | Chromosome< CType > & | toTranspose, | |
| u_short | length, | |||
| u_short | src, | |||
| u_short | srcPos, | |||
| u_short | dst, | |||
| u_short | dstPos, | |||
| bool | head, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
Insert Sequence (IS) Transposition operation performed on a Chromosome<CType>; it is copying of some sequence (transposon) from some position in one ORF and insreting it into some position in the head of some other gene. If the target position is placed everywhere but not in the beginning of the head (index 0) it is called IS transposition. If the target position is the beginning of the head, the operatioin is called Root Insert Sequence (RIS) Transposition. The result will be modified Chromosome<CType>.
| toTranspose | - Chromosome<CType> under trasposition | |
| length | - length of the transposon | |
| src | - source ORF | |
| srcPos | - source position | |
| dst | - destination ORF | |
| dstPos | - destination position | |
| head | - if RIS transposition allowed | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::transposeRIS | ( | Chromosome< CType > & | toTranspose, | |
| bool | fixed, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
RIS transposition with randomly generated src, srcPos, dst, dstPos = 0, head = true. If the generated srcPos is not a function node, the ORF is traversed to search for such Node. If none is encountered, the process ends with no result. length is eq. to _transposeRISLength. The result will be modified Chromosome<CType>.
| toTranspose | - Chromosome<CType> under trasposition | |
| fixed | - if to use maximum, or randomly generated value of transposon | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::transposeRIS | ( | Chromosome< CType > & | toTranspose, | |
| u_short | length, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
RIS transposition with randomly generated src, srcPos, dst, dstPos = 0, head = true. If the generated srcPos is not a function node, the ORF is traversed to search for such Node. If none is encountered, the process ends with no result. The result will be modified Chromosome<CType>.
| toTranspose | - Chromosome<CType> under trasposition | |
| length | - length of the transposon | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::twoPointCross | ( | Chromosome< CType > & | p1, | |
| Chromosome< CType > & | p2, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
Two point crossover. The points of crossover is randomly generated. The result will be two modified Chromosome<CType>s.
| p1 | - first parent | |
| p2 | - second parent | |
| pop_age | the age of the current population - for cheater use only |
| void GEP::Operators< IndividualType >::twoPointCross | ( | Chromosome< CType > & | p1, | |
| Chromosome< CType > & | p2, | |||
| u_short | gene1, | |||
| u_short | pos1, | |||
| u_short | gene2, | |||
| u_short | pos2, | |||
| const size_t | pop_age = 0 | |||
| ) | [inline] |
Two point crossover. Two ORFs and two positions in them are chosen as a points of cross. Every Node between those positions is exchanged. The result will be two modified Chromosome<CType>s.
double GEP::Operators< IndividualType >::_functionProbability [private] |
Probability of generating a function.
u_short GEP::Operators< IndividualType >::_inversionLength [private] |
Length of inversion
boost::mt19937 GEP::Operators< IndividualType >::_mersenne = boost::mt19937(42u) [inline, static] |
Engine of the random number generators - Mersenne Twister
double GEP::Operators< IndividualType >::_oneArgFunctionProbability [private] |
Probability of generating an one argument function
double GEP::Operators< IndividualType >::_rcProbability [private] |
Probability of generating an one argument function
smallGen GEP::Operators< IndividualType >::_rng_genes [private] |
Generator of indexes of gene number in a Chromosome<CType>.
smallGen GEP::Operators< IndividualType >::_rng_head [private] |
Generator of indexes of head position in an ORF.
smallGen GEP::Operators< IndividualType >::_rng_is [private] |
Generator of length of transposons (regular and root).
smallGen GEP::Operators< IndividualType >::_rng_linkPool [private] |
Generator of indexes of two argument functions of _linkPool.
smallGen GEP::Operators< IndividualType >::_rng_links [private] |
Generator of indexes of positions in _links.
smallGen GEP::Operators< IndividualType >::_rng_oneArg [private] |
Generator of indexes of one argument functions.
smallGen GEP::Operators< IndividualType >::_rng_tail [private] |
Generator of indexes of tail position in an ORF.
smallGen GEP::Operators< IndividualType >::_rng_terms [private] |
Generator of indexes of terminal.
smallGen GEP::Operators< IndividualType >::_rng_total [private] |
Generator of indexes of any position in an ORF.
smallGen GEP::Operators< IndividualType >::_rng_twoArg [private] |
Generator of indexes of two argument functions.
boost::uniform_01< boost::mt19937 > GEP::Operators< IndividualType >::_rng_uni_real = boost::uniform_01<boost::mt19937>(_mersenne) [inline, static] |
Random real numbers generator, interval [0,1). Common to all.
u_short GEP::Operators< IndividualType >::_transposonLength [private] |
Maximum length of transposon (used by IS and RIS).
1.6.1