00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MAKE_CONTINUE_MOEO_H_
00014 #define MAKE_CONTINUE_MOEO_H_
00015
00016 #include <eoCombinedContinue.h>
00017 #include <eoGenContinue.h>
00018 #include <eoEvalContinue.h>
00019 #include <eoFitContinue.h>
00020 #include <eoTimeContinue.h>
00021 #ifndef _MSC_VER
00022 #include <eoCtrlCContinue.h>
00023 #endif
00024 #include <utils/eoParser.h>
00025 #include <utils/eoState.h>
00026
00027
00033 template <class MOEOT>
00034 eoCombinedContinue<MOEOT> * make_combinedContinue(eoCombinedContinue<MOEOT> *_combined, eoContinue<MOEOT> *_cont)
00035 {
00036 if (_combined)
00037 _combined->add(*_cont);
00038 else
00039 _combined = new eoCombinedContinue<MOEOT>(*_cont);
00040 return _combined;
00041 }
00042
00043
00050 template <class MOEOT>
00051 eoContinue<MOEOT> & do_make_continue_moeo(eoParser& _parser, eoState& _state, eoEvalFuncCounter<MOEOT> & _eval)
00052 {
00053
00054 eoCombinedContinue<MOEOT> *continuator = NULL;
00055
00056
00057 eoValueParam<unsigned>& maxGenParam = _parser.createParam(unsigned(100), "maxGen", "Maximum number of generations (0 = none)",'G',"Stopping criterion");
00058 if (maxGenParam.value())
00059 {
00060 eoGenContinue<MOEOT> *genCont = new eoGenContinue<MOEOT>(maxGenParam.value());
00061 _state.storeFunctor(genCont);
00062
00063 continuator = make_combinedContinue<MOEOT>(continuator, genCont);
00064 }
00065
00066 eoValueParam<unsigned long>& maxEvalParam = _parser.getORcreateParam((unsigned long)0, "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion");
00067 if (maxEvalParam.value())
00068 {
00069 eoEvalContinue<MOEOT> *evalCont = new eoEvalContinue<MOEOT>(_eval, maxEvalParam.value());
00070 _state.storeFunctor(evalCont);
00071
00072 continuator = make_combinedContinue<MOEOT>(continuator, evalCont);
00073 }
00074
00075 eoValueParam<unsigned long>& maxTimeParam = _parser.getORcreateParam((unsigned long)0, "maxTime", "Maximum running time in seconds (0 = none)", 'T', "Stopping criterion");
00076 if (maxTimeParam.value())
00077 {
00078 eoTimeContinue<MOEOT> *timeCont = new eoTimeContinue<MOEOT>(maxTimeParam.value());
00079 _state.storeFunctor(timeCont);
00080
00081 continuator = make_combinedContinue<MOEOT>(continuator, timeCont);
00082 }
00083
00084 #ifndef _MSC_VER
00085
00086 eoCtrlCContinue<MOEOT> *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<MOEOT>;
00091
00092 _state.storeFunctor(ctrlCCont);
00093
00094 continuator = make_combinedContinue<MOEOT>(continuator, ctrlCCont);
00095 }
00096 #endif
00097
00098 if (!continuator)
00099 throw std::runtime_error("You MUST provide a stopping criterion");
00100
00101 _state.storeFunctor(continuator);
00102
00103 return *continuator;
00104 }
00105
00106 #endif