make_ls_moeo.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // make_ls_moeo.h
00005 // (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
00006 /*
00007     This library...
00008 
00009     Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
00010  */
00011 //-----------------------------------------------------------------------------
00012 
00013 #ifndef MAKE_LS_MOEO_H_
00014 #define MAKE_LS_MOEO_H_
00015 
00016 #include <eoContinue.h>
00017 #include <eoEvalFunc.h>
00018 #include <eoGenOp.h>
00019 #include <utils/eoParser.h>
00020 #include <utils/eoState.h>
00021 #include <algo/moeoIBMOLS.h>
00022 #include <algo/moeoIteratedIBMOLS.h>
00023 #include <algo/moeoLS.h>
00024 #include <archive/moeoArchive.h>
00025 #include <fitness/moeoBinaryIndicatorBasedFitnessAssignment.h>
00026 #include <fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h>
00027 #include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
00028 #include <move/moeoMoveIncrEval.h>
00029 
00043 template < class MOEOT, class Move >
00044 moeoLS < MOEOT, eoPop<MOEOT> & > & do_make_ls_moeo      (
00045     eoParser & _parser,
00046     eoState & _state,
00047     eoEvalFunc < MOEOT > & _eval,
00048     moeoMoveIncrEval < Move > & _moveIncrEval,
00049     eoContinue < MOEOT > & _continue,
00050     eoMonOp < MOEOT > & _op,
00051     eoMonOp < MOEOT > & _opInit,
00052     moMoveInit < Move > & _moveInit,
00053     moNextMove < Move > & _nextMove,
00054     moeoArchive < MOEOT > & _archive
00055 )
00056 {
00057     /* the objective vector type */
00058     typedef typename MOEOT::ObjectiveVector ObjectiveVector;
00059     /* the fitness assignment strategy */
00060     std::string & fitnessParam = _parser.getORcreateParam(std::string("IndicatorBased"), "fitness",
00061                             "Fitness assignment strategy parameter: IndicatorBased...", 'F',
00062                             "Evolution Engine").value();
00063     std::string & indicatorParam = _parser.getORcreateParam(std::string("Epsilon"), "indicator",
00064                               "Binary indicator to use with the IndicatorBased assignment: Epsilon, Hypervolume", 'i',
00065                               "Evolution Engine").value();
00066     double rho = _parser.getORcreateParam(1.1, "rho", "reference point for the hypervolume indicator",
00067                                           'r', "Evolution Engine").value();
00068     double kappa = _parser.getORcreateParam(0.05, "kappa", "Scaling factor kappa for IndicatorBased",
00069                                             'k', "Evolution Engine").value();
00070     moeoBinaryIndicatorBasedFitnessAssignment < MOEOT > * fitnessAssignment;
00071     if (fitnessParam == std::string("IndicatorBased"))
00072     {
00073         // metric
00074         moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > *metric;
00075         if (indicatorParam == std::string("Epsilon"))
00076         {
00077             metric = new moeoAdditiveEpsilonBinaryMetric < ObjectiveVector >;
00078         }
00079         else if (indicatorParam == std::string("Hypervolume"))
00080         {
00081             metric = new moeoHypervolumeBinaryMetric < ObjectiveVector > (rho);
00082         }
00083         else
00084         {
00085             std::string stmp = std::string("Invalid binary quality indicator: ") + indicatorParam;
00086             throw std::runtime_error(stmp.c_str());
00087         }
00088         fitnessAssignment = new moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT> (*metric, kappa);
00089     }
00090     else
00091     {
00092         std::string stmp = std::string("Invalid fitness assignment strategy: ") + fitnessParam;
00093         throw std::runtime_error(stmp.c_str());
00094     }
00095     _state.storeFunctor(fitnessAssignment);
00096     // number of iterations
00097     unsigned int n = _parser.getORcreateParam(1, "n", "Number of iterations for population Initialization", 'n', "Evolution Engine").value();
00098     // LS
00099     std::string & lsParam = _parser.getORcreateParam(std::string("I-IBMOLS"), "ls",
00100                        "Local Search: IBMOLS, I-IBMOLS (Iterated-IBMOLS)...", 'L',
00101                        "Evolution Engine").value();
00102     moeoLS < MOEOT, eoPop<MOEOT> & > * ls;
00103     if (lsParam == std::string("IBMOLS"))
00104     {
00105         ls = new moeoIBMOLS < MOEOT, Move > (_moveInit, _nextMove, _eval, _moveIncrEval, *fitnessAssignment, _continue);;
00106     }
00107     else if (lsParam == std::string("I-IBMOLS"))
00108     {
00109         ls = new moeoIteratedIBMOLS < MOEOT, Move > (_moveInit, _nextMove, _eval, _moveIncrEval, *fitnessAssignment, _continue, _op, _opInit, n);
00110     }
00111     else
00112     {
00113         std::string stmp = std::string("Invalid fitness assignment strategy: ") + fitnessParam;
00114         throw std::runtime_error(stmp.c_str());
00115     }
00116     _state.storeFunctor(ls);
00117     // that's it !
00118     return *ls;
00119 }
00120 
00121 #endif /*MAKE_LS_MOEO_H_*/

Generated on Mon Oct 8 10:35:51 2007 for ParadisEO-MOEOMovingObjects by  doxygen 1.4.7