1#include "../ECF_base.h"
2#include "Permutation.h"
11 myGenotype_->registerParameter(state,
"crx.OX2", (voidP)
new double(0), ECF::DOUBLE);
17 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.OX2");
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]] = 1;
42 int indexChild = (ind2 + 1) % p1->getSize();
43 std::map<int, int>::iterator iter = subSet.begin();
48 for (
int i = 0; i < (int) p1->getSize(); i++) {
52 if (!subSet[p2->variables[i]]) {
53 ch->variables[index] = p2->variables[i];
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 initialize(StateP)
Initialize crossover operator. Called before first crossover operation.
bool mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)
Permutation class - implements genotype as a vector of indices 0..(n-1) (permutation of indices)