diff --git a/contribution/trunk/combinatorial/routing/tsp/benchs/berlin52.tsp b/contribution/trunk/combinatorial/routing/tsp/benchs/berlin52.tsp new file mode 100644 index 000000000..9854458a9 --- /dev/null +++ b/contribution/trunk/combinatorial/routing/tsp/benchs/berlin52.tsp @@ -0,0 +1,53 @@ +52 +565 575 +25 185 +345 750 +945 685 +845 655 +880 660 +25 230 +525 1000 +580 1175 +650 1130 +1605 620 +1220 580 +1465 200 +1530 5 +845 680 +725 370 +145 665 +415 635 +510 875 +560 365 +300 465 +520 585 +480 415 +835 625 +975 580 +1215 245 +1320 315 +1250 400 +660 180 +410 250 +420 555 +575 665 +1150 1160 +700 580 +685 595 +685 610 +770 610 +795 645 +720 635 +760 650 +475 960 +95 260 +875 920 +700 500 +555 815 +830 485 +1170 65 +830 610 +605 625 +595 360 +1340 725 +1740 245 diff --git a/contribution/trunk/combinatorial/routing/tsp/src/part_route_eval.cpp b/contribution/trunk/combinatorial/routing/tsp/src/part_route_eval.cpp index f919b059e..1639e002a 100644 --- a/contribution/trunk/combinatorial/routing/tsp/src/part_route_eval.cpp +++ b/contribution/trunk/combinatorial/routing/tsp/src/part_route_eval.cpp @@ -1,9 +1,9 @@ -/* +/* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 * (C) OPAC Team, LIFL, 2002-2007 * -* Sébastien Cahon, Thomas Legrand +* Sébastien Cahon, Jean-Charles Boisson * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -37,22 +37,17 @@ #include "part_route_eval.h" #include "graph.h" -PartRouteEval :: PartRouteEval (float __from, - float __to - ) : from (__from), - to (__to) { - -} +PartRouteEval :: PartRouteEval (float __from, float __to) : from (__from), to (__to) +{} -void PartRouteEval :: operator () (Route & __route) { - - +void PartRouteEval :: operator () (Route & __route) +{ float len = 0 ; - - for (unsigned i = (unsigned) (__route.size () * from) ; - i < (unsigned) (__route.size () * to) ; - i ++) - len -= Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ; - + + for (unsigned int i = (unsigned int) (__route.size () * from) ; i < (unsigned int ) (__route.size () * to) ; i ++) + { + len += Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ; + } + __route.fitness (len) ; } diff --git a/contribution/trunk/combinatorial/routing/tsp/src/route.h b/contribution/trunk/combinatorial/routing/tsp/src/route.h index 2ba5b680d..ac9629cbb 100644 --- a/contribution/trunk/combinatorial/routing/tsp/src/route.h +++ b/contribution/trunk/combinatorial/routing/tsp/src/route.h @@ -1,9 +1,9 @@ -/* +/* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 * (C) OPAC Team, LIFL, 2002-2007 * -* Sébastien Cahon, Thomas Legrand +* Sébastien Cahon, Jean-Charles Boisson * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -38,7 +38,11 @@ #define route_h #include +#include -typedef eoVector Route ; // [Fitness (- length), Gene (city)] +// A float that has to be minimized. +typedef eoScalarFitness< float, std::greater > tspFitness ; + +typedef eoVector Route ; // [Fitness (length), Gene (city)] #endif diff --git a/contribution/trunk/combinatorial/routing/tsp/src/route_eval.cpp b/contribution/trunk/combinatorial/routing/tsp/src/route_eval.cpp index e8d8074ec..abde85b99 100644 --- a/contribution/trunk/combinatorial/routing/tsp/src/route_eval.cpp +++ b/contribution/trunk/combinatorial/routing/tsp/src/route_eval.cpp @@ -1,9 +1,9 @@ -/* +/* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 * (C) OPAC Team, LIFL, 2002-2007 * -* Sébastien Cahon, Thomas Legrand +* Sébastien Cahon, Jean-Charles Boisson * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -37,12 +37,15 @@ #include "route_eval.h" #include "graph.h" -void RouteEval :: operator () (Route & __route) { - - float len = 0 ; - - for (unsigned i = 0 ; i < Graph :: size () ; i ++) - len -= Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ; - +void RouteEval :: operator () (Route & __route) +{ + + float len = 0.0 ; + + for (unsigned int i = 0 ; i < Graph :: size () ; i ++) + { + len += Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ; + } + __route.fitness (len) ; }