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
00026
00027 #ifndef _make_continue_pareto_h
00028 #define _make_continue_pareto_h
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <eoCombinedContinue.h>
00039 #include <eoGenContinue.h>
00040 #include <eoEvalContinue.h>
00041 #include <eoFitContinue.h>
00042 #ifndef _MSC_VER
00043 #include <eoCtrlCContinue.h>
00044 #endif
00045
00046
00047 #include <utils/eoParser.h>
00048 #include <utils/eoState.h>
00049
00050
00052 template <class Indi>
00053 eoCombinedContinue<Indi> * make_combinedContinue(eoCombinedContinue<Indi> *_combined, eoContinue<Indi> *_cont)
00054 {
00055 if (_combined)
00056 _combined->add(*_cont);
00057 else
00058 _combined = new eoCombinedContinue<Indi>(*_cont);
00059 return _combined;
00060 }
00061
00063 template <class Indi>
00064 eoContinue<Indi> & do_make_continue_pareto(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval)
00065 {
00067
00068 eoCombinedContinue<Indi> *continuator = NULL;
00069
00070
00071
00072
00073
00074 eoValueParam<unsigned>& maxGenParam = _parser.createParam(unsigned(100), "maxGen", "Maximum number of generations () = none)",'G',"Stopping criterion");
00075
00076 if (maxGenParam.value())
00077 {
00078 eoGenContinue<Indi> *genCont = new eoGenContinue<Indi>(maxGenParam.value());
00079 _state.storeFunctor(genCont);
00080
00081 continuator = make_combinedContinue<Indi>(continuator, genCont);
00082 }
00083
00084 #ifndef _MSC_VER
00085
00086 eoCtrlCContinue<Indi> *ctrlCCont;
00087 eoValueParam<bool>& ctrlCParam = _parser.createParam(true, "CtrlC", "Terminate current generation upon Ctrl C",'C', "Stopping criterion");
00088 if (_parser.isItThere(ctrlCParam))
00089 {
00090 ctrlCCont = new eoCtrlCContinue<Indi>;
00091
00092 _state.storeFunctor(ctrlCCont);
00093
00094 continuator = make_combinedContinue<Indi>(continuator, ctrlCCont);
00095 }
00096 #endif
00097
00098
00099 if (!continuator)
00100 throw std::runtime_error("You MUST provide a stopping criterion");
00101
00102 _state.storeFunctor(continuator);
00103
00104
00105 return *continuator;
00106 }
00107
00108 #endif