From 31a487ec4a0a8d743e9c8d47fbf1f4de045e8307 Mon Sep 17 00:00:00 2001 From: legrand Date: Tue, 18 Sep 2007 15:45:15 +0000 Subject: [PATCH] Added wonderful test stuff git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@594 331e1502-861f-0410-8da2-ba01fb791d7f --- trunk/paradiseo-mo/CMakeLists.txt | 107 +++++++++++------- trunk/paradiseo-mo/mo-conf.cmake | 14 +-- trunk/paradiseo-mo/src/mo.h | 3 - trunk/paradiseo-mo/src/moBestImprSelect.h | 8 +- .../src/moExponentialCoolingSchedule.h | 2 +- trunk/paradiseo-mo/src/moFirstImprSelect.h | 4 +- trunk/paradiseo-mo/src/moGenSolContinue.h | 28 +++-- trunk/paradiseo-mo/src/moHCMoveLoopExpl.h | 38 +++---- trunk/paradiseo-mo/src/moRandImprSelect.h | 2 +- trunk/paradiseo-mo/src/moSA.h | 38 +++---- trunk/paradiseo-mo/src/moSolContinue.h | 4 +- trunk/paradiseo-mo/src/moTS.h | 7 +- trunk/paradiseo-mo/test/CMakeLists.txt | 87 ++++++++++++++ trunk/paradiseo-mo/test/t-mo.cpp | 24 ++++ .../tutorial/Lesson1/CMakeLists.txt | 67 +++-------- .../tutorial/Lesson2/CMakeLists.txt | 69 +++-------- .../tutorial/Lesson2/tabu_search.cpp | 5 +- .../tutorial/Lesson3/CMakeLists.txt | 69 +++-------- .../tutorial/examples/tsp/CMakeLists.txt | 18 +-- .../tutorial/examples/tsp/route.h | 7 +- .../tutorial/examples/tsp/route_eval.cpp | 4 +- .../examples/tsp/two_opt_incr_eval.cpp | 10 +- .../tutorial/examples/tsp/two_opt_incr_eval.h | 2 +- 23 files changed, 306 insertions(+), 311 deletions(-) create mode 100644 trunk/paradiseo-mo/test/CMakeLists.txt create mode 100644 trunk/paradiseo-mo/test/t-mo.cpp diff --git a/trunk/paradiseo-mo/CMakeLists.txt b/trunk/paradiseo-mo/CMakeLists.txt index bea386899..cdd2bfcfe 100644 --- a/trunk/paradiseo-mo/CMakeLists.txt +++ b/trunk/paradiseo-mo/CMakeLists.txt @@ -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=") -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 -D") + 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) ###################################################################################### diff --git a/trunk/paradiseo-mo/mo-conf.cmake b/trunk/paradiseo-mo/mo-conf.cmake index af8513804..2920c6c47 100755 --- a/trunk/paradiseo-mo/mo-conf.cmake +++ b/trunk/paradiseo-mo/mo-conf.cmake @@ -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 "" CACHE PATH "ParadisEO-MO main directory") -# SET(EO_DIR "" CACHE PATH "ParadisEO-EO main directory") - -# SET(EO_SRC_DIR "") -# SET(MO_SRC_DIR "") -# SET(MO_DOC_DIR "") +# SET (MYVAR MYVALUE) ###################################################################################### ##################################################################################### -### 5) OPTIONNAL - Overwrite subdirs +### 2) OPTIONNAL - Overwrite subdirs ###################################################################################### # SUBDIRS(doc tutorial) diff --git a/trunk/paradiseo-mo/src/mo.h b/trunk/paradiseo-mo/src/mo.h index 6b87e3608..58476ce6b 100755 --- a/trunk/paradiseo-mo/src/mo.h +++ b/trunk/paradiseo-mo/src/mo.h @@ -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" diff --git a/trunk/paradiseo-mo/src/moBestImprSelect.h b/trunk/paradiseo-mo/src/moBestImprSelect.h index 62a1004b2..30c846236 100755 --- a/trunk/paradiseo-mo/src/moBestImprSelect.h +++ b/trunk/paradiseo-mo/src/moBestImprSelect.h @@ -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 diff --git a/trunk/paradiseo-mo/src/moExponentialCoolingSchedule.h b/trunk/paradiseo-mo/src/moExponentialCoolingSchedule.h index 7f453d9ff..e67614951 100644 --- a/trunk/paradiseo-mo/src/moExponentialCoolingSchedule.h +++ b/trunk/paradiseo-mo/src/moExponentialCoolingSchedule.h @@ -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. diff --git a/trunk/paradiseo-mo/src/moFirstImprSelect.h b/trunk/paradiseo-mo/src/moFirstImprSelect.h index 2a60e66de..6656d5a95 100755 --- a/trunk/paradiseo-mo/src/moFirstImprSelect.h +++ b/trunk/paradiseo-mo/src/moFirstImprSelect.h @@ -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. diff --git a/trunk/paradiseo-mo/src/moGenSolContinue.h b/trunk/paradiseo-mo/src/moGenSolContinue.h index 2bec68287..2bd8ba4e5 100755 --- a/trunk/paradiseo-mo/src/moGenSolContinue.h +++ b/trunk/paradiseo-mo/src/moGenSolContinue.h @@ -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: diff --git a/trunk/paradiseo-mo/src/moHCMoveLoopExpl.h b/trunk/paradiseo-mo/src/moHCMoveLoopExpl.h index 2f3a5413f..f9ff78bea 100755 --- a/trunk/paradiseo-mo/src/moHCMoveLoopExpl.h +++ b/trunk/paradiseo-mo/src/moHCMoveLoopExpl.h @@ -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. diff --git a/trunk/paradiseo-mo/src/moRandImprSelect.h b/trunk/paradiseo-mo/src/moRandImprSelect.h index 59c512c70..4d60e794a 100755 --- a/trunk/paradiseo-mo/src/moRandImprSelect.h +++ b/trunk/paradiseo-mo/src/moRandImprSelect.h @@ -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 > { diff --git a/trunk/paradiseo-mo/src/moSA.h b/trunk/paradiseo-mo/src/moSA.h index ec0a5ba7f..97eaabf8e 100755 --- a/trunk/paradiseo-mo/src/moSA.h +++ b/trunk/paradiseo-mo/src/moSA.h @@ -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)); diff --git a/trunk/paradiseo-mo/src/moSolContinue.h b/trunk/paradiseo-mo/src/moSolContinue.h index 285f6df40..44efdd969 100755 --- a/trunk/paradiseo-mo/src/moSolContinue.h +++ b/trunk/paradiseo-mo/src/moSolContinue.h @@ -14,7 +14,7 @@ #include -//! 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. */ diff --git a/trunk/paradiseo-mo/src/moTS.h b/trunk/paradiseo-mo/src/moTS.h index 4140a5bc0..8aa134d5d 100755 --- a/trunk/paradiseo-mo/src/moTS.h +++ b/trunk/paradiseo-mo/src/moTS.h @@ -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; diff --git a/trunk/paradiseo-mo/test/CMakeLists.txt b/trunk/paradiseo-mo/test/CMakeLists.txt new file mode 100644 index 000000000..1b69ae868 --- /dev/null +++ b/trunk/paradiseo-mo/test/CMakeLists.txt @@ -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) +###################################################################################### + + + diff --git a/trunk/paradiseo-mo/test/t-mo.cpp b/trunk/paradiseo-mo/test/t-mo.cpp new file mode 100644 index 000000000..c2bddfcee --- /dev/null +++ b/trunk/paradiseo-mo/test/t-mo.cpp @@ -0,0 +1,24 @@ +//----------------------------------------------------------------------------- +// t-mo.cpp +//----------------------------------------------------------------------------- + +#include // EO +#include // MO + +//----------------------------------------------------------------------------- + +typedef EO Chrom; + +//----------------------------------------------------------------------------- + +int main() +{ + Chrom chrom1, chrom2; + + std::cout << "chrom1 = " << chrom1 << std::endl + << "chrom2 = " << chrom2 << std::endl; + + return 0; +} + +//----------------------------------------------------------------------------- diff --git a/trunk/paradiseo-mo/tutorial/Lesson1/CMakeLists.txt b/trunk/paradiseo-mo/tutorial/Lesson1/CMakeLists.txt index 86e8c7c3f..22cb04f68 100644 --- a/trunk/paradiseo-mo/tutorial/Lesson1/CMakeLists.txt +++ b/trunk/paradiseo-mo/tutorial/Lesson1/CMakeLists.txt @@ -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) ###################################################################################### diff --git a/trunk/paradiseo-mo/tutorial/Lesson2/CMakeLists.txt b/trunk/paradiseo-mo/tutorial/Lesson2/CMakeLists.txt index 31919c454..e9f8b6602 100644 --- a/trunk/paradiseo-mo/tutorial/Lesson2/CMakeLists.txt +++ b/trunk/paradiseo-mo/tutorial/Lesson2/CMakeLists.txt @@ -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) ###################################################################################### - - diff --git a/trunk/paradiseo-mo/tutorial/Lesson2/tabu_search.cpp b/trunk/paradiseo-mo/tutorial/Lesson2/tabu_search.cpp index ef84ec266..13913bdb7 100644 --- a/trunk/paradiseo-mo/tutorial/Lesson2/tabu_search.cpp +++ b/trunk/paradiseo-mo/tutorial/Lesson2/tabu_search.cpp @@ -58,10 +58,7 @@ main (int __argc, char * __argv []) moNoAspirCrit aspir_crit ; // Aspiration Criterion - moGenSolContinue cont (1000) ; // Continuator - //moFitSolContinue cont (700); - //moNoFitImprSolContinue cont (1000); - //moSteadyFitSolContinue cont (1000, 2000); + moGenSolContinue cont (10000) ; // Continuator moTS tabu_search (two_opt_init, two_opt_next, two_opt_incr_eval, tabu_list, aspir_crit, cont, full_eval) ; tabu_search (route) ; diff --git a/trunk/paradiseo-mo/tutorial/Lesson3/CMakeLists.txt b/trunk/paradiseo-mo/tutorial/Lesson3/CMakeLists.txt index d806f2b2c..f2e974bad 100644 --- a/trunk/paradiseo-mo/tutorial/Lesson3/CMakeLists.txt +++ b/trunk/paradiseo-mo/tutorial/Lesson3/CMakeLists.txt @@ -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) ###################################################################################### - - diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/CMakeLists.txt b/trunk/paradiseo-mo/tutorial/examples/tsp/CMakeLists.txt index 4e75f7b17..83188c3c0 100755 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/CMakeLists.txt +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/CMakeLists.txt @@ -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}") ###################################################################################### diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/route.h b/trunk/paradiseo-mo/tutorial/examples/tsp/route.h index ee2224ac9..2489b63bc 100644 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/route.h +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/route.h @@ -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 -#include -typedef eoScalarFitness< float, std::greater< float > > tspFitness ; - -typedef eoVector Route ; // [Fitness (length), Gene (city)] +typedef eoVector Route ; // [Fitness (- length), Gene (city)] #endif diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/route_eval.cpp b/trunk/paradiseo-mo/tutorial/examples/tsp/route_eval.cpp index 4d5da8b9b..0d0d6e413 100644 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/route_eval.cpp +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/route_eval.cpp @@ -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) ; diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_incr_eval.cpp b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_incr_eval.cpp index aa738e425..1b371104b 100644 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_incr_eval.cpp +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_incr_eval.cpp @@ -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) ; } diff --git a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_incr_eval.h b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_incr_eval.h index 0c217704e..233cb264d 100644 --- a/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_incr_eval.h +++ b/trunk/paradiseo-mo/tutorial/examples/tsp/two_opt_incr_eval.h @@ -20,7 +20,7 @@ class TwoOptIncrEval : public moMoveIncrEval public : - tspFitness operator () (const TwoOpt & __move, const Route & __route) ; + float operator () (const TwoOpt & __move, const Route & __route) ; } ;