00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 // "two_opt_tabu_list.cpp" 00004 00005 // (c) OPAC Team, LIFL, 2003-2006 00006 00007 /* LICENCE TEXT 00008 00009 Contact: paradiseo-help@lists.gforge.inria.fr 00010 */ 00011 00012 #include "two_opt_tabu_list.h" 00013 #include "graph.h" 00014 00015 #define TABU_LENGTH 10 00016 00017 void TwoOptTabuList :: init () 00018 { 00019 // Size (eventually) 00020 tabu_span.resize (Graph :: size ()) ; 00021 for (unsigned int i = 0 ; i < tabu_span.size () ; i ++) 00022 { 00023 tabu_span [i].resize (Graph :: size ()) ; 00024 } 00025 00026 // Clear 00027 for (unsigned int i = 0 ; i < tabu_span.size () ; i ++) 00028 { 00029 for (unsigned int j = 0 ; j < tabu_span [i].size () ; j ++) 00030 { 00031 tabu_span [i] [j] = 0 ; 00032 } 00033 } 00034 } 00035 00036 bool TwoOptTabuList :: operator () (const TwoOpt & __move, const Route & __sol) 00037 { 00038 return tabu_span [__move.first] [__move.second] > 0 ; 00039 } 00040 00041 void TwoOptTabuList :: add (const TwoOpt & __move, const Route & __sol) 00042 { 00043 tabu_span [__move.first] [__move.second] = tabu_span [__move.second] [__move.first] = TABU_LENGTH ; 00044 } 00045 00046 void TwoOptTabuList :: update () 00047 { 00048 for (unsigned int i = 0 ; i < tabu_span.size () ; i ++) 00049 { 00050 for (unsigned int j = 0 ; j < tabu_span [i].size () ; j ++) 00051 { 00052 if (tabu_span [i] [j] > 0) 00053 { 00054 tabu_span [i] [j] -- ; 00055 } 00056 } 00057 } 00058 }
1.5.2