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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef MAKE_CONTINUE_MOEO_H_
00039 #define MAKE_CONTINUE_MOEO_H_
00040
00041 #include <eoCombinedContinue.h>
00042 #include <eoGenContinue.h>
00043 #include <eoEvalContinue.h>
00044 #include <eoFitContinue.h>
00045 #include <eoTimeContinue.h>
00046 #ifndef _MSC_VER
00047 #include <eoCtrlCContinue.h>
00048 #endif
00049 #include <utils/eoParser.h>
00050 #include <utils/eoState.h>
00051
00052
00058 template <class MOEOT>
00059 eoCombinedContinue<MOEOT> * make_combinedContinue(eoCombinedContinue<MOEOT> *_combined, eoContinue<MOEOT> *_cont)
00060 {
00061 if (_combined)
00062 _combined->add(*_cont);
00063 else
00064 _combined = new eoCombinedContinue<MOEOT>(*_cont);
00065 return _combined;
00066 }
00067
00068
00075 template <class MOEOT>
00076 eoContinue<MOEOT> & do_make_continue_moeo(eoParser& _parser, eoState& _state, eoEvalFuncCounter<MOEOT> & _eval)
00077 {
00078
00079 eoCombinedContinue<MOEOT> *continuator = NULL;
00080
00081
00082 eoValueParam<unsigned int>& maxGenParam = _parser.createParam((unsigned int)(100), "maxGen", "Maximum number of generations (0 = none)",'G',"Stopping criterion");
00083 if (maxGenParam.value())
00084 {
00085 eoGenContinue<MOEOT> *genCont = new eoGenContinue<MOEOT>(maxGenParam.value());
00086 _state.storeFunctor(genCont);
00087
00088 continuator = make_combinedContinue<MOEOT>(continuator, genCont);
00089 }
00090
00091 eoValueParam<unsigned long>& maxEvalParam = _parser.getORcreateParam((unsigned long)(0), "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion");
00092 if (maxEvalParam.value())
00093 {
00094 eoEvalContinue<MOEOT> *evalCont = new eoEvalContinue<MOEOT>(_eval, maxEvalParam.value());
00095 _state.storeFunctor(evalCont);
00096
00097 continuator = make_combinedContinue<MOEOT>(continuator, evalCont);
00098 }
00099
00100 eoValueParam<unsigned long>& maxTimeParam = _parser.getORcreateParam((unsigned long)(0), "maxTime", "Maximum running time in seconds (0 = none)", 'T', "Stopping criterion");
00101 if (maxTimeParam.value())
00102 {
00103 eoTimeContinue<MOEOT> *timeCont = new eoTimeContinue<MOEOT>(maxTimeParam.value());
00104 _state.storeFunctor(timeCont);
00105
00106 continuator = make_combinedContinue<MOEOT>(continuator, timeCont);
00107 }
00108
00109 #ifndef _MSC_VER
00110
00111 eoCtrlCContinue<MOEOT> *ctrlCCont;
00112 eoValueParam<bool>& ctrlCParam = _parser.createParam(true, "CtrlC", "Terminate current generation upon Ctrl C",'C', "Stopping criterion");
00113 if (_parser.isItThere(ctrlCParam))
00114 {
00115 ctrlCCont = new eoCtrlCContinue<MOEOT>;
00116
00117 _state.storeFunctor(ctrlCCont);
00118
00119 continuator = make_combinedContinue<MOEOT>(continuator, ctrlCCont);
00120 }
00121 #endif
00122
00123 if (!continuator)
00124 throw std::runtime_error("You MUST provide a stopping criterion");
00125
00126 _state.storeFunctor(continuator);
00127
00128 return *continuator;
00129 }
00130
00131 #endif