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

@ -1,6 +1,6 @@
######################################################################################
### 0) If you want to set your variables in mo-conf.cmake and avoid the cmd line
### 0) If you want to set your own variables in mo-conf.cmake and avoid the cmd line
######################################################################################
INCLUDE(mo-conf.cmake OPTIONAL)
@ -9,12 +9,19 @@ INCLUDE(mo-conf.cmake OPTIONAL)
######################################################################################
### 1) Main project config
### 1) Project properties
######################################################################################
# set the project name
PROJECT(ParadisEO-MO)
SET(PACKAGE_BUGREPORT "paradiseo-help@lists.gforge.inria.fr" CACHE STRING "Package bug report" FORCE)
SET(PACKAGE_NAME "ParadisEO-MO Moving Objects" CACHE STRING "Package name" FORCE)
SET(PACKAGE_STRING "ParadisEO-MO 1.0" CACHE STRING "Package string full name" FORCE)
SET(PACKAGE_VERSION "1.0" CACHE STRING "Package version" FORCE)
SET(GLOBAL_VERSION "1.0" CACHE STRING "Global version" FORCE)
SET(VERSION "1.0" CACHE STRING "Version" FORCE)
# check cmake version compatibility
CMAKE_MINIMUM_REQUIRED(VERSION 2.4 FATAL_ERROR)
@ -31,6 +38,7 @@ ENABLE_LANGUAGE(C)
#####################################################################################
### 2) Include required modules
#####################################################################################
INCLUDE(CMakeBackwardCompatibilityCXX)
INCLUDE(FindDoxygen)
@ -44,68 +52,87 @@ INCLUDE(CheckLibraryExists)
######################################################################################
### 3) SET main paths (can be defined in mo-conf.cmake)
### 3) Include the main configuration variables
######################################################################################
IF(NOT DEFINED MO_DIR)
SET(MO_DIR ${ParadisEO-MO_SOURCE_DIR} CACHE PATH "ParadisEO-MO main directory")
ENDIF(NOT DEFINED MO_DIR)
# The "config" variable must be provided on the command line
IF(NOT DEFINED config OR NOT config)
MESSAGE(FATAL_ERROR "The \"config\" variable must be set on the command line to
give the path of the install configuration file. ")
ENDIF(NOT DEFINED config OR NOT config)
# Need main EO directory path
IF(NOT DEFINED EO_DIR OR NOT EO_DIR)
SET(EO_DIR ${EOdir} CACHE PATH "ParadisEO-EO main directory" FORCE) # given on the command line
ELSE(NOT DEFINED EO_DIR OR NOT EO_DIR)
MESSAGE(STATUS "EOdir already defined as ${EO_DIR}")
ENDIF(NOT DEFINED EO_DIR OR NOT EO_DIR)
# Need the config file whose full path is given thanks to the "config" variable
INCLUDE(${config})
# Set the main paths
IF(NOT DEFINED EO_SRC_DIR)
SET(EO_SRC_DIR "${EO_DIR}/src")
ENDIF(NOT DEFINED EO_SRC_DIR)
IF(NOT DEFINED MO_SRC_DIR)
SET(MO_SRC_DIR ${MO_DIR}/src)
ENDIF(NOT DEFINED MO_SRC_DIR)
IF(NOT DEFINED MO_DOC_DIR)
SET(MO_DOC_DIR ${MO_DIR}/doc)
ENDIF(NOT DEFINED MO_DOC_DIR)
######################################################################################
######################################################################################
### 4) Paths checking
######################################################################################
IF(EXISTS ${EO_DIR})
MESSAGE (STATUS "Using ParadisEO-EO path: ${EO_DIR}")
ELSE(EXISTS ${EO_DIR})
MESSAGE (FATAL_ERROR "Could not find the ParadisEO-EO path: ${EO_DIR}. You should use : cmake . -DEOdir=<your path to paradiseo-eo>")
ENDIF(EXISTS ${EO_DIR})
# Is it an absolute path ?
IF(WIN32)
SET (ABSOLUTE_PATH_REGEX "^[A-Z]:|^[a-z]:")
ELSE(WIN32)
SET (ABSOLUTE_PATH_REGEX "^/")
ENDIF(WIN32)
IF(NOT ${EO_DIR} MATCHES "${ABSOLUTE_PATH_REGEX}")
MESSAGE (FATAL_ERROR "${EO_DIR} MUST BE an absolute path")
ENDIF(NOT ${EO_DIR} MATCHES "${ABSOLUTE_PATH_REGEX}")
SET(REQUIRED_PATHS "EO_SRC_DIR" "EO_BIN_DIR")
FOREACH (path ${REQUIRED_PATHS})
IF(EXISTS ${${path}})
MESSAGE (STATUS "Using ${path}=${${path}}")
ELSE(EXISTS ${${path}})
MESSAGE (FATAL_ERROR "\n Cannot find \"${${path}}\". Please, fill \"${config}\" with a correct value")
ENDIF(EXISTS ${${path}})
IF(NOT ${${path}} MATCHES "${ABSOLUTE_PATH_REGEX}")
MESSAGE (FATAL_ERROR "${${path}} MUST BE an absolute path")
ENDIF(NOT ${${path}} MATCHES "${ABSOLUTE_PATH_REGEX}")
ENDFOREACH (path ${REQUIRED_PATHS})
######################################################################################
IF(WIN32)
SET(EO_LIB_DIR "${EO_DIR}\\win\\lib\\")
ELSE(WIN32)
SET(EO_LIB_DIR "${EO_DIR}/src")
ENDIF(WIN32)
#####################################################################################
### 5) Manage the build type
#####################################################################################
# the user should choose the build type on windows environments,excepted under cygwin (default=none)
SET(CMAKE_DEFAULT_BUILD_TYPE None CACHE STRING "Variable that stores the default CMake build type" FORCE)
IF(WIN32 AND NOT CYGWIN)
IF(NOT CMAKE_BUILD_TYPE)
SET( CMAKE_BUILD_TYPE
${CMAKE_DEFAULT_BUILD_TYPE} CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "")
MESSAGE(STATUS "Warning: The type of build is: ${CMAKE_BUILD_TYPE}.")
MESSAGE(STATUS "The available types are: None Debug Release RelWithDebInfo MinSizeRel.")
MESSAGE(STATUS "You can choose it with: cmake <path-to-source> -D<build-type>")
MESSAGE(STATUS "")
ENDIF(WIN32 AND NOT CYGWIN)
#####################################################################################
######################################################################################
### 6) Where must cmake go now ?
######################################################################################
SUBDIRS(doc test tutorial)
######################################################################################
######################################################################################
### 5) Where must cmake go now ?
### 7) Test config
######################################################################################
SUBDIRS(doc tutorial)
#SET(ENABLE_CMAKE_TESTING TRUE CACHE BOOL "Should we test using Dart")
IF (ENABLE_CMAKE_TESTING)
ENABLE_TESTING()
ENDIF (ENABLE_CMAKE_TESTING)
######################################################################################

View file

@ -2,29 +2,21 @@
######################################################################################
######################################################################################
### In this file, you can specify many CMake variables used to build paradisEO-MO.
### For example, if you don't want ot give the EO path each time on the command line,
### uncomment the line the "SET(EO_DIR...)" and set your path.
### The section numbers are the same as those used in the CMakeLists.txt file.
######################################################################################
######################################################################################
######################################################################################
### 3) OPTIONNAL - Overwrite default paths
### 1) OPTIONNAL
######################################################################################
# SET(MO_DIR "<your path>" CACHE PATH "ParadisEO-MO main directory")
# SET(EO_DIR "<path to ParadisEO-EO>" CACHE PATH "ParadisEO-EO main directory")
# SET(EO_SRC_DIR "<path to ParadisEO-EO src dir>")
# SET(MO_SRC_DIR "<path to ParadisEO-MO src dir>")
# SET(MO_DOC_DIR "<path to ParadisEO-MO doc dir>")
# SET (MYVAR MYVALUE)
######################################################################################
#####################################################################################
### 5) OPTIONNAL - Overwrite subdirs
### 2) OPTIONNAL - Overwrite subdirs
######################################################################################
# SUBDIRS(doc tutorial)

View file

@ -18,7 +18,6 @@
#include "moCoolingSchedule.h"
#include "moExponentialCoolingSchedule.h"
#include "moFirstImprSelect.h"
#include "moFitSolContinue.h"
#include "moGenSolContinue.h"
#include "moHC.h"
#include "moHCMoveLoopExpl.h"
@ -34,14 +33,12 @@
#include "moMoveSelect.h"
#include "moNextMove.h"
#include "moNoAspirCrit.h"
#include "moNoFitImprSolContinue.h"
#include "moRandImprSelect.h"
#include "moRandMove.h"
#include "moSA.h"
#include "moSimpleMoveTabuList.h"
#include "moSimpleSolutionTabuList.h"
#include "moSolContinue.h"
#include "moSteadyFitSolContinue.h"
#include "moTabuList.h"
#include "moTS.h"
#include "moTSMoveLoopExpl.h"

View file

@ -37,7 +37,7 @@ public:
//!Function that indicates if the current move has not improved the fitness.
/*!
If the given fitness enables an improvement,
If the given fitness enables an improvment,
the move (moMove) and the fitness linked to this move are saved.
\param __move a move.
@ -46,13 +46,16 @@ public:
*/
bool update (const M & __move, const Fitness & __fit)
{
if ((first_time) || (__fit > best_fit))
if (first_time || __fit > best_fit)
{
best_fit = __fit;
best_move = __move;
first_time = false;
}
return true;
}
@ -84,6 +87,7 @@ private:
//! The best fitness.
Fitness best_fit;
};
#endif

