1#include "../ECF_base.h"
2#include "Permutation.h"
11 myGenotype_->registerParameter(state,
"crx.cyclic", (voidP)
new double(0), ECF::DOUBLE);
17 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.cyclic");
29 std::map<int, int> invP1, invP2, index;
33 for (
int i = 0; i < (int) p1->getSize(); i++) {
34 invP1[p1->variables[i]] = i;
35 invP2[p2->variables[i]] = i;
39 int rand = state_->getRandomizer()->getRandomInteger(0,1);
45 ch->variables[j] = p1->variables[j];
47 j = invP2[ch->variables[j]];
49 ch->variables[j] = p2->variables[j];
51 j = invP1[ch->variables[j]];
56 while (j < (
int) p1->getSize() && index[j])
58 }
while (j < (
int) p1->getSize());
double probability_
probability of usage of this crossover operator
GenotypeP myGenotype_
pointer to the Genotype that defines this CrossoverOp
void registerParameters(StateP)
Register parameters with the system. Called before CrossoverOp::initialize.
bool mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)
bool initialize(StateP)
Initialize crossover operator. Called before first crossover operation.
Permutation class - implements genotype as a vector of indices 0..(n-1) (permutation of indices)