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/moeoIndicatorBasedFitnessAssignment.h>
00026 #include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
00027 #include <move/moeoMoveIncrEval.h>
00028 
00042 template < class MOEOT, class Move >
00043 moeoLS < MOEOT, eoPop<MOEOT> & > & do_make_ls_moeo      (
00044     eoParser & _parser,
00045     eoState & _state,
00046     eoEvalFunc < MOEOT > & _eval,
00047     moeoMoveIncrEval < Move > & _moveIncrEval,
00048     eoContinue < MOEOT > & _continue,
00049     eoMonOp < MOEOT > & _op,
00050     eoMonOp < MOEOT > & _opInit,
00051     moMoveInit < Move > & _moveInit,
00052     moNextMove < Move > & _nextMove,
00053     moeoArchive < MOEOT > & _archive
00054 )
00055 {
00056     /* the objective vector type */
00057     typedef typename MOEOT::ObjectiveVector ObjectiveVector;
00058     /* the fitness assignment strategy */
00059     std::string & fitnessParam = _parser.getORcreateParam(std::string("IndicatorBased"), "fitness",
00060                             "Fitness assignment strategy parameter: IndicatorBased...", 'F',
00061                             "Evolution Engine").value();
00062     std::string & indicatorParam = _parser.getORcreateParam(std::string("Epsilon"), "indicator",
00063                               "Binary indicator to use with the IndicatorBased assignment: Epsilon, Hypervolume", 'i',
00064                               "Evolution Engine").value();
00065     double rho = _parser.getORcreateParam(1.1, "rho", "reference point for the hypervolume indicator",
00066                                           'r', "Evolution Engine").value();
00067     double kappa = _parser.getORcreateParam(0.05, "kappa", "Scaling factor kappa for IndicatorBased",
00068                                             'k', "Evolution Engine").value();
00069     moeoIndicatorBasedFitnessAssignment < MOEOT > * fitnessAssignment;
00070     if (fitnessParam == std::string("IndicatorBased"))
00071     {
00072         // metric
00073         moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > *metric;
00074         if (indicatorParam == std::string("Epsilon"))
00075         {
00076             metric = new moeoAdditiveEpsilonBinaryMetric < ObjectiveVector >;
00077         }
00078         else if (indicatorParam == std::string("Hypervolume"))
00079         {
00080             metric = new moeoHypervolumeBinaryMetric < ObjectiveVector > (rho);
00081         }
00082         else
00083         {
00084             std::string stmp = std::string("Invalid binary quality indicator: ") + indicatorParam;
00085             throw std::runtime_error(stmp.c_str());
00086         }
00087         fitnessAssignment = new moeoIndicatorBasedFitnessAssignment < MOEOT> (*metric, kappa);
00088     }
00089     else
00090     {
00091         std::string stmp = std::string("Invalid fitness assignment strategy: ") + fitnessParam;
00092         throw std::runtime_error(stmp.c_str());
00093     }
00094     _state.storeFunctor(fitnessAssignment);
00095     // number of iterations
00096     unsigned int n = _parser.getORcreateParam(1, "n", "Number of iterations for population Initialization", 'n', "Evolution Engine").value();
00097     // LS
00098     std::string & lsParam = _parser.getORcreateParam(std::string("I-IBMOLS"), "ls",
00099                        "Local Search: IBMOLS, I-IBMOLS (Iterated-IBMOLS)...", 'L',
00100                        "Evolution Engine").value();
00101     moeoLS < MOEOT, eoPop<MOEOT> & > * ls;
00102     if (lsParam == std::string("IBMOLS"))
00103     {
00104         ls = new moeoIBMOLS < MOEOT, Move > (_moveInit, _nextMove, _eval, _moveIncrEval, *fitnessAssignment, _continue);;
00105     }
00106     else if (lsParam == std::string("I-IBMOLS"))
00107     {
00108         ls = new moeoIteratedIBMOLS < MOEOT, Move > (_moveInit, _nextMove, _eval, _moveIncrEval, *fitnessAssignment, _continue, _op, _opInit, n);
00109     }
00110     else
00111     {
00112         std::string stmp = std::string("Invalid fitness assignment strategy: ") + fitnessParam;
00113         throw std::runtime_error(stmp.c_str());
00114     }
00115     _state.storeFunctor(ls);
00116     // that's it !
00117     return *ls;
00118 }
00119 
00120 #endif /*MAKE_LS_MOEO_H_*/

Generated on Mon Jul 2 16:05:01 2007 for ParadisEO-MOEO by  doxygen 1.4.7