View file

@ -23,7 +23,7 @@ class moExponentialCoolingSchedule: public moCoolingSchedule
{
public:
//! Basic constructor
//! Simple constructor
/*!
\param __threshold the threshold.
\param __ratio the ratio used to descrease the temperature.

View file

@ -17,7 +17,7 @@
//! One possible moMoveSelect.
/*!
The neighborhood is explored until
a move enables an improvement of the
a move enables an improvment of the
current solution.
*/
template < class M > class moFirstImprSelect:public moMoveSelect < M >
@ -42,7 +42,7 @@ public:
//!Function that indicates if the current move has not improved the fitness.
/*!
If the given fitness enables an improvement,
If the given fitness enables an improvment,
the move (moMove) should be applied to the current solution.
\param __move a move.

View file

@ -1,6 +1,6 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
// "moGenSolContinue.h"
// "eoGenSolContinue.h"
// (c) OPAC Team, LIFL, 2003-2006
@ -14,43 +14,47 @@
#include "moSolContinue.h"
//! One possible stopping criterion for a solution-based heuristic.
//! One possible stop criterion for a solution-based heuristic.
/*!
The stopping criterion corresponds to a maximum number of iteration.
The stop criterion corresponds to a maximum number of iteration.
*/
template < class EOT > class moGenSolContinue:public moSolContinue < EOT >
{
public:
//! Basic constructor.
//! Simple constructor.
/*!
\param __maxNumGen the maximum number of generation.
*/
moGenSolContinue (unsigned int __maxNumGen):maxNumGen (__maxNumGen), numGen (0)
{}
{
}
//! Function that activates the stop criterion.
/*!
Increments the counter and returns true if the
Increments the counter and returns TRUE if the
current number of iteration is lower than the given
maximum number of iterations.
\param __sol the current solution.
\return true or false according to the current generation number.
\return TRUE or FALSE according to the current generation number.
*/
bool operator () (const EOT & __sol)
bool operator () (const EOT & __sol)
{
return (++numGen < maxNumGen);
}
//! Procedure which allows to initialise all the stuff needed.
//! Procedure which allows to initialise the generation counter.
/*!
It can be also used to reinitialize the counter all the needed things.
*/
It can also be used to reset the iteration counter.
*/
void init ()
{
numGen=0;
numGen = 0;
}
private:

View file

@ -64,31 +64,31 @@ moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move,
//
move_init (move, __old_sol); /* Restarting the exploration of
of the neighborhood ! */
move_select.init (__old_sol.fitness ());
while (move_select.update (move, incr_eval (move, __old_sol))
&& next_move (move, __old_sol));
try
{
M best_move;
Fitness best_move_fit;
move_select (best_move, best_move_fit);
__new_sol.fitness (best_move_fit);
best_move (__new_sol);
}
{
M best_move;
Fitness best_move_fit;
move_select (best_move, best_move_fit);
__new_sol.fitness (best_move_fit);
best_move (__new_sol);
}
catch (EmptySelection & __ex)
{
// ?
}
{
// ?
}
}
private:
//! Move initialiser.

View file

@ -20,7 +20,7 @@
//! One of the possible moMove selector (moMoveSelect)
/*!
All the neighbors are considered.
One of them that enables an improvement of the objective function is choosen.
One of them that enables an improvment of the objective function is choosen.
*/
template < class M > class moRandImprSelect:public moMoveSelect < M >
{

View file

@ -31,10 +31,16 @@ template < class M > class moSA:public moAlgo < typename M::EOType >
{
//! Alias for the type
typedef typename M::EOType EOT;
typedef
typename
M::EOType
EOT;
//! Alias for the fitness
typedef typename EOT::Fitness Fitness;
typedef
typename
EOT::Fitness
Fitness;
public:
@ -85,38 +91,32 @@ public:
EOT best_sol = __sol;
Fitness current_fitness, delta;
double exp1, exp2;
do
{
cont.init ();
do
{
move_rand (move);
current_fitness= incr_eval (move, __sol);
Fitness delta_fit = incr_eval (move, __sol) - __sol.fitness ();
delta = current_fitness - __sol.fitness();
if(((long double)delta) < 0.0)
if (delta_fit > 0 || rng.uniform () < exp (delta_fit / temp))
{
delta=-delta;
}
if ((current_fitness > __sol.fitness()) || ((rng.uniform ()) < (exp (-delta/ temp))))
{
__sol.fitness (current_fitness);
__sol.fitness (incr_eval (move, __sol));
move (__sol);
/* Updating the best solution found until now ? */
/* Updating the best solution found
until now ? */
if (__sol.fitness () > best_sol.fitness ())
{
best_sol = __sol;
}
best_sol = __sol;
}
}
while (cont (__sol));
}
while (cool_sched (temp));

View file

@ -14,7 +14,7 @@
#include <eoFunctor.h>
//! Class that describes a stopping criterion for a solution-based heuristic
//! Class that describes a stop criterion for a solution-based heuristic
/*!
It allows to add an initialisation procedure to an object that is a unary function (eoUF).
@ -23,7 +23,7 @@ template < class EOT > class moSolContinue:public eoUF < const EOT &, bool >
{
public:
//! Procedure which initialises all that the stopping criterion needs
//! Procedure which initialises all that the stop criterion needs
/*!
Generally, it allocates some data structures or initialises some counters.
*/

View file

@ -91,13 +91,13 @@ moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc <
M move;
EOT best_sol, new_sol;
best_sol = __sol;
EOT best_sol = __sol, new_sol;
cont.init ();
do
{
new_sol = __sol;
try
@ -112,7 +112,8 @@ moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc <
break;
}
/* Updating the best solution found until now ? */
/* Updating the best solution
found until now ? */
if (new_sol.fitness () > __sol.fitness ())
{
best_sol = new_sol;

View file

@ -0,0 +1,87 @@
###############################################################################
##
## CMakeLists file for ParadisEO-MO/test
##
###############################################################################
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${ParadisEO-MO_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
IF(NOT WIN32 OR CYGWIN)
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${ParadisEO-MO_BINARY_DIR}/lib)
ENDIF(NOT WIN32 OR CYGWIN)
# especially for Visual Studio
IF(WIN32 AND NOT CYGWIN)
LINK_DIRECTORIES(${EO_BIN_DIR}\\lib\\${CMAKE_BUILD_TYPE}
${ParadisEO-MO_BINARY_DIR}\\lib\\${CMAKE_BUILD_TYPE}
)
ENDIF(WIN32 AND NOT CYGWIN)
######################################################################################
######################################################################################
### 3) Define your targets and link the librairies
######################################################################################
SET (TEST_LIST t-mo)
FOREACH (test ${TEST_LIST})
SET ("T_${test}_SOURCES" "${test}.cpp")
ENDFOREACH (test)
IF(ENABLE_CMAKE_TESTING)
# Add the tests
FOREACH (test ${TEST_LIST})
ADD_EXECUTABLE(${test} ${T_${test}_SOURCES})
ADD_TEST(${test} ${test})
ENDFOREACH (test)
# Link the librairies
FOREACH (test ${TEST_LIST})
TARGET_LINK_LIBRARIES(${test} ga es eoutils eo)
ENDFOREACH (test)
ENDIF(ENABLE_CMAKE_TESTING)
######################################################################################
######################################################################################
### 5) Windows advanced config - especially for Microsoft Visual Studio 8
######################################################################################
IF(CMAKE_CXX_COMPILER MATCHES cl)
IF(NOT WITH_SHARED_LIBS)
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005")
SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy")
SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Z7 /Od")
SET(CMAKE_CXX_FLAGS_RELEASE "/MT /O2")
SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005")
ENDIF(NOT WITH_SHARED_LIBS)
ENDIF(CMAKE_CXX_COMPILER MATCHES cl)
######################################################################################

View file

@ -0,0 +1,24 @@
//-----------------------------------------------------------------------------
// t-mo.cpp
//-----------------------------------------------------------------------------
#include <eo> // EO
#include <mo.h> // MO
//-----------------------------------------------------------------------------
typedef EO<float> Chrom;
//-----------------------------------------------------------------------------
int main()
{
Chrom chrom1, chrom2;
std::cout << "chrom1 = " << chrom1 << std::endl
<< "chrom2 = " << chrom2 << std::endl;
return 0;
}
//-----------------------------------------------------------------------------

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