- Main Page
- Classes
- Files

- Search for |

# moHC.h

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 // "moHC.h"
    00004
    00005 // (c) OPAC Team, LIFL, 2003-2006
    00006
    00007 /* LICENCE TEXT
    00008
    00009    Contact: paradiseo-help@lists.gforge.inria.fr
    00010 */
    00011
    00012 #ifndef __moHC_h
    00013 #define __moHC_h
    00014
    00015 #include <eoOp.h>
    00016 #include <eoEvalFunc.h>
    00017
    00018 #include "moAlgo.h"
    00019 #include "moMoveExpl.h"
    00020 #include "moHCMoveLoopExpl.h"
    00021
    00023
    00026 template < class M > class moHC:public moAlgo < typename M::EOType >
    00027 {
    00028
    00030   typedef
    00031     typename
    00032     M::EOType
    00033     EOT;
    00034
    00036   typedef
    00037     typename
    00038     EOT::Fitness
    00039     Fitness;
    00040
    00041 public:
    00042
    00044
    00053 moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select, eoEvalFunc < EOT > &__full_eval):move_expl (*new moHCMoveLoopExpl < M >
    00054              (__move_init, __next_move, __incr_eval, __move_select)),
    00055     full_eval (__full_eval)
    00056   {
    00057
    00058   }
    00059
    00061
    00067 moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
    00068     full_eval
    00069     (__full_eval)
    00070   {
    00071
    00072   }
    00073
    00075
    00082   bool operator   ()(EOT & __sol)
    00083   {
    00084
    00085     if (__sol.invalid ())
    00086       {
    00087         full_eval (__sol);
    00088       }
    00089
    00090     EOT new_sol;
    00091
    00092     do
    00093       {
    00094
    00095         new_sol = __sol;
    00096
    00097         try
    00098         {
    00099
    00100           move_expl (__sol, new_sol);
    00101
    00102         }
    00103         catch (EmptySelection & __ex)
    00104         {
    00105
    00106           break;
    00107         }
    00108
    00109         if (new_sol.fitness () > __sol.fitness ())
    00110           {
    00111             __sol = new_sol;
    00112           }
    00113         else
    00114           {
    00115             break;
    00116           }
    00117
    00118       }
    00119     while (true);
    00120
    00121     return true;
    00122   }
    00123
    00124 private:
    00125
    00127   moMoveExpl < M > &move_expl;
    00128
    00130   eoEvalFunc < EOT > &full_eval;
    00131 };
    00132
    00133 #endif