GEP::Operators< IndividualType > Class Template Reference

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>

List of all members.

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

Detailed Description

template<class IndividualType>
class GEP::Operators< IndividualType >

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.


Member Typedef Documentation

template<class IndividualType >
typedef IndividualType::chromo_type GEP::Operators< IndividualType >::CType [private]

Constructor & Destructor Documentation

template<class IndividualType >
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

template<class IndividualType >
GEP::Operators< IndividualType >::~Operators (  )  [inline]

Default destructor. Do not touch ChromosomeFactory pointer - it will be cleaned.


Member Function Documentation

template<class IndividualType >
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.

Parameters:
p1 - first parent
p2 - second parent
pop_age the age of the current population - for cheater use only
template<class IndividualType >
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

Parameters:
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?)
template<class IndividualType >
CElement GEP::Operators< IndividualType >::generateElement ( short  type  )  [inline]

Generates random element of

Parameters:
type 
template<class IndividualType >
CElement GEP::Operators< IndividualType >::generateElement (  )  [inline]

Generates random element of random type

template<class IndividualType >
u_short GEP::Operators< IndividualType >::getInversionLength (  )  const [inline]
template<class IndividualType >
u_short GEP::Operators< IndividualType >::getTransposonLength (  )  const [inline]
template<class IndividualType >
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>.

Parameters:
inverted - a Chromosome<CType> to be mutated
pop_age the age of the current population - for cheater use only
template<class IndividualType >
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>.

Parameters:
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
template<class IndividualType >
void GEP::Operators< IndividualType >::mutate ( Chromosome< CType > &  mutant,
const size_t  pop_age = 0 
) [inline]

The result will be modified Chromosome<CType>.

Parameters:
mutant - a Chromosome<CType> to be mutated
pop_age - age of the population -- used by cheaters (a variable, perhaps, set by Population?)
template<class IndividualType >
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>.

Parameters:
mutant - a Chromosome<CType> to be mutated
template<class IndividualType >
void GEP::Operators< IndividualType >::mutateGene ( Chromosome< CType > &  mutant,
u_short  gene,
u_short  index 
) [inline]

The result will be modified Chromosome<CType>.

Parameters:
mutant - a Chromosome<CType> to be mutated
gene - an ORF to be mutated
index - position in ORF to be mutated
template<class IndividualType >
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>.

Parameters:
mutant - a Chromosome<CType> to be mutated
pop_age - age of the population -- used by cheaters (a variable, perhaps, set by Population?)
template<class IndividualType >
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.

Parameters:
p1 - first parent
p2 - second parent
pop_age the age of the current population
template<class IndividualType >
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.

Parameters:
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
template<class IndividualType >
bool GEP::Operators< IndividualType >::p_geneCross ( const double &  prob,
IndividualType &  p1,
IndividualType &  p2,
const size_t  pop_age = 0 
) [inline]
template<class IndividualType >
bool GEP::Operators< IndividualType >::p_invert ( const double &  prob,
IndividualType &  inverted,
const size_t  pop_age = 0 
) [inline]
template<class IndividualType >
bool GEP::Operators< IndividualType >::p_mutate ( const double &  prob,
IndividualType &  mutant,
const size_t  pop_age = 0 
) [inline]
template<class IndividualType >
bool GEP::Operators< IndividualType >::p_mutateLink ( const double &  prob,
IndividualType &  mutant,
const size_t  pop_age = 0 
) [inline]
template<class IndividualType >
bool GEP::Operators< IndividualType >::p_onePointCross ( const double &  prob,
IndividualType &  p1,
IndividualType &  p2,
const size_t  pop_age = 0 
) [inline]
template<class IndividualType >
bool GEP::Operators< IndividualType >::p_transposeGene ( const double &  prob,
IndividualType &  toTranspose,
const size_t  pop_age = 0 
) [inline]
template<class IndividualType >
bool GEP::Operators< IndividualType >::p_transposeIS ( const double &  prob,
IndividualType &  toTranspose,
bool  fixed,
const size_t  pop_age = 0 
) [inline]
template<class IndividualType >
bool GEP::Operators< IndividualType >::p_transposeRIS ( const double &  prob,
IndividualType &  toTranspose,
bool  fixed,
const size_t  pop_age = 0 
) [inline]
template<class IndividualType >
bool GEP::Operators< IndividualType >::p_twoPointCross ( const double &  prob,
IndividualType &  p1,
IndividualType &  p2,
const size_t  pop_age = 0 
) [inline]
template<class IndividualType >
void GEP::Operators< IndividualType >::seedTheGenerator (  )  [inline]
template<class IndividualType >
void GEP::Operators< IndividualType >::setFunctionProbability ( const double &  fpb  )  [inline]
template<class IndividualType >
void GEP::Operators< IndividualType >::setInversionLength ( u_short  finversionLength  )  [inline]
template<class IndividualType >
void GEP::Operators< IndividualType >::setOneArgFunctionProbability ( const double &  oafpb  )  [inline]
template<class IndividualType >
void GEP::Operators< IndividualType >::setTransposonLength ( u_short  ftransposonLength  )  [inline]
template<class IndividualType >
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.

