ECF 1.5
SolverSHC.cpp
1#include "ECF/ECF_base.h"
2#include "SolverSHC.h"
3
4
5SolverSHC :: SolverSHC()
6{
7 name_ = "SolverSHC";
8}
9
10
11bool SolverSHC :: advanceGeneration(StateP state, DemeP deme)
12{
13 // generate and apply move on every individual
14 for(uint i = 0; i < deme->size(); i++) {
15 IndividualP copy = (IndividualP) deme->at(i)->copy();
16 MoveP move = getProblem()->randomMove(copy);
17 getProblem()->applyMove(copy, move);
19 // replace if better or equal
20 if(!deme->at(i)->getFitness()->isBetterThan(copy->getFitness()))
21 replaceWith(deme->at(i), copy);
22 }
23
24 return true;
25}
IndividualP copy(IndividualP source)
Helper function: make a copy of an individual.
Definition: Algorithm.h:291
std::string name_
algorithm name
Definition: Algorithm.h:23
void replaceWith(IndividualP oldInd, IndividualP newInd)
Helper function: replace an individual in current deme.
Definition: Algorithm.h:187
void evaluate(IndividualP ind)
Helper function: evaluate an individual.
Definition: Algorithm.h:157
bool advanceGeneration(StateP state, DemeP deme)
Perform a single generation on a single deme.
Definition: SolverSHC.cpp:11
Definition: flowshop.h:78