ECF 1.5
SelBestOp.cpp
1#include "ECF_base.h"
2#include "SelBestOp.h"
3
4bool SelBestOp::initialize(StateP state)
5{
6 state_ = state;
7 return true;
8}
9
10
11IndividualP SelBestOp::select(const std::vector<IndividualP>& pool)
12{
13 if(pool.empty())
14 return IndividualP();
15
16 IndividualP best = pool[0];
17 for (uint i = 1; i < pool.size(); i++) {
18 if (!(best->fitness->isBetterThan(pool[i]->fitness))){
19 best = pool[i];
20 }
21 }
22
23 return best;
24}
25
bool initialize(StateP)
Selection operator initialization. Must be called before individual selection.
Definition: SelBestOp.cpp:4
IndividualP select(const std::vector< IndividualP > &)
Select one individual from a set.
Definition: SelBestOp.cpp:11