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