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
90 changed files with 0 additions and 0 deletions

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,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,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,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,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,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,63 @@
20
5
873654221
0
468
54 79 16 66 58
1
325
83 3 89 58 56
2
923
15 11 49 31 20
3
513
71 99 15 68 85
4
1070
77 56 89 78 53
5
690
36 70 45 91 35
6
602
53 99 60 13 53
7
289
38 60 23 59 41
8
873
27 5 57 49 69
9
342
87 56 64 85 13
10
764
76 3 7 85 86
11
268
91 61 1 9 72
12
1158
14 73 63 39 8
13
646
29 75 41 41 49
14
1111
12 47 63 56 47
15
965
77 14 47 40 87
16
703
32 21 26 54 58
17
1205
87 86 75 77 18
18
334
68 5 77 51 68
19
1111
94 77 40 31 28

View file

@ -0,0 +1,63 @@
20
5
379008056
0
517
26 59 78 88 69
1
461
38 62 90 54 30
2
832
27 44 64 47 61
3
653
88 10 49 83 35
4
933
95 23 47 84 53
5
811
55 64 20 9 98
6
966
54 47 61 30 94
7
448
63 68 93 11 33
8
577
23 54 36 92 77
9
1122
45 9 47 63 31
10
666
86 30 70 62 54
11
1189
43 31 54 75 71
12
470
43 92 87 48 78
13
475
40 7 13 23 9
14
462
37 14 40 85 79
15
866
54 95 34 23 51
16
392
35 76 55 4 76
17
310
59 82 13 31 56
18
719
43 91 11 13 80
19
1221
50 37 5 98 72

View file

@ -0,0 +1,63 @@
20
10
587595453
0
1250
74 28 89 60 54 92 9 4 25 15
1
1371
21 3 52 88 66 11 8 18 15 84
2
637
58 27 56 26 12 54 88 25 91 8
3
616
4 61 13 58 57 97 72 28 49 30
4
917
21 34 7 76 70 57 27 95 56 95
5
937
28 76 32 98 82 53 22 51 10 79
6
1435
58 64 32 29 99 65 50 84 62 9
7
1197
83 87 98 47 84 77 2 18 70 91
8
1301
31 54 46 79 16 51 49 6 76 76
9
637
61 98 60 26 41 36 82 90 99 26
10
749
94 76 23 19 23 53 93 69 58 42
11
1223
44 41 87 48 11 19 96 61 83 66
12
887
97 70 7 95 68 54 43 57 84 70
13
1316
94 43 36 78 58 86 13 5 64 91
14
1330
66 42 26 77 30 40 60 75 74 67
15
1380
6 79 85 90 5 56 11 4 14 3
16
767
37 88 7 24 5 79 37 38 18 98
17
574
22 15 34 10 39 74 91 28 48 4
18
1398
99 49 36 85 58 24 84 4 96 71
19
1179
83 72 48 55 31 3 67 80 86 62

View file

@ -0,0 +1,63 @@
20
10
1401007982
0
1279
80 59 59 31 30 53 93 90 65 64
1
1481
13 83 70 64 88 19 79 92 97 38
2
1157
64 85 76 11 14 99 88 35 27 44
3
1391
77 85 10 9 22 62 77 13 25 46
4
763
17 70 65 32 93 88 94 75 61 66
5
1456
78 35 19 58 48 93 39 55 24 31
6
900
82 2 77 98 10 34 74 80 97 48
7
1047
4 76 86 95 7 72 46 67 61 27
8
1355
72 46 21 25 14 42 17 3 75 82
9
1262
93 72 75 4 91 65 30 93 92 51
10
1329
68 69 96 45 5 39 62 54 73 90
11
562
25 46 3 60 43 79 77 67 21 63
12
684
67 3 50 87 30 9 43 25 29 85
13
567
80 57 57 31 79 26 98 77 3 36
14
765
43 71 66 1 39 72 48 38 96 69
15
808
93 77 84 96 34 29 14 98 51 67
16
999
21 33 98 22 77 36 45 96 26 81
17
548
33 49 55 95 81 48 25 20 44 18
18
577
14 59 70 73 11 57 98 15 56 81
19
704
30 82 32 77 10 95 30 36 31 72

View file

