ECF 1.5
FloatingPointMutSimple.cpp
1#include "../ECF_base.h"
2#include "FloatingPoint.h"
3#include <cmath>
4
5
6namespace FloatingPoint
7{
8
10{
11 myGenotype_->registerParameter(state, "mut.simple", (voidP) new double(0), ECF::DOUBLE);
12}
13
15{
16 voidP sptr = myGenotype_->getParameterValue(state, "mut.simple");
17 probability_ = *((double*)sptr.get());
18
19 return true;
20}
21
23{
24 FloatingPoint* FP = (FloatingPoint*) (gene.get());
25
26 uint dimension = state_->getRandomizer()->getRandomInteger((uint) FP->realValue.size());
27 FP->realValue[dimension] = state_->getRandomizer()->getRandomDouble() * (FP->getUBound() - FP->getLBound()) + FP->getLBound();
28
29 return true;
30}
31
32}
FloatingPoint class - implements genotype as a vector of floating point values.
Definition: FloatingPoint.h:39
bool initialize(StateP)
Initialize mutation operator. Called before first mutation operation.
bool mutate(GenotypeP gene)
Performs mutation of a genotype object. The genotype object must be initialized!
void registerParameters(StateP)
Register parameters with the system. Called before MutationOp::initialize.
double probability_
probability of usage of this mutation operator
Definition: Mutation.h:40
GenotypeP myGenotype_
pointer to the Genotype that defines this MutationOp
Definition: Mutation.h:41