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

@ -4,41 +4,26 @@
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/utils)
INCLUDE_DIRECTORIES(${MO_SRC_DIR})
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
INCLUDE_DIRECTORIES(${ParadisEO-MO_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries (mandatory: before 3) )
### 2) Specify where CMake can find the libraries
######################################################################################
# --> UNIX
IF(UNIX)
LINK_DIRECTORIES(${EO_SRC_DIR} ${EO_SRC_DIR}/utils ${TSP_BINARY_DIR}/lib)
ENDIF(UNIX)
IF(NOT WIN32 OR CYGWIN)
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BINARY_DIR}/lib)
ENDIF(NOT WIN32 OR CYGWIN)
# --> WIN
IF(WIN32)
# "CMAKE_BUILD_TYPE" supposed to be given on the command line, default=Debug
IF (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Debug)
ENDIF (NOT DEFINED CMAKE_BUILD_TYPE)
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
LINK_DIRECTORIES(${TSP_BINARY_DIR}\\debug)
LINK_DIRECTORIES(${EO_LIB_DIR}\\debug)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
IF (CMAKE_BUILD_TYPE STREQUAL Release)
LINK_DIRECTORIES(${TSP_BINARY_DIR}\\release)
LINK_DIRECTORIES(${EO_LIB_DIR}\\release)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
ENDIF(WIN32)
# especially for Visual Studio
IF(WIN32 AND NOT CYGWIN)
LINK_DIRECTORIES(${EO_BIN_DIR}\\lib\\${CMAKE_BUILD_TYPE})
ENDIF(WIN32 AND NOT CYGWIN)
######################################################################################
@ -48,7 +33,6 @@ ENDIF(WIN32)
### 3) Define your target(s): just an executable here
######################################################################################
# no matter what is the OS, hopefully
ADD_EXECUTABLE(hill_climbing hill_climbing.cpp)
ADD_DEPENDENCIES(hill_climbing tsp)
@ -60,7 +44,7 @@ ADD_DEPENDENCIES(hill_climbing tsp)
### 4) Optionnal: define your target(s)'s version: no effect for windows
######################################################################################
SET(HILLCLIMBING_VERSION "1.0.beta")
SET(HILLCLIMBING_VERSION ${GLOBAL_VERSION})
SET_TARGET_PROPERTIES(hill_climbing PROPERTIES VERSION "${HILLCLIMBING_VERSION}")
######################################################################################
@ -70,33 +54,8 @@ SET_TARGET_PROPERTIES(hill_climbing PROPERTIES VERSION "${HILLCLIMBING_VERSION}"
### 5) Link the librairies for your target(s)
######################################################################################
# --> UNIX
IF(UNIX)
TARGET_LINK_LIBRARIES(hill_climbing tsp)
TARGET_LINK_LIBRARIES(hill_climbing eo)
TARGET_LINK_LIBRARIES(hill_climbing eoutils)
ENDIF(UNIX)
TARGET_LINK_LIBRARIES(hill_climbing tsp eo eoutils)
# --> WIN
IF(WIN32)
# "CMAKE_BUILD_TYPE" supposed to be given on the command line, default=Debug
IF (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Debug)
ENDIF (NOT DEFINED CMAKE_BUILD_TYPE)
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
TARGET_LINK_LIBRARIES(hill_climbing tsp)
TARGET_LINK_LIBRARIES(hill_climbing eod)
TARGET_LINK_LIBRARIES(hill_climbing eoutilsd)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
IF(CMAKE_BUILD_TYPE STREQUAL Release)
TARGET_LINK_LIBRARIES(hill_climbing tsp)
TARGET_LINK_LIBRARIES(hill_climbing eo)
TARGET_LINK_LIBRARIES(hill_climbing eoutils)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
ENDIF(WIN32)
######################################################################################

View file

@ -4,41 +4,26 @@
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/utils)
INCLUDE_DIRECTORIES(${MO_SRC_DIR})
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
INCLUDE_DIRECTORIES(${ParadisEO-MO_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries (mandatory: before 3) )
### 2) Specify where CMake can find the libraries
######################################################################################
# --> UNIX
IF(UNIX)
LINK_DIRECTORIES(${EO_SRC_DIR} ${EO_SRC_DIR}/utils ${TSP_BINARY_DIR}/lib)
ENDIF(UNIX)
IF(NOT WIN32 OR CYGWIN)
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BINARY_DIR}/lib)
ENDIF(NOT WIN32 OR CYGWIN)
# --> WIN
IF(WIN32)
# "CMAKE_BUILD_TYPE" supposed to be given on the command line, default=Debug
IF (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Debug)
ENDIF (NOT DEFINED CMAKE_BUILD_TYPE)
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
LINK_DIRECTORIES(${TSP_BINARY_DIR}\\debug)
LINK_DIRECTORIES(${EO_LIB_DIR}\\debug)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
IF(CMAKE_BUILD_TYPE STREQUAL Release)
LINK_DIRECTORIES(${TSP_BINARY_DIR}\\release)
LINK_DIRECTORIES(${EO_LIB_DIR}\\release)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
ENDIF(WIN32)
# especially for Visual Studio
IF(WIN32 AND NOT CYGWIN)
LINK_DIRECTORIES(${EO_BIN_DIR}\\lib\\${CMAKE_BUILD_TYPE})
ENDIF(WIN32 AND NOT CYGWIN)
######################################################################################
@ -48,7 +33,6 @@ ENDIF(WIN32)
### 3) Define your target(s): just an executable here
######################################################################################
# no matter what is the OS, hopefully
ADD_EXECUTABLE(tabu_search tabu_search.cpp)
ADD_DEPENDENCIES(tabu_search tsp)
@ -60,7 +44,7 @@ ADD_DEPENDENCIES(tabu_search tsp)
### 4) Optionnal: define your target(s)'s version: no effect for windows
######################################################################################
SET(TABUSEARCH_VERSION "1.0.beta")
SET(TABUSEARCH_VERSION ${GLOBAL_VERSION})
SET_TARGET_PROPERTIES(tabu_search PROPERTIES VERSION "${TABUSEARCH_VERSION}")
######################################################################################
@ -70,33 +54,8 @@ SET_TARGET_PROPERTIES(tabu_search PROPERTIES VERSION "${TABUSEARCH_VERSION}")
### 5) Link the librairies for your target(s)
######################################################################################
# --> UNIX
IF(UNIX)
TARGET_LINK_LIBRARIES(tabu_search tsp)
TARGET_LINK_LIBRARIES(tabu_search eo)
TARGET_LINK_LIBRARIES(tabu_search eoutils)
ENDIF(UNIX)
TARGET_LINK_LIBRARIES(tabu_search tsp eo eoutils)
# --> WIN
IF(WIN32)
# "CMAKE_BUILD_TYPE" supposed to be given on the command line, default=Debug
IF (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Debug)
ENDIF (NOT DEFINED CMAKE_BUILD_TYPE)
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
TARGET_LINK_LIBRARIES(tabu_search tsp)
TARGET_LINK_LIBRARIES(tabu_search eod)
TARGET_LINK_LIBRARIES(tabu_search eoutilsd)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
IF(CMAKE_BUILD_TYPE STREQUAL Release)
TARGET_LINK_LIBRARIES(tabu_search tsp)
TARGET_LINK_LIBRARIES(tabu_search eo)
TARGET_LINK_LIBRARIES(tabu_search eoutils)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
ENDIF(WIN32)
######################################################################################
@ -120,5 +79,3 @@ ENDIF(WIN32)
ENDIF(CMAKE_CXX_COMPILER MATCHES cl)
######################################################################################

