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 <eoEvalFunc.h>
00016 
00017 #include "moAlgo.h"
00018 #include "moMoveExpl.h"
00019 #include "moHCMoveLoopExpl.h"
00020 
00022 
00025 template < class M > class moHC:public moAlgo < typename M::EOType >
00026 {
00027 
00029   typedef
00030     typename
00031     M::EOType
00032     EOT;
00033 
00035   typedef
00036     typename
00037     EOT::Fitness
00038     Fitness;
00039 
00040 public:
00041 
00043 
00052 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 >
00053              (__move_init, __next_move, __incr_eval, __move_select)),
00054     full_eval (__full_eval)
00055   {
00056 
00057   }
00058 
00060 
00066 moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
00067     full_eval
00068     (__full_eval)
00069   {
00070 
00071   }
00072 
00074 
00081   bool operator   ()(EOT & __sol)
00082   {
00083 
00084     if (__sol.invalid ())
00085       {
00086         full_eval (__sol);
00087       }
00088 
00089     EOT new_sol;
00090 
00091     do
00092       {
00093 
00094         new_sol = __sol;
00095 
00096         try
00097         {
00098 
00099           move_expl (__sol, new_sol);
00100 
00101         }
00102         catch (EmptySelection & __ex)
00103         {
00104 
00105           break;
00106         }
00107 
00108         if (new_sol.fitness () > __sol.fitness ())
00109           {
00110             __sol = new_sol;
00111           }
00112         else
00113           {
00114             break;
00115           }
00116 
00117       }
00118     while (true);
00119 
00120     return true;
00121   }
00122 
00123 private:
00124 
00126   moMoveExpl < M > &move_expl;
00127 
00129   eoEvalFunc < EOT > &full_eval;
00130 };
00131 
00132 #endif

Generated on Tue Sep 25 16:25:46 2007 for PARADISEO-MO by  doxygen 1.5.2