Added the lastCall construct: if the stopping condition becomes true in eoCheckPoint,

a method called lastCall is called for everything contained in that checkpoint
      (stats, updaters and monitors). This can be extremely useful
      - for stateSavers (see below)
      - for monitoring things like rates of success of operators, where what you
        are interested in is the final result only.
Added of course a virtual method lastCall that does nothing by default in classes
      eoBaseStat, eoBaseSortedStat, eoUpdater and eoMonitor
Added a boolean to control the save of the state in method eoCountedStateSaver::lastCall
      so you can ask that the state is saved at final population, whatever happens.
      I also added the corresponding constructor to take this into account.
This commit is contained in:
evomarc 2000-12-04 06:58:43 +00:00
commit 0e62de2d14
5 changed files with 63 additions and 14 deletions

View file

@ -35,7 +35,10 @@
Yet again an empty name
*/
class eoUpdater : public eoF<void>
{};
{
public:
virtual void lastCall() {}
};
/**
an eoUpdater that simply increments a counter
@ -85,16 +88,26 @@ private :
class eoCountedStateSaver : public eoUpdater
{
public :
eoCountedStateSaver(unsigned _interval, const eoState& _state, std::string _prefix = "state", std::string _extension = "sav")
: state(_state), interval(_interval), counter(0),
prefix(_prefix), extension(_extension) {}
eoCountedStateSaver(unsigned _interval, const eoState& _state, std::string _prefix, bool _saveOnLastCall, std::string _extension = "sav")
: state(_state), interval(_interval), counter(0),
saveOnLastCall(_saveOnLastCall),
prefix(_prefix), extension(_extension) {}
eoCountedStateSaver(unsigned _interval, const eoState& _state, std::string _prefix = "state", std::string _extension = "sav")
: state(_state), interval(_interval), counter(0),
saveOnLastCall(false),
prefix(_prefix), extension(_extension) {}
virtual void lastCall(void);
void operator()(void);
private :
void doItNow(void);
const eoState& state;
const unsigned interval;
unsigned counter;
bool saveOnLastCall;
const std::string prefix;
const std::string extension;