- Main Page
- Classes
- Files

- Search for |

# moTSMoveLoopExpl.h

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 // "moTSMoveLoopExpl.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 __moTSMoveLoopExpl_h
    00013 #define __moTSMoveLoopExpl_h
    00014
    00015 #include "moMoveLoopExpl.h"
    00016
    00017 #include "moMoveInit.h"
    00018 #include "moNextMove.h"
    00019 #include "moMoveIncrEval.h"
    00020 #include "moMoveSelect.h"
    00021
    00022 #include "moTabuList.h"
    00023 #include "moAspirCrit.h"
    00024 #include "moBestImprSelect.h"
    00025
    00027
    00030 template < class M > class moTSMoveLoopExpl:public moMoveLoopExpl < M >
    00031 {
    00032
    00034   typedef typename M::EOType EOT;
    00035
    00037   typedef typename M::EOType::Fitness Fitness;
    00038
    00039 public:
    00040
    00042
    00049 moTSMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit):
    00050   move_init (__move_init),
    00051     next_move (__next_move),
    00052     incr_eval (__incr_eval),
    00053     tabu_list (__tabu_list), aspir_crit (__aspir_crit)
    00054   {
    00055
    00056     tabu_list.init ();
    00057     aspir_crit.init ();
    00058   }
    00059
    00061
    00069   void operator   () (const EOT & __old_sol, EOT & __new_sol)
    00070   {
    00071
    00072     M move;
    00073
    00074
    00075     move_init (move, __old_sol);        /* Restarting the exploration of
    00076                                            of the neighborhood ! */
    00077
    00078     move_select.init (__old_sol.fitness ());
    00079
    00080     do
    00081       {
    00082
    00083         Fitness fit = incr_eval (move, __old_sol);
    00084
    00085         if (!tabu_list (move, __old_sol) || aspir_crit (move, fit))
    00086           {
    00087             if (!move_select.update (move, fit))
    00088               break;
    00089           }
    00090
    00091       }
    00092     while (next_move (move, __old_sol));
    00093
    00094     M best_move;
    00095
    00096     Fitness best_move_fit;
    00097
    00098     move_select (best_move, best_move_fit);
    00099
    00100     __new_sol.fitness (best_move_fit);
    00101     best_move (__new_sol);
    00102
    00103     /* Removing moves that are
    00104        no more tabu */
    00105     tabu_list.update ();
    00106
    00107     // Updating the tabu list
    00108     tabu_list.add (best_move, __new_sol);
    00109   }
    00110
    00111 private:
    00112
    00114   moMoveInit < M > &move_init;
    00115
    00117   moNextMove < M > &next_move;
    00118
    00120   moMoveIncrEval < M > &incr_eval;
    00121
    00123   moBestImprSelect < M > move_select;
    00124
    00126   moTabuList < M > &tabu_list;
    00127
    00129   moAspirCrit < M > &aspir_crit;
    00130 };
    00131
    00132 #endif