ECF 1.5
TermFitnessValOp.cpp
1#include "ECF_base.h"
2#include "TermFitnessValOp.h"
3
4
6{
7 double *value = new double(0);
8 state->getRegistry()->registerEntry("term.fitnessval", (voidP) value, ECF::DOUBLE,
9 "fitness value for termination (default: none)");
10}
11
12
14{
15 if(!state->getRegistry()->isModified("term.fitnessval"))
16 return false;
17
18 voidP sptr = state->getRegistry()->getEntry("term.fitnessval");
19 termValue_ = *((double*) sptr.get());
20
21 return true;
22}
23
24
25bool TermFitnessValOp::operate(StateP state)
26{
27 double minFitness = state->getStats()->getFitnessMin();
28 double maxFitness = state->getStats()->getFitnessMax();
29
30 if(termValue_ >= minFitness && termValue_ <= maxFitness) {
31 state->setTerminateCond();
32 ECF_LOG(state, 1, "Termination: fitness value (" + dbl2str(termValue_) + ") reached");
33 }
34
35 return true;
36}
bool operate(StateP)
perform the designated operation
void registerParameters(StateP)
Register parameters with the Registry. Called before Operator::initialize.
bool initialize(StateP)
Perform initialization. Called before Operator::operate. By default, if the return value is false,...