make_continue_moeo.h

00001 /* 
00002 * <make_continue_moeo.h>
00003 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
00004 * (C) OPAC Team, LIFL, 2002-2007
00005 *
00006 * Arnaud Liefooghe
00007 *
00008 * This software is governed by the CeCILL license under French law and
00009 * abiding by the rules of distribution of free software.  You can  use,
00010 * modify and/ or redistribute the software under the terms of the CeCILL
00011 * license as circulated by CEA, CNRS and INRIA at the following URL
00012 * "http://www.cecill.info".
00013 *
00014 * As a counterpart to the access to the source code and  rights to copy,
00015 * modify and redistribute granted by the license, users are provided only
00016 * with a limited warranty  and the software's author,  the holder of the
00017 * economic rights,  and the successive licensors  have only  limited liability.
00018 *
00019 * In this respect, the user's attention is drawn to the risks associated
00020 * with loading,  using,  modifying and/or developing or reproducing the
00021 * software by the user in light of its specific status of free software,
00022 * that may mean  that it is complicated to manipulate,  and  that  also
00023 * therefore means  that it is reserved for developers  and  experienced
00024 * professionals having in-depth computer knowledge. Users are therefore
00025 * encouraged to load and test the software's suitability as regards their
00026 * requirements in conditions enabling the security of their systems and/or
00027 * data to be ensured and,  more generally, to use and operate it in the
00028 * same conditions as regards security.
00029 * The fact that you are presently reading this means that you have had
00030 * knowledge of the CeCILL license and that you accept its terms.
00031 *
00032 * ParadisEO WebSite : http://paradiseo.gforge.inria.fr
00033 * Contact: paradiseo-help@lists.gforge.inria.fr
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)                 // already exists
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     // the combined continue - to be filled
00079     eoCombinedContinue<MOEOT> *continuator = NULL;
00080     // First the eoGenContinue - need a default value so you can run blind
00081     // but we also need to be able to avoid it <--> 0
00082     eoValueParam<unsigned int>& maxGenParam = _parser.createParam((unsigned int)(100), "maxGen", "Maximum number of generations (0 = none)",'G',"Stopping criterion");
00083     if (maxGenParam.value()) // positive: -> define and store
00084     {
00085         eoGenContinue<MOEOT> *genCont = new eoGenContinue<MOEOT>(maxGenParam.value());
00086         _state.storeFunctor(genCont);
00087         // and "add" to combined
00088         continuator = make_combinedContinue<MOEOT>(continuator, genCont);
00089     }
00090     // maxEval
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         // and "add" to combined
00097         continuator = make_combinedContinue<MOEOT>(continuator, evalCont);
00098     }
00099     // maxTime
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()) // positive: -> define and store
00102     {
00103         eoTimeContinue<MOEOT> *timeCont = new eoTimeContinue<MOEOT>(maxTimeParam.value());
00104         _state.storeFunctor(timeCont);
00105         // and "add" to combined
00106         continuator = make_combinedContinue<MOEOT>(continuator, timeCont);
00107     }
00108     // CtrlC
00109 #ifndef _MSC_VER
00110     // the CtrlC interception (Linux only I'm afraid)
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         // store
00117         _state.storeFunctor(ctrlCCont);
00118         // add to combinedContinue
00119         continuator = make_combinedContinue<MOEOT>(continuator, ctrlCCont);
00120     }
00121 #endif
00122     // now check that there is at least one!
00123     if (!continuator)
00124         throw std::runtime_error("You MUST provide a stopping criterion");
00125     // OK, it's there: store in the eoState
00126     _state.storeFunctor(continuator);
00127     // and return
00128     return *continuator;
00129 }
00130 
00131 #endif /*MAKE_CONTINUE_MOEO_H_*/

Generated on Fri Oct 12 15:16:04 2007 for ParadisEO-MOEO:MultiObjectiveEvolvingObjects by  doxygen 1.4.7