git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1707 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
baf31d0c30
commit
18901c5769
165 changed files with 38091 additions and 0 deletions
222
trunk/paradiseo-old-mo/tutorial/CMakeLists.txt
Normal file
222
trunk/paradiseo-old-mo/tutorial/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
IF(COMMAND cmake_policy)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
ENDIF(COMMAND cmake_policy)
|
||||
######################################################################################
|
||||
### 1) Definitions (required for tsp target)
|
||||
######################################################################################
|
||||
|
||||
SET(TSP_SRC_DIR ${MO_SRC_DIR}/tutorial/examples/tsp CACHE PATH "TSP src directory")
|
||||
SET(TSP_BIN_DIR ${MO_BIN_DIR}/tutorial/examples/tsp CACHE PATH "TSP binary directory")
|
||||
|
||||
SET(FUNCTION_SRC_DIR ${MO_SRC_DIR}/tutorial/examples/function CACHE PATH "FUNCTION src directory")
|
||||
SET(FUNCTION_BIN_DIR ${MO_BIN_DIR}/tutorial/examples/function CACHE PATH "FUNCTION binary directory")
|
||||
|
||||
######################################################################################
|
||||
|
||||
######################################################################################
|
||||
### 2) How to manage copy of benchs ?
|
||||
######################################################################################
|
||||
|
||||
IF(ENABLE_CMAKE_EXAMPLE OR CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SET(BENCH_LIST
|
||||
berlin52.tsp
|
||||
eil101.tsp
|
||||
pr2392.tsp
|
||||
rl5915.tsp
|
||||
usa13509.tsp
|
||||
)
|
||||
|
||||
FOREACH (bench ${BENCH_LIST})
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/${bench}
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/${bench}
|
||||
)
|
||||
ENDFOREACH (bench)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson1/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson1/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson2/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson2/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson3/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson3/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson4/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson4/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson5/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson5/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/HybridLesson/param
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson/param
|
||||
)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE OR CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
######################################################################################
|
||||
### 3) Where must cmake go now ?
|
||||
######################################################################################
|
||||
|
||||
MACRO(ADD_COMMANDS_MO)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson1/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson1/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson1
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson2/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson2/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson2
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson3/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson3/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson3
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson4/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson4/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson4
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson5/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson5/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson5
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson6/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/HybridLesson/param
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson
|
||||
)
|
||||
ENDMACRO(ADD_COMMANDS_MO)
|
||||
|
||||
MACRO(ADD_TARGET_MO n)
|
||||
IF(${n} STREQUAL "lesson1")
|
||||
ADD_CUSTOM_TARGET(lesson1 DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson1/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson1/hill_climbing
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "lesson2")
|
||||
ADD_CUSTOM_TARGET(lesson2 DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson2/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson2/tabu_search
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "lesson3")
|
||||
ADD_CUSTOM_TARGET(lesson3 DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson3/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson3/simulated_annealing
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "lesson4")
|
||||
ADD_CUSTOM_TARGET(lesson4 DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson4/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson4/iterated_local_search
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "lesson5")
|
||||
ADD_CUSTOM_TARGET(lesson5 DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson5/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson5/variable_neighborhood_search
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "hybridlesson")
|
||||
ADD_CUSTOM_TARGET(hybridlesson DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson/param
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson/hybrid_ga
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "install")
|
||||
ADD_CUSTOM_TARGET(install DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson1/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson2/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson3/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson4/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson5/param
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson/param
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "benchs")
|
||||
ADD_CUSTOM_TARGET(benchs DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ENDIF(${n} STREQUAL "lesson1")
|
||||
ENDMACRO(ADD_TARGET_MO)
|
||||
|
||||
IF(NOT CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" AND NOT CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
ADD_COMMANDS_MO()
|
||||
ADD_TARGET_MO(install)
|
||||
ADD_TARGET_MO(benchs)
|
||||
ENDIF(NOT CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" AND NOT CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_SUBDIRECTORY(examples)
|
||||
ADD_SUBDIRECTORY(Lesson1)
|
||||
ADD_SUBDIRECTORY(Lesson2)
|
||||
ADD_SUBDIRECTORY(Lesson3)
|
||||
ADD_SUBDIRECTORY(Lesson4)
|
||||
ADD_SUBDIRECTORY(Lesson5)
|
||||
ADD_SUBDIRECTORY(HybridLesson)
|
||||
65
trunk/paradiseo-old-mo/tutorial/HybridLesson/CMakeLists.txt
Normal file
65
trunk/paradiseo-old-mo/tutorial/HybridLesson/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
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
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES hybrid_ga.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(hybrid_ga
|
||||
hybrid_ga.cpp
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson/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(lesson6)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(hybrid_ga hybrid_ga.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(hybrid_ga EXCLUDE_FROM_ALL hybrid_ga.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(hybrid_ga tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(HYBRIDGA_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(hybrid_ga PROPERTIES VERSION "${HYBRIDGA_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(hybrid_ga tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
194
trunk/paradiseo-old-mo/tutorial/HybridLesson/hybrid_ga.cpp
Normal file
194
trunk/paradiseo-old-mo/tutorial/HybridLesson/hybrid_ga.cpp
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* <tsp.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, Thomas Legrand
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath, crossoverType, selectionType;
|
||||
unsigned int seed, populationSize, maxIterations, selectedParentNumber;
|
||||
double crossoverRate, mutationRate, elitismRate, tournamentRate;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
populationSize=atoi( (parser.getParamWithLongName("popSize")->getValue()).c_str() );
|
||||
maxIterations=atoi( (parser.getParamWithLongName("maxIter")->getValue()).c_str() );
|
||||
crossoverRate=atof( (parser.getParamWithLongName("crossRate")->getValue()).c_str() );
|
||||
mutationRate=atof( (parser.getParamWithLongName("mutRate")->getValue()).c_str() );
|
||||
selectedParentNumber=atoi( (parser.getParamWithLongName("nbSelPar")->getValue()).c_str() );
|
||||
elitismRate=atof( (parser.getParamWithLongName("elitismRate")->getValue()).c_str() );
|
||||
tournamentRate=atof( (parser.getParamWithLongName("tournRate")->getValue()).c_str() );
|
||||
crossoverType=parser.getParamWithLongName("crossType")->getValue();
|
||||
selectionType=parser.getParamWithLongName("selectionType")->getValue();
|
||||
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
RouteInit init ;
|
||||
|
||||
RouteEval full_evaluation ;
|
||||
|
||||
eoPop <Route> population (populationSize, init) ;
|
||||
apply <Route> (full_evaluation, population) ;
|
||||
|
||||
std :: cout << "[From] " << population.best_element () << std :: endl ;
|
||||
|
||||
eoGenContinue <Route> continu (maxIterations) ;
|
||||
|
||||
eoStochTournamentSelect <Route> select_one ;
|
||||
|
||||
eoSelectNumber <Route> select (select_one, selectedParentNumber) ;
|
||||
|
||||
eoQuadOp <Route>*crossover;
|
||||
|
||||
if(crossoverType.compare("Partial")==0)
|
||||
{
|
||||
crossover=new PartialMappedXover();
|
||||
}
|
||||
else if (crossoverType.compare("Order")==0)
|
||||
{
|
||||
crossover=new OrderXover();
|
||||
}
|
||||
else if (crossoverType.compare("Edge")==0)
|
||||
{
|
||||
crossover=new EdgeXover();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[tsp.cpp]: the crossover type '"+crossoverType+"' is not correct.");
|
||||
}
|
||||
|
||||
TwoOptInit two_opt_initializer;
|
||||
|
||||
TwoOptNext two_opt_next_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moMoveSelect<TwoOpt>* two_opt_selection;
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
moHC <TwoOpt> hill_climbing_mutation (two_opt_initializer, two_opt_next_move_generator, two_opt_incremental_evaluation,
|
||||
*two_opt_selection, full_evaluation);
|
||||
|
||||
eoSGATransform <Route> transform (*crossover, crossoverRate, hill_climbing_mutation, mutationRate) ;
|
||||
|
||||
eoElitism <Route> merge (elitismRate) ;
|
||||
|
||||
eoStochTournamentTruncate <Route> reduce (tournamentRate) ;
|
||||
|
||||
eoEasyEA <Route> ea (continu, full_evaluation, select, transform, merge, reduce) ;
|
||||
|
||||
ea (population) ;
|
||||
|
||||
std :: cout << "[To] " << population.best_element () << std :: endl ;
|
||||
|
||||
delete(crossover);
|
||||
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)100, "popSize", "Size of the population.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)1000, "maxIter", "Maximum number of iterations.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)1.0, "crossRate", "Probability of crossover.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)0.01, "mutRate", "Probability of mutation.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)100, "nbSelPar", "Number of selected parents.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)1.0, "elitismRate", "Percentage of the best individuals kept.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)0.7, "tournRate", "Percentage of the individuals used during the tournament.",
|
||||
0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam(std::string("Partial"), "crossType", "Crossover to use, it can be 'Partial', 'Order' or 'Edge'.",
|
||||
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("[tsp.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
17
trunk/paradiseo-old-mo/tutorial/HybridLesson/param
Normal file
17
trunk/paradiseo-old-mo/tutorial/HybridLesson/param
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
###### 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=1224599328 # Seed for rand.
|
||||
# --popSize=100 # Size of the population.
|
||||
# --maxIter=1000 # Maximum number of iterations.
|
||||
# --crossRate=1 # Probability of crossover.
|
||||
# --mutRate=0.01 # Probability of mutation.
|
||||
# --nbSelPar=100 # Number of selected parents.
|
||||
# --elitismRate=1 # Percentage of the best individuals kept.
|
||||
# --tournRate=0.7 # Percentage of the individuals used during the tournament.
|
||||
# --crossType=Partial # Crossover to use, it can be 'Partial', 'Order' or 'Edge'.
|
||||
# --selectionType=Best # Type of the selection: 'Best', 'First' or 'Random'.
|
||||
67
trunk/paradiseo-old-mo/tutorial/Lesson1/CMakeLists.txt
Normal file
67
trunk/paradiseo-old-mo/tutorial/Lesson1/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
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
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES hill_climbing.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(hill_climbing
|
||||
hill_climbing.cpp
|
||||
${MO_BIN_DIR}/tutorial/Lesson1/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(lesson1)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(hill_climbing hill_climbing.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(hill_climbing EXCLUDE_FROM_ALL hill_climbing.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
|
||||
ADD_DEPENDENCIES(hill_climbing tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(HILLCLIMBING_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(hill_climbing PROPERTIES VERSION "${HILLCLIMBING_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(hill_climbing tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
|
||||
134
trunk/paradiseo-old-mo/tutorial/Lesson1/hill_climbing.cpp
Normal file
134
trunk/paradiseo-old-mo/tutorial/Lesson1/hill_climbing.cpp
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
<hill_climbing.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, 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,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath, selectionType;
|
||||
unsigned int seed;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
selectionType=parser.getParamWithLongName("selectionType")->getValue();
|
||||
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
RouteInit initializer;
|
||||
initializer (solution);
|
||||
|
||||
RouteEval full_evaluation;
|
||||
full_evaluation (solution);
|
||||
|
||||
std :: cout << "[From] " << solution << std :: endl;
|
||||
|
||||
/* Tools for an efficient (? :-))
|
||||
local search ! */
|
||||
|
||||
TwoOptInit two_opt_initializer;
|
||||
|
||||
TwoOptNext two_opt_next_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moMoveSelect<TwoOpt>* two_opt_selection;
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
moHC <TwoOpt> hill_climbing (two_opt_initializer, two_opt_next_move_generator, two_opt_incremental_evaluation,
|
||||
*two_opt_selection, full_evaluation);
|
||||
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(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("[hill_climbing.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
9
trunk/paradiseo-old-mo/tutorial/Lesson1/param
Normal file
9
trunk/paradiseo-old-mo/tutorial/Lesson1/param
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
###### 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=1203517190 # Seed for rand.
|
||||
# --selectionType=Best # Type of the selection: 'Best', 'First' or 'Random'.
|
||||
66
trunk/paradiseo-old-mo/tutorial/Lesson2/CMakeLists.txt
Normal file
66
trunk/paradiseo-old-mo/tutorial/Lesson2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
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
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES tabu_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(tabu_search
|
||||
tabu_search.cpp
|
||||
${MO_BIN_DIR}/tutorial/Lesson2/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(lesson2)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(tabu_search tabu_search.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(tabu_search EXCLUDE_FROM_ALL tabu_search.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(tabu_search tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(TABUSEARCH_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(tabu_search PROPERTIES VERSION "${TABUSEARCH_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(tabu_search tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
|
||||
11
trunk/paradiseo-old-mo/tutorial/Lesson2/param
Normal file
11
trunk/paradiseo-old-mo/tutorial/Lesson2/param
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
###### 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=1202917905 # Seed for rand
|
||||
# --tabuListSize=10 # Size of the tabu list
|
||||
# --maxIter=1000 # Maximum number of iterations
|
||||
# --tabuListType=TwoOpt # Type of the tabu list: 'TwoOpt', 'SimpleMove' or 'SimpleSolution'
|
||||
145
trunk/paradiseo-old-mo/tutorial/Lesson2/tabu_search.cpp
Normal file
145
trunk/paradiseo-old-mo/tutorial/Lesson2/tabu_search.cpp
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
<tabu_search.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, 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,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath, value;
|
||||
unsigned int seed, maxIterations, tabuListSize;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
maxIterations=atoi( (parser.getParamWithLongName("maxIter")->getValue()).c_str() );
|
||||
tabuListSize=atoi( (parser.getParamWithLongName("tabuListSize")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
value=parser.getParamWithLongName("tabuListType")->getValue();
|
||||
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
RouteInit initializer;
|
||||
initializer(solution);
|
||||
|
||||
RouteEval full_evaluation;
|
||||
full_evaluation(solution);
|
||||
|
||||
std :: cout << "[From] " << solution << std :: endl;
|
||||
|
||||
/* Tools for an efficient (? :-))
|
||||
local search ! */
|
||||
|
||||
TwoOptInit two_opt_initializer;
|
||||
|
||||
TwoOptNext two_opt_next_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moTabuList<TwoOpt> *tabuList;
|
||||
|
||||
if(value.compare("TwoOpt")==0)
|
||||
{
|
||||
tabuList=new TwoOptTabuList();
|
||||
}
|
||||
else if (value.compare("SimpleMove")==0)
|
||||
{
|
||||
tabuList=new moSimpleMoveTabuList<TwoOpt>(tabuListSize);
|
||||
}
|
||||
else if (value.compare("SimpleSolution")==0)
|
||||
{
|
||||
tabuList=new moSimpleSolutionTabuList<TwoOpt>(tabuListSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[tabu_search.cpp]: the type of tabu list '"+value+"' is not correct.");
|
||||
}
|
||||
|
||||
moNoAspirCrit <TwoOpt> aspiration_criterion;
|
||||
|
||||
moGenSolContinue <Route> continu (maxIterations);
|
||||
|
||||
moTS <TwoOpt> tabu_search (two_opt_initializer, two_opt_next_move_generator,
|
||||
two_opt_incremental_evaluation, *tabuList, aspiration_criterion, continu, full_evaluation);
|
||||
tabu_search(solution);
|
||||
|
||||
std :: cout << "[To] " << solution << std :: endl;
|
||||
|
||||
delete(tabuList);
|
||||
|
||||
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)10, "tabuListSize", "Size of the tabu list.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)1000, "maxIter", "Maximum number of iterations.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam(std::string("TwoOpt"), "tabuListType", "Type of the tabu list: 'TwoOpt', 'SimpleMove' or 'SimpleSolution'.",
|
||||
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("[tabu_search.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
66
trunk/paradiseo-old-mo/tutorial/Lesson3/CMakeLists.txt
Normal file
66
trunk/paradiseo-old-mo/tutorial/Lesson3/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
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
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES simulated_annealing.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(simulated_annealing
|
||||
simulated_annealing.cpp
|
||||
${MO_BIN_DIR}/tutorial/Lesson3/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(lesson3)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(simulated_annealing simulated_annealing.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(simulated_annealing EXCLUDE_FROM_ALL simulated_annealing.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(simulated_annealing tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(SIMULATEDANNEALING_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(simulated_annealing PROPERTIES VERSION "${SIMULATEDANNEALING_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(simulated_annealing tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
|
||||
14
trunk/paradiseo-old-mo/tutorial/Lesson3/param
Normal file
14
trunk/paradiseo-old-mo/tutorial/Lesson3/param
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
###### 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=1202919978 # Seed for rand.
|
||||
# --maxIter=1000 # Maximum number of iterations.
|
||||
# --initialTemp=1000 # Initial temperature.
|
||||
# --threshold=0.1 # Minimum temperature allowed.
|
||||
# --expoRatio=0.98 # Ratio used if exponential cooling schedule is chosen.
|
||||
# --lineaRatio=0.5 # Ratio used if linear cooling schedule is chosen.
|
||||
# --coolSchedType=Expo # Type the cooling schedule: 'Expo' or 'Linear'.
|
||||
148
trunk/paradiseo-old-mo/tutorial/Lesson3/simulated_annealing.cpp
Normal file
148
trunk/paradiseo-old-mo/tutorial/Lesson3/simulated_annealing.cpp
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
<simulated_annealing.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, 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,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath, value;
|
||||
unsigned int seed, maxIterations;
|
||||
double threshold, geometricRatio, linearRatio, initialTemperature;
|
||||
|
||||
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() );
|
||||
initialTemperature=atof( (parser.getParamWithLongName("initialTemp")->getValue()).c_str() );
|
||||
threshold=atof( (parser.getParamWithLongName("threshold")->getValue()).c_str() );
|
||||
geometricRatio=atof( (parser.getParamWithLongName("geometricRatio")->getValue()).c_str() );
|
||||
linearRatio=atof( (parser.getParamWithLongName("lineaRatio")->getValue()).c_str() );
|
||||
value=parser.getParamWithLongName("coolSchedType")->getValue();
|
||||
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
RouteInit initializer;
|
||||
initializer (solution);
|
||||
|
||||
RouteEval full_evaluation;
|
||||
full_evaluation (solution);
|
||||
|
||||
std :: cout << "[From] " << solution << std :: endl;
|
||||
|
||||
/* Tools for an efficient (? :-))
|
||||
local search ! */
|
||||
|
||||
TwoOptRand two_opt_random_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
TwoOpt move;
|
||||
|
||||
moCoolingSchedule* coolingSchedule;
|
||||
|
||||
if(value.compare("Geometric")==0)
|
||||
{
|
||||
coolingSchedule=new moGeometricCoolingSchedule(threshold, geometricRatio);
|
||||
}
|
||||
else if (value.compare("Linear")==0)
|
||||
{
|
||||
coolingSchedule=new moLinearCoolingSchedule(threshold, linearRatio);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[simulated_annealing.cpp]: the type of cooling schedule '"+value+"' is not correct.");
|
||||
}
|
||||
|
||||
moGenSolContinue <Route> continu (maxIterations);
|
||||
|
||||
moSA <TwoOpt> simulated_annealing (two_opt_random_move_generator, two_opt_incremental_evaluation,
|
||||
continu, initialTemperature, *coolingSchedule, full_evaluation);
|
||||
simulated_annealing (solution);
|
||||
|
||||
std :: cout << "[To] " << solution << std :: endl;
|
||||
|
||||
delete(coolingSchedule);
|
||||
|
||||
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((double)1000, "initialTemp", "Initial temperature.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)0.1, "threshold", "Minimum temperature allowed.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)0.98, "geometricRatio", "Ratio used if exponential cooling schedule is chosen.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)0.5, "lineaRatio", "Ratio used if linear cooling schedule is chosen.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam(std::string("Geometric"), "coolSchedType", "Type the cooling schedule: 'Geometric' or 'Linear'.",
|
||||
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("[simulated_annealing.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
65
trunk/paradiseo-old-mo/tutorial/Lesson4/CMakeLists.txt
Normal file
65
trunk/paradiseo-old-mo/tutorial/Lesson4/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
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
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
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
|
||||
iterated_local_search.cpp
|
||||
${MO_BIN_DIR}/tutorial/Lesson4/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(lesson4)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(iterated_local_search iterated_local_search.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(iterated_local_search EXCLUDE_FROM_ALL iterated_local_search.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(iterated_local_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}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(iterated_local_search tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
<iterated_local_search.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, 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,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath;
|
||||
unsigned int seed, maxIterations;
|
||||
|
||||
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() );
|
||||
|
||||
srand(seed);
|
||||
Graph::load (instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
RouteInit initializer;
|
||||
initializer (solution);
|
||||
|
||||
RouteEval full_evaluation;
|
||||
full_evaluation (solution);
|
||||
|
||||
std :: cout << "[From] " << solution << std :: endl;
|
||||
|
||||
TwoOptInit two_opt_initializer;
|
||||
|
||||
TwoOptNext two_opt_next_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moBestImprSelect <TwoOpt> two_opt_selection;
|
||||
|
||||
moGenSolContinue <Route> continu(maxIterations);
|
||||
|
||||
moFitComparator<Route> comparator;
|
||||
|
||||
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);
|
||||
|
||||
std :: cout << "[To] " << solution << std :: endl;
|
||||
|
||||
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);
|
||||
|
||||
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.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
9
trunk/paradiseo-old-mo/tutorial/Lesson4/param
Normal file
9
trunk/paradiseo-old-mo/tutorial/Lesson4/param
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
###### 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.
|
||||
65
trunk/paradiseo-old-mo/tutorial/Lesson5/CMakeLists.txt
Normal file
65
trunk/paradiseo-old-mo/tutorial/Lesson5/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
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
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES variable_neighborhood_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(variable_neighborhood_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(variable_neighborhood_search PROPERTIES VERSION "${ITERATEDLOCALSEARCH_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(variable_neighborhood_search tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
8
trunk/paradiseo-old-mo/tutorial/Lesson5/param
Normal file
8
trunk/paradiseo-old-mo/tutorial/Lesson5/param
Normal file
|
|
@ -0,0 +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=1231949999 # Seed for rand.
|
||||
# --selectionType=Best # Type of the selection: 'Best', 'First' or 'Random'.
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
<variable_neighborhood_search.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#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, selectionType;
|
||||
unsigned int seed;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
selectionType=parser.getParamWithLongName("selectionType")->getValue();
|
||||
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
RouteInit initializer;
|
||||
initializer (solution);
|
||||
|
||||
RouteEval full_evaluation;
|
||||
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;
|
||||
|
||||
TwoOptNext two_opt_next_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moMoveSelect<TwoOpt>* two_opt_selection;
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
//-----------neighbor vector--------------------------
|
||||
|
||||
moExpl<Route> explorer(perturbation);
|
||||
explorer.addExplorer(hill_climbing);
|
||||
explorer.addExplorer(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(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("[hill_climbing.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
36
trunk/paradiseo-old-mo/tutorial/OldLesson/CMakeLists.txt
Normal file
36
trunk/paradiseo-old-mo/tutorial/OldLesson/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${FUNCTION_SRC_DIR})
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${FUNCTION_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
ADD_EXECUTABLE(minimize_function
|
||||
ADD_DEPENDENCIES(minimize_function function)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(MINIMIZEFUNCTION_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(minimize_function PROPERTIES VERSION "${MINIMIZEFUNCTION_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(minimize_function function eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
136
trunk/paradiseo-old-mo/tutorial/OldLesson/minimize_function.cpp
Normal file
136
trunk/paradiseo-old-mo/tutorial/OldLesson/minimize_function.cpp
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
<minimize_function.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, 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,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <function>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string selectionType;
|
||||
double initialBound, searchBound, searchStep;
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
initialBound=atof( (parser.getParamWithLongName("initialBound")->getValue()).c_str() );
|
||||
searchBound=atof( (parser.getParamWithLongName("searchBound")->getValue()).c_str() );
|
||||
searchStep=atof( (parser.getParamWithLongName("searchStep")->getValue()).c_str() );
|
||||
selectionType=parser.getParamWithLongName("selectionType")->getValue();
|
||||
|
||||
Affectation solution;
|
||||
|
||||
AffectationInit initialize(initialBound);
|
||||
initialize (solution);
|
||||
|
||||
AffectationEval evaluation;
|
||||
evaluation (solution);
|
||||
|
||||
std::cout << "Initial affectation : " << std::endl;
|
||||
std::cout << "\t x1 = " << solution.first << std::endl;
|
||||
std::cout << "\t x2 = " << solution.second << std::endl;
|
||||
std::cout << "\t f(x1,x2) = " << solution.fitness() << std::endl;
|
||||
|
||||
DeviationInit deviation_initializer(searchBound);
|
||||
|
||||
DeviationNext deviation_next_move_generator(searchBound, searchStep);
|
||||
|
||||
DeviationIncrEval deviation_incremental_evaluation;
|
||||
|
||||
moMoveSelect<Deviation>* deviation_selection;
|
||||
|
||||
if(selectionType.compare("Best")==0)
|
||||
{
|
||||
deviation_selection= new moBestImprSelect<Deviation>();
|
||||
}
|
||||
else if (selectionType.compare("First")==0)
|
||||
{
|
||||
deviation_selection= new moFirstImprSelect<Deviation>();
|
||||
}
|
||||
else if (selectionType.compare("Random")==0)
|
||||
{
|
||||
deviation_selection= new moRandImprSelect<Deviation>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[minimize_function.cpp]: the type of selection '"+selectionType+"' is not correct.");
|
||||
}
|
||||
|
||||
moHC <Deviation> hill_climbing (deviation_initializer, deviation_next_move_generator, deviation_incremental_evaluation,
|
||||
*deviation_selection, evaluation);
|
||||
hill_climbing (solution) ;
|
||||
|
||||
std::cout << "Final affectation : " << std::endl;
|
||||
std::cout << "\t x1 = " << solution.first << std::endl;
|
||||
std::cout << "\t x2 = " << solution.second << std::endl;
|
||||
std::cout << "\t f(x1,x2) = " << solution.fitness() << std::endl;
|
||||
|
||||
delete(deviation_selection);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
manage_configuration_file(eoParser & _parser)
|
||||
{
|
||||
std::ofstream os;
|
||||
|
||||
_parser.createParam((double)1, "initialBound", "Bound for the initial affectation.", 0, "Configuration", false);
|
||||
|
||||
_parser.createParam((double)1, "searchBound", "Bound for neighbourhood exploration.", 0, "Configuration", false);
|
||||
|
||||
_parser.createParam((double)1, "searchStep", "Step between two values during the neighbourhood exploration.",
|
||||
0, "Configuration", false);
|
||||
|
||||
_parser.createParam(std::string("First"), "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("[minimize_function.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
10
trunk/paradiseo-old-mo/tutorial/OldLesson/param
Normal file
10
trunk/paradiseo-old-mo/tutorial/OldLesson/param
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
|
||||
###### Configuration ######
|
||||
# --initialBound=1 # Bound for the initial affectation.
|
||||
# --searchBound=1 # Bound for neighbourhood exploration.
|
||||
# --searchStep=1 # Step between two values during the neighbourhood exploration.
|
||||
# --selectionType=First # Type of the selection: 'Best', 'First' or 'Random'.
|
||||
13
trunk/paradiseo-old-mo/tutorial/examples/CMakeLists.txt
Normal file
13
trunk/paradiseo-old-mo/tutorial/examples/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
|
||||
######################################################################################
|
||||
### 1) Where must cmake go now ?
|
||||
######################################################################################
|
||||
|
||||
#SUBDIRS(tsp function)
|
||||
ADD_SUBDIRECTORY(tsp)
|
||||
ADD_SUBDIRECTORY(function)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
######################################################################################
|
||||
### 0) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 1) Define your target(s): just the tsp here
|
||||
######################################################################################
|
||||
|
||||
SET(FUNCTION_LIB_OUTPUT_PATH ${FUNCTION_BIN_DIR}/lib)
|
||||
SET(LIBRARY_OUTPUT_PATH ${FUNCTION_LIB_OUTPUT_PATH})
|
||||
|
||||
SET (FUNCTION_SOURCES affectation_eval.cpp
|
||||
affectation_init.cpp
|
||||
deviation.cpp
|
||||
deviation_init.cpp
|
||||
deviation_next.cpp
|
||||
deviation_incr_eval.cpp )
|
||||
|
||||
ADD_LIBRARY(function STATIC ${FUNCTION_SOURCES})
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(FUNCTION_VERSION "${GLOBAL_VERSION}")
|
||||
SET_TARGET_PROPERTIES(function PROPERTIES VERSION "${FUNCTION_VERSION}")
|
||||
######################################################################################
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* <affectation.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef affectation_h
|
||||
#define affectation_h
|
||||
|
||||
#include <eoScalarFitness.h>
|
||||
#include <EO.h>
|
||||
|
||||
// A double that has to be minimized.
|
||||
typedef eoScalarFitness< double, std::greater<double> > functionFitness ;
|
||||
|
||||
class Affectation : public EO<functionFitness>, public std::pair<double, double>
|
||||
{};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* <affectationEval.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "affectation_eval.h"
|
||||
|
||||
void AffectationEval :: operator () (Affectation & _affectation)
|
||||
{
|
||||
double x1, x2, result;
|
||||
|
||||
//std::cout << "AffectationEval" << std::endl;
|
||||
|
||||
x1=_affectation.first;
|
||||
x2=_affectation.second;
|
||||
|
||||
result=(2*x1*x1) + (x2*x2) + (x1*x2) - (2*x1) - x2;
|
||||
|
||||
//std::cout << result << std::endl;
|
||||
|
||||
_affectation.fitness(result);
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* <affectationEval.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef affectation_eval_h
|
||||
#define affectation_eval_h
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
#include "affectation.h"
|
||||
|
||||
//! Affectation Evaluator
|
||||
class AffectationEval : public eoEvalFunc <Affectation>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
void operator () (Affectation & _affectation) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* <affectation_init.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "affectation_init.h"
|
||||
|
||||
AffectationInit::AffectationInit(double _bound): bound(_bound)
|
||||
{
|
||||
if(bound < 0.0)
|
||||
{
|
||||
std::cout << "[affectation_init.cpp][AffectationInit]: bound is negative, " << bound << " is tranformed to ";
|
||||
bound = -bound;
|
||||
std::cout << bound << "." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void AffectationInit::operator()(Affectation & _affectation)
|
||||
{
|
||||
eoBooleanGenerator booleanGenerator;
|
||||
|
||||
eoUniformGenerator<double> doubleGenerator(bound);
|
||||
|
||||
//A value between 0.0 and bound.
|
||||
_affectation.first = doubleGenerator();
|
||||
|
||||
//value or -value ?
|
||||
if(booleanGenerator())
|
||||
{
|
||||
_affectation.first= - _affectation.first;
|
||||
}
|
||||
|
||||
//A value between 0.0 and bound.
|
||||
_affectation.second = doubleGenerator();
|
||||
|
||||
//value or -value ?
|
||||
if(booleanGenerator())
|
||||
{
|
||||
_affectation.second= - _affectation.second;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* <affectation_init.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef affectation_init_h
|
||||
#define affectation_init_h
|
||||
|
||||
#include <eoInit.h>
|
||||
|
||||
#include "affectation.h"
|
||||
|
||||
class AffectationInit : public eoInit <Affectation>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
AffectationInit(double _bound);
|
||||
|
||||
void operator () (Affectation & _affectation) ;
|
||||
|
||||
//! A bound for the initial value for the affectation
|
||||
double bound;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* <deviation.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "deviation.h"
|
||||
|
||||
void Deviation::operator () (Affectation & _affectation)
|
||||
{
|
||||
_affectation.first += first;
|
||||
_affectation.second += second;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* <deviation.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef deviation_h
|
||||
#define deviation_h
|
||||
|
||||
#include <moMove.h>
|
||||
#include "affectation.h"
|
||||
|
||||
class Deviation : public moMove <Affectation>, public std :: pair <double, double>
|
||||
{
|
||||
public :
|
||||
|
||||
void operator () (Affectation & _affectation) ;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* <deviation_incr_eval.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "deviation_incr_eval.h"
|
||||
|
||||
functionFitness DeviationIncrEval :: operator () (const Deviation & _move, const Affectation & _affectation)
|
||||
{
|
||||
double x1, x2, deltaX1, deltaX2;
|
||||
|
||||
x1=_affectation.first;
|
||||
x2=_affectation.second;
|
||||
|
||||
deltaX1=_move.first;
|
||||
deltaX2=_move.second;
|
||||
|
||||
return _affectation.fitness()
|
||||
+ ( 2*deltaX1*deltaX1 ) + ( deltaX2*deltaX2 ) + ( deltaX1*deltaX2 ) - ( 2*deltaX1 ) - deltaX2
|
||||
+ ( deltaX1 * ( (4*x1) + x2 ) ) + ( x2*deltaX1 );
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* <deviation_incr_eval.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef deviation_incr_eval_h
|
||||
#define deviation_incr_eval_h
|
||||
|
||||
#include <moMoveIncrEval.h>
|
||||
#include "deviation.h"
|
||||
|
||||
class DeviationIncrEval : public moMoveIncrEval <Deviation>
|
||||
{
|
||||
public :
|
||||
|
||||
functionFitness operator () (const Deviation & _move, const Affectation & _affectation);
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* <deviation_init.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "deviation_init.h"
|
||||
|
||||
DeviationInit::DeviationInit(double _bound): bound(_bound)
|
||||
{
|
||||
if(bound < 0.0)
|
||||
{
|
||||
std::cout << "[deviation_init.cpp][DeviationInit]: bound is negative, " << bound << " is tranformed to ";
|
||||
bound = -bound;
|
||||
std::cout << bound << "." << std::endl;;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviationInit::operator () (Deviation & _move, const Affectation & _affectation)
|
||||
{
|
||||
//Code only used to avoid compilation warning because _affectation is not used in this procedure.
|
||||
Affectation affectation(_affectation);
|
||||
|
||||
_move.first=-bound;
|
||||
_move.second=-bound;
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* <deviation_init.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef deviation_init_h
|
||||
#define deviation_init_h
|
||||
|
||||
#include <moMoveInit.h>
|
||||
#include <utils/eoRndGenerators.h>
|
||||
|
||||
#include "deviation.h"
|
||||
|
||||
/** It sets the first couple of edges */
|
||||
class DeviationInit : public moMoveInit <Deviation>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
DeviationInit(double _bound);
|
||||
|
||||
void operator () (Deviation & _move, const Affectation & _affectation) ;
|
||||
|
||||
private :
|
||||
|
||||
//! A bound for the initial value for the deviations
|
||||
double bound;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* <deviation_next.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "deviation_next.h"
|
||||
|
||||
DeviationNext::DeviationNext(double _bound, double _step): bound(_bound), step(_step)
|
||||
{
|
||||
if(bound<0.0)
|
||||
{
|
||||
std::cout << "[deviation_next.cpp][DeviationNext]: bound is negative, " << bound << " is tranformed to ";
|
||||
bound=-bound;
|
||||
std::cout << bound << "." << std::endl;
|
||||
}
|
||||
|
||||
if(step<0.0)
|
||||
{
|
||||
std::cout << "[deviation_next.cpp][DeviationNext]: step is negative, " << step << " is tranformed to ";
|
||||
step=-step;
|
||||
std::cout << step << "." << std::endl;
|
||||
}
|
||||
|
||||
if(step>bound)
|
||||
{
|
||||
std::cout << "[deviation_next.cpp][DeviationNext]: step is higher than bound, " << step << " is tranformed to ";
|
||||
step = bound / 2;
|
||||
std::cout << step << "." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviationNext::operator () (Deviation & _move, const Affectation & _affectation)
|
||||
{
|
||||
Affectation affectation(_affectation);
|
||||
|
||||
double deltaX1, deltaX2;
|
||||
|
||||
deltaX1=_move.first;
|
||||
deltaX2=_move.second;
|
||||
|
||||
//std::cout << "deltaX1 = " << deltaX1 << ", deltaX2 = " << deltaX2 << std::endl;
|
||||
|
||||
if( (deltaX1 >= bound) && (deltaX2 > bound) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(deltaX2 > bound)
|
||||
{
|
||||
deltaX1+=step;
|
||||
deltaX2=-bound;
|
||||
|
||||
_move.first=deltaX1;
|
||||
_move.second=deltaX2;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
deltaX2+=step;
|
||||
|
||||
_move.second=deltaX2;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* <deviation_next.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef deviation_next_h
|
||||
#define deviation_next_h
|
||||
|
||||
#include <moNextMove.h>
|
||||
#include "deviation.h"
|
||||
|
||||
class DeviationNext : public moNextMove <Deviation>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
DeviationNext (double _bound, double _step);
|
||||
|
||||
bool operator () (Deviation & _move, const Affectation & _affectation) ;
|
||||
|
||||
|
||||
private :
|
||||
|
||||
//! A bound for the search in the neighbourhood.
|
||||
double bound;
|
||||
|
||||
//! A step between two values.
|
||||
double step;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
41
trunk/paradiseo-old-mo/tutorial/examples/function/function
Normal file
41
trunk/paradiseo-old-mo/tutorial/examples/function/function
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* <function>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
#ifndef __function
|
||||
#define __function
|
||||
|
||||
#include "function.h"
|
||||
|
||||
#endif
|
||||
48
trunk/paradiseo-old-mo/tutorial/examples/function/function.h
Normal file
48
trunk/paradiseo-old-mo/tutorial/examples/function/function.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* <tsp.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __function_h
|
||||
#define __function_h
|
||||
|
||||
#include "affectation.h"
|
||||
#include "affectation_eval.h"
|
||||
#include "affectation_init.h"
|
||||
#include "deviation.h"
|
||||
#include "deviation_incr_eval.h"
|
||||
#include "deviation_init.h"
|
||||
#include "deviation_next.h"
|
||||
|
||||
#endif
|
||||
45
trunk/paradiseo-old-mo/tutorial/examples/tsp/CMakeLists.txt
Executable file
45
trunk/paradiseo-old-mo/tutorial/examples/tsp/CMakeLists.txt
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Define your target(s): just the tsp here
|
||||
######################################################################################
|
||||
|
||||
SET(TSP_LIB_OUTPUT_PATH ${TSP_BIN_DIR}/lib)
|
||||
SET(LIBRARY_OUTPUT_PATH ${TSP_LIB_OUTPUT_PATH})
|
||||
|
||||
SET (TSP_SOURCES graph.cpp
|
||||
route_init.cpp
|
||||
route_eval.cpp
|
||||
part_route_eval.cpp
|
||||
edge_xover.cpp
|
||||
order_xover.cpp
|
||||
route_valid.cpp
|
||||
partial_mapped_xover.cpp
|
||||
city_swap.cpp
|
||||
two_opt.cpp
|
||||
two_opt_init.cpp
|
||||
two_opt_next.cpp
|
||||
two_opt_incr_eval.cpp
|
||||
two_opt_tabu_list.cpp
|
||||
two_opt_rand.cpp)
|
||||
|
||||
ADD_LIBRARY(tsp STATIC ${TSP_SOURCES})
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 3) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(TSP_VERSION "${GLOBAL_VERSION}")
|
||||
SET_TARGET_PROPERTIES(tsp PROPERTIES VERSION "${TSP_VERSION}")
|
||||
######################################################################################
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
NAME: berlin52
|
||||
TYPE: TSP
|
||||
COMMENT: 52 locations in Berlin (Groetschel)
|
||||
DIMENSION: 52
|
||||
EDGE_WEIGHT_TYPE: EUC_2D
|
||||
NODE_COORD_SECTION
|
||||
1 565.0 575.0
|
||||
2 25.0 185.0
|
||||
3 345.0 750.0
|
||||
4 945.0 685.0
|
||||
5 845.0 655.0
|
||||
6 880.0 660.0
|
||||
7 25.0 230.0
|
||||
8 525.0 1000.0
|
||||
9 580.0 1175.0
|
||||
10 650.0 1130.0
|
||||
11 1605.0 620.0
|
||||
12 1220.0 580.0
|
||||
13 1465.0 200.0
|
||||
14 1530.0 5.0
|
||||
15 845.0 680.0
|
||||
16 725.0 370.0
|
||||
17 145.0 665.0
|
||||
18 415.0 635.0
|
||||
19 510.0 875.0
|
||||
20 560.0 365.0
|
||||
21 300.0 465.0
|
||||
22 520.0 585.0
|
||||
23 480.0 415.0
|
||||
24 835.0 625.0
|
||||
25 975.0 580.0
|
||||
26 1215.0 245.0
|
||||
27 1320.0 315.0
|
||||
28 1250.0 400.0
|
||||
29 660.0 180.0
|
||||
30 410.0 250.0
|
||||
31 420.0 555.0
|
||||
32 575.0 665.0
|
||||
33 1150.0 1160.0
|
||||
34 700.0 580.0
|
||||
35 685.0 595.0
|
||||
36 685.0 610.0
|
||||
37 770.0 610.0
|
||||
38 795.0 645.0
|
||||
39 720.0 635.0
|
||||
40 760.0 650.0
|
||||
41 475.0 960.0
|
||||
42 95.0 260.0
|
||||
43 875.0 920.0
|
||||
44 700.0 500.0
|
||||
45 555.0 815.0
|
||||
46 830.0 485.0
|
||||
47 1170.0 65.0
|
||||
48 830.0 610.0
|
||||
49 605.0 625.0
|
||||
50 595.0 360.0
|
||||
51 1340.0 725.0
|
||||
52 1740.0 245.0
|
||||
EOF
|
||||
|
||||
108
trunk/paradiseo-old-mo/tutorial/examples/tsp/benchs/eil101.tsp
Normal file
108
trunk/paradiseo-old-mo/tutorial/examples/tsp/benchs/eil101.tsp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
NAME: eil101
|
||||
TYPE: TSP
|
||||
COMMENT: 101-city problem (Christofides/Eilon)
|
||||
DIMENSION: 101
|
||||
EDGE_WEIGHT_TYPE: EUC_2D
|
||||
NODE_COORD_SECTION
|
||||
1 41 49
|
||||
2 35 17
|
||||
3 55 45
|
||||
4 55 20
|
||||
5 15 30
|
||||
6 25 30
|
||||
7 20 50
|
||||
8 10 43
|
||||
9 55 60
|
||||
10 30 60
|
||||
11 20 65
|
||||
12 50 35
|
||||
13 30 25
|
||||
14 15 10
|
||||
15 30 5
|
||||
16 10 20
|
||||
17 5 30
|
||||
18 20 40
|
||||
19 15 60
|
||||
20 45 65
|
||||
21 45 20
|
||||
22 45 10
|
||||
23 55 5
|
||||
24 65 35
|
||||
25 65 20
|
||||
26 45 30
|
||||
27 35 40
|
||||
28 41 37
|
||||
29 64 42
|
||||
30 40 60
|
||||
31 31 52
|
||||
32 35 69
|
||||
33 53 52
|
||||
34 65 55
|
||||
35 63 65
|
||||
36 2 60
|
||||
37 20 20
|
||||
38 5 5
|
||||
39 60 12
|
||||
40 40 25
|
||||
41 42 7
|
||||
42 24 12
|
||||
43 23 3
|
||||
44 11 14
|
||||
45 6 38
|
||||
46 2 48
|
||||
47 8 56
|
||||
48 13 52
|
||||
49 6 68
|
||||
50 47 47
|
||||
51 49 58
|
||||
52 27 43
|
||||
53 37 31
|
||||
54 57 29
|
||||
55 63 23
|
||||
56 53 12
|
||||
57 32 12
|
||||
58 36 26
|
||||
59 21 24
|
||||
60 17 34
|
||||
61 12 24
|
||||
62 24 58
|
||||
63 27 69
|
||||
64 15 77
|
||||
65 62 77
|
||||
66 49 73
|
||||
67 67 5
|
||||
68 56 39
|
||||
69 37 47
|
||||
70 37 56
|
||||
71 57 68
|
||||
72 47 16
|
||||
73 44 17
|
||||
74 46 13
|
||||
75 49 11
|
||||
76 49 42
|
||||
77 53 43
|
||||
78 61 52
|
||||
79 57 48
|
||||
80 56 37
|
||||
81 55 54
|
||||
82 15 47
|
||||
83 14 37
|
||||
84 11 31
|
||||
85 16 22
|
||||
86 4 18
|
||||
87 28 18
|
||||
88 26 52
|
||||
89 26 35
|
||||
90 31 67
|
||||
91 15 19
|
||||
92 22 22
|
||||
93 18 24
|
||||
94 26 27
|
||||
95 25 24
|
||||
96 22 27
|
||||
97 25 21
|
||||
98 19 21
|
||||
99 20 26
|
||||
100 18 18
|
||||
101 35 35
|
||||
EOF
|
||||
2399
trunk/paradiseo-old-mo/tutorial/examples/tsp/benchs/pr2392.tsp
Normal file
2399
trunk/paradiseo-old-mo/tutorial/examples/tsp/benchs/pr2392.tsp
Normal file
File diff suppressed because it is too large
Load diff
93
trunk/paradiseo-old-mo/tutorial/examples/tsp/benchs/readme
Normal file
93
trunk/paradiseo-old-mo/tutorial/examples/tsp/benchs/readme
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
All the instances in this directory come from the TSPLIB database. All the TSPLIB instances can be downloaded at this address:
|
||||
http://www.iwr.uni-heidelberg.de/groups/comopt/software/TSPLIB95/tsp/
|
||||
|
||||
The accepted format is:
|
||||
|
||||
NAME: instance_name
|
||||
TYPE: TSP
|
||||
COMMENT: comments about the instance
|
||||
DIMENSION: number of towns.
|
||||
EDGE_WEIGHT_TYPE: EUC_2D
|
||||
NODE_COORD_SECTION
|
||||
1 565.0 575.0
|
||||
2 25.0 185.0
|
||||
3 345.0 750.0
|
||||
.
|
||||
.
|
||||
.
|
||||
.
|
||||
.
|
||||
.
|
||||
EOF
|
||||
|
||||
Compatibility bugs with some TSPLIB instances (soon corrected):
|
||||
|
||||
==> some instances have a space after a section title, for example "NAME :" instead of "NAME:".
|
||||
==> several instances have the "COMMENT:" section before the "TYPE:" section.
|
||||
==> several section are not yet implemented ("DISPLAY_DATA_TYPE:", ...).
|
||||
|
||||
Already corrected bugs:
|
||||
|
||||
==> some instances have several lines with the keyword "COMMENTS:"
|
||||
|
||||
For instance, the Berlin52 instance:
|
||||
|
||||
NAME: berlin52
|
||||
TYPE: TSP
|
||||
COMMENT: 52 locations in Berlin (Groetschel)
|
||||
DIMENSION: 52
|
||||
EDGE_WEIGHT_TYPE: EUC_2D
|
||||
NODE_COORD_SECTION
|
||||
1 565.0 575.0
|
||||
2 25.0 185.0
|
||||
3 345.0 750.0
|
||||
4 945.0 685.0
|
||||
5 845.0 655.0
|
||||
6 880.0 660.0
|
||||
7 25.0 230.0
|
||||
8 525.0 1000.0
|
||||
9 580.0 1175.0
|
||||
10 650.0 1130.0
|
||||
11 1605.0 620.0
|
||||
12 1220.0 580.0
|
||||
13 1465.0 200.0
|
||||
14 1530.0 5.0
|
||||
15 845.0 680.0
|
||||
16 725.0 370.0
|
||||
17 145.0 665.0
|
||||
18 415.0 635.0
|
||||
19 510.0 875.0
|
||||
20 560.0 365.0
|
||||
21 300.0 465.0
|
||||
22 520.0 585.0
|
||||
23 480.0 415.0
|
||||
24 835.0 625.0
|
||||
25 975.0 580.0
|
||||
26 1215.0 245.0
|
||||
27 1320.0 315.0
|
||||
28 1250.0 400.0
|
||||
29 660.0 180.0
|
||||
30 410.0 250.0
|
||||
31 420.0 555.0
|
||||
32 575.0 665.0
|
||||
33 1150.0 1160.0
|
||||
34 700.0 580.0
|
||||
35 685.0 595.0
|
||||
36 685.0 610.0
|
||||
37 770.0 610.0
|
||||
38 795.0 645.0
|
||||
39 720.0 635.0
|
||||
40 760.0 650.0
|
||||
41 475.0 960.0
|
||||
42 95.0 260.0
|
||||
43 875.0 920.0
|
||||
44 700.0 500.0
|
||||
45 555.0 815.0
|
||||
46 830.0 485.0
|
||||
47 1170.0 65.0
|
||||
48 830.0 610.0
|
||||
49 605.0 625.0
|
||||
50 595.0 360.0
|
||||
51 1340.0 725.0
|
||||
52 1740.0 245.0
|
||||
EOF
|
||||
5922
trunk/paradiseo-old-mo/tutorial/examples/tsp/benchs/rl5915.tsp
Normal file
5922
trunk/paradiseo-old-mo/tutorial/examples/tsp/benchs/rl5915.tsp
Normal file
File diff suppressed because it is too large
Load diff
13519
trunk/paradiseo-old-mo/tutorial/examples/tsp/benchs/usa13509.tsp
Normal file
13519
trunk/paradiseo-old-mo/tutorial/examples/tsp/benchs/usa13509.tsp
Normal file
File diff suppressed because it is too large
Load diff
50
trunk/paradiseo-old-mo/tutorial/examples/tsp/city_swap.cpp
Normal file
50
trunk/paradiseo-old-mo/tutorial/examples/tsp/city_swap.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* <city_swap.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "city_swap.h"
|
||||
|
||||
bool CitySwap :: operator () (Route & __route)
|
||||
{
|
||||
|
||||
std :: swap (__route [rng.random (__route.size ())],
|
||||
__route [rng.random (__route.size ())]) ;
|
||||
|
||||
__route.invalidate () ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
55
trunk/paradiseo-old-mo/tutorial/examples/tsp/city_swap.h
Normal file
55
trunk/paradiseo-old-mo/tutorial/examples/tsp/city_swap.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* <city_swap.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef city_swap_h
|
||||
#define city_swap_h
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Its swaps two vertices
|
||||
randomly choosen */
|
||||
class CitySwap : public eoMonOp <Route>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
bool operator () (Route & __route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
169
trunk/paradiseo-old-mo/tutorial/examples/tsp/edge_xover.cpp
Normal file
169
trunk/paradiseo-old-mo/tutorial/examples/tsp/edge_xover.cpp
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* <edge_xover.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "edge_xover.h"
|
||||
#include "route_valid.h"
|
||||
|
||||
#define MAXINT 1000000
|
||||
|
||||
void
|
||||
EdgeXover :: build_map (const Route & __par1, const Route & __par2)
|
||||
{
|
||||
|
||||
unsigned int len = __par1.size () ;
|
||||
|
||||
/* Initialization */
|
||||
_map.clear () ;
|
||||
_map.resize (len) ;
|
||||
|
||||
for (unsigned int i = 0 ; i < len ; i ++)
|
||||
{
|
||||
_map [__par1 [i]].insert (__par1 [(i + 1) % len]) ;
|
||||
_map [__par2 [i]].insert (__par2 [(i + 1) % len]) ;
|
||||
_map [__par1 [i]].insert (__par1 [(i - 1 + len) % len]) ;
|
||||
_map [__par2 [i]].insert (__par2 [(i - 1 + len) % len]) ;
|
||||
}
|
||||
|
||||
visited.clear () ;
|
||||
visited.resize (len, false) ;
|
||||
}
|
||||
|
||||
void
|
||||
EdgeXover :: remove_entry (unsigned int __vertex, std :: vector <std :: set <unsigned int> > & __map)
|
||||
{
|
||||
|
||||
std :: set <unsigned int> & neigh = __map [__vertex] ;
|
||||
|
||||
for (std :: set <unsigned int> :: iterator it = neigh.begin () ; it != neigh.end () ; it ++)
|
||||
{
|
||||
__map [* it].erase (__vertex) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
EdgeXover :: add_vertex (unsigned int __vertex, Route & __child)
|
||||
{
|
||||
visited [__vertex] = true ;
|
||||
__child.push_back (__vertex) ;
|
||||
remove_entry (__vertex, _map) ; /* Removing entries */
|
||||
}
|
||||
|
||||
void
|
||||
EdgeXover :: cross (const Route & __par1, const Route & __par2, Route & __child)
|
||||
{
|
||||
|
||||
build_map (__par1, __par2) ;
|
||||
|
||||
unsigned int len = __par1.size () ;
|
||||
|
||||
/* Go ! */
|
||||
__child.clear () ;
|
||||
|
||||
unsigned int cur_vertex = rng.random (len) ;
|
||||
|
||||
add_vertex (cur_vertex, __child) ;
|
||||
|
||||
for (unsigned int i = 1 ; i < len ; i ++)
|
||||
{
|
||||
|
||||
unsigned int len_min_entry = MAXINT ;
|
||||
|
||||
std :: set <unsigned int> & neigh = _map [cur_vertex] ;
|
||||
|
||||
for (std :: set <unsigned int> :: iterator it = neigh.begin () ; it != neigh.end () ; it ++)
|
||||
{
|
||||
unsigned int l = _map [* it].size () ;
|
||||
if (len_min_entry > l)
|
||||
{
|
||||
len_min_entry = l ;
|
||||
}
|
||||
}
|
||||
|
||||
std :: vector <unsigned int> cand ; /* Candidates */
|
||||
|
||||
for (std :: set <unsigned> :: iterator it = neigh.begin () ; it != neigh.end () ; it ++)
|
||||
{
|
||||
unsigned int l = _map [* it].size () ;
|
||||
if (len_min_entry == l)
|
||||
{
|
||||
cand.push_back (* it) ;
|
||||
}
|
||||
}
|
||||
|
||||
if (! cand.size ())
|
||||
{
|
||||
|
||||
/* Oh no ! Implicit mutation */
|
||||
for (unsigned int j = 0 ; j < len ; j ++)
|
||||
{
|
||||
if (! visited [j])
|
||||
{
|
||||
cand.push_back (j) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_vertex = cand [rng.random (cand.size ())] ;
|
||||
|
||||
add_vertex (cur_vertex, __child) ;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
EdgeXover :: operator () (Route & __route1, Route & __route2)
|
||||
{
|
||||
|
||||
// Init. copy
|
||||
Route par [2] ;
|
||||
par [0] = __route1 ;
|
||||
par [1] = __route2 ;
|
||||
|
||||
cross (par [0], par [1], __route1) ;
|
||||
cross (par [1], par [0], __route2) ;
|
||||
|
||||
assert (valid (__route1)) ;
|
||||
assert (valid (__route2)) ;
|
||||
|
||||
__route1.invalidate () ;
|
||||
__route2.invalidate () ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
72
trunk/paradiseo-old-mo/tutorial/examples/tsp/edge_xover.h
Normal file
72
trunk/paradiseo-old-mo/tutorial/examples/tsp/edge_xover.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* <edge_xover.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef edge_xover_h
|
||||
#define edge_xover_h
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Edge Crossover */
|
||||
class EdgeXover : public eoQuadOp <Route>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
bool operator () (Route & __route1, Route & __route2) ;
|
||||
|
||||
private :
|
||||
|
||||
void cross (const Route & __par1, const Route & __par2, Route & __child) ; /* Binary */
|
||||
|
||||
void remove_entry (unsigned int __vertex, std :: vector <std :: set <unsigned> > & __map) ;
|
||||
/* Updating the map of entries */
|
||||
|
||||
void build_map (const Route & __par1, const Route & __par2) ;
|
||||
|
||||
void add_vertex (unsigned int __vertex, Route & __child) ;
|
||||
|
||||
std :: vector <std :: set <unsigned int> > _map ; /* The handled map */
|
||||
|
||||
std :: vector <bool> visited ; /* Vertices that are already visited */
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
207
trunk/paradiseo-old-mo/tutorial/examples/tsp/graph.cpp
Normal file
207
trunk/paradiseo-old-mo/tutorial/examples/tsp/graph.cpp
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* <graph.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "graph.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
namespace Graph
|
||||
{
|
||||
|
||||
static std :: vector <std :: pair <double, double> > vectCoord ; // Coordinates
|
||||
|
||||
static std :: vector <std :: vector <unsigned int> > dist ; // Distances Mat.
|
||||
|
||||
unsigned size ()
|
||||
{
|
||||
return dist.size () ;
|
||||
}
|
||||
|
||||
void computeDistances ()
|
||||
{
|
||||
|
||||
// Dim.
|
||||
unsigned int numCities = vectCoord.size () ;
|
||||
dist.resize (numCities) ;
|
||||
for (unsigned int i = 0 ; i < dist.size () ; i ++)
|
||||
{
|
||||
dist [i].resize (numCities) ;
|
||||
}
|
||||
|
||||
// Computations.
|
||||
for (unsigned int i = 0 ; i < dist.size () ; i ++)
|
||||
{
|
||||
for (unsigned int j = i + 1 ; j < dist.size () ; j ++)
|
||||
{
|
||||
double distX = (double)(vectCoord [i].first - vectCoord [j].first) ;
|
||||
double distY = (double)(vectCoord [i].second - vectCoord [j].second) ;
|
||||
dist [i] [j] = dist [j] [i] = (unsigned int) (sqrt ((float) (distX * distX + distY * distY)) + 0.5) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void load (const char * _fileName)
|
||||
{
|
||||
unsigned int i, dimension;
|
||||
|
||||
std::string string_read, buffer;
|
||||
|
||||
std :: ifstream file (_fileName) ;
|
||||
|
||||
cout << endl << "\tLoading [" << _fileName << "]" << endl << endl;
|
||||
|
||||
if( file.is_open() )
|
||||
{
|
||||
// Read NAME:
|
||||
file >> string_read;
|
||||
if (string_read.compare("NAME:")!=0)
|
||||
{
|
||||
cout << "ERROR: \'NAME:\' espected, \'" << string_read << "\' found" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Read instance name
|
||||
file >> string_read;
|
||||
cout << "\t\tInstance Name = " << string_read << endl;
|
||||
// Read TYPE:
|
||||
file >> string_read;
|
||||
if (string_read.compare("TYPE:")!=0)
|
||||
{
|
||||
cout << "ERROR: \'TYPE:\' espected, \'" << string_read << "\' found" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Read instance type;
|
||||
file >> string_read;
|
||||
cout << "\t\tInstance type = " << string_read << endl;
|
||||
if (string_read.compare("TSP")!=0)
|
||||
{
|
||||
cout << "ERROR: only TSP type instance can be loaded" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Read COMMENT:
|
||||
file >> string_read;
|
||||
if (string_read.compare("COMMENT:")!=0)
|
||||
{
|
||||
cout << "ERROR: \'COMMENT:\' espected, \'" << string_read << "\' found" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Read comments
|
||||
cout << "\t\tInstance comments = ";
|
||||
file >> string_read;
|
||||
buffer = string_read+"_first";
|
||||
while((string_read.compare("DIMENSION:")!=0) && (string_read.compare(buffer)!=0))
|
||||
{
|
||||
if(string_read.compare("COMMENT:")!=0)
|
||||
{
|
||||
cout << string_read << " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << endl << "\t ";
|
||||
}
|
||||
buffer = string_read;
|
||||
file >> string_read;
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
|
||||
// Read dimension;
|
||||
file >> dimension ;
|
||||
cout << "\t\tInstance dimension = " << dimension << endl;
|
||||
vectCoord.resize (dimension) ;
|
||||
|
||||
// Read EDGE_WEIGHT_TYPE
|
||||
file >> string_read;
|
||||
if (string_read.compare("EDGE_WEIGHT_TYPE:")!=0)
|
||||
{
|
||||
cout << "ERROR: \'EDGE_WEIGHT_TYPE:\' espected, \'" << string_read << "\' found" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Read edge weight type
|
||||
file >> string_read;
|
||||
cout << "\t\tInstance edge weight type = " << string_read << endl;
|
||||
if (string_read.compare("EUC_2D")!=0)
|
||||
{
|
||||
cout << "ERROR: only EUC_2D edge weight type instance can be loaded" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Read NODE_COORD_SECTION
|
||||
file >> string_read;
|
||||
if (string_read.compare("NODE_COORD_SECTION")!=0)
|
||||
{
|
||||
cout << "ERROR: \'NODE_COORD_SECTION\' espected, \'" << string_read << "\' found" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Read coordonates.
|
||||
for(i=0;i<dimension;i++)
|
||||
{
|
||||
// Read index
|
||||
file >> string_read;
|
||||
//Read Coordinate
|
||||
file >> vectCoord [i].first >> vectCoord [i].second ;
|
||||
}
|
||||
|
||||
// Read EOF
|
||||
file >> string_read;
|
||||
if(string_read.compare("EOF")!=0)
|
||||
{
|
||||
cout << "ERROR: \'EOF\' espected, \'" << string_read << "\' found" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
|
||||
file.close () ;
|
||||
|
||||
computeDistances () ;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << _fileName << " does not exist !!!" << endl ;
|
||||
exit(EXIT_FAILURE) ;
|
||||
}
|
||||
}
|
||||
|
||||
float distance (unsigned int _from, unsigned int _to)
|
||||
{
|
||||
return (float)(dist [_from] [_to]) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
61
trunk/paradiseo-old-mo/tutorial/examples/tsp/graph.h
Normal file
61
trunk/paradiseo-old-mo/tutorial/examples/tsp/graph.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* <graph.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef graph_h
|
||||
#define graph_h
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
namespace Graph
|
||||
{
|
||||
void load (const char * _file_name) ;
|
||||
/* Loading cities
|
||||
(expressed by their coordinates)
|
||||
from the given file name */
|
||||
|
||||
float distance (unsigned int _from, unsigned int _to) ;
|
||||
|
||||
unsigned int size () ; // How many cities ?
|
||||
}
|
||||
|
||||
#endif
|
||||
50
trunk/paradiseo-old-mo/tutorial/examples/tsp/mix.h
Normal file
50
trunk/paradiseo-old-mo/tutorial/examples/tsp/mix.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* <mix.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef mix_h
|
||||
#define mix_h
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
template <class T> void mix (std :: vector <T> & __vect)
|
||||
{
|
||||
for (unsigned int i = 0 ; i < __vect.size () ; i ++)
|
||||
{
|
||||
std :: swap (__vect [i], __vect [rng.random (__vect.size ())]) ;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
119
trunk/paradiseo-old-mo/tutorial/examples/tsp/order_xover.cpp
Normal file
119
trunk/paradiseo-old-mo/tutorial/examples/tsp/order_xover.cpp
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* <order_xover.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "order_xover.h"
|
||||
#include "route_valid.h"
|
||||
|
||||
void OrderXover :: cross (const Route & __par1, const Route & __par2, Route & __child)
|
||||
{
|
||||
|
||||
unsigned int cut = rng.random (__par1.size ()) ;
|
||||
|
||||
/* To store vertices that have
|
||||
already been crossed */
|
||||
std::vector<bool> v;
|
||||
v.resize(__par1.size());
|
||||
|
||||
for (unsigned int i = 0 ; i < __par1.size () ; i ++)
|
||||
{
|
||||
v [i] = false ;
|
||||
}
|
||||
|
||||
/* Copy of the left partial
|
||||
route of the first parent */
|
||||
for (unsigned int i = 0 ; i < cut ; i ++)
|
||||
{
|
||||
__child [i] = __par1 [i] ;
|
||||
v [__par1 [i]] = true ;
|
||||
}
|
||||
|
||||
/* Searching the vertex of the second path, that ended
|
||||
the previous first one */
|
||||
unsigned int from = 0 ;
|
||||
for (unsigned int i = 0 ; i < __par2.size () ; i ++)
|
||||
{
|
||||
if (__par2 [i] == __child [cut - 1])
|
||||
{
|
||||
from = i ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Selecting a direction
|
||||
Left or Right */
|
||||
char direct = rng.flip () ? 1 : -1 ;
|
||||
|
||||
/* Copy of the left vertices from
|
||||
the second parent path */
|
||||
unsigned int l = cut ;
|
||||
|
||||
for (unsigned int i = 0 ; i < __par2.size () ; i ++)
|
||||
{
|
||||
unsigned int bidule /* :-) */ = (direct * i + from + __par2.size ()) % __par2.size () ;
|
||||
if (! v [__par2 [bidule]])
|
||||
{
|
||||
__child [l ++] = __par2 [bidule] ;
|
||||
v [__par2 [bidule]] = true ;
|
||||
}
|
||||
}
|
||||
|
||||
v.clear();
|
||||
}
|
||||
|
||||
bool OrderXover :: operator () (Route & __route1, Route & __route2)
|
||||
{
|
||||
|
||||
// Init. copy
|
||||
Route par [2] ;
|
||||
par [0] = __route1 ;
|
||||
par [1] = __route2 ;
|
||||
|
||||
cross (par [0], par [1], __route1) ;
|
||||
cross (par [1], par [0], __route2) ;
|
||||
|
||||
assert (valid (__route1)) ;
|
||||
assert (valid (__route2)) ;
|
||||
|
||||
__route1.invalidate () ;
|
||||
__route2.invalidate () ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
57
trunk/paradiseo-old-mo/tutorial/examples/tsp/order_xover.h
Normal file
57
trunk/paradiseo-old-mo/tutorial/examples/tsp/order_xover.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* <order_xover.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef order_xover_h
|
||||
#define order_xover_h
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Order Crossover */
|
||||
class OrderXover : public eoQuadOp <Route>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
bool operator () (Route & __route1, Route & __route2) ;
|
||||
|
||||
private :
|
||||
|
||||
void cross (const Route & __par1, const Route & __par2, Route & __child) ;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* <part_route_eval.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "part_route_eval.h"
|
||||
#include "graph.h"
|
||||
|
||||
PartRouteEval :: PartRouteEval (float __from, float __to) : from (__from), to (__to)
|
||||
{}
|
||||
|
||||
void PartRouteEval :: operator () (Route & __route)
|
||||
{
|
||||
float len = 0 ;
|
||||
|
||||
for (unsigned int i = (unsigned int) (__route.size () * from) ; i < (unsigned int ) (__route.size () * to) ; i ++)
|
||||
{
|
||||
len += Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
|
||||
}
|
||||
|
||||
__route.fitness (len) ;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* <part_route_eval.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef part_route_eval_h
|
||||
#define part_route_eval_h
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Route Evaluator */
|
||||
class PartRouteEval : public eoEvalFunc <Route>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
/** Constructor */
|
||||
PartRouteEval (float __from, float __to) ;
|
||||
|
||||
void operator () (Route & __route) ;
|
||||
|
||||
private :
|
||||
|
||||
float from, to ;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* <part_two_opt_init.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "part_two_opt_init.h"
|
||||
|
||||
void PartTwoOptInit :: operator () (TwoOpt & __move, const Route & __route)
|
||||
{
|
||||
__move.first = rng.random (__route.size () - 6) ;
|
||||
__move.second = __move.first + 2 ;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* <part_two_opt_init.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef part_two_opt_init_h
|
||||
#define part_two_opt_init_h
|
||||
|
||||
#include <moMoveInit.h>
|
||||
|
||||
#include "two_opt.h"
|
||||
|
||||
/** It sets the first couple of edges */
|
||||
class PartTwoOptInit : public moMoveInit <TwoOpt>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
void operator () (TwoOpt & __move, const Route & __route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* <part_two_opt_next.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "part_two_opt_next.h"
|
||||
#include "graph.h"
|
||||
|
||||
bool PartTwoOptNext :: operator () (TwoOpt & __move, const Route & __route)
|
||||
{
|
||||
if (__move.first == Graph :: size () - 4 && __move.second == __move.first + 2)
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
{
|
||||
__move.second ++ ;
|
||||
if (__move.second == Graph :: size () - 1)
|
||||
{
|
||||
__move.first ++ ;
|
||||
__move.second = __move.first + 2 ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* <part_two_opt_next.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef part_two_opt_next_h
|
||||
#define part_two_opt_next_h
|
||||
|
||||
#include <moNextMove.h>
|
||||
#include "two_opt.h"
|
||||
|
||||
/** It updates a couple of edges */
|
||||
class PartTwoOptNext : public moNextMove <TwoOpt>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
bool operator () (TwoOpt & __move, const Route & __route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* <partial_mapped_xover.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "partial_mapped_xover.h"
|
||||
#include "route_valid.h"
|
||||
#include "mix.h"
|
||||
|
||||
void PartialMappedXover :: repair (Route & __route, unsigned __cut1, unsigned __cut2)
|
||||
{
|
||||
|
||||
std::vector<unsigned int> v; // Number of times a cities are visited ...
|
||||
|
||||
v.resize(__route.size ());
|
||||
|
||||
for (unsigned int i = 0 ; i < __route.size () ; i ++)
|
||||
{
|
||||
v [i] = 0 ;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0 ; i < __route.size () ; i ++)
|
||||
{
|
||||
v [__route [i]] ++ ;
|
||||
}
|
||||
|
||||
std :: vector <unsigned int> vert ;
|
||||
|
||||
for (unsigned int i = 0 ; i < __route.size () ; i ++)
|
||||
{
|
||||
if (! v [i])
|
||||
{
|
||||
vert.push_back (i) ;
|
||||
}
|
||||
}
|
||||
|
||||
mix (vert) ;
|
||||
|
||||
for (unsigned int i = 0 ; i < __route.size () ; i ++)
|
||||
{
|
||||
if (i < __cut1 || i >= __cut2)
|
||||
{
|
||||
if (v [__route [i]] > 1)
|
||||
{
|
||||
__route [i] = vert.back () ;
|
||||
vert.pop_back () ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
v.clear();
|
||||
}
|
||||
|
||||
bool PartialMappedXover :: operator () (Route & __route1, Route & __route2)
|
||||
{
|
||||
unsigned int cut1 = rng.random (__route1.size ()), cut2 = rng.random (__route2.size ()) ;
|
||||
|
||||
if (cut2 < cut1)
|
||||
{
|
||||
std :: swap (cut1, cut2) ;
|
||||
}
|
||||
|
||||
// Between the cuts
|
||||
for (unsigned int i = cut1 ; i < cut2 ; i ++)
|
||||
{
|
||||
std :: swap (__route1 [i], __route2 [i]) ;
|
||||
}
|
||||
|
||||
// Outside the cuts
|
||||
repair (__route1, cut1, cut2) ;
|
||||
repair (__route2, cut1, cut2) ;
|
||||
|
||||
// Debug
|
||||
assert (valid (__route1)) ;
|
||||
assert (valid (__route2)) ;
|
||||
|
||||
__route1.invalidate () ;
|
||||
__route2.invalidate () ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* <partial_mapped_xover.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef partial_mapped_xover_h
|
||||
#define partial_mapped_xover_h
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Partial Mapped Crossover */
|
||||
class PartialMappedXover : public eoQuadOp <Route>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
bool operator () (Route & __route1, Route & __route2) ;
|
||||
|
||||
private :
|
||||
|
||||
void repair (Route & __route, unsigned __cut1, unsigned __cut2) ;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
48
trunk/paradiseo-old-mo/tutorial/examples/tsp/route.h
Normal file
48
trunk/paradiseo-old-mo/tutorial/examples/tsp/route.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* <route.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef route_h
|
||||
#define route_h
|
||||
|
||||
#include <eoVector.h>
|
||||
#include <eoScalarFitness.h>
|
||||
|
||||
// A float that has to be minimized.
|
||||
typedef eoScalarFitness< float, std::greater<float> > tspFitness ;
|
||||
|
||||
typedef eoVector <tspFitness, unsigned int> Route ; // [Fitness (length), Gene (city)]
|
||||
|
||||
#endif
|
||||
51
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_eval.cpp
Normal file
51
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_eval.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* <route_eval.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "route_eval.h"
|
||||
#include "graph.h"
|
||||
|
||||
void RouteEval :: operator () (Route & __route)
|
||||
{
|
||||
|
||||
float len = 0.0 ;
|
||||
|
||||
for (unsigned int i = 0 ; i < Graph :: size () ; i ++)
|
||||
{
|
||||
len += Graph :: distance (__route [i], __route [(i + 1) % Graph :: size ()]) ;
|
||||
}
|
||||
|
||||
__route.fitness (len) ;
|
||||
}
|
||||
55
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_eval.h
Normal file
55
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_eval.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* <route_eval.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef route_eval_h
|
||||
#define route_eval_h
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
/** Route Evaluator */
|
||||
class RouteEval : public eoEvalFunc <Route>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
void operator () (Route & __route) ;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
63
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_init.cpp
Normal file
63
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_init.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* <route_init.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "route_init.h"
|
||||
#include "graph.h"
|
||||
|
||||
void RouteInit :: operator () (Route & __route)
|
||||
{
|
||||
|
||||
// Init.
|
||||
__route.clear () ;
|
||||
for (unsigned int i = 0 ; i < Graph :: size () ; i ++)
|
||||
{
|
||||
__route.push_back (i) ;
|
||||
}
|
||||
|
||||
// Swap. cities
|
||||
|
||||
for (unsigned int i = 0 ; i < Graph :: size () ; i ++)
|
||||
{
|
||||
//unsigned int j = rng.random (Graph :: size ()) ;
|
||||
|
||||
unsigned int j = (unsigned int) (Graph :: size () * (rand () / (RAND_MAX + 1.0))) ;
|
||||
unsigned int city = __route [i] ;
|
||||
__route [i] = __route [j] ;
|
||||
__route [j] = city ;
|
||||
}
|
||||
}
|
||||
53
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_init.h
Normal file
53
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_init.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* <route_init.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef route_init_h
|
||||
#define route_init_h
|
||||
|
||||
#include <eoInit.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
class RouteInit : public eoInit <Route>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
void operator () (Route & __route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
68
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_valid.cpp
Normal file
68
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_valid.cpp
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* <route_valid.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "route_valid.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
bool valid (Route & __route)
|
||||
{
|
||||
|
||||
std::vector<unsigned int> t;
|
||||
t.resize(__route.size());
|
||||
|
||||
for (unsigned int i = 0 ; i < __route.size () ; i ++)
|
||||
{
|
||||
t [i] = 0 ;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0 ; i < __route.size () ; i ++)
|
||||
{
|
||||
t [__route [i]] ++ ;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0 ; i < __route.size () ; i ++)
|
||||
{
|
||||
if (t [i] != 1)
|
||||
{
|
||||
t.clear();
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
t.clear();
|
||||
return true ; // OK.
|
||||
}
|
||||
44
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_valid.h
Normal file
44
trunk/paradiseo-old-mo/tutorial/examples/tsp/route_valid.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* <route_valid.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef route_valid_h
|
||||
#define route_valid_h
|
||||
|
||||
#include "route.h"
|
||||
|
||||
bool valid (Route & __route) ;
|
||||
|
||||
#endif
|
||||
41
trunk/paradiseo-old-mo/tutorial/examples/tsp/tsp
Normal file
41
trunk/paradiseo-old-mo/tutorial/examples/tsp/tsp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* <tsp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
#ifndef __tsp
|
||||
#define __tsp
|
||||
|
||||
#include "tsp.h"
|
||||
|
||||
#endif
|
||||
60
trunk/paradiseo-old-mo/tutorial/examples/tsp/tsp.h
Normal file
60
trunk/paradiseo-old-mo/tutorial/examples/tsp/tsp.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* <tsp.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __tsp_h
|
||||
#define __tsp_h
|
||||
|
||||
#include "city_swap.h"
|
||||
#include "edge_xover.h"
|
||||
#include "graph.h"
|
||||
#include "mix.h"
|
||||
#include "order_xover.h"
|
||||
#include "partial_mapped_xover.h"
|
||||
#include "part_route_eval.h"
|
||||
#include "part_two_opt_init.h"
|
||||
#include "part_two_opt_next.h"
|
||||
#include "route_eval.h"
|
||||
#include "route.h"
|
||||
#include "route_init.h"
|
||||
#include "route_valid.h"
|
||||
#include "two_opt.h"
|
||||
#include "two_opt_incr_eval.h"
|
||||
#include "two_opt_init.h"
|
||||
#include "two_opt_next.h"
|
||||
#include "two_opt_rand.h"
|
||||
#include "two_opt_tabu_list.h"
|
||||
|
||||
#endif
|
||||
72
trunk/paradiseo-old-mo/tutorial/examples/tsp/two_opt.cpp
Normal file
72
trunk/paradiseo-old-mo/tutorial/examples/tsp/two_opt.cpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* <two_opt.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "two_opt.h"
|
||||
|
||||
TwoOpt TwoOpt :: operator ! () const
|
||||
{
|
||||
TwoOpt move = * this ;
|
||||
std :: swap (move.first, move.second) ;
|
||||
|
||||
return move ;
|
||||
}
|
||||
|
||||
void TwoOpt :: operator () (Route & __route)
|
||||
{
|
||||
|
||||
std :: vector <unsigned int> seq_cities ;
|
||||
|
||||
for (unsigned int i = second ; i > first ; i --)
|
||||
{
|
||||
seq_cities.push_back (__route [i]) ;
|
||||
}
|
||||
|
||||
unsigned int j = 0 ;
|
||||
for (unsigned int i = first + 1 ; i < second + 1 ; i ++)
|
||||
{
|
||||
__route [i] = seq_cities [j ++] ;
|
||||
}
|
||||
}
|
||||
|
||||
void TwoOpt :: readFrom (std :: istream & __is)
|
||||
{
|
||||
__is >> first >> second ;
|
||||
}
|
||||
|
||||
void TwoOpt :: printOn (std :: ostream & __os) const
|
||||
{
|
||||
__os << first << ' ' << second ;
|
||||
}
|
||||
61
trunk/paradiseo-old-mo/tutorial/examples/tsp/two_opt.h
Normal file
61
trunk/paradiseo-old-mo/tutorial/examples/tsp/two_opt.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* <two_opt.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef two_opt_h
|
||||
#define two_opt_h
|
||||
|
||||
#include <eoPersistent.h>
|
||||
|
||||
#include <utility>
|
||||
#include <moMove.h>
|
||||
|
||||
#include "route.h"
|
||||
|
||||
class TwoOpt : public moMove <Route>, public std :: pair <unsigned, unsigned>, public eoPersistent
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
TwoOpt operator ! () const ;
|
||||
|
||||
void operator () (Route & __route) ;
|
||||
|
||||
void readFrom (std :: istream & __is) ;
|
||||
|
||||
void printOn (std :: ostream & __os) const ;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* <two_opt_incr_eval.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "two_opt_incr_eval.h"
|
||||
#include "graph.h"
|
||||
|
||||
tspFitness TwoOptIncrEval :: operator () (const TwoOpt & __move, const Route & __route)
|
||||
{
|
||||
// From
|
||||
unsigned int v1 = __route [__move.first], v1_next = __route [__move.first + 1] ;
|
||||
|
||||
// To
|
||||
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) ;
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* <two_opt_incr_eval.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef two_optincr_eval_h
|
||||
#define two_optincr_eval_h
|
||||
|
||||
#include <moMoveIncrEval.h>
|
||||
#include "two_opt.h"
|
||||
|
||||
class TwoOptIncrEval : public moMoveIncrEval <TwoOpt>
|
||||
{
|
||||
public :
|
||||
|
||||
tspFitness operator () (const TwoOpt & __move, const Route & __route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* <two_opt_init.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "two_opt_init.h"
|
||||
|
||||
void TwoOptInit :: operator () (TwoOpt & _move, const Route & _route)
|
||||
{
|
||||
Route route=_route;
|
||||
|
||||
_move.first = 0 ;
|
||||
_move.second = 2 ;
|
||||
}
|
||||
54
trunk/paradiseo-old-mo/tutorial/examples/tsp/two_opt_init.h
Normal file
54
trunk/paradiseo-old-mo/tutorial/examples/tsp/two_opt_init.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* <two_opt_init.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef two_opt_init_h
|
||||
#define two_opt_init_h
|
||||
|
||||
#include <moMoveInit.h>
|
||||
|
||||
#include "two_opt.h"
|
||||
|
||||
/** It sets the first couple of edges */
|
||||
class TwoOptInit : public moMoveInit <TwoOpt>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
void operator () (TwoOpt & _move, const Route & _route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* <two_opt_next.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "two_opt_next.h"
|
||||
#include "graph.h"
|
||||
|
||||
bool TwoOptNext :: operator () (TwoOpt & _move, const Route & _route)
|
||||
{
|
||||
Route route=_route;
|
||||
|
||||
if (_move.first == Graph :: size () - 4 && _move.second == _move.first + 2)
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
{
|
||||
_move.second ++ ;
|
||||
if (_move.second == Graph :: size () - 1)
|
||||
{
|
||||
_move.first ++ ;
|
||||
_move.second = _move.first + 2 ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
53
trunk/paradiseo-old-mo/tutorial/examples/tsp/two_opt_next.h
Normal file
53
trunk/paradiseo-old-mo/tutorial/examples/tsp/two_opt_next.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* <two_opt_next.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef two_opt_next_h
|
||||
#define two_opt_next_h
|
||||
|
||||
#include <moNextMove.h>
|
||||
#include "two_opt.h"
|
||||
|
||||
/** It updates a couple of edges */
|
||||
class TwoOptNext : public moNextMove <TwoOpt>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
bool operator () (TwoOpt & _move, const Route & _route) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* <two_opt_rand.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "two_opt_rand.h"
|
||||
#include "graph.h"
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
void TwoOptRand :: operator () (TwoOpt & __move)
|
||||
{
|
||||
__move.first = rng.random (Graph :: size () - 3) ;
|
||||
__move.second = __move.first + 2 + rng.random (Graph :: size () - __move.first - 3) ;
|
||||
}
|
||||
53
trunk/paradiseo-old-mo/tutorial/examples/tsp/two_opt_rand.h
Normal file
53
trunk/paradiseo-old-mo/tutorial/examples/tsp/two_opt_rand.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* <two_opt_rand.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef two_opt_rand_h
|
||||
#define two_opt_rand_h
|
||||
|
||||
#include <moRandMove.h>
|
||||
|
||||
#include "two_opt.h"
|
||||
|
||||
class TwoOptRand : public moRandMove <TwoOpt>
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
void operator () (TwoOpt & __move) ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* <two_opt_tabu_list.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include "two_opt_tabu_list.h"
|
||||
#include "graph.h"
|
||||
|
||||
#define TABU_LENGTH 10
|
||||
|
||||
void
|
||||
TwoOptTabuList :: init ()
|
||||
{
|
||||
// Size (eventually)
|
||||
tabu_span.resize (Graph :: size ()) ;
|
||||
for (unsigned int i = 0 ; i < tabu_span.size () ; i ++)
|
||||
{
|
||||
tabu_span [i].resize (Graph :: size ()) ;
|
||||
}
|
||||
|
||||
// Clear
|
||||
for (unsigned int i = 0 ; i < tabu_span.size () ; i ++)
|
||||
{
|
||||
for (unsigned int j = 0 ; j < tabu_span [i].size () ; j ++)
|
||||
{
|
||||
tabu_span [i] [j] = 0 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
TwoOptTabuList :: operator () (const TwoOpt & _move, const Route & _route)
|
||||
{
|
||||
Route route=_route;
|
||||
|
||||
return tabu_span [_move.first] [_move.second] > 0 ;
|
||||
}
|
||||
|
||||
void
|
||||
TwoOptTabuList :: add (const TwoOpt & _move, const Route & _route)
|
||||
{
|
||||
Route route=_route;
|
||||
|
||||
tabu_span [_move.first] [_move.second] = tabu_span [_move.second] [_move.first] = TABU_LENGTH ;
|
||||
}
|
||||
|
||||
void
|
||||
TwoOptTabuList :: update ()
|
||||
{
|
||||
unsigned int i,j;
|
||||
|
||||
for (i = 0 ; i < tabu_span.size () ; i ++)
|
||||
{
|
||||
for (j = 0 ; j < tabu_span [i].size () ; j ++)
|
||||
{
|
||||
if ( tabu_span [i] [j] > 0 )
|
||||
{
|
||||
tabu_span [i] [j] -- ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* <two_opt_tabu_list.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, 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,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef two_opt_tabu_list_h
|
||||
#define two_opt_tabu_list_h
|
||||
|
||||
#include <moTabuList.h>
|
||||
#include "two_opt.h"
|
||||
#include "route.h"
|
||||
|
||||
/** The table of tabu movements, i.e. forbidden edges */
|
||||
class TwoOptTabuList : public moTabuList <TwoOpt>
|
||||
{
|
||||
public :
|
||||
|
||||
bool operator () (const TwoOpt & _move, const Route & _route) ;
|
||||
|
||||
void add (const TwoOpt & _move, const Route & _route) ;
|
||||
|
||||
void update () ;
|
||||
|
||||
void init () ;
|
||||
|
||||
private :
|
||||
|
||||
std :: vector <std :: vector <unsigned> > tabu_span ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue