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

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

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

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