1#include "../ECF_base.h"
9 myGenotype_->registerParameter(state,
"crx.reducedsurrogate", (voidP)
new double(0), ECF::DOUBLE);
15 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.reducedsurrogate");
27 for (uint dimension = 0; dimension < p1->variables.size(); dimension++) {
29 std::vector<int> reduced;
30 for(uint i = 0; i < p1->getNumBits(); i++) {
31 if (p1->variables[dimension][i] != p2->variables[dimension][i])
32 reduced.push_back((
int)i);
38 if (reduced.size() > 0 ) {
39 location = state_->getRandomizer()->getRandomInteger((
int) reduced.size());
40 bitCrs=reduced[location];
43 uint parent = state_->getRandomizer()->getRandomInteger(0, 1);
45 for(uint i = 0; i < p1->getNumBits(); i++) {
46 if (p1->variables[dimension][i] == p2->variables[dimension][i])
47 ch->variables[dimension][i] = p1->variables[dimension][i];
51 ch->variables[dimension][i] = p1->variables[dimension][i];
53 ch->variables[dimension][i] = p2->variables[dimension][i];
57 ch->variables[dimension][i] = p2->variables[dimension][i];
59 ch->variables[dimension][i] = p1->variables[dimension][i];
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)
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