7HallOfFame::HallOfFame()
9 this->selectBest_ =
static_cast<SelBestOpP
> (
new SelBestOp);
21 bestGenerations_.clear();
35 PopulationP population = state->getPopulation();
38 for(uint i = 0; i < population->size(); i++) {
54 best = selectBest_->select(individuals);
60 bestGenerations_[ind] = state_->getGenerationNo();
73 xHoF = XMLNode::createXMLTopNode(
"HallOfFame");
74 std::stringstream sValue;
76 xHoF.addAttribute(
"size", uint2str(
hofSize_).c_str());
81 xInd.addAttribute(
"gen", uint2str(bestGenerations_[i]).c_str());
90 ss << xHof.getAttribute(
"size");
92 ss.clear(); ss.str(
"");
100 for(uint i = 0; i <
hofSize_; i++) {
101 xInd = xHof.getChildNode((
int)i);
102 ss << xInd.getAttribute(
"gen");
103 ss >> bestGenerations_[i];
104 ss.clear(); ss.str(
"");
uint hofSize_
no. of individuals in HoF
void read(XMLNode &)
Read operator state from XMLNode or the Registry. Called after Operator::initialize.
void write(XMLNode &)
Write operator state to XMLNode or the Registry. Called after Operator::initialize.
std::vector< IndividualP > bestIndividuals_
vector of individuals in HoF
uint lastChangeGen_
generation of last update
bool initialize(StateP)
Perform initialization. Called before Operator::operate. By default, if the return value is false,...
bool operate(StateP)
Collect best individuals of the whole Population.
Best individual selection operator.