1#include "../ECF_base.h"
2#include "Permutation.h"
11 myGenotype_->registerParameter(state,
"crx.PMX", (voidP)
new double(0), ECF::DOUBLE);
17 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.PMX");
29 uint start = state_->getRandomizer()->getRandomInteger(p1->getSize());
30 uint end = state_->getRandomizer()->getRandomInteger((
int) start, (int) p1->getSize() - 1);
32 std::map<int, int> mappings;
34 for(uint i = start; i < end; i++) {
35 ch->variables[i] = p1->variables[i];
36 mappings[p1->variables[i]] = p2->variables[i];
39 std::map<int, int>::iterator iter = mappings.begin();
41 for(uint i = 0; i < p1->getSize(); i++) {
43 if(i >= start && i < end)
46 int map = p2->variables[i];
50 iter = mappings.find(map);
52 if(iter != mappings.end()) {
58 ch->variables[i] = map;
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)