View file

@ -58,10 +58,7 @@ main (int __argc, char * __argv [])
moNoAspirCrit <TwoOpt> aspir_crit ; // Aspiration Criterion
moGenSolContinue <Route> cont (1000) ; // Continuator
//moFitSolContinue <Route> cont (700);
//moNoFitImprSolContinue <Route> cont (1000);
//moSteadyFitSolContinue <Route> cont (1000, 2000);
moGenSolContinue <Route> cont (10000) ; // Continuator
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

@ -4,41 +4,26 @@
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/utils)
INCLUDE_DIRECTORIES(${MO_SRC_DIR})
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
INCLUDE_DIRECTORIES(${ParadisEO-MO_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries (mandatory: before 3) )
### 2) Specify where CMake can find the libraries
######################################################################################
# --> UNIX
IF(UNIX)
LINK_DIRECTORIES(${EO_SRC_DIR} ${EO_SRC_DIR}/utils ${TSP_BINARY_DIR}/lib)
ENDIF(UNIX)
IF(NOT WIN32 OR CYGWIN)
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BINARY_DIR}/lib)
ENDIF(NOT WIN32 OR CYGWIN)
# --> WIN
IF(WIN32)
# "CMAKE_BUILD_TYPE" supposed to be given on the command line, default=Debug
IF (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Debug)
ENDIF (NOT DEFINED CMAKE_BUILD_TYPE)
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
LINK_DIRECTORIES(${TSP_BINARY_DIR}\\debug)
LINK_DIRECTORIES(${EO_LIB_DIR}\\debug)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
IF(CMAKE_BUILD_TYPE STREQUAL Release)
LINK_DIRECTORIES(${TSP_BINARY_DIR}\\release)
LINK_DIRECTORIES(${EO_LIB_DIR}\\release)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
ENDIF(WIN32)
# especially for Visual Studio
IF(WIN32 AND NOT CYGWIN)
LINK_DIRECTORIES(${EO_BIN_DIR}\\lib\\${CMAKE_BUILD_TYPE})
ENDIF(WIN32 AND NOT CYGWIN)
######################################################################################
@ -48,7 +33,6 @@ ENDIF(WIN32)
### 3) Define your target(s): just an executable here
######################################################################################
# no matter what is the OS, hopefully
ADD_EXECUTABLE(simulated_annealing simulated_annealing.cpp)
ADD_DEPENDENCIES(simulated_annealing tsp)
@ -60,7 +44,7 @@ ADD_DEPENDENCIES(simulated_annealing tsp)
### 4) Optionnal: define your target(s)'s version: no effect for windows
######################################################################################
SET(SIMULATEDANNEALING_VERSION "1.0.beta")
SET(SIMULATEDANNEALING_VERSION ${GLOBAL_VERSION})
SET_TARGET_PROPERTIES(simulated_annealing PROPERTIES VERSION "${SIMULATEDANNEALING_VERSION}")
######################################################################################
@ -70,33 +54,8 @@ SET_TARGET_PROPERTIES(simulated_annealing PROPERTIES VERSION "${SIMULATEDANNEALI
### 5) Link the librairies for your target(s)
######################################################################################
# --> UNIX
IF(UNIX)
TARGET_LINK_LIBRARIES(simulated_annealing tsp)
TARGET_LINK_LIBRARIES(simulated_annealing eo)
TARGET_LINK_LIBRARIES(simulated_annealing eoutils)
ENDIF(UNIX)
TARGET_LINK_LIBRARIES(simulated_annealing tsp eo eoutils)
# --> WIN
IF(WIN32)
# "CMAKE_BUILD_TYPE" supposed to be given on the command line, default=Debug
IF (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Debug)
ENDIF (NOT DEFINED CMAKE_BUILD_TYPE)
IF (CMAKE_BUILD_TYPE STREQUAL Debug)
TARGET_LINK_LIBRARIES(simulated_annealing tsp)
TARGET_LINK_LIBRARIES(simulated_annealing eod)
TARGET_LINK_LIBRARIES(simulated_annealing eoutilsd)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
IF(CMAKE_BUILD_TYPE STREQUAL Release)
TARGET_LINK_LIBRARIES(simulated_annealing tsp)
TARGET_LINK_LIBRARIES(simulated_annealing eo)
TARGET_LINK_LIBRARIES(simulated_annealing eoutils)
ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
ENDIF(WIN32)
######################################################################################
@ -120,5 +79,3 @@ ENDIF(WIN32)
ENDIF(CMAKE_CXX_COMPILER MATCHES cl)
######################################################################################

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) ;
} ;