- Main Page
- Classes
- Files

- Search for |

# moTSMoveLoopExpl.h

    00001 /*
    00002   <moTSMoveLoopExpl.h>
    00003   Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
    00004   (C) OPAC Team, LIFL, 2002-2008
    00005
    00006   Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
    00007
    00008   This software is governed by the CeCILL license under French law and
    00009   abiding by the rules of distribution of free software.  You can  use,
    00010   modify and/ or redistribute the software under the terms of the CeCILL
    00011   license as circulated by CEA, CNRS and INRIA at the following URL
    00012   "http://www.cecill.info".
    00013
    00014   As a counterpart to the access to the source code and  rights to copy,
    00015   modify and redistribute granted by the license, users are provided only
    00016   with a limited warranty  and the software's author,  the holder of the
    00017   economic rights,  and the successive licensors  have only  limited liability.
    00018
    00019   In this respect, the user's attention is drawn to the risks associated
    00020   with loading,  using,  modifying and/or developing or reproducing the
    00021   software by the user in light of its specific status of free software,
    00022   that may mean  that it is complicated to manipulate,  and  that  also
    00023   therefore means  that it is reserved for developers  and  experienced
    00024   professionals having in-depth computer knowledge. Users are therefore
    00025   encouraged to load and test the software's suitability as regards their
    00026   requirements in conditions enabling the security of their systems and/or
    00027   data to be ensured and,  more generally, to use and operate it in the
    00028   same conditions as regards security.
    00029   The fact that you are presently reading this means that you have had
    00030   knowledge of the CeCILL license and that you accept its terms.
    00031
    00032   ParadisEO WebSite : http://paradiseo.gforge.inria.fr
    00033   Contact: paradiseo-help@lists.gforge.inria.fr
    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     if( _old_solution.invalid() )
    00098       {
    00099         throw std::runtime_error("[moTSMoveLoopExpl.h]: The current solution has not been evaluated.");
    00100       }
    00101
    00102     //At the begining, the new solution is equivalent to the old one.
    00103     _new_solution=(EOT)_old_solution;
    00104
    00105     // Restarting the exploration of  of the neighborhood !
    00106     move_initializer (move, _old_solution);
    00107
    00108     move_selection.init( _old_solution.fitness() );
    00109
    00110     do
    00111       {
    00112         fitness = incremental_evaluation(move, _old_solution);
    00113
    00114         move_is_tabu = tabu_list(move, _old_solution);
    00115
    00116         aspiration_criterion_is_verified = aspiration_criterion(move, fitness);
    00117
    00118         if( !move_is_tabu || aspiration_criterion_is_verified )
    00119           {
    00120             selection_update_is_ok = move_selection.update(move, fitness);
    00121           }
    00122
    00123         has_next_move = next_move_generator(move, _old_solution);
    00124       }
    00125     while( has_next_move && selection_update_is_ok );
    00126
    00127     move_selection(best_move, best_move_fitness);
    00128
    00129     // Apply the best move.
    00130     best_move(_new_solution);
    00131
    00132     // The fitness is set to avoid an additionnal fitness computation.
    00133     _new_solution.fitness(best_move_fitness);
    00134
    00135     // Removing moves that are no more tabu.
    00136     tabu_list.update ();
    00137
    00138     // Updating the tabu list
    00139     tabu_list.add(best_move, _new_solution);
    00140   }
    00141
    00142  private:
    00143
    00145   moMoveInit < M > & move_initializer;
    00146
    00148   moNextMove < M > & next_move_generator;
    00149
    00151   moMoveIncrEval < M > & incremental_evaluation;
    00152
    00154   moBestImprSelect < M > move_selection;
    00155
    00157   moTabuList < M > & tabu_list;
    00158
    00160   moAspirCrit < M > & aspiration_criterion;
    00161 };
    00162
    00163 #endif