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 _moTSMoveLoopExpl_h
00037 #define _moTSMoveLoopExpl_h
00038
00039 #include <moMoveLoopExpl.h>
00040 #include <moMoveInit.h>
00041 #include <moNextMove.h>
00042 #include <moMoveIncrEval.h>
00043 #include <moMoveSelect.h>
00044 #include <moTabuList.h>
00045 #include <moAspirCrit.h>
00046 #include <moBestImprSelect.h>
00047
00049
00052 template < class M >
00053 class moTSMoveLoopExpl:public moMoveLoopExpl < M >
00054 {
00056 typedef typename M::EOType EOT;
00057
00059 typedef typename M::EOType::Fitness Fitness;
00060
00061 public:
00062
00064
00071 moTSMoveLoopExpl (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
00072 moMoveIncrEval < M > & _incremental_evaluation, moTabuList < M > & _tabu_list,
00073 moAspirCrit < M > & _aspiration_criterion):
00074 move_initializer(_move_initializer), next_move_generator(_next_move_generator), incremental_evaluation(_incremental_evaluation),
00075 tabu_list(_tabu_list), aspiration_criterion(_aspiration_criterion)
00076 {
00077 tabu_list.init ();
00078 aspiration_criterion.init ();
00079 }
00080
00082
00090 void operator () (const EOT & _old_solution, EOT & _new_solution)
00091 {
00092 M move, best_move;
00093 Fitness fitness, best_move_fitness;
00094
00095 bool move_is_tabu, aspiration_criterion_is_verified, selection_update_is_ok, has_next_move;
00096
00097
00098 _new_solution=(EOT)_old_solution;
00099
00100
00101 move_initializer (move, _old_solution);
00102
00103 move_selection.init( _old_solution.fitness() );
00104
00105 do
00106 {
00107 fitness = incremental_evaluation(move, _old_solution);
00108
00109 move_is_tabu = tabu_list(move, _old_solution);
00110
00111 aspiration_criterion_is_verified = aspiration_criterion(move, fitness);
00112
00113 if( !move_is_tabu || aspiration_criterion_is_verified )
00114 {
00115 selection_update_is_ok = move_selection.update(move, fitness);
00116 }
00117
00118 has_next_move = next_move_generator(move, _old_solution);
00119 }
00120 while( has_next_move && selection_update_is_ok );
00121
00122 move_selection(best_move, best_move_fitness);
00123
00124
00125 best_move(_new_solution);
00126
00127
00128 _new_solution.fitness(best_move_fitness);
00129
00130
00131 tabu_list.update ();
00132
00133
00134 tabu_list.add(best_move, _new_solution);
00135 }
00136
00137 private:
00138
00140 moMoveInit < M > & move_initializer;
00141
00143 moNextMove < M > & next_move_generator;
00144
00146 moMoveIncrEval < M > & incremental_evaluation;
00147
00149 moBestImprSelect < M > move_selection;
00150
00152 moTabuList < M > & tabu_list;
00153
00155 moAspirCrit < M > & aspiration_criterion;
00156 };
00157
00158 #endif