00001 #include "CartesianCrsOnePoint.h"
00002 #include "Cartesian_c.h"
00003
00004 namespace cart{
00005
00006 void CartesianCrsOnePoint::registerParameters(StateP state)
00007 {
00008
00009
00010 }
00011
00012
00013 bool CartesianCrsOnePoint::initialize(StateP state)
00014 {
00015
00016
00017
00018 return true;
00019 }
00020
00021
00022 bool CartesianCrsOnePoint::mate(GenotypeP gen1, GenotypeP gen2, GenotypeP child)
00023 {
00024 Cartesian* p1 = (Cartesian*) (gen1.get());
00025 Cartesian* p2 = (Cartesian*) (gen2.get());
00026 Cartesian* ch = (Cartesian*) (child.get());
00027
00028
00029 int crsPoint = state_->getRandomizer()->getRandomInteger(p1->size());
00030
00031 ch->clear();
00032
00033 if ((state_->getRandomizer()->getRandomInteger(0, 1)) == 0)
00034 {
00035 for (int i = 0; i < crsPoint; i++)
00036 {
00037 ch->push_back(p1->at(i));
00038 }
00039 for (int i = crsPoint; i < (int)p2->size(); i++)
00040 {
00041 ch->push_back(p2->at(i));
00042 }
00043 }
00044 else
00045 {
00046 for (int i = 0; i < crsPoint; i++)
00047 {
00048 ch->push_back(p2->at(i));
00049 }
00050 for (int i = crsPoint; i < (int)p1->size(); i++)
00051 {
00052 ch->push_back(p1->at(i));
00053 }
00054 }
00055
00056 return true;
00057 }
00058
00059 }
00060