11 uint freq, maxGen, eval;
13 bool termEval, termFitness, termStagn, termGen;
19 termEval = termFitness = termStagn = termGen =
false;
21 if(state->getRegistry()->isModified(
"term.eval"))
23 if(state->getRegistry()->isModified(
"term.stagnation"))
25 if(state->getRegistry()->isModified(
"term.fitnessval"))
27 if(state->getRegistry()->isModified(
"term.maxgen"))
31 voidP sptr = state->getRegistry()->getEntry(
"term.stagnation");
32 freq = *((uint*)sptr.get());
34 sptr = state->getRegistry()->getEntry(
"term.maxgen");
35 maxGen = *((uint*)sptr.get());
37 sptr = state->getRegistry()->getEntry(
"term.eval");
38 eval = *((uint*)sptr.get());
40 sptr = state->getRegistry()->getEntry(
"term.fitnessval");
41 fitnessVal = *((
double*)sptr.get());
48 ECF_LOG(state, 3,
"Best in " + uint2str(state->getGenerationNo()));
49 IndividualP bestInd = state->getPopulation()->getHof()->getBest().at(0);
50 ECF_LOG(state, 3, bestInd->toString());
53 uint currentGen = state->getGenerationNo();
54 double minFitness = state->getStats()->getFitnessMin();
55 double maxFitness = state->getStats()->getFitnessMax();
57 if(termGen && currentGen >= maxGen)
60 if(termStagn && (currentGen - state->getPopulation()->getHof()->getLastChange()) > freq)
63 if(termEval && state->getEvaluations() >= eval)
66 if(termFitness && (fitnessVal >= minFitness && fitnessVal <= maxFitness))
70 std::vector<IndividualP> hof = state->getHoF()->getBest();
71 IndividualP ind = hof[0];
73 evaluateVerbose =
true;
74 state->getAlgorithm()->evaluate(ind);
75 evaluateVerbose =
false;
77 ECF_LOG(state, 1, ind->toString());
bool operate(StateP state)
perform the designated operation
bool initialize(StateP state)
Perform initialization. Called before Operator::operate. By default, if the return value is false,...