New config of Paradiseo with Cmake 2.6
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1347 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
aa8109322c
commit
712e8d6cfa
84 changed files with 1468 additions and 739 deletions
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
|
@ -8,7 +6,6 @@ INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
|||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
|
||||
######################################################################################
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
|
|
@ -16,36 +13,53 @@ INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
|
|||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
ADD_EXECUTABLE(iterated_local_search iterated_local_search.cpp)
|
||||
|
||||
ADD_DEPENDENCIES(iterated_local_search tsp)
|
||||
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES iterated_local_search.cpp)
|
||||
|
||||
SOURCE_GROUP(benchs FILES
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(iterated_local_search
|
||||
variable_neighborhood_search.cpp
|
||||
${MO_BIN_DIR}/tutorial/Lesson5/param
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
ELSE(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
ADD_COMMANDS_MO()
|
||||
ADD_TARGET_MO(lesson5)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(variable_neighborhood_search variable_neighborhood_search.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(variable_neighborhood_search EXCLUDE_FROM_ALL variable_neighborhood_search.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(variable_neighborhood_search tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(ITERATEDLOCALSEARCH_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(iterated_local_search PROPERTIES VERSION "${ITERATEDLOCALSEARCH_VERSION}")
|
||||
######################################################################################
|
||||
|
||||
|
||||
SET_TARGET_PROPERTIES(variable_neighborhood_search PROPERTIES VERSION "${ITERATEDLOCALSEARCH_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(iterated_local_search tsp eo eoutils)
|
||||
TARGET_LINK_LIBRARIES(variable_neighborhood_search tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
|
||||
###### Configuration ######
|
||||
# --instancePath=../examples/tsp/benchs/berlin52.tsp # Path to the instance.
|
||||
# --seed=1203080388 # Seed for rand.
|
||||
# --maxIter=1000 # Maximum number of iterations.
|
||||
# --seed=1231949999 # Seed for rand.
|
||||
# --selectionType=Best # Type of the selection: 'Best', 'First' or 'Random'.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
<iterated_local_search.cpp>
|
||||
<variable_neighborhood_search.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, Jean-Charles Boisson
|
||||
Salma Mesmoudi (salma.mesmoudi@inria.fr), Jean-Charles Boisson
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
|
|
@ -36,25 +36,29 @@
|
|||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
#include <vector>
|
||||
|
||||
|
||||
//template <class T, class P>void add(T& var, P& vect);
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
//void ajouter (std::vector<moMoveInit<moMove<Route> > >& V, moMove<Route>& K)const ;
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath;
|
||||
unsigned int seed, maxIterations;
|
||||
std::string instancePath, selectionType;
|
||||
unsigned int seed;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
maxIterations=atoi( (parser.getParamWithLongName("maxIter")->getValue()).c_str() );
|
||||
selectionType=parser.getParamWithLongName("selectionType")->getValue();
|
||||
|
||||
srand(seed);
|
||||
Graph::load (instancePath.c_str());
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
|
|
@ -65,6 +69,11 @@ main (int _argc, char* _argv [])
|
|||
full_evaluation (solution);
|
||||
|
||||
std :: cout << "[From] " << solution << std :: endl;
|
||||
//A neighbor is a local search or mutation
|
||||
|
||||
/*Tools for an efficient (? :-))
|
||||
local search ! */
|
||||
//---------------------first neighbor----------------------------------
|
||||
|
||||
TwoOptInit two_opt_initializer;
|
||||
|
||||
|
|
@ -72,46 +81,80 @@ main (int _argc, char* _argv [])
|
|||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moBestImprSelect <TwoOpt> two_opt_selection;
|
||||
moMoveSelect<TwoOpt>* two_opt_selection;
|
||||
|
||||
moGenSolContinue <Route> continu(maxIterations);
|
||||
if(selectionType.compare("Best")==0)
|
||||
{
|
||||
two_opt_selection= new moBestImprSelect<TwoOpt>();
|
||||
}
|
||||
else if (selectionType.compare("First")==0)
|
||||
{
|
||||
two_opt_selection= new moFirstImprSelect<TwoOpt>();
|
||||
}
|
||||
else if (selectionType.compare("Random")==0)
|
||||
{
|
||||
two_opt_selection= new moRandImprSelect<TwoOpt>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[hill_climbing.cpp]: the type of selection '"+selectionType+"' is not correct.");
|
||||
}
|
||||
|
||||
moFitComparator<Route> comparator;
|
||||
|
||||
moHC <TwoOpt> hill_climbing (two_opt_initializer, two_opt_next_move_generator, two_opt_incremental_evaluation,
|
||||
*two_opt_selection, full_evaluation);
|
||||
|
||||
|
||||
//--------------------second neighbor-----------------
|
||||
|
||||
CitySwap perturbation;
|
||||
|
||||
moILS<TwoOpt> iterated_local_search (two_opt_initializer, two_opt_next_move_generator, two_opt_incremental_evaluation,
|
||||
two_opt_selection, continu, comparator, perturbation, full_evaluation) ;
|
||||
iterated_local_search(solution);
|
||||
//-----------neighbor vector--------------------------
|
||||
|
||||
moExpl<Route> explorer(perturbation);
|
||||
explorer.add(hill_climbing);
|
||||
explorer.add(perturbation);
|
||||
|
||||
//------------VNS application--------------------------
|
||||
|
||||
moVNS<Route> vns(explorer, full_evaluation);
|
||||
vns(solution);
|
||||
//hill_climbing(solution);
|
||||
std :: cout << "[To] " << solution << std :: endl;
|
||||
|
||||
delete(two_opt_selection);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
manage_configuration_file(eoParser & _parser)
|
||||
{
|
||||
std::ofstream os;
|
||||
|
||||
|
||||
_parser.createParam(std::string("../examples/tsp/benchs/berlin52.tsp"), "instancePath", "Path to the instance.",
|
||||
0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)time(0), "seed", "Seed for rand.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)1000, "maxIter", "Maximum number of iterations.", 0, "Configuration", false);
|
||||
_parser.getORcreateParam(std::string("Best"), "selectionType", "Type of the selection: 'Best', 'First' or 'Random'.",
|
||||
0, "Configuration", false);
|
||||
|
||||
if (_parser.userNeedsHelp())
|
||||
{
|
||||
_parser.printHelp(std::cout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
os.open("current_param");
|
||||
if(!os.is_open())
|
||||
{
|
||||
throw std::runtime_error("[iterated_local_search.cpp]: the file current_param cannot be created.");
|
||||
throw std::runtime_error("[hill_climbing.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue