moved utilities and contribution in branchez

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2183 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2011-03-11 13:58:48 +00:00
commit 8280cf082b
103 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,147 @@
######################################################################################
### 1) Project properties
######################################################################################
# set the project name
PROJECT(TUTORIAUX)
# check cmake version compatibility
CMAKE_MINIMUM_REQUIRED(VERSION 2.4 FATAL_ERROR)
# regular expression checking
INCLUDE_REGULAR_EXPRESSION("^.*$" "^$")
# set a language
ENABLE_LANGUAGE(CXX)
ENABLE_LANGUAGE(C)
#####################################################################################
######################################################################################
### 2) Include the main configuration variables
######################################################################################
# Need the config file whose full path is given thanks to the "config" variable
INCLUDE("install.cmake")
######################################################################################
######################################################################################
### 3) Paths checking
######################################################################################
IF(WIN32)
SET (ABSOLUTE_PATH_REGEX "^[A-Z]:|^[a-z]:")
ELSE(WIN32)
SET (ABSOLUTE_PATH_REGEX "^/")
ENDIF(WIN32)
SET(REQUIRED_PATHS "PARADISEO_EO_SRC_DIR" "PARADISEO_EO_BIN_DIR" "PARADISEO_MO_SRC_DIR" "PARADISEO_MO_BIN_DIR" "PARADISEO_MO_SRC_DIR" "PARADISEO_MOEO_BIN_DIR")
FOREACH (path ${REQUIRED_PATHS})
IF(EXISTS ${${path}})
MESSAGE (STATUS "Using ${path}=${${path}}")
ELSE(EXISTS ${${path}})
MESSAGE (FATAL_ERROR "\n Cannot find \"${${path}}\". Please, fill \"${config}\" with a correct value")
ENDIF(EXISTS ${${path}})
IF(NOT ${${path}} MATCHES "${ABSOLUTE_PATH_REGEX}")
MESSAGE (FATAL_ERROR "${${path}} MUST BE an absolute path")
ENDIF(NOT ${${path}} MATCHES "${ABSOLUTE_PATH_REGEX}")
ENDFOREACH (path ${REQUIRED_PATHS})
######################################################################################
ADD_CUSTOM_TARGET(installall DEPENDS
${SOURCES_DIR}/tsp/benchs
${SOURCES_DIR}/flowshop/benchs
${SOURCES_DIR}/EO_lesson1/param
${SOURCES_DIR}/MO_lesson1/param
${SOURCES_DIR}/MO_lesson2/param
${SOURCES_DIR}/MO_lesson3/param
${SOURCES_DIR}/MO_lesson4/param
${SOURCES_DIR}/MOEO_lesson/param
${SOURCES_DIR}/hybrid_lesson/param
)
ADD_CUSTOM_COMMAND(
TARGET installall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_directory
${SOURCES_DIR}/tsp/benchs
${INSTALL_DIR}/tsp/benchs)
ADD_CUSTOM_COMMAND(
TARGET installall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_directory
${SOURCES_DIR}/flowshop/benchs
${INSTALL_DIR}/flowshop/benchs)
ADD_CUSTOM_COMMAND(
TARGET installall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/EO_lesson1/param
${INSTALL_DIR}/EO_lesson1/Release)
ADD_CUSTOM_COMMAND(
TARGET installall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/MOEO_lesson/param
${INSTALL_DIR}/MOEO_lesson/Release)
ADD_CUSTOM_COMMAND(
TARGET installall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/MO_lesson1/param
${INSTALL_DIR}/MO_lesson1/Release)
ADD_CUSTOM_COMMAND(
TARGET installall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/MO_lesson2/param
${INSTALL_DIR}/MO_lesson2/Release)
ADD_CUSTOM_COMMAND(
TARGET installall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/MO_lesson3/param
${INSTALL_DIR}/MO_lesson3/Release)
ADD_CUSTOM_COMMAND(
TARGET installall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/MO_lesson4/param
${INSTALL_DIR}/MO_lesson4/Release)
ADD_CUSTOM_COMMAND(
TARGET installall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/hybrid_lesson/param
${INSTALL_DIR}/hybrid_lesson/Release)
######################################################################################
### 6) Where must cmake go now ?
######################################################################################
SUBDIRS(tsp EO_lesson1 MO_lesson1 MO_lesson2 MO_lesson3 MO_lesson4 flowshop MOEO_lesson hybrid_lesson)
######################################################################################

