• Main Page
  • Modules
  • Classes
  • Files
  • File List

D:/Projekt/ECF_trunk/ECF/floatingpoint/FloatingPointCrsLocal.cpp

00001 #include "../ECF_base.h"
00002 #include "FloatingPoint.h"
00003 
00004 namespace FloatingPoint
00005 {
00006 
00007 void FloatingPointCrsLocal::registerParameters(StateP state)
00008 {
00009     myGenotype_->registerParameter(state, "crx.local", (voidP) new double(0), ECF::DOUBLE);
00010 }
00011 
00012 
00013 bool FloatingPointCrsLocal::initialize(StateP state)
00014 {
00015     voidP sptr = myGenotype_->getParameterValue(state, "crx.local");
00016     probability_ = *((double*)sptr.get());
00017     return true;
00018 }
00019 
00020 
00021 bool FloatingPointCrsLocal::mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)
00022 {
00023     FloatingPoint* p1 = (FloatingPoint*) (gen1.get());
00024     FloatingPoint* p2 = (FloatingPoint*) (gen2.get());
00025     FloatingPoint* ch = (FloatingPoint*) (child.get());
00026 
00027     double a;
00028 
00029     switch (state_->getRandomizer()->getRandomInteger(0, 1)) {
00030         case 0: for (uint i = 0; i < p1->realValue.size(); i++) {
00031                     a = state_->getRandomizer()->getRandomDouble();
00032                     ch->realValue[i] = a * (p1->realValue[i]) + (1 - a) * (p2->realValue[i]);
00033                 }
00034                 break;
00035         case 1: for (uint i = 0; i < p1->realValue.size(); i++) {
00036                     a = state_->getRandomizer()->getRandomDouble();
00037                     ch->realValue[i] = a * (p2->realValue[i]) + (1 - a) * (p1->realValue[i]);
00038                 }
00039     }
00040 
00041     return true;
00042 }
00043 
00044 }

Generated on Tue Nov 4 2014 13:04:31 for ECF by  doxygen 1.7.1