Parameters:
toSwap1 - first chromosome to swap
toSwap2 - second chromosome to swap
gene - ORF of swap point
index - index of chosen point
template<class IndividualType >
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.

Parameters:
toSwap1 - first chromosome to swap
toSwap2 - second chromosome to swap
gene - ORF of swap point
index - index of chosen point
template<class IndividualType >
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>.

Parameters:
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
template<class IndividualType >
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>.

Parameters:
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
template<class IndividualType >
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.

template<class IndividualType >
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.

Parameters:
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
template<class IndividualType >
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>.

Parameters:
toTranspose - Chromosome<CType> under trasposition
length - length of the transposon
pop_age the age of the current population - for cheater use only
template<class IndividualType >
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>.

Parameters:
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
template<class IndividualType >
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>.

Parameters:
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
template<class IndividualType >
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>.

Parameters:
toTranspose - Chromosome<CType> under trasposition
length - length of the transposon
pop_age the age of the current population - for cheater use only
template<class IndividualType >
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.

Parameters:
p1 - first parent
p2 - second parent
pop_age the age of the current population - for cheater use only
template<class IndividualType >
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.

Parameters:
p1 - first parent
p2 - second parent
gene1 - index of first ORF
pos1 - index of its Node
gene2 - index of second ORF
pos2 - index of its Node
pop_age the age of the current population - for cheater use only

Member Data Documentation

template<class IndividualType >
double GEP::Operators< IndividualType >::_functionProbability [private]

Probability of generating a function.

template<class IndividualType >
u_short GEP::Operators< IndividualType >::_inversionLength [private]

Length of inversion

template<class IndividualType >
boost::mt19937 GEP::Operators< IndividualType >::_mersenne = boost::mt19937(42u) [inline, static]

Engine of the random number generators - Mersenne Twister

template<class IndividualType >
double GEP::Operators< IndividualType >::_oneArgFunctionProbability [private]

Probability of generating an one argument function

template<class IndividualType >
double GEP::Operators< IndividualType >::_rcProbability [private]

Probability of generating an one argument function

template<class IndividualType >
smallGen GEP::Operators< IndividualType >::_rng_genes [private]

Generator of indexes of gene number in a Chromosome<CType>.

template<class IndividualType >
smallGen GEP::Operators< IndividualType >::_rng_head [private]

Generator of indexes of head position in an ORF.

template<class IndividualType >
smallGen GEP::Operators< IndividualType >::_rng_is [private]

Generator of length of transposons (regular and root).

template<class IndividualType >
smallGen GEP::Operators< IndividualType >::_rng_linkPool [private]

Generator of indexes of two argument functions of _linkPool.

template<class IndividualType >
smallGen GEP::Operators< IndividualType >::_rng_links [private]

Generator of indexes of positions in _links.

template<class IndividualType >
smallGen GEP::Operators< IndividualType >::_rng_oneArg [private]

Generator of indexes of one argument functions.

template<class IndividualType >
smallGen GEP::Operators< IndividualType >::_rng_tail [private]

Generator of indexes of tail position in an ORF.

template<class IndividualType >
smallGen GEP::Operators< IndividualType >::_rng_terms [private]

Generator of indexes of terminal.

template<class IndividualType >
smallGen GEP::Operators< IndividualType >::_rng_total [private]

Generator of indexes of any position in an ORF.

template<class IndividualType >
smallGen GEP::Operators< IndividualType >::_rng_twoArg [private]

Generator of indexes of two argument functions.

template<class IndividualType >
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.

template<class IndividualType >
u_short GEP::Operators< IndividualType >::_transposonLength [private]

Maximum length of transposon (used by IS and RIS).


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

Generated on Fri Dec 11 22:28:17 2009 for LibGEP by  doxygen 1.6.1