00001 #include "ECF_base.h"
00002 #include "SelBestOp.h"
00003
00004 bool SelBestOp::initialize(StateP state)
00005 {
00006 state_ = state;
00007 return true;
00008 }
00009
00010
00011 IndividualP SelBestOp::select(const std::vector<IndividualP>& pool)
00012 {
00013 if(pool.empty())
00014 return IndividualP();
00015
00016 IndividualP best = pool[0];
00017 for (uint i = 1; i < pool.size(); i++) {
00018 if (!(best->fitness->isBetterThan(pool[i]->fitness))){
00019 best = pool[i];
00020 }
00021 }
00022
00023 return best;
00024 }
00025