Added wonderful test stuff

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@594 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
legrand 2007-09-18 15:45:15 +00:00
commit 31a487ec4a
23 changed files with 307 additions and 312 deletions

View file

@ -19,8 +19,8 @@ ADD_CUSTOM_COMMAND(
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
INCLUDE_DIRECTORIES(${MO_SRC_DIR})
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${ParadisEO-MO_SOURCE_DIR}/src)
######################################################################################
@ -47,16 +47,8 @@ SET (TSP_SOURCES graph.cpp
two_opt_incr_eval.cpp
two_opt_tabu_list.cpp
two_opt_rand.cpp)
# --> UNIX
IF(UNIX)
ADD_LIBRARY(tsp STATIC ${TSP_SOURCES})
ENDIF(UNIX)
# --> WIN
IF(WIN32)
ADD_LIBRARY(tsp STATIC ${TSP_SOURCES})
ENDIF(WIN32)
ADD_LIBRARY(tsp STATIC ${TSP_SOURCES})
######################################################################################
@ -66,7 +58,7 @@ ENDIF(WIN32)
### 3) Optionnal: define your target(s)'s version: no effect for windows
######################################################################################
SET(TSP_VERSION "1.0.beta")
SET(TSP_VERSION "${GLOBAL_VERSION}")
SET_TARGET_PROPERTIES(tsp PROPERTIES VERSION "${TSP_VERSION}")
######################################################################################

View file

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

View file

@ -15,11 +15,11 @@
void RouteEval :: operator () (Route & __route)
{
tspFitness len = 0 ;
float len = 0 ;
for (unsigned int i = 0 ; i < Graph :: size () ; i ++)
{
len = len + Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
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"
tspFitness TwoOptIncrEval :: operator () (const TwoOpt & __move, const Route & __route)
float 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 @@ tspFitness TwoOptIncrEval :: operator () (const TwoOpt & __move, const Route & _
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 :
tspFitness operator () (const TwoOpt & __move, const Route & __route) ;
float operator () (const TwoOpt & __move, const Route & __route) ;
} ;