3#include "AlgSteadyStateTournament.h"
4#include "SelRandomOp.h"
8SteadyStateTournament::SteadyStateTournament()
11 name_ =
"SteadyStateTournament";
15 selRandomOp =
static_cast<SelectionOperatorP
> (
new SelRandomOp);
16 selWorstOp =
static_cast<SelectionOperatorP
> (
new SelWorstOp);
23 "tournament size (individuals selected randomly, worst one eliminated)");
30 selRandomOp->initialize(state);
31 selWorstOp->initialize(state);
38 ECF_LOG(state, 1,
"Error: SteadyStateTournament algorithm requires minimum tournament size of 3!");
49 for(uint iIter = 0; iIter < deme->size(); iIter++) {
51 ECF_LOG(state, 5,
"Individuals in tournament: ");
53 std::vector<IndividualP> tournament;
56 tournament.push_back(selRandomOp->select(*deme));
57 ECF_LOG(state, 5, uint2str(i) +
": " + tournament[i]->toString());
61 IndividualP worst = selWorstOp->select(tournament);
62 ECF_LOG(state, 5,
"The worst from the tournament: " + worst->toString());
68 mate(tournament[0], tournament[1], worst);
75 ECF_LOG(state, 5,
"New individual: " + worst->toString());
uint mutate(const std::vector< IndividualP > &pool)
Helper function: send a vector of individuals to mutation.
std::string name_
algorithm name
bool registerParameter(StateP state, std::string name, voidP value, enum ECF::type T, std::string description="")
Helper function: register a single parameter with the system.
voidP getParameterValue(StateP state, std::string name)
Helper function: get parameter value from the system.
bool mate(IndividualP p1, IndividualP p2, IndividualP child)
Helper function: crossover two individuals.
bool removeFrom(IndividualP victim, std::vector< IndividualP > &pool)
Helper function: remove victim from pool of individual pointers.
void evaluate(IndividualP ind)
Helper function: evaluate an individual.
Random individual selection operator.
Worst individual selection operator.
bool advanceGeneration(StateP state, DemeP deme)
Perform a single generation on a single deme.
void registerParameters(StateP state)
Register algorithm's parameters (if any).
bool initialize(StateP state)
Initialize the algorithm, read parameters from the system, do a sanity check.
uint nTournament_
tournament size