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 #ifndef __moHC_h
00037 #define __moHC_h
00038
00039 #include <eoEvalFunc.h>
00040
00041 #include <moAlgo.h>
00042 #include <moHCMoveLoopExpl.h>
00043
00045
00048 template < class M >
00049 class moHC:public moAlgo < typename M::EOType >
00050 {
00052 typedef typename M::EOType EOT;
00053
00055 typedef typename EOT::Fitness Fitness;
00056
00057 public:
00058
00060
00069 moHC (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
00070 moMoveIncrEval < M > & _incremental_evaluation, moMoveSelect < M > & _move_selection, eoEvalFunc < EOT > & _full_evaluation) :
00071 move_explorer(new moHCMoveLoopExpl<M>(_move_initializer, _next_move_generator, _incremental_evaluation, _move_selection)),
00072 full_evaluation (_full_evaluation), move_explorer_memory_allocation(true)
00073 {}
00074
00076
00082 moHC (moMoveExpl < M > & _move_explorer, eoEvalFunc < EOT > & _full_evaluation):
00083 move_explorer (&_move_explorer), full_evaluation (_full_evaluation), move_explorer_memory_allocation(false)
00084 {}
00085
00087 ~moHC()
00088 {
00089 if(move_explorer_memory_allocation)
00090 {
00091 delete(move_explorer);
00092 }
00093 }
00094
00096
00103 bool operator ()(EOT & _solution)
00104 {
00105 EOT new_solution;
00106
00107 if ( _solution.invalid() )
00108 {
00109 full_evaluation(_solution);
00110 }
00111
00112 new_solution=_solution;
00113
00114 do
00115 {
00116 _solution=new_solution;
00117 (*move_explorer) (_solution, new_solution);
00118 }
00119 while ( new_solution.fitness() > _solution.fitness() );
00120
00121 return true;
00122 }
00123
00124 private:
00125
00127 moMoveExpl < M > * move_explorer;
00128
00130 eoEvalFunc < EOT > & full_evaluation;
00131
00133 bool move_explorer_memory_allocation;
00134 };
00135
00136 #endif