View file

@ -0,0 +1,57 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src/utils)
INCLUDE_DIRECTORIES(${PARADISEO_MO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${SOURCES_DIR}/tsp/src)
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
#IF(NOT WIN32 OR CYGWIN)
LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib ${INSTALL_DIR}/tsp/lib)
#ENDIF(NOT WIN32 OR CYGWIN)
# especially for Visual Studio
#IF(WIN32 AND NOT CYGWIN)
# LINK_DIRECTORIES(${EO_BINARY_DIR}\\lib\\${CMAKE_BUILD_TYPE${INSTALL_DIR}\\tsp\\lib\\${CMAKE_BUILD_TYPE})
#ENDIF(WIN32 AND NOT CYGWIN)
######################################################################################
######################################################################################
### 3) Define your target(s): just an executable here
######################################################################################
ADD_CUSTOM_TARGET(install DEPENDS ${SOURCES_DIR}/EO_lesson1/param )
ADD_CUSTOM_COMMAND(
TARGET install
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/EO_lesson1/param
${INSTALL_DIR}/EO_lesson1)
ADD_EXECUTABLE(tsp_EA tsp.cpp)
ADD_DEPENDENCIES(tsp_EA tsp)
######################################################################################
######################################################################################
### 4) Link the librairies for your target(s)
######################################################################################
TARGET_LINK_LIBRARIES(tsp_EA tsp eo eoutils)
######################################################################################

View file

@ -0,0 +1,9 @@
###### Configuration ######
--instancePath=../tsp/benchs/berlin52.tsp # Path to the instance.
--popSize=100 # Size of the population.
--nbOffspring=100 # Number of selected parents.
--maxGen=1000 # Maximum number of iterations.
--crossType=Partial # Crossover to use, it can be 'Partial', 'Order' or 'Edge'.
--crossRate=1 # Probability of crossover.
--mutRate=0.01 # Probability of mutation

View file

@ -0,0 +1,160 @@
/*
* <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 <tsp>
void manage_configuration_file(eoParser & _parser);
int main (int _argc, char* _argv [])
{
eoParser parser(_argc, _argv);
manage_configuration_file(parser);
unsigned int seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
std::string instancePath=parser.getParamWithLongName("instancePath")->getValue();
unsigned int populationSize=atoi( (parser.getParamWithLongName("popSize")->getValue()).c_str() );
unsigned int maxGen=atoi( (parser.getParamWithLongName("maxGen")->getValue()).c_str() );
double crossoverRate=atof( (parser.getParamWithLongName("crossRate")->getValue()).c_str() );
double mutationRate=atof( (parser.getParamWithLongName("mutRate")->getValue()).c_str() );
unsigned int nbOffspring=atoi( (parser.getParamWithLongName("nbOffspring")->getValue()).c_str() );
std::string crossoverType=parser.getParamWithLongName("crossType")->getValue();
// random number generator
srand (seed);
// load test instance
Graph::load(instancePath.c_str());
/*** the representation-dependent things ***/
// the evaluation function
RouteEval full_eval ;
// the genotype (through a genotype initializer)
RouteInit init ;
// crossover
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.");
}
// mutation
CitySwap mutation ;
// variation operators
eoSGATransform <Route> transform (*crossover, crossoverRate, mutation, mutationRate) ;
/*** the representation-independent things ***/
// initialization of the population
eoPop <Route> pop (populationSize, init) ;
apply <Route> (full_eval, pop) ;
// select
eoDetTournamentSelect <Route> select_one ;
eoSelectNumber <Route> select (select_one, nbOffspring) ;
// replace
eoGenerationalReplacement <Route> genReplace;
eoWeakElitistReplacement <Route> replace(genReplace);
// stopping criteria
eoGenContinue <Route> continu (maxGen) ;
// algorithm
eoEasyEA <Route> ea (continu, full_eval, select, transform, replace) ;
/*** Go ! ***/
// initial solution
std :: cout << "[From] " << pop.best_element () << std :: endl ;
// run the algo
ea(pop);
// final solution
std :: cout << "[To] " << pop.best_element () << std :: endl ;
// delete pointer
delete(crossover);
// that's all
return EXIT_SUCCESS;
}
void manage_configuration_file(eoParser & _parser)
{
std::ofstream os;
_parser.getORcreateParam(std::string("../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, "maxGen", "Maximum number of generations.", 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, "nbOffspring", "Number of offspring.", 0, "Configuration", false);
_parser.getORcreateParam(std::string("Partial"), "crossType", "Crossover to use, it can be 'Partial', 'Order' or 'Edge'.", 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();
}

View file

@ -0,0 +1,52 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src/utils)
INCLUDE_DIRECTORIES(${PARADISEO_MOEO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${SOURCES_DIR}/flowshop/src)
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib)
LINK_DIRECTORIES(${PARADISEO_MOEO_BIN_DIR}/lib)
LINK_DIRECTORIES(${INSTALL_DIR}/flowshop/lib)
######################################################################################
######################################################################################
### 3) Define your target(s): just an executable here
######################################################################################
ADD_CUSTOM_TARGET(install DEPENDS ${SOURCES_DIR}/MOEO_lesson/param )
ADD_CUSTOM_COMMAND(
TARGET install
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/MOEO_lesson/param
${INSTALL_DIR}/MOEO_lesson)
ADD_EXECUTABLE(FlowShopEA FlowShopEA.cpp)
ADD_DEPENDENCIES(FlowShopEA flowshop)
######################################################################################
######################################################################################
### 4) Link the librairies for your target(s)
######################################################################################
TARGET_LINK_LIBRARIES(FlowShopEA flowshop eo eoutils moeo)
######################################################################################

View file

@ -0,0 +1,132 @@
/*
* <FlowShopEA.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
// moeo general include
#include <moeo>
// for the creation of an evaluator
#include <make_eval_FlowShop.h>
// for the creation of an initializer
#include <make_genotype_FlowShop.h>
// for the creation of the variation operators
#include <make_op_FlowShop.h>
// how to initialize the population
#include <do/make_pop.h>
// the stopping criterion
#include <do/make_continue_moeo.h>
// outputs (stats, population dumps, ...)
#include <do/make_checkpoint_moeo.h>
// evolution engine (selection and replacement)
#include <do/make_ea_moeo.h>
// simple call to the algo
#include <do/make_run.h>
// checks for help demand, and writes the status file and make_help; in libutils
void make_help(eoParser & _parser);
// definition of the representation
#include <FlowShop.h>
using namespace std;
int main(int argc, char* argv[])
{
try
{
eoParser parser(argc, argv); // for user-parameter reading
eoState state; // to keep all things allocated
/*** the representation-dependent things ***/
// The evaluation
eoEvalFuncCounter<FlowShop>& eval = do_make_eval(parser, state);
// the genotype (through a genotype initializer)
eoInit<FlowShop>& init = do_make_genotype(parser, state);
// the variation operators
eoGenOp<FlowShop>& op = do_make_op(parser, state);
/*** the representation-independent things ***/
// initialization of the population
eoPop<FlowShop>& pop = do_make_pop(parser, state, init);
// definition of the archive
moeoArchive<FlowShop> arch;
// stopping criteria
eoContinue<FlowShop>& term = do_make_continue_moeo(parser, state, eval);
// output
eoCheckPoint<FlowShop>& checkpoint = do_make_checkpoint_moeo(parser, state, eval, term, pop, arch);
// algorithm
eoAlgo<FlowShop>& algo = do_make_ea_moeo(parser, state, eval, checkpoint, op, arch);
/*** Go ! ***/
// help ?
make_help(parser);
// first evalution (for printing)
apply<FlowShop>(eval, pop);
// printing of the initial population
cout << "Initial Population\n";
pop.sortedPrintOn(cout);
cout << endl;
// run the algo
algo(pop);
// printing of the final population
cout << "Final Population\n";
pop.sortedPrintOn(cout);
cout << endl;
// printing of the final archive
cout << "Final Archive\n";
arch.sortedPrintOn(cout);
cout << endl;
}
catch (exception& e)
{
cout << e.what() << endl;
}
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,33 @@
###### Evolution Engine ######
--popSize=100 # -P : Population Size
--updateArch=1 # Update the archive at each gen.
--fitness=FastNonDominatedSorting # -F : Fitness assignment scheme: Dummy, FastNonDominatedSorting or IndicatorBased
--indicator=Epsilon # -i : Binary indicator for IndicatorBased: Epsilon, Hypervolume
--diversity=Crowding # -D : Diversity assignment scheme: Dummy, Sharing(nicheSize) or Crowding
--comparator=FitnessThenDiversity # -C : Comparator scheme: FitnessThenDiversity, DiversityThenFitness or Aggregative
--selection=DetTour(2) # -S : Selection scheme: DetTour(T), StochTour(t) or Random
--replacement=Elitist # -R : Replacement scheme: Elitist, Environmental or Generational
--nbOffspring=100% # -O : Number of offspring (percentage or absolute)
###### Output ######
--resDir=Res # Directory to store DISK outputs
--eraseDir=1 # erase files in dirName if any
--printPop=0 # Print sorted pop. every gen.
--storeArch=1 # Store the archive's objective vectors at each gen.
--contribution=0 # Store the contribution of the archive at each gen.
--entropy=0 # Store the entropy of the archive at each gen.
###### Representation ######
--BenchmarkFile=../flowshop/benchs/020_10_01.txt # -B : Benchmark file name REQUIRED
###### Stopping criterion ######
--maxGen=100 # -G : Maximum number of generations (0 = none)
--maxEval=0 # -E : Maximum number of evaluations (0 = none)
--maxTime=0 # -T : Maximum running time in seconds (0 = none)
###### Variation Operators ######
--crossRate=1 # Relative rate for the only crossover
--shiftMutRate=0.5 # Relative rate for shift mutation
--exchangeMutRate=0.5 # Relative rate for exchange mutation
--pCross=0.25 # -c : Probability of Crossover
--pMut=0.35 # -m : Probability of Mutation

View file

@ -0,0 +1,49 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src/utils)
INCLUDE_DIRECTORIES(${PARADISEO_MO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${SOURCES_DIR}/tsp/src)
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib ${INSTALL_DIR}/tsp/lib)
######################################################################################
######################################################################################
### 3) Define your target(s): just an executable here
######################################################################################
ADD_CUSTOM_TARGET(install DEPENDS ${SOURCES_DIR}/MO_lesson1/param )
ADD_CUSTOM_COMMAND(
TARGET install
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/MO_lesson1/param
${INSTALL_DIR}/MO_lesson1)
ADD_EXECUTABLE(hill_climbing hill_climbing.cpp)
ADD_DEPENDENCIES(hill_climbing tsp)
######################################################################################
######################################################################################
### 4) Link the librairies for your target(s)
######################################################################################
TARGET_LINK_LIBRARIES(hill_climbing tsp eo eoutils)
######################################################################################

