00001 #include "../ECF_base.h"
00002 #include "FloatingPoint.h"
00003 #include <cmath>
00004
00005
00006 namespace FloatingPoint
00007 {
00008
00009 void FloatingPointMutSimple::registerParameters(StateP state)
00010 {
00011 myGenotype_->registerParameter(state, "mut.simple", (voidP) new double(0), ECF::DOUBLE);
00012 }
00013
00014 bool FloatingPointMutSimple::initialize(StateP state)
00015 {
00016 voidP sptr = myGenotype_->getParameterValue(state, "mut.simple");
00017 probability_ = *((double*)sptr.get());
00018
00019 return true;
00020 }
00021
00022 bool FloatingPointMutSimple::mutate(GenotypeP gene)
00023 {
00024 FloatingPoint* FP = (FloatingPoint*) (gene.get());
00025
00026 uint dimension = state_->getRandomizer()->getRandomInteger((uint) FP->realValue.size());
00027 FP->realValue[dimension] = state_->getRandomizer()->getRandomDouble() * (FP->getUBound() - FP->getLBound()) + FP->getLBound();
00028
00029 return true;
00030 }
00031
00032 }