1#include "../ECF_base.h"
2#include "Permutation.h"
11 myGenotype_->registerParameter(state,
"crx.DPX", (voidP)
new double(0), ECF::DOUBLE);
17 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.DPX");
29 int capacity = (int) p1->getSize();
32 bool* takenPositions =
new bool[capacity];
39 int* unusedElements =
new int[capacity];
42 for(
int i = 0; i < capacity; i++) {
43 takenPositions[i] =
false;
49 for(
int ind = 0; ind < capacity; ind++) {
50 if(p1->variables[ind]==p2->variables[ind]) {
51 ch->variables[ind] = p1->variables[ind];
52 takenPositions[ind] =
true;
54 unusedElements[unusedNo] = p1->variables[ind];
60 int candidatePosition = 0;
65 int index = state_->getRandomizer()->getRandomInteger(unusedNo);
66 while(takenPositions[candidatePosition]) {
69 ch->variables[candidatePosition] = unusedElements[index];
71 unusedElements[index] = unusedElements[unusedNo];
76 while(takenPositions[candidatePosition]) {
79 ch->variables[candidatePosition] = unusedElements[0];
83 delete[] unusedElements;
84 delete[] takenPositions;
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)