1#include "../ECF_base.h"
2#include "FloatingPoint.h"
11 myGenotype_->registerParameter(state,
"crx.bga", (voidP)
new double(0), ECF::DOUBLE);
17 voidP sptr =
myGenotype_->getParameterValue(state,
"crx.bga");
31 uint size = (uint) p1->realValue.size();
33 double range = 0.5 * (p1->getUBound() - p1->getLBound());
34 double gama = 0, lambda = 0, b;
36 for (
int i = 0; i <= 15; i++) {
37 a = state_->getRandomizer()->getRandomInteger(1, 16);
43 gama = gama + a * pow((
double) 2., -i);
47 for(uint i = 0; i < size; i++)
48 norm += pow(p1->realValue[i] - p2->realValue[i], 2);
57 FitnessP parent2 = state_->getContext()->secondParent->fitness;
58 if(state_->getContext()->firstParent->fitness->isBetterThan(parent2)) {
67 for (uint i = 0; i < size; i++) {
69 lambda = (worse->realValue[i] - better->realValue[i]) / norm;
71 b = state_->getRandomizer()->getRandomDouble();
74 ch->realValue[i] = better->realValue[i] - range * gama * lambda;
76 ch->realValue[i] = better->realValue[i] + range * gama * lambda;
79 if(ch->realValue[i] > ch->getUBound())
80 ch->realValue[i] = better->realValue[i] + state_->getRandomizer()->getRandomDouble() * (ch->getUBound() - better->realValue[i]);
81 else if(ch->realValue[i] < ch->getLBound())
82 ch->realValue[i] = better->realValue[i] - state_->getRandomizer()->getRandomDouble() * (better->realValue[i] - ch->getLBound());
double probability_
probability of usage of this crossover operator
GenotypeP myGenotype_
pointer to the Genotype that defines this CrossoverOp
bool mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)
bool initialize(StateP)
Initialize crossover operator. Called before first crossover operation.
void registerParameters(StateP)
Register parameters with the system. Called before CrossoverOp::initialize.
FloatingPoint class - implements genotype as a vector of floating point values.