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 __moILS_h
00038 #define __moILS_h
00039
00040 #include <eoEvalFunc.h>
00041
00042 #include "moHC.h"
00043 #include "moTS.h"
00044 #include "moSA.h"
00045
00047
00050 template < class M > class moILS:public moAlgo < typename M::EOType >
00051 {
00052
00054 typedef typename M::EOType EOT;
00055
00057 typedef typename EOT::Fitness Fitness;
00058
00059 public:
00060
00062
00071 moILS (moAlgo<EOT> &__algo, moSolContinue <EOT> &__continue, moComparator<EOT> &__acceptance_criterion, eoMonOp<EOT> &__perturbation,
00072 eoEvalFunc<EOT> &__full_eval):
00073 algo(__algo), cont(__continue), acceptance_criterion(__acceptance_criterion), perturbation(__perturbation), full_eval(__full_eval)
00074 {}
00075
00077
00087 moILS (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval,
00088 moMoveSelect < M > &__move_select, moSolContinue <EOT> &__continue, moComparator<EOT> &__acceptance_criterion,
00089 eoMonOp<EOT> &__perturbation, eoEvalFunc<EOT> &__full_eval):
00090 algo(*new moHC<M>(__move_init, __next_move, __incr_eval, __move_select, __full_eval)), cont(__continue),
00091 acceptance_criterion(__acceptance_criterion), perturbation(__perturbation), full_eval(__full_eval)
00092 {}
00093
00095
00107 moILS (moMoveInit <M> &__move_init, moNextMove <M> &__next_move, moMoveIncrEval <M> &__incr_eval,
00108 moTabuList <M> &__tabu_list, moAspirCrit <M> &__aspir_crit, moSolContinue <EOT> &__moTS_continue,
00109 moSolContinue <EOT> &__continue, moComparator<EOT> &__acceptance_criterion, eoMonOp<EOT> &__perturbation,
00110 eoEvalFunc<EOT> &__full_eval):
00111 algo(*new moTS<M>(__move_init, __next_move, __incr_eval, __tabu_list, __aspir_crit, __moTS_continue, __full_eval)),
00112 cont(__continue), acceptance_criterion(__acceptance_criterion), perturbation(__perturbation), full_eval(__full_eval)
00113 {}
00114
00116
00127 moILS (moRandMove<M> &__move_rand, moMoveIncrEval <M> &__incr_eval, moSolContinue <EOT> &__moSA_continue, double __init_temp,
00128 moCoolingSchedule & __cool_sched, moSolContinue <EOT> &__continue, moComparator<EOT> &__acceptance_criterion,
00129 eoMonOp<EOT> &__perturbation, eoEvalFunc<EOT> &__full_eval):
00130 algo(*new moSA<M>(__move_rand, __incr_eval, __moSA_continue, __init_temp, __cool_sched, __full_eval)),
00131 cont(__continue), acceptance_criterion(__acceptance_criterion), perturbation(__perturbation), full_eval(__full_eval)
00132 {}
00133
00134
00135
00137
00144 bool operator()(EOT & __sol)
00145 {
00146 EOT __sol_saved=__sol;
00147
00148 cont.init ();
00149
00150
00151
00152
00153 algo(__sol);
00154
00155 if(acceptance_criterion(__sol, __sol_saved))
00156 {
00157 __sol_saved=__sol;
00158
00159 }
00160 else
00161 {
00162 __sol=__sol_saved;
00163 }
00164
00165 while (cont (__sol))
00166 {
00167 perturbation(__sol);
00168 full_eval(__sol);
00169
00170 algo(__sol);
00171
00172 if(acceptance_criterion(__sol, __sol_saved))
00173 {
00174 __sol_saved=__sol;
00175 }
00176 else
00177 {
00178 __sol=__sol_saved;
00179 }
00180 }
00181
00182 return true;
00183 }
00184
00185 private:
00186
00188 moAlgo<EOT> &algo;
00189
00191 moSolContinue<EOT> &cont;
00192
00194 moComparator<EOT> &acceptance_criterion;
00195
00197 eoMonOp<EOT> &perturbation;
00198
00200 eoEvalFunc<EOT> &full_eval;
00201 };
00202
00203 #endif