1#include "GepChromosomeCrsGene.h"
2namespace GEPChromosome{
5 myGenotype_->registerParameter(state,
"crx.gene", (voidP)
new double(0), ECF::DOUBLE);
11 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.gene");
23 ECF_LOG(state_, 5,
"Gene crossover failed: chromosome consists of fewer than 2 genes");
28 uint geneCrs = state_->getRandomizer()->getRandomInteger(0, (
int)p1->genes);
29 uint geneLen = p1->geneLength;
30 ECF_LOG(state_, 5,
"Performing Gene crossover in gene ("+ uint2str(geneCrs) +
")...");
33 switch (state_->getRandomizer()->getRandomInteger(0, 1)) {
35 for (uint i = 0; i <= ch->genes; i++) {
36 jStop = (i == ch->genes) ? ch->linkHeadLength + ch->linkTailLength : geneLen;
37 for (uint j = 0; j < jStop; j++){
38 ch->push_back(
static_cast<Tree::NodeP
> (
new Tree::Node(i == geneCrs ? p2->at(i*geneLen + j) : p1->at(i*geneLen + j))));
43 for (uint i = 0; i <= ch->genes; i++) {
44 jStop = (i == ch->genes) ? ch->linkHeadLength + ch->linkTailLength : geneLen;
45 for (uint j = 0; j < jStop; j++){
46 ch->push_back(
static_cast<Tree::NodeP
> (
new Tree::Node(i == geneCrs ? p1->at(i*geneLen + j) : p2->at(i*geneLen + j))));
double probability_
probability of usage of this crossover operator
GenotypeP myGenotype_
pointer to the Genotype that defines this CrossoverOp
bool mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)
void registerParameters(StateP)
Register parameters with the system. Called before CrossoverOp::initialize.
bool initialize(StateP)
Initialize crossover operator. Called before first crossover operation.
GEPChromosome class - implements genotype as a Gene Expression Programming chromosome.
Node base class (Tree genotype)