tree modifications
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@512 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
0d2b55437a
commit
61c0424eed
3 changed files with 395 additions and 458 deletions
|
|
@ -1,18 +1,122 @@
|
|||
|
||||
|
||||
######################################################################################
|
||||
### 0) Need lesson2 directory
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
SET(TUTORIAL_LESSON2_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR})
|
||||
INCLUDE_DIRECTORIES(${TSP_EXAMPLE_DIR}/src)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries (mandatory: before 3) )
|
||||
######################################################################################
|
||||
|
||||
# --> UNIX
|
||||
IF(UNIX)
|
||||
LINK_DIRECTORIES(${EO_SRC_DIR} ${EO_SRC_DIR}/utils ${TSP_EXAMPLE_DIR}/build)
|
||||
|
||||
# --> WIN
|
||||
ELSEIF(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_EXAMPLE_DIR}\\build\\debug)
|
||||
LINK_DIRECTORIES(${EO_LIB_DIR}\\debug)
|
||||
ELSEIF(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
LINK_DIRECTORIES(${TSP_EXAMPLE_DIR}\\build\\release)
|
||||
LINK_DIRECTORIES(${EO_LIB_DIR}\\release)
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
ENDIF(UNIX)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 1) Where must cmake go now ?
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
SUBDIRS(src)
|
||||
# no matter what is the OS, hopefully
|
||||
ADD_EXECUTABLE(tabu_search tabu_search.cpp)
|
||||
|
||||
ADD_DEPENDENCIES(tabu_search tsp)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${TUTORIAL_LESSON2_DIR}/build)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(TABUSEARCH_VERSION "1.0.beta")
|
||||
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)
|
||||
|
||||
# --> WIN
|
||||
ELSEIF(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)
|
||||
ELSEIF(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
TARGET_LINK_LIBRARIES(tabu_search tsp)
|
||||
TARGET_LINK_LIBRARIES(tabu_search eo)
|
||||
TARGET_LINK_LIBRARIES(tabu_search eoutils)
|
||||
ELSE(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
MESSAGE(FATAL_ERROR " Cmake build type can only be \"Debug\" or \"Release\" ")
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
ENDIF(UNIX)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 6) 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)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,122 +0,0 @@
|
|||
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR})
|
||||
INCLUDE_DIRECTORIES(${TSP_EXAMPLE_DIR}/src)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries (mandatory: before 3) )
|
||||
######################################################################################
|
||||
|
||||
# --> UNIX
|
||||
IF(UNIX)
|
||||
LINK_DIRECTORIES(${EO_SRC_DIR} ${EO_SRC_DIR}/utils ${TSP_EXAMPLE_DIR}/build)
|
||||
|
||||
# --> WIN
|
||||
ELSEIF(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_EXAMPLE_DIR}\\build\\debug)
|
||||
LINK_DIRECTORIES(${EO_LIB_DIR}\\debug)
|
||||
ELSEIF(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
LINK_DIRECTORIES(${TSP_EXAMPLE_DIR}\\build\\release)
|
||||
LINK_DIRECTORIES(${EO_LIB_DIR}\\release)
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
ENDIF(UNIX)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 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)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${TUTORIAL_LESSON2_DIR}/build)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(TABUSEARCH_VERSION "1.0.beta")
|
||||
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)
|
||||
|
||||
# --> WIN
|
||||
ELSEIF(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)
|
||||
ELSEIF(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
TARGET_LINK_LIBRARIES(tabu_search tsp)
|
||||
TARGET_LINK_LIBRARIES(tabu_search eo)
|
||||
TARGET_LINK_LIBRARIES(tabu_search eoutils)
|
||||
ELSE(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
MESSAGE(FATAL_ERROR " Cmake build type can only be \"Debug\" or \"Release\" ")
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
ENDIF(UNIX)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 6) 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)
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
69
trunk/paradiseo-mo/tutorial/Lesson2/tabu_search.cpp
Normal file
69
trunk/paradiseo-mo/tutorial/Lesson2/tabu_search.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// "tabu_search.cpp"
|
||||
|
||||
// (c) OPAC Team, LIFL, 2003-2006
|
||||
|
||||
/* LICENCE TEXT
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <mo.h>
|
||||
|
||||
#include <graph.h>
|
||||
#include <route.h>
|
||||
#include <route_eval.h>
|
||||
#include <route_init.h>
|
||||
|
||||
#include <two_opt.h>
|
||||
#include <two_opt_init.h>
|
||||
#include <two_opt_next.h>
|
||||
#include <two_opt_incr_eval.h>
|
||||
#include <two_opt_tabu_list.h>
|
||||
|
||||
int main (int __argc, char * __argv []) {
|
||||
|
||||
if (__argc != 2) {
|
||||
|
||||
std :: cerr << "Usage : ./tabu_search [instance]" << std :: endl ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
Graph :: load (__argv [1]) ; // Instance
|
||||
|
||||
Route route ; // Solution
|
||||
|
||||
RouteInit init ; // Sol. Random Init.
|
||||
init (route) ;
|
||||
|
||||
RouteEval full_eval ; // Full. Eval.
|
||||
full_eval (route) ;
|
||||
|
||||
std :: cout << "[From] " << route << std :: endl ;
|
||||
|
||||
/* Tools for an efficient (? :-))
|
||||
local search ! */
|
||||
|
||||
TwoOptInit two_opt_init ; // Init.
|
||||
|
||||
TwoOptNext two_opt_next ; // Explorer.
|
||||
|
||||
TwoOptIncrEval two_opt_incr_eval ; // Eff. eval.
|
||||
|
||||
TwoOptTabuList tabu_list ; // Tabu List
|
||||
//moSimpleMoveTabuList<TwoOpt> tabu_list(10);
|
||||
//moSimpleSolutionTabuList<TwoOpt> tabu_list(10);
|
||||
|
||||
moNoAspirCrit <TwoOpt> aspir_crit ; // Aspiration Criterion
|
||||
|
||||
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) ;
|
||||
|
||||
std :: cout << "[To] " << route << std :: endl ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue