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

D:/Projekt/ECF_trunk/ECF/floatingpoint/floatingpoint/novi_operatori/FloatingPointCrsBlxAlphaBeta.cpp

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

Generated on Tue Jul 2 2013 10:51:47 for ECF by  doxygen 1.7.1