1#include "GEPChromosomeCrsTwoPoint.h"
2namespace GEPChromosome{
5 myGenotype_->registerParameter(state,
"crx.twopoint", (voidP)
new double(0), ECF::DOUBLE);
11 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.twopoint");
23 uint bitCrs = state_->getRandomizer()->getRandomInteger(0, (
int)p1->size() - 1);
24 uint bitCrsSecond, tmp;
27 bitCrsSecond = state_->getRandomizer()->getRandomInteger(p1->size());
28 }
while (bitCrs == bitCrsSecond);
30 if (bitCrs>bitCrsSecond)
33 bitCrs = bitCrsSecond;
36 ECF_LOG(state_, 5,
"Performing Two-Pt crossover at nodes (" + uint2str(bitCrs) +
") and (" + uint2str(bitCrsSecond) +
")...");
38 switch (state_->getRandomizer()->getRandomInteger(0, 1)) {
40 for (uint i = 0; i < bitCrs; i++) {
41 ch->push_back(
static_cast<Tree::NodeP
> (
new Tree::Node((p1->at(i)))));
43 for (uint i = bitCrs; i < bitCrsSecond; i++) {
44 ch->push_back(
static_cast<Tree::NodeP
> (
new Tree::Node((p2->at(i)))));
46 for (uint i = bitCrsSecond; i < p2->size(); i++) {
47 ch->push_back(
static_cast<Tree::NodeP
> (
new Tree::Node((p1->at(i)))));
51 for (uint i = 0; i < bitCrs; i++) {
52 ch->push_back(
static_cast<Tree::NodeP
> (
new Tree::Node((p2->at(i)))));
54 for (uint i = bitCrs; i < bitCrsSecond; i++) {
55 ch->push_back(
static_cast<Tree::NodeP
> (
new Tree::Node((p1->at(i)))));
57 for (uint i = bitCrsSecond; i < p1->size(); i++) {
58 ch->push_back(
static_cast<Tree::NodeP
> (
new Tree::Node((p2->at(i)))));
double probability_
probability of usage of this crossover operator
GenotypeP myGenotype_
pointer to the Genotype that defines this CrossoverOp
bool initialize(StateP)
Initialize crossover operator. Called before first crossover operation.
bool mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)
void registerParameters(StateP)
Register parameters with the system. Called before CrossoverOp::initialize.
GEPChromosome class - implements genotype as a Gene Expression Programming chromosome.
Node base class (Tree genotype)