00001 #include "ECF_base.h"
00002 #include "TermMaxEvalOp.h"
00003
00004
00005 void TermMaxEvalOp::registerParameters(StateP state)
00006 {
00007 int *eval = new int(0);
00008 state->getRegistry()->registerEntry("term.eval", (voidP) eval, ECF::UINT,
00009 "max number of fitness evaluations (default: none)");
00010 }
00011
00012
00013 bool TermMaxEvalOp::initialize(StateP state)
00014 {
00015 voidP sptr = state->getRegistry()->getEntry("term.eval");
00016 nEvaluations_ = *((uint*) sptr.get());
00017
00018 if(state->getRegistry()->isModified("term.eval"))
00019 return true;
00020
00021 return false;
00022 }
00023
00024
00025 bool TermMaxEvalOp::operate(StateP state)
00026 {
00027 if(state->getEvaluations() >= nEvaluations_) {
00028 state->setTerminateCond();
00029 ECF_LOG(state, 1, "Termination: max evaluations reached (" + uint2str(nEvaluations_) + ")");
00030 }
00031
00032 return true;
00033 }