@ -0,0 +1,63 @@
20
20
479340445
0
1696
50 78 36 85 9 75 46 73 71 7 49 3 60 12 75 31 70 20 88 9
1
1273
90 56 43 88 92 64 94 3 49 40 49 53 88 47 19 61 78 78 30 41
2
1546
39 9 10 60 98 96 6 56 36 33 15 59 15 46 60 47 41 38 34 22
3
1882
34 43 19 98 44 95 19 73 87 64 18 7 26 17 87 32 9 26 33 34
4
1117
66 84 55 4 51 22 20 80 8 5 65 65 11 43 27 34 47 64 21 83
5
1181
81 73 48 99 8 41 51 82 25 25 55 58 16 16 48 69 94 62 7 55
6
1416
27 66 85 53 31 26 85 36 76 89 1 24 55 91 72 32 26 11 94 3
7
1635
48 38 70 21 15 33 92 98 73 95 79 55 59 94 88 1 65 38 10 8
8
1723
46 83 82 33 47 68 43 90 80 58 10 26 81 73 48 1 17 68 73 75
9
1932
68 57 39 53 31 9 75 46 6 83 37 40 53 89 59 80 42 37 85 30
10
1219
48 97 91 63 80 81 70 10 6 28 77 89 92 12 74 19 59 74 82 57
11
1521
92 52 82 18 83 28 70 46 33 35 80 94 23 58 86 57 80 9 62 65
12
1322
78 77 85 45 20 61 36 65 79 74 79 51 55 25 49 98 7 65 99 89
13
1057
84 13 17 29 84 69 31 83 10 5 84 74 79 24 94 37 75 16 67 60
14
1922
93 12 6 43 69 37 76 75 93 6 93 54 13 55 15 31 63 38 61 90
15
1130
39 2 54 41 49 57 63 47 65 9 21 86 89 1 95 51 96 85 10 84
16
1411
43 65 87 80 93 36 89 61 26 3 85 22 2 67 41 66 7 50 4 74
17
1840
1 93 85 4 39 80 46 28 73 2 64 83 17 3 94 38 10 62 70 17
18
1741
65 39 4 31 13 96 25 59 42 35 46 19 97 1 15 62 47 39 31 2
19
1377
87 1 72 19 88 74 88 22 18 41 35 44 41 71 71 72 38 97 49 19

View file

@ -0,0 +1,153 @@
50
5
1328042058
0
1290
75 26 48 26 77
1
2352
87 37 4 67 94
2
362
13 25 92 4 9
3
305
11 95 92 14 57
4
262
41 49 72 93 29
5
1250
43 12 45 54 79
6
2170
93 59 5 21 55
7
1601
69 17 98 20 73
8
2039
80 46 93 6 65
9
1628
13 20 17 18 86
10
483
24 52 79 75 25
11
285
72 44 11 25 39
12
1092
38 92 16 16 76
13
936
81 75 89 77 24
14
2349
83 95 81 28 38
15
473
88 33 92 24 5
16
2325
26 10 45 15 91
17
747
6 45 61 77 29
18
970
89 2 39 36 22
19
434
67 62 28 16 27
20
1258
70 62 94 32 39
21
2405
30 82 87 46 31
22
862
89 29 23 21 46
23
298
30 29 1 81 18
24
2014
68 94 55 28 93
25
2608
21 20 91 70 58
26
1737
78 42 67 89 85
27
2214
46 80 91 54 58
28
1910
99 94 4 96 97
29
2245
10 35 60 62 10
30
2211
17 8 38 46 79
31
547
23 41 25 60 93
32
2237
83 65 90 19 2
33
1327
47 4 93 97 87
34
700
86 71 13 13 17
35
1011
18 30 65 7 18
36
2001
67 14 25 44 10
37
1230
46 32 34 7 50
38
1020
4 50 47 73 8
39
1918
14 30 98 15 26
40
1001
4 27 91 66 14
41
1383
20 98 11 70 21
42
1229
88 39 46 97 15
43
2594
50 84 50 33 10
44
403
84 65 77 97 85
45
1515
58 12 5 64 46
46
431
93 58 14 73 42
47
1971
76 45 47 28 18
48
939
50 49 80 4 36
49
2028
30 15 45 87 2

View file

