1#include "../ECF_base.h"
2#include "Permutation.h"
11 myGenotype_->registerParameter(state,
"crx.COSA", (voidP)
new double(0), ECF::DOUBLE);
17 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.COSA");
29 int indexChild, start, end;
31 indexChild = (int) state_->getRandomizer()->getRandomInteger(p1->getSize());
32 start = (indexChild + 1) % p1->getSize();
35 while ((i < (
int) p2->getSize()) && (p2->variables[i] != p1->variables[indexChild])) {
38 int crx = p2->variables[(i + 1) % p2->getSize()];
40 while ((end < (
int) p1->getSize()) && (p1->variables[end] != crx)) {
45 for (i = 0; i < (int) p1->getSize(); i++) {
46 if (i >= start && i <= end) {
47 ch->variables[i] = p1->variables[end - i + start];
49 ch->variables[i] = p1->variables[i];
53 for (i = 0; i < (int) p1->getSize(); i++) {
54 if (i >= start || i <= end) {
55 ch->variables[i] = p1->variables[(end - i + start + p1->getSize()) % p1->getSize()];
57 ch->variables[i] = p1->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)