ECF 1.5
TermMaxEvalOp.cpp
1#include "ECF_base.h"
2#include "TermMaxEvalOp.h"
3
4
6{
7 uint *eval = new uint(0);
8 state->getRegistry()->registerEntry("term.eval", (voidP) eval, ECF::UINT,
9 "max number of fitness evaluations (default: none)");
10}
11
12
13bool TermMaxEvalOp::initialize(StateP state)
14{
15 voidP sptr = state->getRegistry()->getEntry("term.eval");
16 nEvaluations_ = *((uint*) sptr.get());
17
18 if(state->getRegistry()->isModified("term.eval"))
19 return true;
20
21 return false;
22}
23
24
25bool TermMaxEvalOp::operate(StateP state)
26{
27 if(state->getEvaluations() >= nEvaluations_) {
28 state->setTerminateCond();
29 ECF_LOG(state, 1, "Termination: max evaluations reached (" + uint2str(nEvaluations_) + ")");
30 }
31
32 return true;
33}
bool initialize(StateP)
Perform initialization. Called before Operator::operate. By default, if the return value is false,...
void registerParameters(StateP)
Register parameters with the Registry. Called before Operator::initialize.
bool operate(StateP)
perform the designated operation