1#include "../ECF_base.h"
2#include "Permutation.h"
11 myGenotype_->registerParameter(state,
"crx.OX", (voidP)
new double(0), ECF::DOUBLE);
17 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.OX");
29 int start = state_->getRandomizer()->getRandomInteger(p1->getSize());
30 int end = state_->getRandomizer()->getRandomInteger(start, (
int) p1->getSize() - 1);
32 std::map<int, int> subSet;
34 int ind1 = state_->getRandomizer()->getRandomInteger(p1->getSize() - 1);
35 int ind2 = state_->getRandomizer()->getRandomInteger(ind1, (
int) p1->getSize() - 1);
38 for(
int i = ind1; i <= ind2; i++) {
39 ch->variables[i] = p1->variables[i];
40 subSet[p1->variables[i]] = 0;
42 int indexChild = (ind2 + 1) % p1->getSize();
43 std::map<int, int>::iterator iter = subSet.begin();
50 ind2 = (++ind2) % p1->getSize();
51 if(subSet.find(p2->variables[ind2]) == subSet.end()) {
52 ch->variables[indexChild] = p2->variables[ind2];
53 indexChild = (++indexChild) % p1->getSize();
55 }
while(indexChild != ind1);
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.
Permutation class - implements genotype as a vector of indices 0..(n-1) (permutation of indices)