@ -0,0 +1,153 @@
50
10
1958948863
0
793
46 61 3 51 37 79 83 22 27 24
1
2280
52 87 1 24 16 93 87 29 92 47
2
939
79 51 58 21 42 68 38 99 75 39
3
2591
45 25 85 57 47 75 38 25 94 66
4
1540
97 73 33 69 94 37 86 98 18 41
5
2386
10 93 71 51 14 44 67 55 41 46
6
812
44 28 58 50 94 34 23 80 37 24
7
2524
24 90 56 51 34 39 19 82 58 23
8
1370
85 94 64 21 72 76 97 33 56 68
9
1319
75 59 43 19 36 62 78 68 20 50
10
2388
66 64 48 63 88 74 66 47 2 93
11
961
49 2 69 91 51 28 67 74 39 22
12
2831
95 16 96 11 41 78 7 26 91 64
13
2790
61 35 35 6 71 43 23 61 81 81
14
2076
19 53 82 31 94 98 67 95 33 94
15
2519
47 40 53 63 99 83 8 55 14 97
16
1981
84 81 64 36 11 91 77 11 88 54
17
695
13 26 11 39 97 27 71 42 22 82
18
2133
11 85 61 57 44 6 85 72 36 11
19
1871
19 4 36 47 77 82 29 14 65 91
20
1495
98 4 53 56 69 60 49 8 79 23
21
754
2 10 87 65 91 44 3 98 23 32
22
783
85 63 88 59 38 43 94 90 66 26
23
984
44 96 10 4 25 76 76 36 5 22
24
2004
7 55 32 10 87 99 95 75 15 12
25
2269
73 71 38 12 7 66 48 69 51 23
26
1771
19 66 25 62 66 11 4 26 2 34
27
2030
69 94 24 43 54 35 37 24 81 87
28
2603
12 7 90 49 86 52 82 55 12 59
29
2150
73 15 7 54 49 8 57 98 40 2
30
2157
85 11 11 87 3 40 61 86 59 38
31
2187
23 99 49 29 48 62 6 30 32 84
32
937
53 37 2 2 44 25 97 92 16 62
33
728
16 50 76 18 93 24 5 94 87 10
34
510
88 56 17 75 37 30 27 66 78 11
35
2786
8 69 32 39 82 1 95 47 41 93
36
2134
26 22 39 77 31 73 46 3 43 57
37
1046
42 56 9 69 59 27 92 41 94 81
38
2849
58 67 83 15 78 16 46 41 1 10
39
1956
63 63 69 78 33 91 52 47 93 40
40
2456
7 96 67 68 36 33 8 89 22 62
41
1105
2 74 28 37 3 11 11 28 93 49
42
1560
44 4 88 22 58 99 7 39 62 90
43
1745
38 42 23 41 10 2 54 80 53 34
44
2216
24 40 91 92 98 60 72 47 30 11
45
1157
76 30 71 67 6 90 57 57 34 81
46
1317
85 93 3 24 44 36 85 74 27 51
47
2372
61 36 26 87 62 62 22 38 30 21
48
777
32 25 41 91 24 15 87 59 54 39
49
972
90 87 96 31 94 3 65 5 77 27

View file

