1#include "../ECF_base.h"
10 myGenotype_->registerParameter(state,
"crx.shuffle", (voidP)
new double(0), ECF::DOUBLE);
16 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.shuffle");
33 typedef std::vector<uint> v_uint;
40 for (uint i = 0; i < p1->getNumBits(); i++) {
41 mapiranje.push_back(i);
44 std::random_shuffle(mapiranje.begin(), mapiranje.end());
46 uint bitCrs = state_->getRandomizer()->getRandomInteger(p1->getNumBits());
51 for (uint dimension = 0; dimension < p1->variables.size(); dimension++) {
53 for (uint i = 0; i < p1->getNumBits(); i++) {
55 p1copy->variables[dimension][i] = p1->variables[dimension][mapiranje[i]];
56 p2copy->variables[dimension][i] = p2->variables[dimension][mapiranje[i]];
60 switch (state_->getRandomizer()->getRandomInteger(0, 1)) {
61 case 0:
for (uint i = 0; i < bitCrs; i++) {
62 chcopy->variables[dimension][i] = p1copy->variables[dimension][i];
64 for (uint i = bitCrs; i < p2->getNumBits(); i++) {
65 chcopy->variables[dimension][i] = p2copy->variables[dimension][i];
68 case 1:
for (uint i = 0; i < bitCrs; i++) {
69 chcopy->variables[dimension][i] = p2copy->variables[dimension][i];
71 for (uint i = bitCrs; i < p1->getNumBits(); i++) {
72 chcopy->variables[dimension][i] = p1copy->variables[dimension][i];
76 for (uint i = 0; i < p1->getNumBits(); i++) {
77 ch->variables[dimension][mapiranje[i]] = chcopy->variables[dimension][i];
bool mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)
void registerParameters(StateP)
Register parameters with the system. Called before CrossoverOp::initialize.
bool initialize(StateP)
Initialize crossover operator. Called before first crossover operation.
Binary class - implements genotype as a vector of binary coded real values with variable interval and...
double probability_
probability of usage of this crossover operator
GenotypeP myGenotype_
pointer to the Genotype that defines this CrossoverOp