00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _eoGenContinue_h
00026 #define _eoGenContinue_h
00027
00028 #include <eoContinue.h>
00029 #include <utils/eoParam.h>
00033 template< class EOT>
00034 class eoGenContinue: public eoContinue<EOT>, public eoValueParam<unsigned>
00035 {
00036 public:
00037
00039 eoGenContinue( unsigned long _totalGens)
00040 : eoValueParam<unsigned>(0, "Generations", "Generations"),
00041 repTotalGenerations( _totalGens ),
00042 thisGenerationPlaceHolder(0),
00043 thisGeneration(thisGenerationPlaceHolder), verbose(true) {};
00044
00046 eoGenContinue( unsigned long _totalGens, unsigned long& _currentGen)
00047 : eoValueParam<unsigned>(0, "Generations", "Generations"),
00048 repTotalGenerations( _totalGens ),
00049 thisGenerationPlaceHolder(0),
00050 thisGeneration(_currentGen), verbose(true){};
00051
00054 virtual bool operator() ( const eoPop<EOT>& _vEO ) {
00055 thisGeneration++;
00056 value() = thisGeneration;
00057
00058 if (thisGeneration >= repTotalGenerations)
00059 {
00060 if (verbose)
00061 std::cout << "STOP in eoGenContinue: Reached maximum number of generations [" << thisGeneration << "/" << repTotalGenerations << "]\n";
00062 return false;
00063 }
00064 return true;
00065 }
00066
00069 virtual void totalGenerations( unsigned long _tg ) {
00070 repTotalGenerations = _tg;
00071 thisGeneration = 0;
00072 };
00073
00075 virtual unsigned long totalGenerations( )
00076 {
00077 return repTotalGenerations;
00078 };
00079
00080
00081 virtual std::string className(void) const { return "eoGenContinue"; }
00082
00083 void readFrom (std :: istream & __is) {
00084
00085 __is >> thisGeneration;
00086 }
00087
00088 void printOn (std :: ostream & __os) const {
00089
00090 __os << thisGeneration << std :: endl;
00091 }
00092
00093 private:
00094 unsigned long repTotalGenerations;
00095 unsigned long thisGenerationPlaceHolder;
00096 unsigned long& thisGeneration;
00097
00098 public:
00099 bool verbose;
00100 };
00101
00102 #endif
00103