@ -0,0 +1,153 @@
50
20
1539989115
0
2509
52 63 82 16 63 94 79 22 80 96 53 54 71 27 95 3 92 80 61 74
1
2039
95 99 21 26 55 34 21 6 13 3 19 67 90 93 53 80 62 38 86 38
2
3096
42 69 79 46 59 89 93 24 64 50 99 25 59 49 54 78 11 55 16 4
3
2950
75 70 95 66 35 62 32 55 77 57 62 77 82 63 22 32 83 34 42 31
4
1249
44 53 46 76 21 47 8 48 17 66 88 38 22 65 84 53 87 85 14 62
5
2481
57 21 23 31 59 66 45 57 78 84 93 98 88 34 54 43 66 44 92 39
6
3193
89 10 40 36 78 76 37 78 82 98 34 96 35 10 2 85 98 47 67 97
7
3253
53 31 95 8 25 15 78 5 4 55 72 20 49 56 80 19 42 66 77 57
8
2123
84 80 87 37 30 18 26 50 72 70 42 15 78 51 84 48 23 19 46 9
9
2390
62 18 37 21 38 54 98 83 93 32 65 36 69 97 66 49 45 66 41 54
10
1764
91 5 24 3 78 24 17 70 68 31 39 65 76 52 25 66 52 61 78 13
11
2940
14 18 24 76 79 55 25 21 25 64 79 97 2 46 16 22 6 60 3 47
12
1635
95 17 65 67 58 96 21 71 67 11 9 27 14 16 79 37 3 98 72 6
13
3171
89 71 62 5 44 10 28 58 80 9 26 25 3 50 90 51 64 82 95 70
14
2670
4 90 19 47 38 12 68 36 43 32 72 61 22 96 51 82 55 79 53 19
15
2932
95 93 67 72 76 96 24 50 93 58 29 24 26 85 29 59 97 71 59 97
16
2054
2 14 66 66 70 53 62 31 21 98 36 97 44 61 29 88 83 28 34 41
17
3238
97 49 6 56 72 92 89 86 33 95 48 61 1 76 90 77 42 74 66 1
18
2466
68 52 65 95 85 77 60 29 14 25 57 75 4 30 83 19 81 27 42 57
19
2384
20 7 59 49 8 6 64 30 30 4 95 92 16 90 83 32 92 33 63 60
20
3473
33 78 2 47 10 91 38 93 59 45 93 73 55 42 19 52 68 13 27 62
21
3290
51 57 67 26 84 14 90 49 83 60 79 21 43 88 95 9 46 9 92 14
22
2086
98 41 82 81 42 41 87 83 85 87 88 29 87 37 87 96 56 12 8 90
23
2560
8 75 90 56 67 30 1 89 85 31 77 3 35 43 12 23 88 51 65 76
24
3253
85 98 30 76 20 85 99 44 70 1 94 96 76 88 34 64 50 16 34 12
25
3205
86 93 63 66 24 17 34 38 35 96 39 51 98 91 23 22 13 49 6 89
26
2534
73 33 5 36 75 23 9 62 2 22 74 26 78 14 44 37 23 83 42 37
27
2039
4 75 93 53 23 60 22 45 76 95 46 44 81 63 30 3 13 48 39 35
28
2273
40 68 53 26 33 76 74 22 46 73 17 56 48 65 82 52 49 13 2 91
29
2062
98 33 85 52 60 39 14 85 72 77 30 31 25 74 83 44 18 78 7 69
30
1909
12 60 81 29 20 85 14 39 69 30 62 64 81 71 42 11 50 96 85 55
31
2432
59 82 73 36 75 10 84 98 46 88 77 38 27 8 56 21 94 77 32 48
32
2624
44 24 34 68 83 65 75 56 3 14 43 44 84 39 89 85 71 68 14 56
33
3325
46 99 74 21 26 15 37 68 57 22 98 46 59 95 38 6 64 88 74 84
34
3427
2 4 13 71 92 55 32 84 71 93 48 66 98 82 96 40 31 77 59 22
35
1318
41 97 78 61 29 41 29 77 77 48 14 31 14 17 10 68 21 76 95 51
36
1539
28 24 35 71 39 28 32 67 33 10 45 48 32 38 3 30 2 73 48 43
37
3223
83 50 20 69 14 93 89 53 49 7 25 27 95 69 53 35 63 92 37 50
38
1703
28 55 16 28 74 88 12 46 59 14 98 82 30 17 97 58 58 72 59 62
39
1051
21 91 48 86 66 27 47 24 82 91 30 51 13 24 11 31 36 87 4 61
40
1512
80 46 12 27 86 77 19 52 59 5 90 90 68 66 65 11 64 66 42 10
41
2589
71 58 11 41 10 81 97 96 70 43 92 63 19 75 47 11 52 98 93 87
42
3248
4 17 80 86 27 19 7 2 76 30 35 85 57 52 76 6 8 40 32 99
43
2047
60 47 9 55 8 76 12 88 10 79 13 36 65 59 22 59 94 31 30 40
44
3333
34 82 24 17 7 55 43 33 65 39 75 69 13 4 17 64 51 75 16 91
45
1760
55 6 76 62 97 67 89 27 19 34 55 67 63 73 14 65 36 45 95 64
46
2333
53 15 32 96 84 65 14 49 77 77 80 81 26 56 11 23 82 98 58 62
47
2400
96 91 35 59 56 8 33 78 86 81 67 18 96 19 69 80 30 90 12 53
48
2142
37 74 66 53 61 18 56 82 21 11 3 81 53 39 91 75 17 4 95 33
49
1231
37 42 48 93 9 56 57 65 75 10 93 72 94 51 53 63 21 23 21 16

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