New config of Paradiseo with Cmake 2.6
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1347 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
aa8109322c
commit
712e8d6cfa
84 changed files with 1468 additions and 739 deletions
|
|
@ -3,7 +3,7 @@
|
|||
######################################################################################
|
||||
|
||||
# check cmake version compatibility
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.4 FATAL_ERROR)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
|
||||
|
||||
# regular expression checking
|
||||
INCLUDE_REGULAR_EXPRESSION("^.*$" "^$")
|
||||
|
|
@ -26,7 +26,9 @@ INCLUDE(FindGnuplot)
|
|||
|
||||
INCLUDE(CheckLibraryExists)
|
||||
|
||||
INCLUDE(Dart OPTIONAL)
|
||||
INCLUDE(Dart OPTIONAL)
|
||||
|
||||
INCLUDE(CPack)
|
||||
|
||||
# Set a special flag if the environment is windows (should do the same in a config.g file)
|
||||
IF (WIN32)
|
||||
|
|
@ -70,7 +72,7 @@ IF(WIN32 AND NOT CYGWIN)
|
|||
ENDIF(CMAKE_CXX_COMPILER MATCHES cl)
|
||||
ELSE(WIN32 AND NOT CYGWIN)
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -fprofile-arcs -ftest-coverage -Wall -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -fprofile-arcs -ftest-coverage -Wall -Wextra -Wno-unused-parameter")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||
SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -O6")
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
|
@ -82,6 +84,11 @@ ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
|
|||
|
||||
#####################################################################################
|
||||
|
||||
######################################################################################
|
||||
### compilation of examples?
|
||||
######################################################################################
|
||||
|
||||
SET(ENABLE_CMAKE_EXAMPLE TRUE CACHE BOOL "Enable copy of benchs and parameters file?")
|
||||
|
||||
######################################################################################
|
||||
### Test config
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
|
||||
|
||||
##########################################################################################################################################
|
||||
### 0) If you want to set your own variables in mo-conf.cmake and avoid the cmd line
|
||||
|
|
@ -17,10 +18,10 @@ PROJECT(ParadisEO-MO)
|
|||
|
||||
SET(PACKAGE_BUGREPORT "paradiseo-help@lists.gforge.inria.fr" CACHE STRING "Package bug report" FORCE)
|
||||
SET(PACKAGE_NAME "ParadisEO-MO - Moving Objects" CACHE STRING "Package name" FORCE)
|
||||
SET(PACKAGE_STRING "ParadisEO-MO 1.1" CACHE STRING "MO Package string full name" FORCE)
|
||||
SET(PACKAGE_VERSION "1.1" CACHE STRING "Package version" FORCE)
|
||||
SET(GLOBAL_VERSION "1.1" CACHE STRING "Global version" FORCE)
|
||||
SET(VERSION "1.1" CACHE STRING "Version" FORCE)
|
||||
SET(PACKAGE_STRING "ParadisEO-MO 1.2" CACHE STRING "MO Package string full name" FORCE)
|
||||
SET(PACKAGE_VERSION "1.2" CACHE STRING "Package version" FORCE)
|
||||
SET(GLOBAL_VERSION "1.2" CACHE STRING "Global version" FORCE)
|
||||
SET(VERSION "1.2" CACHE STRING "Version" FORCE)
|
||||
##########################################################################################################################################
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -156,6 +156,13 @@ JAVADOC_AUTOBRIEF = YES
|
|||
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
|
||||
# If the DETAILS_AT_TOP tag is set to YES then Doxygen
|
||||
# will output the detailed description near the top, like JavaDoc.
|
||||
# If set to NO, the detailed description appears after the member
|
||||
# documentation.
|
||||
|
||||
DETAILS_AT_TOP = NO
|
||||
|
||||
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
|
||||
# member inherits the documentation from any documented member that it
|
||||
# re-implements.
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@
|
|||
#include <moBestImprSelect.h>
|
||||
#include <moComparator.h>
|
||||
#include <moCoolingSchedule.h>
|
||||
#include <moExponentialCoolingSchedule.h>
|
||||
#include <moFirstImprSelect.h>
|
||||
#include <moFitComparator.h>
|
||||
#include <moFitSolContinue.h>
|
||||
#include <moGenSolContinue.h>
|
||||
#include <moGeometricCoolingSchedule.h>
|
||||
#include <moHC.h>
|
||||
#include <moHCMoveLoopExpl.h>
|
||||
#include <moILS.h>
|
||||
|
|
@ -72,9 +72,8 @@
|
|||
#include <moTabuList.h>
|
||||
#include <moTS.h>
|
||||
#include <moTSMoveLoopExpl.h>
|
||||
#include <moTA.h>
|
||||
#include <moExpl.h>
|
||||
#include <moVNS.h>
|
||||
|
||||
#include <moTA.h>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -57,6 +57,14 @@ class moBestImprSelect:public moMoveSelect < M >
|
|||
*/
|
||||
void init (const Fitness & _fitness)
|
||||
{
|
||||
//Code only used to avoid warning because _fitness is not used in this procedure.
|
||||
Fitness fitness;
|
||||
fitness=(Fitness)_fitness;
|
||||
|
||||
//std::cout.precision(10);
|
||||
|
||||
//std::cout << "old fitness = " << _fitness << std::endl;
|
||||
|
||||
first_time = true;
|
||||
}
|
||||
|
||||
|
|
@ -80,6 +88,8 @@ class moBestImprSelect:public moMoveSelect < M >
|
|||
first_time = false;
|
||||
}
|
||||
|
||||
//std::cout << "best fitness = " << best_fitness << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +107,9 @@ class moBestImprSelect:public moMoveSelect < M >
|
|||
|
||||
_move = best_move;
|
||||
_fitness = best_fitness;
|
||||
|
||||
|
||||
|
||||
//std::cout << "Final fitness = " << best_fitness << std::endl;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -49,27 +49,28 @@ public:
|
|||
|
||||
//Neighborhoods vector
|
||||
std::vector< eoMonOp<EOT>* > explore;
|
||||
|
||||
|
||||
//! Generic constructor
|
||||
/*!
|
||||
Generic constructor using a eoMonOp
|
||||
|
||||
\param _expl Algorithme or mutation.
|
||||
|
||||
|
||||
*/
|
||||
moExpl(eoMonOp<EOT> & expl){
|
||||
i=0;
|
||||
explore.resize(0);
|
||||
add(expl);
|
||||
}
|
||||
|
||||
|
||||
//! Generic constructor
|
||||
/*!
|
||||
Generic constructor using a eoMonOp
|
||||
|
||||
\param _expl Algorithme or mutation.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//! Procedure which launches the moExpl.
|
||||
/*!
|
||||
The exploration starts from an old solution and provides a new solution.
|
||||
|
|
@ -98,7 +99,7 @@ public:
|
|||
//return the size of the class
|
||||
unsigned int size(){
|
||||
return explore.size();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
79
trunk/paradiseo-mo/src/moExponentialCoolingSchedule.h
Normal file
79
trunk/paradiseo-mo/src/moExponentialCoolingSchedule.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
<moExponentialCoolingSchedule.h>
|
||||
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 _moExponentialCoolingSchedule_h
|
||||
#define _moExponentialCoolingSchedule_h
|
||||
|
||||
#include <moCoolingSchedule.h>
|
||||
|
||||
//! One of the possible moCoolingSchedule
|
||||
/*!
|
||||
An other very simple cooling schedule, the temperature decrease according to a ratio while
|
||||
the temperature is greater than a given threshold.
|
||||
*/
|
||||
class moExponentialCoolingSchedule: public moCoolingSchedule
|
||||
{
|
||||
public:
|
||||
|
||||
//! Simple constructor
|
||||
/*!
|
||||
\param _threshold the threshold.
|
||||
\param _ratio the ratio used to descrease the temperature.
|
||||
*/
|
||||
moExponentialCoolingSchedule (double _threshold, double _ratio):threshold (_threshold), ratio (_ratio)
|
||||
{}
|
||||
|
||||
//! Function which proceeds to the cooling.
|
||||
/*!
|
||||
It decreases the temperature and indicates if it is greater than the threshold.
|
||||
|
||||
\param _temperature the current temperature.
|
||||
\return if the new temperature (current temperature * ratio) is greater than the threshold.
|
||||
*/
|
||||
bool operator() (double & _temperature)
|
||||
{
|
||||
return (_temperature *= ratio) > threshold;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! The temperature threhold.
|
||||
double threshold;
|
||||
|
||||
//! The decreasing factor of the temperature.
|
||||
double ratio;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -65,6 +65,9 @@ class moGenSolContinue:public moSolContinue < EOT >
|
|||
*/
|
||||
bool operator () (const EOT & _solution)
|
||||
{
|
||||
//code only used for avoiding warning because _sol is not used in this function.
|
||||
const EOT solution(_solution);
|
||||
|
||||
return (++generationNumber < generationMaximumNumber);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class moHCMoveLoopExpl:public moMoveLoopExpl < M >
|
|||
//The best move is applied on the new solution.
|
||||
best_move(_new_solution);
|
||||
|
||||
//The fitness is set (avoid an additional fitness computation).
|
||||
//The fitness is set (avoid an additional fitness compuation).
|
||||
_new_solution.fitness (best_fitness);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,10 +68,13 @@ class moImprBestFitAspirCrit:public moAspirCrit < M >
|
|||
|
||||
\param _move A move.
|
||||
\param _fitness A fitness linked to the move.
|
||||
\return true The first time and if _fitness > best_fitness, else false.
|
||||
\return true The first time and if _fitntess > best_fitness, else false.
|
||||
*/
|
||||
bool operator () (const M & _move, const Fitness & _fitness)
|
||||
{
|
||||
//code only used for avoiding warning because _move is not used in this function.
|
||||
const M move(_move);
|
||||
|
||||
if (first_time)
|
||||
{
|
||||
best_fitness = _fitness;
|
||||
|
|
@ -80,12 +83,14 @@ class moImprBestFitAspirCrit:public moAspirCrit < M >
|
|||
return true;
|
||||
}
|
||||
|
||||
if (_fitness > best_fitness)
|
||||
if (_fitness < best_fitness)
|
||||
{
|
||||
best_fitness = _fitness;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
best_fitness = _fitness;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -72,6 +72,9 @@ class moItRandNextMove:public moNextMove < M >
|
|||
*/
|
||||
bool operator () (M & _move, const EOT & _solution)
|
||||
{
|
||||
//code only used to avoid warning because _solution is not used in this function.
|
||||
const EOT solution(_solution);
|
||||
|
||||
if (iteration_number > iteration_maximum_number)
|
||||
{
|
||||
iteration_number = 0;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,11 @@ class moNoAspirCrit:public moAspirCrit < M >
|
|||
*/
|
||||
bool operator () (const M & _move, const typename M::EOType::Fitness & _fitness)
|
||||
{
|
||||
//Code only used to avoid warning because _move and _fitness are not used in this procedure.
|
||||
const M move(_move);
|
||||
typename M::EOType::Fitness fitness;
|
||||
fitness=(typename M::EOType::Fitness)_fitness;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ class moSimpleMoveTabuList: public moTabuList < M >
|
|||
bool operator () (const M & _move, const EOT & _solution)
|
||||
{
|
||||
moveIterator it;
|
||||
//code only used to avoid warning because _solution is not used in this function.
|
||||
EOT solution=(EOT)_solution;
|
||||
|
||||
it=tabuList.begin();
|
||||
// The code is !(*it)==_move instead of (*it)!=_move because people designing their specific move representation
|
||||
|
|
@ -83,6 +85,8 @@ class moSimpleMoveTabuList: public moTabuList < M >
|
|||
|
||||
void add(const M & _move, const EOT & _solution)
|
||||
{
|
||||
//code only used to avoid warning because _solution is not used in this function.
|
||||
const EOT solution(_solution);
|
||||
|
||||
if (memory_size!=0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,20 +2,20 @@
|
|||
<moTS.h>
|
||||
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,
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
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
|
||||
*/
|
||||
|
|
@ -54,9 +54,9 @@ class moTS:public moAlgo < typename M::EOType >
|
|||
|
||||
//!Alias for the fitness
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//!Constructor of a moTS specifying all the boxes
|
||||
/*!
|
||||
In this constructor, a moTSMoveLoopExpl is instanciated.
|
||||
|
|
@ -69,15 +69,15 @@ class moTS:public moAlgo < typename M::EOType >
|
|||
\param _continue The stopping criterion.
|
||||
\param _full_evaluation A full evaluation function.
|
||||
*/
|
||||
moTS (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moTabuList < M > & _tabu_list,
|
||||
moAspirCrit < M > & _aspiration_criterion, moSolContinue < EOT > & _continue,
|
||||
eoEvalFunc < EOT > & _full_evaluation):
|
||||
moTS (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moTabuList < M > & _tabu_list,
|
||||
moAspirCrit < M > & _aspiration_criterion, moSolContinue < EOT > & _continue,
|
||||
eoEvalFunc < EOT > & _full_evaluation):
|
||||
move_explorer (new moTSMoveLoopExpl < M >(_move_initializer, _next_move_generator, _incremental_evaluation,
|
||||
_tabu_list,_aspiration_criterion) ),
|
||||
continu (_continue), full_evaluation (_full_evaluation), move_explorer_memory_allocation(true)
|
||||
{}
|
||||
|
||||
|
||||
//! Constructor with less parameters
|
||||
/*!
|
||||
The explorer is given in the parameters.
|
||||
|
|
@ -98,44 +98,44 @@ class moTS:public moAlgo < typename M::EOType >
|
|||
delete(move_explorer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Function which launchs the Tabu Search
|
||||
/*!
|
||||
Algorithm of the tabu search.
|
||||
As a moSA or a moHC, it can be used for HYBRIDATION in an evolutionary algorithm.
|
||||
For security a lock (pthread_mutex_t) is closed during the algorithm.
|
||||
|
||||
For security a lock (pthread_mutex_t) is closed during the algorithm.
|
||||
|
||||
\param _solution a solution to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
bool operator ()(EOT & _solution)
|
||||
{
|
||||
M move;
|
||||
|
||||
|
||||
EOT best_solution, new_solution;
|
||||
|
||||
if ( _solution.invalid () )
|
||||
{
|
||||
full_evaluation (_solution);
|
||||
}
|
||||
|
||||
|
||||
best_solution=_solution;
|
||||
|
||||
// code used for avoiding warning because new_solution is indirectly initialized by move_expl.
|
||||
new_solution=_solution;
|
||||
|
||||
|
||||
continu.init ();
|
||||
|
||||
do
|
||||
{
|
||||
(*move_explorer) (_solution, new_solution);
|
||||
|
||||
|
||||
// Updating the best solution found until now ?
|
||||
if (new_solution.fitness() > best_solution.fitness())
|
||||
if (new_solution.fitness() > _solution.fitness())
|
||||
{
|
||||
best_solution = new_solution;
|
||||
}
|
||||
|
||||
|
||||
_solution = new_solution;
|
||||
}
|
||||
while ( continu (_solution) );
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class moVNS : public moAlgo < EOT>
|
|||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//! Generic constructor
|
||||
/*!
|
||||
Generic constructor using a moExpl
|
||||
|
|
@ -62,7 +62,7 @@ public:
|
|||
*/
|
||||
|
||||
moVNS(moExpl< EOT> & _explorer, eoEvalFunc < EOT> & _full_evaluation): explorer(_explorer), full_evaluation(_full_evaluation) {}
|
||||
|
||||
|
||||
|
||||
//! Function which launches the VNS
|
||||
/*!
|
||||
|
|
@ -79,17 +79,16 @@ public:
|
|||
EOT solution_initial=_solution;
|
||||
EOT solution_prime, solution_second;
|
||||
|
||||
|
||||
explorer.setIndice(i);
|
||||
|
||||
while(i<explorer.size()) {
|
||||
solution_prime=solution_initial;
|
||||
if(solution_prime.invalid())
|
||||
full_evaluation(solution_prime);
|
||||
|
||||
explorer(solution_prime, solution_second);
|
||||
|
||||
if(solution_second.invalid())
|
||||
full_evaluation(solution_second);
|
||||
|
||||
if(solution_second > solution_initial) {
|
||||
solution_initial=solution_second;
|
||||
change=true;
|
||||
|
|
@ -103,7 +102,6 @@ public:
|
|||
if(i<explorer.size())
|
||||
explorer.setIndice(i);
|
||||
}
|
||||
|
||||
}
|
||||
_solution=solution_initial;
|
||||
return change;
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ SET (TEST_LIST t-moBestImprSelect
|
|||
t-moTS
|
||||
t-moTS_2
|
||||
t-moTSMoveLoopExpl
|
||||
t-moVNS
|
||||
t-moTA
|
||||
)
|
||||
t-moVNS
|
||||
)
|
||||
|
||||
FOREACH (test ${TEST_LIST})
|
||||
SET ("T_${test}_SOURCES" "${test}.cpp")
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public :
|
|||
class testMoveIncrEval : public moMoveIncrEval <testMove>
|
||||
{
|
||||
public :
|
||||
|
||||
|
||||
testMoveIncrEval() : counter(0)
|
||||
{}
|
||||
|
||||
|
|
@ -94,17 +94,17 @@ public :
|
|||
|
||||
solutionContinue() : counter(0)
|
||||
{}
|
||||
|
||||
|
||||
bool operator () (const solution & _solution)
|
||||
{
|
||||
const solution sol(_solution);
|
||||
|
||||
|
||||
if(counter==0)
|
||||
{
|
||||
counter++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -145,17 +145,17 @@ main()
|
|||
int return_value;
|
||||
|
||||
solution solution;
|
||||
|
||||
|
||||
testRandMove rand;
|
||||
testMoveIncrEval incrEval;
|
||||
solutionContinue continu;
|
||||
testCooling cooling;
|
||||
solutionEval eval;
|
||||
|
||||
|
||||
moTA<testMove> ta(rand, incrEval, continu, 10.0, cooling, eval);
|
||||
|
||||
cout << "[ moTA ] ==> ";
|
||||
|
||||
|
||||
cout << "[ moTA ] ==> ";
|
||||
|
||||
ta(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
IF(COMMAND cmake_policy)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
ENDIF(COMMAND cmake_policy)
|
||||
######################################################################################
|
||||
### 1) Definitions (required for tsp target)
|
||||
######################################################################################
|
||||
|
|
@ -12,82 +14,209 @@ SET(FUNCTION_BIN_DIR ${MO_BIN_DIR}/tutorial/examples/function CACHE PATH "FUNCTI
|
|||
######################################################################################
|
||||
|
||||
######################################################################################
|
||||
### 2) Where must cmake go now ?
|
||||
### 2) How to manage copy of benchs ?
|
||||
######################################################################################
|
||||
|
||||
#SUBDIRS(examples Lesson1 Lesson2 Lesson3 Lesson4 Lesson5 Lesson6)
|
||||
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(Lesson6)
|
||||
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
ADD_CUSTOM_TARGET(install DEPENDS ${MO_SRC_DIR}/tutorial/examples/tsp/benchs
|
||||
${MO_SRC_DIR}/tutorial/Lesson1/param
|
||||
${MO_SRC_DIR}/tutorial/Lesson2/param
|
||||
${MO_SRC_DIR}/tutorial/Lesson3/param
|
||||
${MO_SRC_DIR}/tutorial/Lesson4/param
|
||||
${MO_SRC_DIR}/tutorial/Lesson5/param
|
||||
${MO_SRC_DIR}/tutorial/Lesson6/param )
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET install
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_directory
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs)
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET install
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson1/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson1)
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET install
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson2/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson2)
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET install
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson3/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson3)
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET install
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson4/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson4)
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET install
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson5/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson5)
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET install
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson6/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson6)
|
||||
ADD_SUBDIRECTORY(HybridLesson)
|
||||
|
|
|
|||
65
trunk/paradiseo-mo/tutorial/HybridLesson/CMakeLists.txt
Normal file
65
trunk/paradiseo-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/Lesson6/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-mo/tutorial/HybridLesson/hybrid_ga.cpp
Normal file
194
trunk/paradiseo-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();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue