moTS.h

00001 /* 
00002 * <moTS.h>
00003 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
00004 * (C) OPAC Team, LIFL, 2002-2007
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 
00037 #ifndef __moTS_h
00038 #define __moTS_h
00039 
00040 #include <eoOp.h>
00041 #include <eoEvalFunc.h>
00042 
00043 #include "moAlgo.h"
00044 #include "moSolContinue.h"
00045 
00046 #include "moMoveExpl.h"
00047 #include "moTSMoveLoopExpl.h"
00048 
00049 
00051 
00054 template < class M > class moTS:public moAlgo < typename M::EOType >
00055 {
00056 
00058   typedef
00059     typename
00060     M::EOType
00061     EOT;
00062 
00064   typedef
00065     typename
00066     EOT::Fitness
00067     Fitness;
00068 
00069 public:
00070 
00072 
00083 moTS (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (*new moTSMoveLoopExpl < M >
00084              (__move_init, __next_move, __incr_eval, __tabu_list,
00085               __aspir_crit)), cont (__cont), full_eval (__full_eval)
00086       {}
00087 
00089 
00096 moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
00097     cont (__cont),
00098     full_eval (__full_eval)
00099     {}
00100 
00102 
00110   bool operator   ()(EOT & __sol)
00111   {
00112     if (__sol.invalid ())
00113       {
00114         full_eval (__sol);
00115       }
00116 
00117     M move;
00118 
00119     EOT best_sol = __sol, new_sol;
00120 
00121     cont.init ();
00122 
00123     do
00124       {
00125 
00126         new_sol = __sol;
00127 
00128         try
00129         {
00130 
00131           move_expl (__sol, new_sol);
00132 
00133         }
00134         catch (EmptySelection & __ex)
00135         {
00136 
00137           break;
00138         }
00139 
00140         /* Updating the best solution
00141            found until now ? */
00142         if (new_sol.fitness () > __sol.fitness ())
00143           {
00144             best_sol = new_sol;
00145           }
00146 
00147         __sol = new_sol;
00148 
00149       }
00150     while (cont (__sol));
00151 
00152     __sol = best_sol;
00153  
00154     return true;
00155   }
00156 
00157 private:
00158 
00160   moMoveExpl < M > &move_expl;
00161 
00163   moSolContinue < EOT > &cont;
00164 
00166   eoEvalFunc < EOT > &full_eval;
00167 };
00168 
00169 #endif

Generated on Tue Oct 23 15:29:28 2007 for ParadisEO-MOMovingObjects by  doxygen 1.5.2