two_opt_incr_eval.cpp

00001 // "TwoOptIncrEval.cpp"
00002 
00003 // (c) OPAC Team, LIFL, January 2006
00004 
00005 /* 
00006    Contact: paradiseo-help@lists.gforge.inria.fr
00007 */
00008 
00009 #include "two_opt_incr_eval.h"
00010 #include "node.h"
00011 
00012 int TwoOptIncrEval :: operator () (const TwoOpt & __move, const Route & __route) {
00013   
00014   /* From */
00015   Node v1 = __route [__move.first], v1_left = __route [(__move.first - 1 + numNodes) % numNodes];
00016   
00017   /* To */
00018   Node v2 = __route [__move.second], v2_right = __route [(__move.second + 1) % numNodes];
00019  
00020   if (v1 == v2 || v2_right == v1)
00021     return __route.fitness ();
00022   else 
00023     return __route.fitness () - distance (v1_left, v2) - distance (v1, v2_right) + distance (v1_left, v1) + distance (v2, v2_right);
00024 }

Generated on Tue Jan 9 15:47:41 2007 for ParadisEO-PEO - Lessons by  doxygen 1.4.7