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

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

00001 #include "../ECF_base.h"
00002 #include "FloatingPoint.h"
00003 #include<cmath>
00004 
00005 
00006 namespace FloatingPoint
00007 {
00008 
00009 void FloatingPointCrsBlxAlpha::registerParameters(StateP state)
00010 {
00011     myGenotype_->registerParameter(state, "crx.blxalpha", (voidP) new double(0), ECF::DOUBLE);
00012     state->getRegistry()->registerEntry("alpha", (voidP) new double(0.5), ECF::DOUBLE);
00013 }
00014 
00015 
00016 bool FloatingPointCrsBlxAlpha::initialize(StateP state)
00017 {
00018     voidP sptr = myGenotype_->getParameterValue(state, "crx.blxalpha");
00019     probability_ = *((double*)sptr.get());
00020 
00021     voidP par = state->getRegistry()->getEntry("alpha");
00022     alpha = *((uint*) par.get());
00023     return true;
00024 }
00025 
00026 
00027 bool FloatingPointCrsBlxAlpha::mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)
00028 {
00029     FloatingPoint* p1 = (FloatingPoint*) (gen1.get());
00030     FloatingPoint* p2 = (FloatingPoint*) (gen2.get());
00031     FloatingPoint* ch = (FloatingPoint*) (child.get());
00032 
00033     double min, max, a, I, resMin = 0, resMax = 0;
00034 
00035     for (uint i = 1; i < p1->realValue.size(); i++) {
00036         a = state_->getRandomizer()->getRandomDouble();
00037          if (p1->realValue[i] < p2->realValue[i]){
00038             min = p1->realValue[i];
00039          }
00040          else {
00041             min = p2->realValue[i];
00042          }
00043          if (p1->realValue[i] > p2->realValue[i]){
00044             max = p1->realValue[i];
00045          }
00046          else {
00047             max = p2->realValue[i];
00048          }
00049         I = fabs(max - min);
00050         resMin = min - I * alpha;
00051         resMax = max + I * alpha;
00052         ch->realValue[i] = resMin + a * fabs(resMax - resMin);
00053     }
00054 
00055     return true;
00056 }
00057 
00058 }

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