00001 #include "../ECF_base.h" 00002 #include "FloatingPoint.h" 00003 00004 namespace FloatingPoint 00005 { 00006 00007 void FloatingPointCrsAverage::registerParameters(StateP state) 00008 { 00009 myGenotype_->registerParameter(state, "crx.average", (voidP) new double(0), ECF::DOUBLE); 00010 } 00011 00012 00013 bool FloatingPointCrsAverage::initialize(StateP state) 00014 { 00015 voidP sptr = myGenotype_->getParameterValue(state, "crx.average"); 00016 probability_ = *((double*)sptr.get()); 00017 return true; 00018 } 00019 00020 00021 bool FloatingPointCrsAverage::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 for (uint i = 0; i < p1->realValue.size(); i++) { 00028 ch->realValue[i] = 0.5 * (p1->realValue[i]) + 0.5 * (p2->realValue[i]); 00029 } 00030 00031 return true; 00032 } 00033 00034 }