00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __moHC_h
00038 #define __moHC_h
00039
00040 #include <eoEvalFunc.h>
00041
00042 #include "moAlgo.h"
00043 #include "moMoveExpl.h"
00044 #include "moHCMoveLoopExpl.h"
00045
00047
00050 template < class M > class moHC:public moAlgo < typename M::EOType >
00051 {
00052
00054 typedef
00055 typename
00056 M::EOType
00057 EOT;
00058
00060 typedef
00061 typename
00062 EOT::Fitness
00063 Fitness;
00064
00065 public:
00066
00068
00077 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 >
00078 (__move_init, __next_move, __incr_eval, __move_select)),
00079 full_eval (__full_eval)
00080 {
00081
00082 }
00083
00085
00091 moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
00092 full_eval
00093 (__full_eval)
00094 {
00095
00096 }
00097
00099
00106 bool operator ()(EOT & __sol)
00107 {
00108
00109 if (__sol.invalid ())
00110 {
00111 full_eval (__sol);
00112 }
00113
00114 EOT new_sol;
00115
00116 do
00117 {
00118
00119 new_sol = __sol;
00120
00121 try
00122 {
00123
00124 move_expl (__sol, new_sol);
00125
00126 }
00127 catch (EmptySelection & __ex)
00128 {
00129
00130 break;
00131 }
00132
00133 if (new_sol.fitness () > __sol.fitness ())
00134 {
00135 __sol = new_sol;
00136 }
00137 else
00138 {
00139 break;
00140 }
00141
00142 }
00143 while (true);
00144
00145 return true;
00146 }
00147
00148 private:
00149
00151 moMoveExpl < M > &move_expl;
00152
00154 eoEvalFunc < EOT > &full_eval;
00155 };
00156
00157 #endif