In the TSP, the fitness has to be minimized ... with all the needed modification (for example, moSA.h)

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@587 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jboisson 2007-08-03 14:28:06 +00:00
commit 1d94071693
170 changed files with 748 additions and 837 deletions

View file

@ -58,10 +58,10 @@ main (int __argc, char * __argv [])
moNoAspirCrit <TwoOpt> aspir_crit ; // Aspiration Criterion
moGenSolContinue <Route> cont (10000) ; // Continuator
//moFitSolContinue <Route> cont (-700,false);
//moSteadyFitSolContinue <Route> cont (1000, 2000,false);
//moNoFitImprSolContinue <Route> cont (1000,false);
moGenSolContinue <Route> cont (1000) ; // Continuator
//moFitSolContinue <Route> cont (700);
//moNoFitImprSolContinue <Route> cont (1000);
//moSteadyFitSolContinue <Route> cont (1000, 2000);
moTS <TwoOpt> tabu_search (two_opt_init, two_opt_next, two_opt_incr_eval, tabu_list, aspir_crit, cont, full_eval) ;
tabu_search (route) ;

View file

@ -2,7 +2,7 @@
// "route.h"
// (c) OPAC Team, LIFL, 2003-2006
// (c) OPAC Team, LIFL, 2003-2007
/* LICENCE TEXT
@ -13,7 +13,10 @@
#define route_h
#include <eoVector.h>
#include <eoScalarFitness.h>
typedef eoVector <float, unsigned int> Route ; // [Fitness (- length), Gene (city)]
typedef eoScalarFitness< float, std::greater< float > > tspFitness ;
typedef eoVector <tspFitness, unsigned int> Route ; // [Fitness (length), Gene (city)]
#endif

View file

@ -15,11 +15,11 @@
void RouteEval :: operator () (Route & __route)
{
float len = 0 ;
tspFitness len = 0 ;
for (unsigned int i = 0 ; i < Graph :: size () ; i ++)
{
len -= Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
len = len + Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
}
__route.fitness (len) ;

View file

@ -12,7 +12,7 @@
#include "two_opt_incr_eval.h"
#include "graph.h"
float TwoOptIncrEval :: operator () (const TwoOpt & __move, const Route & __route)
tspFitness TwoOptIncrEval :: operator () (const TwoOpt & __move, const Route & __route)
{
// From
unsigned int v1 = __route [__move.first], v1_next = __route [__move.first + 1] ;
@ -21,8 +21,8 @@ float TwoOptIncrEval :: operator () (const TwoOpt & __move, const Route & __rout
unsigned int v2 = __route [__move.second], v2_next = __route [__move.second + 1] ;
return __route.fitness ()
- Graph :: distance (v1, v2)
- Graph :: distance (v1_next, v2_next)
+ Graph :: distance (v1, v1_next)
+ Graph :: distance (v2, v2_next) ;
+ Graph :: distance (v1, v2)
+ Graph :: distance (v1_next, v2_next)
- Graph :: distance (v1, v1_next)
- Graph :: distance (v2, v2_next) ;
}

View file

@ -20,7 +20,7 @@ class TwoOptIncrEval : public moMoveIncrEval <TwoOpt>
public :
float operator () (const TwoOpt & __move, const Route & __route) ;
tspFitness operator () (const TwoOpt & __move, const Route & __route) ;
} ;