ECF 1.5
SelRandomOp.cpp
1#include "ECF_base.h"
2#include "SelRandomOp.h"
3
4
5bool SelRandomOp::initialize(StateP state)
6{
7 state_ = state;
8 randomizer_ = state->getRandomizer();
9 return true;
10}
11
12
13IndividualP SelRandomOp::select(const std::vector<IndividualP>& pool)
14{
15 if(pool.empty())
16 return IndividualP();
17
18 return pool[ randomizer_->getRandomInteger(0, (int) pool.size()-1) ];
19}
20
bool initialize(StateP)
Selection operator initialization. Must be called before individual selection.
Definition: SelRandomOp.cpp:5
IndividualP select(const std::vector< IndividualP > &)
Select one individual from a set.
Definition: SelRandomOp.cpp:13