1#include "../ECF_base.h"
9 myGenotype_->registerParameter(state,
"mut.mix", (voidP)
new double(0), ECF::DOUBLE);
15 voidP sptr =
myGenotype_->getParameterValue(state,
"mut.mix");
25 uint dimension = state_->getRandomizer()->getRandomInteger((uint) bin->variables.size());
28 uint bitIndexSmaller = state_->getRandomizer()->getRandomInteger((uint) bin->getNumBits());
31 bitIndexBigger = state_->getRandomizer()->getRandomInteger((uint) bin->getNumBits());
32 }
while(bitIndexBigger == bitIndexSmaller);
34 uint tmp = bitIndexSmaller;
35 if(bitIndexSmaller > bitIndexBigger) {
36 bitIndexSmaller = bitIndexBigger;
44 for(uint i = bitIndexSmaller; i <= bitIndexBigger; i++) {
45 if(bin->variables[dimension][i]) counter1++;
49 int fairness0 = counter0;
50 int fairness1 = counter1;
53 for(uint i = bitIndexSmaller; i <= bitIndexBigger; i++) {
54 int random = state_->getRandomizer()->getRandomInteger(1, fairness0 + fairness1);
55 if(random <= fairness1) {
57 bin->variables[dimension][i] =
true;
61 bin->variables[dimension][i] =
false;
67 bin->variables[dimension][i] =
false;
71 bin->variables[dimension][i] =
true;
Binary class - implements genotype as a vector of binary coded real values with variable interval and...
bool initialize(StateP)
Initialize mutation operator. Called before first mutation operation.
void registerParameters(StateP)
Register parameters with the system. Called before MutationOp::initialize.
bool mutate(GenotypeP gene)
Performs mutation of a genotype object. The genotype object must be initialized!
double probability_
probability of usage of this mutation operator
GenotypeP myGenotype_
pointer to the Genotype that defines this MutationOp