View 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("../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();
}

View file

@ -0,0 +1,3 @@
###### Configuration ######
--instancePath=../tsp/benchs/berlin52.tsp # Path to the instance.
--selectionType=Best # Type of the selection: 'Best', 'First' or 'Random'.

View file

@ -0,0 +1,61 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src/utils)
INCLUDE_DIRECTORIES(${PARADISEO_MO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${SOURCES_DIR}/tsp/src)
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib ${INSTALL_DIR}/tsp/lib)
######################################################################################
######################################################################################
### 3) Define your target(s): just an executable here
######################################################################################
ADD_CUSTOM_TARGET(install DEPENDS ${SOURCES_DIR}/MO_lesson2/param )
ADD_CUSTOM_COMMAND(
TARGET install
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/MO_lesson2/param
${INSTALL_DIR}/MO_lesson2)
ADD_EXECUTABLE(tabu_search tabu_search.cpp)
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)
######################################################################################

View file

@ -0,0 +1,5 @@
###### Configuration ######
--instancePath=../tsp/benchs/berlin52.tsp # Path to the instance
--tabuListSize=10 # Size of the tabu list
--maxIter=1000 # Maximum number of iterations
--tabuListType=TwoOpt # Type of the tabu list: 'TwoOpt', 'SimpleMove' or 'SimpleSolution'

View 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("../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();
}

View file

@ -0,0 +1,59 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src/utils)
INCLUDE_DIRECTORIES(${PARADISEO_MO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${SOURCES_DIR}/tsp/src)
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib ${INSTALL_DIR}/tsp/lib)
######################################################################################
######################################################################################
### 3) Define your target(s): just an executable here
######################################################################################
ADD_CUSTOM_TARGET(install DEPENDS ${SOURCES_DIR}/MO_lesson3/param )
ADD_CUSTOM_COMMAND(
TARGET install
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/MO_lesson3/param
${INSTALL_DIR}/MO_lesson3)
ADD_EXECUTABLE(simulated_annealing simulated_annealing.cpp)
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)
######################################################################################

View file

@ -0,0 +1,8 @@
###### Configuration ######
--instancePath=../tsp/benchs/berlin52.tsp # Path to the instance.
--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'.

View 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, exponentialRatio, 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() );
exponentialRatio=atof( (parser.getParamWithLongName("expoRatio")->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("Expo")==0)
{
coolingSchedule=new moExponentialCoolingSchedule(threshold, exponentialRatio);
}
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("../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, "expoRatio", "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("Expo"), "coolSchedType", "Type the cooling schedule: 'Expo' 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();
}

View file

@ -0,0 +1,61 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src/utils)
INCLUDE_DIRECTORIES(${PARADISEO_MO_SRC_DIR}/src)
INCLUDE_DIRECTORIES(${SOURCES_DIR}/tsp/src)
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib ${INSTALL_DIR}/tsp/lib)
######################################################################################
######################################################################################
### 3) Define your target(s): just an executable here
######################################################################################
ADD_CUSTOM_TARGET(install DEPENDS ${SOURCES_DIR}/MO_lesson4/param )
ADD_CUSTOM_COMMAND(
TARGET install
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different
${SOURCES_DIR}/MO_lesson4/param
${INSTALL_DIR}/MO_lesson4)
ADD_EXECUTABLE(iterated_local_search iterated_local_search.cpp)
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)
######################################################################################

View file

@ -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("../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();
}

View file

@ -0,0 +1,3 @@
###### Configuration ######
--instancePath=../tsp/benchs/berlin52.tsp # Path to the instance.
--maxIter=1000 # Maximum number of iterations.

View file

@ -0,0 +1,17 @@
######################################################################################
### 1) Where must cmake go now ?
######################################################################################
ADD_CUSTOM_TARGET(install DEPENDS ${SOURCES_DIR}/flowshop/benchs)
ADD_CUSTOM_COMMAND(
TARGET install
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_directory
${SOURCES_DIR}/flowshop/benchs
${INSTALL_DIR}/flowshop/benchs)
SUBDIRS(src)
######################################################################################

Some files were not shown because too many files have changed in this diff Show more