git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1707 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
baf31d0c30
commit
18901c5769
165 changed files with 38091 additions and 0 deletions
9
trunk/paradiseo-old-mo/AUTHORS
Normal file
9
trunk/paradiseo-old-mo/AUTHORS
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
Source Code:
|
||||
Sebastien CAHON
|
||||
Jean-Charles BOISSON : Jean-Charles.Boisson@lifl.fr
|
||||
|
||||
Lessons:
|
||||
Sebastien CAHON
|
||||
|
||||
Documentation:
|
||||
Jean-Charles BOISSON : Jean-Charles.Boisson@lifl.fr
|
||||
41
trunk/paradiseo-old-mo/CMakeLists.txt
Normal file
41
trunk/paradiseo-old-mo/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
|
||||
##########################################################################################################################################
|
||||
### 0) If you want to set your own variables in mo-conf.cmake and avoid the cmd line
|
||||
##########################################################################################################################################
|
||||
|
||||
INCLUDE(mo-conf.cmake OPTIONAL)
|
||||
|
||||
##########################################################################################################################################
|
||||
|
||||
|
||||
##########################################################################################################################################
|
||||
### 1) Project properties
|
||||
##########################################################################################################################################
|
||||
|
||||
# set the project name
|
||||
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.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)
|
||||
##########################################################################################################################################
|
||||
|
||||
|
||||
##########################################################################################################################################
|
||||
### 2) Include the common CMake configuration
|
||||
##########################################################################################################################################
|
||||
|
||||
# The "config" variable must be provided on the command line
|
||||
IF(NOT DEFINED config OR NOT config)
|
||||
MESSAGE(FATAL_ERROR "The \"config\" variable must be set on the command line to
|
||||
give the path of the install configuration file. ")
|
||||
ENDIF(NOT DEFINED config OR NOT config)
|
||||
|
||||
# Need the config file whose full path is given thanks to the "config" variable
|
||||
INCLUDE(${config})
|
||||
##########################################################################################################################################
|
||||
|
||||
7
trunk/paradiseo-old-mo/CTestConfig.cmake
Normal file
7
trunk/paradiseo-old-mo/CTestConfig.cmake
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
set(CTEST_PROJECT_NAME "ParadisEO")
|
||||
set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
|
||||
|
||||
set(CTEST_DROP_METHOD "http")
|
||||
set(CTEST_DROP_SITE "cdash.inria.fr")
|
||||
set(CTEST_DROP_LOCATION "/CDash/submit.php?project=ParadisEO")
|
||||
set(CTEST_DROP_SITE_CDASH TRUE)
|
||||
76
trunk/paradiseo-old-mo/README
Normal file
76
trunk/paradiseo-old-mo/README
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
PARADISEO-MO README FILE
|
||||
=======================================================================
|
||||
|
||||
=======================================================================
|
||||
|
||||
Welcome to PARADISEO-MO (Moving Objects), one part of the ParadisEO framework.
|
||||
|
||||
=======================================================================
|
||||
BUILDING PARADISEO-MO
|
||||
=======================================================================
|
||||
The basic installation procedure goes the following:
|
||||
|
||||
To compile paradiseo-mo in the default directory,
|
||||
go to paradiseo-mo/build/ and run:
|
||||
> cmake ../ -Dconfig=<path to the install.cmake file>
|
||||
> make
|
||||
// for an easy-use of the provided lessons
|
||||
> make install
|
||||
// optional (if the documentation is not already available)
|
||||
> make doc
|
||||
|
||||
To compile paradiseo-mo anywhere else, simply run:
|
||||
> cmake $(MO) -Dconfig=<path to the install.cmake file>
|
||||
> make
|
||||
// for an easy-use of the provided lessons
|
||||
> make install
|
||||
// optional (if the documentation is not already available)
|
||||
> make doc
|
||||
|
||||
where $(MO) is the top-level directory of PARADISEO-MO.
|
||||
|
||||
To clean everything, simply run
|
||||
> make clean
|
||||
|
||||
======================================================================
|
||||
DIRECTORY STRUCTURE
|
||||
======================================================================
|
||||
After unpacking the archive file, you should end up with the following
|
||||
structure:
|
||||
|
||||
.../ The MAIN PARADISEO-MO directory, created when unpacking.
|
||||
|
|
||||
+-- build Repertory where the executables will be produced.
|
||||
|
|
||||
|
|
||||
+-- src SOURCE directory contains most PARADISEO-MO .h files.
|
||||
|
|
||||
|
|
||||
+-- doc DOCUMENTATION directory (generated by Doxygen).
|
||||
| |
|
||||
| +- html HTML files - start at index.html.
|
||||
| |
|
||||
| +- latex latex files - use to generate Postcript doc.
|
||||
| |
|
||||
| +- man Unix man format documentation.
|
||||
|
|
||||
|
|
||||
+-- tutorial TUTORIAL with lessons
|
||||
|
|
||||
+- examples APPLICATIONS - one directory per separate application.
|
||||
| |
|
||||
| +- tsp traveling salesman problem (TSP) example sources.
|
||||
| |
|
||||
| +- benchs TSP instance files.
|
||||
|
|
||||
+- Lesson1 How make a Hill Climbing on the TSP example (source file and lesson_1.pdf).
|
||||
|
|
||||
+- Lesson2 How make a Tabu Search on the TSP example (source file and lesson_2.pdf).
|
||||
|
|
||||
+- Lesson3 How make a Simulated Annealing on the TSP example (source file and lesson_3.pdf).
|
||||
|
||||
===================================================================
|
||||
NOTES
|
||||
===================================================================
|
||||
|
||||
Mailing list : paradiseo-help@lists.gforge.inria.fr
|
||||
26
trunk/paradiseo-old-mo/doc/CMakeLists.txt
Executable file
26
trunk/paradiseo-old-mo/doc/CMakeLists.txt
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
##########################################################################################
|
||||
### MO Doc generation using Doxygen
|
||||
##########################################################################################
|
||||
|
||||
IF (DOXYGEN_FOUND)
|
||||
|
||||
SET(DOC_DIR ${CMAKE_BINARY_DIR}/doc CACHE PATH "MO documentation directory")
|
||||
SET(MO_DOC_CONFIG_FILE "mo.doxyfile" CACHE PATH "MO documentation configuration file")
|
||||
# define the doc target
|
||||
IF (DOXYGEN_EXECUTABLE)
|
||||
ADD_CUSTOM_TARGET(doc
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${MO_DOC_CONFIG_FILE}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
ENDIF (DOXYGEN_EXECUTABLE)
|
||||
|
||||
# configure doxyfile file
|
||||
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/doc/${MO_DOC_CONFIG_FILE}.cmake"
|
||||
"${CMAKE_BINARY_DIR}/doc/${MO_DOC_CONFIG_FILE}")
|
||||
|
||||
ELSE (DOXYGEN_FOUND)
|
||||
MESSAGE(STATUS "Unable to generate the documentation, Doxygen package not found")
|
||||
ENDIF (DOXYGEN_FOUND)
|
||||
|
||||
##########################################################################################
|
||||
1261
trunk/paradiseo-old-mo/doc/mo.doxyfile.cmake
Normal file
1261
trunk/paradiseo-old-mo/doc/mo.doxyfile.cmake
Normal file
File diff suppressed because it is too large
Load diff
1367
trunk/paradiseo-old-mo/doc/mo.doxytag
Normal file
1367
trunk/paradiseo-old-mo/doc/mo.doxytag
Normal file
File diff suppressed because it is too large
Load diff
6
trunk/paradiseo-old-mo/mo-conf.cmake
Executable file
6
trunk/paradiseo-old-mo/mo-conf.cmake
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
######################################################################################
|
||||
######################################################################################
|
||||
### In this file, you can specify many CMake variables used to build paradisEO-MO.
|
||||
######################################################################################
|
||||
######################################################################################
|
||||
|
||||
4
trunk/paradiseo-old-mo/src/CMakeLists.txt
Normal file
4
trunk/paradiseo-old-mo/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
###############################################################
|
||||
# This is a dummy file
|
||||
###############################################################
|
||||
68
trunk/paradiseo-old-mo/src/index.h
Normal file
68
trunk/paradiseo-old-mo/src/index.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/** @mainpage Welcome to PARADISEO-Moving Objects
|
||||
|
||||
@section Introduction
|
||||
|
||||
MO is an extension of the ANSI-C++ compliant evolutionary computation library EO.
|
||||
<BR>
|
||||
It contains classes for almost any kind of one solution based heuristics.
|
||||
|
||||
@section authors AUTHORS
|
||||
|
||||
<TABLE>
|
||||
<TR>
|
||||
<TD>Sebastien CAHON</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<A href=http://www.lifl.fr/~boisson TARGET=blank>Jean-Charles BOISSON</A>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
@section LICENSE
|
||||
|
||||
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
|
||||
|
||||
|
||||
@section Paradiseo Home Page
|
||||
|
||||
<A href=http://paradiseo.gforge.inria.fr>http://paradiseo.gforge.inria.fr</A>
|
||||
|
||||
@section Installation
|
||||
|
||||
The installation procedure of the package is detailed in the
|
||||
<a href="../../README">README</a> file in the top-directory of the source-tree.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// coding: iso-8859-1
|
||||
// mode: C++
|
||||
// c-file-style: "Stroustrup"
|
||||
// fill-column: 80
|
||||
// End:
|
||||
41
trunk/paradiseo-old-mo/src/mo
Executable file
41
trunk/paradiseo-old-mo/src/mo
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
<mo>
|
||||
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 __mo
|
||||
#define __mo
|
||||
|
||||
#include "mo.h"
|
||||
|
||||
#endif
|
||||
79
trunk/paradiseo-old-mo/src/mo.h
Executable file
79
trunk/paradiseo-old-mo/src/mo.h
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
<mo.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
(C) OPAC Team, LIFL, 2002-2007
|
||||
|
||||
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#ifndef _mo_h
|
||||
#define _mo_h
|
||||
|
||||
#include <moAlgo.h>
|
||||
#include <moAspirCrit.h>
|
||||
#include <moBestImprSelect.h>
|
||||
#include <moComparator.h>
|
||||
#include <moCoolingSchedule.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>
|
||||
#include <moImprBestFitAspirCrit.h>
|
||||
#include <moItRandNextMove.h>
|
||||
#include <moLinearCoolingSchedule.h>
|
||||
#include <moLSCheckPoint.h>
|
||||
#include <moMoveExpl.h>
|
||||
#include <moMove.h>
|
||||
#include <moMoveIncrEval.h>
|
||||
#include <moMoveInit.h>
|
||||
#include <moMoveLoopExpl.h>
|
||||
#include <moMoveSelect.h>
|
||||
#include <moNextMove.h>
|
||||
#include <moNoAspirCrit.h>
|
||||
#include <moNoFitImprSolContinue.h>
|
||||
#include <moRandImprSelect.h>
|
||||
#include <moRandMove.h>
|
||||
#include <moSA.h>
|
||||
#include <moSimpleMoveTabuList.h>
|
||||
#include <moSimpleSolutionTabuList.h>
|
||||
#include <moSolContinue.h>
|
||||
#include <moSteadyFitSolContinue.h>
|
||||
#include <moTabuList.h>
|
||||
#include <moTS.h>
|
||||
#include <moTSMoveLoopExpl.h>
|
||||
#include <moExpl.h>
|
||||
#include <moVNS.h>
|
||||
#include <moTA.h>
|
||||
|
||||
#endif
|
||||
49
trunk/paradiseo-old-mo/src/moAlgo.h
Executable file
49
trunk/paradiseo-old-mo/src/moAlgo.h
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
<moAlgo.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 _moAlgo_h
|
||||
#define _moAlgo_h
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
//! Description of an algorithm of the paradiseo-mo library
|
||||
/*!
|
||||
moHC, moTS and moSA are 3 examples of algorithm of the paradiseo-mo library.
|
||||
*/
|
||||
template < class EOT > class moAlgo:public eoMonOp < EOT >
|
||||
{};
|
||||
|
||||
#endif
|
||||
58
trunk/paradiseo-old-mo/src/moAspirCrit.h
Executable file
58
trunk/paradiseo-old-mo/src/moAspirCrit.h
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
<moAspirCrit.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 _moAspirCrit_h
|
||||
#define _moAspirCrit_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Description of the conditions in which a tabu move could be accepted
|
||||
/*!
|
||||
It is only a description... An object that herits from this class is needed to be used in a moTS.
|
||||
See moNoAspriCrit for example.
|
||||
*/
|
||||
template < class M >
|
||||
class moAspirCrit: public eoBF < const M &, const typename M::EOType::Fitness &, bool >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Procedure which initialises all that needs an aspiration criterion.
|
||||
/*!
|
||||
It can be possible that this procedure does nothing...
|
||||
*/
|
||||
virtual void init () = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
127
trunk/paradiseo-old-mo/src/moBestImprSelect.h
Executable file
127
trunk/paradiseo-old-mo/src/moBestImprSelect.h
Executable file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
<moBestImprSelect.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 _moBestImprSelect_h
|
||||
#define _moBestImprSelect_h
|
||||
|
||||
#include <moMoveSelect.h>
|
||||
|
||||
//! One of the possible moMoveSelect.
|
||||
/*!
|
||||
All neighbors are considered, and the movement
|
||||
which enables the best improvement is selected.
|
||||
*/
|
||||
template < class M >
|
||||
class moBestImprSelect:public moMoveSelect < M >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
||||
//! Procedure which initialise the exploration
|
||||
/*!
|
||||
\param _fitness The current fitness.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
//!Function that indicates if the current move has not improved the fitness.
|
||||
/*!
|
||||
If the given fitness enables an improvment,
|
||||
the move (moMove) and the fitness linked to this move are saved.
|
||||
|
||||
\param _move a move.
|
||||
\param _fitness a fitness linked to the move.
|
||||
\return TRUE if the move does not improve the fitness.
|
||||
*/
|
||||
bool update (const M & _move, const Fitness & _fitness)
|
||||
{
|
||||
if ( first_time || (_fitness > best_fitness) )
|
||||
{
|
||||
best_fitness = _fitness;
|
||||
best_move = _move;
|
||||
|
||||
first_time = false;
|
||||
}
|
||||
|
||||
//std::cout << "best fitness = " << best_fitness << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Procedure which saved the best move and fitness.
|
||||
/*!
|
||||
\param _move the current move (result of the procedure).
|
||||
\param _fitness the current fitness (result of the procedure).
|
||||
*/
|
||||
void operator () (M & _move, Fitness & _fitness)
|
||||
{
|
||||
if(first_time)
|
||||
{
|
||||
throw std::runtime_error("[moBestImprSelect.h]: no move or/and no fitness already saved, update has to be called first.");
|
||||
}
|
||||
|
||||
_move = best_move;
|
||||
_fitness = best_fitness;
|
||||
|
||||
|
||||
//std::cout << "Final fitness = " << best_fitness << std::endl;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Allowing to know if at least one move has been generated.
|
||||
bool first_time;
|
||||
|
||||
//! The best move.
|
||||
M best_move;
|
||||
|
||||
//! The best fitness.
|
||||
Fitness best_fitness;
|
||||
};
|
||||
|
||||
#endif
|
||||
48
trunk/paradiseo-old-mo/src/moComparator.h
Normal file
48
trunk/paradiseo-old-mo/src/moComparator.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
<moComparator.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 _moComparator_h
|
||||
#define _moComparator_h
|
||||
|
||||
|
||||
//! Template for classes which need to compare two EOT and indicate if the first is "better" than the second.
|
||||
/*!
|
||||
The objects that extend this template describe how an EOT is "better" than an other.
|
||||
*/
|
||||
template<class EOT>
|
||||
class moComparator: public eoBF<const EOT &, const EOT &, bool>
|
||||
{};
|
||||
|
||||
#endif
|
||||
49
trunk/paradiseo-old-mo/src/moCoolingSchedule.h
Normal file
49
trunk/paradiseo-old-mo/src/moCoolingSchedule.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
<moCoolingSchedule.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 _moCoolingSchedule_h
|
||||
#define _moCoolingSchedule_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! This class gives the description of a cooling schedule.
|
||||
/*!
|
||||
It is only a description... An object that herits from this class is needed to be used in a moSA.
|
||||
See moExponentialCoolingSchedule or moLinearCoolingSchedule for example.
|
||||
*/
|
||||
class moCoolingSchedule : public eoUF < double &, bool >
|
||||
{};
|
||||
|
||||
#endif
|
||||
113
trunk/paradiseo-old-mo/src/moExpl.h
Normal file
113
trunk/paradiseo-old-mo/src/moExpl.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
<moExpl.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Salma Mesmoudi (salma.mesmoudi@inria.fr), 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 _moExpl_h
|
||||
#define _moExpl_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Description of an explorer
|
||||
/*!
|
||||
This class allows to use any mutation object as a neighborhood.
|
||||
*/
|
||||
template < class EOT >
|
||||
class moExpl : public eoBF < const EOT &, EOT &, bool >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Generic constructor
|
||||
/*!
|
||||
Generic constructor using a eoMonOp
|
||||
|
||||
\param _explorer Algorithme or mutation.
|
||||
|
||||
*/
|
||||
moExpl(eoMonOp<EOT> & _explorer): index(0)
|
||||
{
|
||||
explorers.clear();
|
||||
addExplorer(_explorer);
|
||||
}
|
||||
|
||||
//! Procedure which launches the moExpl.
|
||||
/*!
|
||||
The exploration starts from an old solution and provides a new solution.
|
||||
|
||||
\param _old_solution The current solution.
|
||||
\param _new_solution The new solution (result of the procedure).
|
||||
*/
|
||||
|
||||
bool operator ()(const EOT & _old_solution, EOT & _new_solution)
|
||||
{
|
||||
_new_solution=(EOT)_old_solution;
|
||||
return (*explorers[index])(_new_solution);
|
||||
}
|
||||
|
||||
//! Add an algorithm or mutation to neighborhoods vector
|
||||
void addExplorer(eoMonOp<EOT> & _new_explorer)
|
||||
{
|
||||
explorers.push_back(&_new_explorer);
|
||||
}
|
||||
|
||||
//! Procedure which modified the current explorer to use.
|
||||
/*!
|
||||
\param _index Index of the explorer to use.
|
||||
*/
|
||||
void setCurrentExplorer(unsigned int _index)
|
||||
{
|
||||
if( _index >= explorers.size() )
|
||||
{
|
||||
std::cout << "[" << _index << "]" << std::endl;
|
||||
throw std::runtime_error("[moExpl.h]: bad index "+_index);
|
||||
}
|
||||
index=_index;
|
||||
}
|
||||
|
||||
//! Function which returns the number of explorers already saved.
|
||||
/*!
|
||||
\return The number of explorers contained in the moExpl.
|
||||
*/
|
||||
unsigned int getExplorerNumber()
|
||||
{
|
||||
return explorers.size();
|
||||
}
|
||||
|
||||
private :
|
||||
|
||||
unsigned int index;
|
||||
|
||||
//!Neighborhoods vector
|
||||
std::vector< eoMonOp<EOT>* > explorers;
|
||||
};
|
||||
|
||||
#endif
|
||||
120
trunk/paradiseo-old-mo/src/moFirstImprSelect.h
Executable file
120
trunk/paradiseo-old-mo/src/moFirstImprSelect.h
Executable file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
<moFirstImprSelect.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 _moFirstImprSelect_h
|
||||
#define _moFirstImprSelect_h
|
||||
|
||||
#include <moMoveSelect.h>
|
||||
|
||||
//! One possible moMoveSelect.
|
||||
/*!
|
||||
The neighborhood is explored until
|
||||
a move enables an improvment of the
|
||||
current solution.
|
||||
*/
|
||||
template < class M >
|
||||
class moFirstImprSelect:public moMoveSelect < M >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
||||
//! Procedure which initialise the exploration.
|
||||
/*!
|
||||
It save the current fitness as the initial value for the fitness.
|
||||
\param _fitness The current fitness.
|
||||
*/
|
||||
virtual void init (const Fitness & _fitness)
|
||||
{
|
||||
valid = false;
|
||||
initial_fitness = _fitness;
|
||||
}
|
||||
|
||||
//!Function that indicates if the current move has not improved the fitness.
|
||||
/*!
|
||||
If the given fitness enables an improvment,
|
||||
the move (moMove) should be applied to the current solution.
|
||||
|
||||
\param _move a move.
|
||||
\param _fitness a fitness linked to the move.
|
||||
\return true if the move does not improve the fitness.
|
||||
*/
|
||||
bool update (const M & _move, const Fitness & _fitness)
|
||||
{
|
||||
|
||||
if (_fitness > initial_fitness)
|
||||
{
|
||||
|
||||
best_fitness = _fitness;
|
||||
best_move = _move;
|
||||
valid = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Procedure which saved the best move and fitness.
|
||||
/*!
|
||||
\param _move the current move (result of the procedure).
|
||||
\param _fitness the current fitness (result of the procedure).
|
||||
*/
|
||||
void operator () (M & _move, Fitness & _fitness)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
_move = best_move;
|
||||
_fitness = best_fitness;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Allow to know if at least one move has improved the solution.
|
||||
bool valid;
|
||||
|
||||
//! Best stored movement.
|
||||
M best_move;
|
||||
|
||||
//! Initial fitness.
|
||||
Fitness initial_fitness;
|
||||
|
||||
//! Best stored fitness.
|
||||
Fitness best_fitness;
|
||||
};
|
||||
|
||||
#endif
|
||||
62
trunk/paradiseo-old-mo/src/moFitComparator.h
Normal file
62
trunk/paradiseo-old-mo/src/moFitComparator.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
<moFitComparator.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 _moFitComparator_h
|
||||
#define _moFitComparator_h
|
||||
|
||||
#include <moComparator.h>
|
||||
|
||||
//! Comparison according to the fitness.
|
||||
/*!
|
||||
An EOT is better than an other if its fitness is better.
|
||||
*/
|
||||
template<class EOT>
|
||||
class moFitComparator: public moComparator<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
//! Function which makes the comparison and gives the result.
|
||||
/*!
|
||||
\param _solution1 The first solution.
|
||||
\param _solution2 The second solution.
|
||||
\return true if the fitness of the first solution is better than the second solution, false else.
|
||||
*/
|
||||
bool operator()(const EOT & _solution1, const EOT & _solution2)
|
||||
{
|
||||
return _solution1.fitness() > _solution2.fitness();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
90
trunk/paradiseo-old-mo/src/moFitSolContinue.h
Normal file
90
trunk/paradiseo-old-mo/src/moFitSolContinue.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
<moFitSolContinue.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 _moFitSolContinue_h
|
||||
#define _moFitSolContinue_h
|
||||
|
||||
#include <moSolContinue.h>
|
||||
|
||||
//! One possible stop criterion for a solution-based heuristic.
|
||||
/*!
|
||||
The stop criterion corresponds to a fitness threshold gained.
|
||||
*/
|
||||
template < class EOT >
|
||||
class moFitSolContinue:public moSolContinue < EOT >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
//! Basic constructor.
|
||||
/*!
|
||||
\param _fitness The fitness to reach.
|
||||
*/
|
||||
moFitSolContinue (Fitness _fitness): fitness(_fitness)
|
||||
{}
|
||||
|
||||
//! Function that activates the stopping criterion.
|
||||
/*!
|
||||
Indicates if the fitness threshold has not yet been reached.
|
||||
|
||||
\param _solution the current solution.
|
||||
\return true or false according to the value of the fitness.
|
||||
*/
|
||||
bool operator () (const EOT & _solution)
|
||||
{
|
||||
if ( _solution.invalid() )
|
||||
{
|
||||
throw std::runtime_error("[moFitSolContinue.h]: The current solution has not been evaluated.");
|
||||
}
|
||||
|
||||
return fitness > _solution.fitness();
|
||||
}
|
||||
|
||||
//! Procedure which allows to initialise all the stuff needed.
|
||||
/*!
|
||||
It can be also used to reinitialize all the needed things.
|
||||
*/
|
||||
void init ()
|
||||
{}
|
||||
|
||||
private:
|
||||
|
||||
//! Fitness target.
|
||||
Fitness fitness;
|
||||
};
|
||||
|
||||
#endif
|
||||
92
trunk/paradiseo-old-mo/src/moGenSolContinue.h
Executable file
92
trunk/paradiseo-old-mo/src/moGenSolContinue.h
Executable file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
<moGenSolContinue.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 _moGenSolContinue_h
|
||||
#define _moGenSolContinue_h
|
||||
|
||||
#include "moSolContinue.h"
|
||||
|
||||
//! One possible stop criterion for a solution-based heuristic.
|
||||
/*!
|
||||
The stop criterion corresponds to a maximum number of iteration.
|
||||
*/
|
||||
template < class EOT >
|
||||
class moGenSolContinue:public moSolContinue < EOT >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Simple constructor.
|
||||
/*!
|
||||
\param _generationMaximumNumber The maximum number of generations.
|
||||
*/
|
||||
moGenSolContinue (unsigned int _generationMaximumNumber): generationMaximumNumber(_generationMaximumNumber), generationNumber(0)
|
||||
{}
|
||||
|
||||
//! Function that activates the stop criterion.
|
||||
/*!
|
||||
Increments the counter and returns TRUE if the
|
||||
current number of iteration is lower than the given
|
||||
maximum number of iterations.
|
||||
|
||||
\param _solution The current solution.
|
||||
\return true or false according to the current generation number.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
//! Procedure which allows to initialise the generation counter.
|
||||
/*!
|
||||
It can also be used to reset the iteration counter.
|
||||
*/
|
||||
void init ()
|
||||
{
|
||||
generationNumber = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Iteration maximum number.
|
||||
unsigned int generationMaximumNumber;
|
||||
|
||||
//! Iteration current number.
|
||||
unsigned int generationNumber;
|
||||
};
|
||||
|
||||
#endif
|
||||
79
trunk/paradiseo-old-mo/src/moGeometricCoolingSchedule.h
Normal file
79
trunk/paradiseo-old-mo/src/moGeometricCoolingSchedule.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
<moGeometricCoolingSchedule.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 _moGeometricCoolingSchedule_h
|
||||
#define _moGeometricCoolingSchedule_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 moGeometricCoolingSchedule: public moCoolingSchedule
|
||||
{
|
||||
public:
|
||||
|
||||
//! Simple constructor
|
||||
/*!
|
||||
\param _threshold the threshold.
|
||||
\param _ratio the ratio used to descrease the temperature.
|
||||
*/
|
||||
moGeometricCoolingSchedule (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
|
||||
136
trunk/paradiseo-old-mo/src/moHC.h
Executable file
136
trunk/paradiseo-old-mo/src/moHC.h
Executable file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
<moHC.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 __moHC_h
|
||||
#define __moHC_h
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
#include <moAlgo.h>
|
||||
#include <moHCMoveLoopExpl.h>
|
||||
|
||||
//! Hill Climbing (HC)
|
||||
/*!
|
||||
Class which describes the algorithm for a hill climbing.
|
||||
*/
|
||||
template < class M >
|
||||
class moHC:public moAlgo < typename M::EOType >
|
||||
{
|
||||
//! Alias for the type.
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//! Full constructor.
|
||||
/*!
|
||||
All the boxes are given in order the HC to use a moHCMoveLoopExpl.
|
||||
|
||||
\param _move_initializer a move initialiser.
|
||||
\param _next_move_generator a neighborhood explorer.
|
||||
\param _incremental_evaluation a (generally) efficient evaluation function.
|
||||
\param _move_selection a move selector.
|
||||
\param _full_evaluation a full evaluation function.
|
||||
*/
|
||||
moHC (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moMoveSelect < M > & _move_selection, eoEvalFunc < EOT > & _full_evaluation) :
|
||||
move_explorer(new moHCMoveLoopExpl<M>(_move_initializer, _next_move_generator, _incremental_evaluation, _move_selection)),
|
||||
full_evaluation (_full_evaluation), move_explorer_memory_allocation(true)
|
||||
{}
|
||||
|
||||
//! Light constructor.
|
||||
/*!
|
||||
This constructor allow to use another moMoveExpl (generally not a moHCMoveLoopExpl).
|
||||
|
||||
\param _move_explorer a complete explorer.
|
||||
\param _full_evaluation a full evaluation function.
|
||||
*/
|
||||
moHC (moMoveExpl < M > & _move_explorer, eoEvalFunc < EOT > & _full_evaluation):
|
||||
move_explorer (&_move_explorer), full_evaluation (_full_evaluation), move_explorer_memory_allocation(false)
|
||||
{}
|
||||
|
||||
//! Destructor
|
||||
~moHC()
|
||||
{
|
||||
if(move_explorer_memory_allocation)
|
||||
{
|
||||
delete(move_explorer);
|
||||
}
|
||||
}
|
||||
|
||||
//! Function which launches the HC
|
||||
/*!
|
||||
The HC has to improve a current solution.
|
||||
As the moSA and the mo TS, it can be used for HYBRIDATION in an evolutionnary algorithm.
|
||||
|
||||
\param _solution a current solution to improve.
|
||||
\return true.
|
||||
*/
|
||||
bool operator ()(EOT & _solution)
|
||||
{
|
||||
EOT new_solution;
|
||||
|
||||
if ( _solution.invalid() )
|
||||
{
|
||||
full_evaluation(_solution);
|
||||
}
|
||||
|
||||
new_solution=_solution;
|
||||
|
||||
do
|
||||
{
|
||||
_solution=new_solution;
|
||||
(*move_explorer) (_solution, new_solution);
|
||||
}
|
||||
while ( new_solution.fitness() > _solution.fitness() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Complete exploration of the neighborhood.
|
||||
moMoveExpl < M > * move_explorer;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & full_evaluation;
|
||||
|
||||
//! Indicate if the memory has been allocated for the move_explorer.
|
||||
bool move_explorer_memory_allocation;
|
||||
};
|
||||
|
||||
#endif
|
||||
138
trunk/paradiseo-old-mo/src/moHCMoveLoopExpl.h
Executable file
138
trunk/paradiseo-old-mo/src/moHCMoveLoopExpl.h
Executable file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
<moHCMoveLoopExpl.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 __moHCMoveLoopExpl_h
|
||||
#define __moHCMoveLoopExpl_h
|
||||
|
||||
#include <moMoveLoopExpl.h>
|
||||
#include <moMoveInit.h>
|
||||
#include <moNextMove.h>
|
||||
#include <moMoveIncrEval.h>
|
||||
#include <moMoveSelect.h>
|
||||
|
||||
//! Iterative explorer used by a moHC.
|
||||
template < class M >
|
||||
class moHCMoveLoopExpl:public moMoveLoopExpl < M >
|
||||
{
|
||||
//! Alias for the type.
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
/*!
|
||||
All the boxes have to be specified.
|
||||
|
||||
\param _move_initializer The move initialiser.
|
||||
\param _next_move_generator The neighbourhood explorer.
|
||||
\param _incremental_evaluation (generally) Efficient evaluation function.
|
||||
\param _move_selection The move selector.
|
||||
*/
|
||||
moHCMoveLoopExpl (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moMoveSelect < M > & _move_selection) :
|
||||
move_initializer (_move_initializer), next_move_generator (_next_move_generator),
|
||||
incremental_evaluation (_incremental_evaluation), move_selection (_move_selection)
|
||||
{}
|
||||
|
||||
//! Procedure which launches the explorer.
|
||||
/*!
|
||||
The exploration starts from an old solution and provides a new solution.
|
||||
|
||||
\param _old_solution The current solution.
|
||||
\param _new_solution The new solution (result of the procedure).
|
||||
*/
|
||||
void operator () (const EOT & _old_solution, EOT & _new_solution)
|
||||
{
|
||||
M move, best_move;
|
||||
Fitness best_fitness;
|
||||
bool has_next_move, selection_update_is_ok;
|
||||
|
||||
if( _old_solution.invalid() )
|
||||
{
|
||||
throw std::runtime_error("[moHCMoveLoopExpl.h]: The current solution has not been evaluated.");
|
||||
}
|
||||
|
||||
/*
|
||||
The two following lines are added to avoid compilation warning.
|
||||
<=> current best move fitness is the current fitness.
|
||||
<=> move and best move are empty for the moment.
|
||||
*/
|
||||
best_fitness=_old_solution.fitness();
|
||||
move=best_move;
|
||||
|
||||
//At the begining, the new sol is equivalent to the old one.
|
||||
_new_solution=(EOT)_old_solution;
|
||||
|
||||
// Restarting the exploration of the neighbourhood
|
||||
move_initializer(move, _old_solution);
|
||||
|
||||
move_selection.init(_old_solution.fitness ());
|
||||
|
||||
do
|
||||
{
|
||||
selection_update_is_ok = move_selection.update (move, incremental_evaluation(move, _old_solution) );
|
||||
has_next_move = next_move_generator (move, _old_solution);
|
||||
}
|
||||
while ( selection_update_is_ok && has_next_move);
|
||||
|
||||
//The selecter gives the value of the best move and the corresponding best fitness.
|
||||
move_selection (best_move, best_fitness);
|
||||
|
||||
//The best move is applied on the new solution.
|
||||
best_move(_new_solution);
|
||||
|
||||
//The fitness is set (avoid an additional fitness compuation).
|
||||
_new_solution.fitness (best_fitness);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Move initialiser.
|
||||
moMoveInit < M > & move_initializer;
|
||||
|
||||
//! Neighborhood explorer.
|
||||
moNextMove < M > & next_move_generator;
|
||||
|
||||
//! (generally) Efficient evaluation.
|
||||
moMoveIncrEval < M > & incremental_evaluation;
|
||||
|
||||
//! Move selector.
|
||||
moMoveSelect < M > & move_selection;
|
||||
};
|
||||
|
||||
#endif
|
||||
228
trunk/paradiseo-old-mo/src/moILS.h
Normal file
228
trunk/paradiseo-old-mo/src/moILS.h
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
<moILS.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 _moILS_h
|
||||
#define _moILS_h
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
#include <moHC.h>
|
||||
#include <moTS.h>
|
||||
#include <moSA.h>
|
||||
|
||||
//! Iterated Local Search (ILS)
|
||||
/*!
|
||||
Class which describes the algorithm for a iterated local search.
|
||||
*/
|
||||
template < class M >
|
||||
class moILS:public moAlgo < typename M::EOType >
|
||||
{
|
||||
//! Alias for the type.
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//! Generic constructor
|
||||
/*!
|
||||
Generic constructor using a moAlgo
|
||||
|
||||
\param _algorithm The solution based heuristic to use.
|
||||
\param _continue The stopping criterion.
|
||||
\param _acceptance_criterion The acceptance criterion.
|
||||
\param _perturbation The pertubation generator.
|
||||
\param _full_evaluation The evaluation function.
|
||||
*/
|
||||
moILS (moAlgo<EOT> & _algorithm, moSolContinue <EOT> & _continue, moComparator<EOT> & _acceptance_criterion,
|
||||
eoMonOp<EOT> & _perturbation, eoEvalFunc<EOT> & _full_evaluation):
|
||||
algorithm(& _algorithm), continu(_continue), acceptance_criterion(_acceptance_criterion),
|
||||
perturbation(_perturbation), full_evaluation(_full_evaluation), algorithm_memory_allocation(false)
|
||||
{}
|
||||
|
||||
//! Constructor for using a moHC for the moAlgo
|
||||
/*!
|
||||
\param _move_initializer The move initialisation (for the moHC).
|
||||
\param _next_move_generator The move generator (for the moHC).
|
||||
\param _incremental_evaluation The partial evaluation function (for the moHC).
|
||||
\param _move_selection The move selection strategy (for the moHC).
|
||||
\param _continue The stopping criterion.
|
||||
\param _acceptance_criterion The acceptance criterion.
|
||||
\param _perturbation The pertubation generator.
|
||||
\param _full_evaluation The evaluation function.
|
||||
*/
|
||||
moILS (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moMoveSelect < M > & _move_selection,
|
||||
moSolContinue <EOT> & _continue, moComparator<EOT> & _acceptance_criterion,
|
||||
eoMonOp<EOT> & _perturbation, eoEvalFunc<EOT> & _full_evaluation):
|
||||
algorithm(new moHC<M>(_move_initializer, _next_move_generator, _incremental_evaluation, _move_selection, _full_evaluation) ),
|
||||
continu(_continue), acceptance_criterion(_acceptance_criterion), perturbation(_perturbation), full_evaluation(_full_evaluation),
|
||||
algorithm_memory_allocation(true)
|
||||
{}
|
||||
|
||||
//! Constructor for using a moTS for the moAlgo
|
||||
/*!
|
||||
\param _move_initializer The move initialisation (for the moTS).
|
||||
\param _next_move_generator The move generator (for the moTS).
|
||||
\param _incremental_evaluation The partial evaluation function (for the moTS).
|
||||
\param _tabu_list The tabu list (for the moTS !!!!).
|
||||
\param _aspiration_criterion The aspiration criterion (for the moTS).
|
||||
\param _moTS_continue The stopping criterion (for the moTS).
|
||||
\param _continue The stopping criterion.
|
||||
\param _acceptance_criterion The acceptance criterion.
|
||||
\param _perturbation The pertubation generator.
|
||||
\param _full_evaluation The evaluation function.
|
||||
*/
|
||||
moILS (moMoveInit <M> & _move_initializer, moNextMove <M> & _next_move_generator,
|
||||
moMoveIncrEval <M> & _incremental_evaluation, moTabuList <M> & _tabu_list,
|
||||
moAspirCrit <M> & _aspiration_criterion, moSolContinue <EOT> & _moTS_continue,
|
||||
moSolContinue <EOT> & _continue, moComparator<EOT> & _acceptance_criterion, eoMonOp<EOT> & _perturbation,
|
||||
eoEvalFunc<EOT> & _full_evaluation):
|
||||
algorithm(new moTS<M>(_move_initializer, _next_move_generator, _incremental_evaluation, _tabu_list, _aspiration_criterion,
|
||||
_moTS_continue, _full_evaluation) ),
|
||||
continu(_continue), acceptance_criterion(_acceptance_criterion), perturbation(_perturbation), full_evaluation(_full_evaluation),
|
||||
algorithm_memory_allocation(true)
|
||||
{}
|
||||
|
||||
//! Constructor for using a moSA for the moAlgo
|
||||
/*!
|
||||
\param _random_move_generator The random move generator (for the moSA).
|
||||
\param _incremental_evaluation The partial evaluation function (for the moSA).
|
||||
\param _moSA_continue The stopping criterion (for the moSA).
|
||||
\param _initial_temperature The initial temperature (for the moSA).
|
||||
\param _cooling_schedule The cooling schedule (for the moSA).
|
||||
\param _continue The stopping criterion.
|
||||
\param _acceptance_criterion The acceptance criterion.
|
||||
\param _perturbation The pertubation generator.
|
||||
\param _full_evaluation The evaluation function.
|
||||
*/
|
||||
moILS (moRandMove<M> & _random_move_generator, moMoveIncrEval <M> & _incremental_evaluation, moSolContinue <EOT> & _moSA_continue,
|
||||
double _initial_temperature, moCoolingSchedule & _cooling_schedule, moSolContinue <EOT> & _continue,
|
||||
moComparator<EOT> & _acceptance_criterion, eoMonOp<EOT> & _perturbation, eoEvalFunc<EOT> & _full_evaluation):
|
||||
algorithm(new moSA<M>(_random_move_generator, _incremental_evaluation, _moSA_continue, _initial_temperature,
|
||||
_cooling_schedule, _full_evaluation) ),
|
||||
continu(_continue), acceptance_criterion(_acceptance_criterion), perturbation(_perturbation), full_evaluation(_full_evaluation),
|
||||
algorithm_memory_allocation(true)
|
||||
{}
|
||||
|
||||
//! Destructor
|
||||
~moILS()
|
||||
{
|
||||
if(algorithm_memory_allocation)
|
||||
{
|
||||
delete(algorithm);
|
||||
}
|
||||
}
|
||||
|
||||
//! Function which launches the ILS
|
||||
/*!
|
||||
The ILS has to improve a current solution.
|
||||
As the moSA, the moTS and the moHC, it can be used for HYBRIDATION in an evolutionnary algorithm.
|
||||
|
||||
\param _solution a current solution to improve.
|
||||
\return true.
|
||||
*/
|
||||
bool operator()(EOT & _solution)
|
||||
{
|
||||
EOT _solution_saved;
|
||||
|
||||
if ( _solution.invalid() )
|
||||
{
|
||||
full_evaluation(_solution);
|
||||
}
|
||||
|
||||
_solution_saved=_solution;
|
||||
|
||||
continu.init ();
|
||||
|
||||
// some code has been duplicated in order to avoid one perturbation and one evaluation without adding a test in the loop.
|
||||
// better than a do {} while; with a test in the loop.
|
||||
|
||||
(*algorithm)(_solution);
|
||||
|
||||
if ( acceptance_criterion(_solution, _solution_saved) )
|
||||
{
|
||||
_solution_saved=_solution;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_solution=_solution_saved;
|
||||
}
|
||||
|
||||
while ( continu (_solution) )
|
||||
{
|
||||
perturbation(_solution);
|
||||
//_solution.invalidate();
|
||||
full_evaluation(_solution);
|
||||
|
||||
(*algorithm)(_solution);
|
||||
|
||||
if ( acceptance_criterion(_solution, _solution_saved) )
|
||||
{
|
||||
_solution_saved=_solution;
|
||||
}
|
||||
else
|
||||
{
|
||||
_solution=_solution_saved;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! The solution based heuristic.
|
||||
moAlgo<EOT> * algorithm;
|
||||
|
||||
//! The stopping criterion.
|
||||
moSolContinue<EOT> & continu;
|
||||
|
||||
//! The acceptance criterion.
|
||||
moComparator<EOT> & acceptance_criterion;
|
||||
|
||||
//! The perturbation generator
|
||||
eoMonOp<EOT> & perturbation;
|
||||
|
||||
//! The full evaluation function
|
||||
eoEvalFunc<EOT> & full_evaluation;
|
||||
|
||||
//! Indicate if the memory has been allocated for the algorithm.
|
||||
bool algorithm_memory_allocation;
|
||||
};
|
||||
|
||||
#endif
|
||||
103
trunk/paradiseo-old-mo/src/moImprBestFitAspirCrit.h
Executable file
103
trunk/paradiseo-old-mo/src/moImprBestFitAspirCrit.h
Executable file
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
<moImprBestFitAspirCrit.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 _moImprBestFitAspirCrit_h
|
||||
#define _moImprBestFitAspirCrit_h
|
||||
|
||||
#include <moAspirCrit.h>
|
||||
|
||||
//! One of the possible moAspirCrit
|
||||
/*!
|
||||
This criterion is satisfied when a given fitness
|
||||
is the best ever considered.
|
||||
*/
|
||||
template < class M >
|
||||
class moImprBestFitAspirCrit:public moAspirCrit < M >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
||||
//! Contructor
|
||||
moImprBestFitAspirCrit (): first_time(true)
|
||||
{}
|
||||
|
||||
//! Initialisation procedure
|
||||
void init ()
|
||||
{
|
||||
first_time = true;
|
||||
}
|
||||
|
||||
//! Function that indicates if the current fitness is better that the already saved fitness
|
||||
/*!
|
||||
The first time, the function only saved the current move and fitness.
|
||||
|
||||
\param _move A move.
|
||||
\param _fitness A fitness linked to the move.
|
||||
\return true The first time and if _fitness > 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;
|
||||
first_time = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_fitness > best_fitness)
|
||||
{
|
||||
best_fitness = _fitness;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Best fitness found until now
|
||||
Fitness best_fitness;
|
||||
|
||||
//! Indicates that a fitness has been already saved or not
|
||||
bool first_time;
|
||||
};
|
||||
|
||||
#endif
|
||||
102
trunk/paradiseo-old-mo/src/moItRandNextMove.h
Executable file
102
trunk/paradiseo-old-mo/src/moItRandNextMove.h
Executable file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
<moItRandNextMove.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 _moItRandNextMove_h
|
||||
#define _moItRandNextMove_h
|
||||
|
||||
#include <moNextMove.h>
|
||||
#include <moRandMove.h>
|
||||
|
||||
//! One of the possible moNextMove.
|
||||
/*!
|
||||
This class is a move (moMove) generator with a bound for the maximum number of iterations.
|
||||
*/
|
||||
template < class M >
|
||||
class moItRandNextMove:public moNextMove < M >
|
||||
{
|
||||
//! Alias for the type.
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
public:
|
||||
|
||||
//! The constructor.
|
||||
/*!
|
||||
Parameters only for initialising the attributes.
|
||||
|
||||
\param _random_move_generator The random move generator.
|
||||
\param _iteration_maximum_number The iteration maximum number.
|
||||
*/
|
||||
moItRandNextMove (moRandMove < M > & _random_move_generator, unsigned int _iteration_maximum_number):
|
||||
random_move_generator(_random_move_generator), iteration_maximum_number(_iteration_maximum_number), iteration_number(0)
|
||||
{}
|
||||
|
||||
//! Generation of a new move
|
||||
/*!
|
||||
If the maximum number is not already reached, the current move is forgotten and remplaced by another one.
|
||||
|
||||
\param _move the current move.
|
||||
\param _solution the current solution.
|
||||
\return false if the maximum number of iteration is reached, else true.
|
||||
*/
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
random_move_generator (_move);
|
||||
iteration_number++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! A move generator (generally randomly).
|
||||
moRandMove < M > & random_move_generator;
|
||||
|
||||
//! Iteration maximum number.
|
||||
unsigned int iteration_maximum_number;
|
||||
|
||||
//! Iteration current number.
|
||||
unsigned int iteration_number;
|
||||
};
|
||||
|
||||
#endif
|
||||
83
trunk/paradiseo-old-mo/src/moLSCheckPoint.h
Executable file
83
trunk/paradiseo-old-mo/src/moLSCheckPoint.h
Executable file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
<moLSCheckPoint.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 _moLSCheckPoint_h
|
||||
#define _moLSCheckPoint_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Class which allows a checkpointing system.
|
||||
/*!
|
||||
Thanks to this class, at each iteration, additionnal function can be used (and not only one).
|
||||
*/
|
||||
template < class M >
|
||||
class moLSCheckPoint:public eoBF < const M &, const typename M::EOType &, void >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Function which launches the checkpointing
|
||||
/*!
|
||||
Each saved function is used on the current move and the current solution.
|
||||
|
||||
\param _move a move.
|
||||
\param _solution a solution.
|
||||
*/
|
||||
void operator () (const M & _move, const typename M::EOType & _solution)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < functions.size (); i++)
|
||||
{
|
||||
functions[i]->operator ()(_move, _solution);
|
||||
}
|
||||
}
|
||||
|
||||
//! Procedure which add a new function to the function vector
|
||||
/*!
|
||||
The new function is added at the end of the vector.
|
||||
\param _function a new function to add.
|
||||
*/
|
||||
void add (eoBF < const M &, const typename M::EOType &, void >& _function)
|
||||
{
|
||||
functions.push_back(& _function);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Vector of functions.
|
||||
std::vector < eoBF < const M &, const typename M::EOType &, void >*> functions;
|
||||
};
|
||||
|
||||
#endif
|
||||
79
trunk/paradiseo-old-mo/src/moLinearCoolingSchedule.h
Normal file
79
trunk/paradiseo-old-mo/src/moLinearCoolingSchedule.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
<moLinearCoolingSchedule.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 _moLinearCoolingSchedule_h
|
||||
#define _moLinearCoolingSchedule_h
|
||||
|
||||
#include <moCoolingSchedule.h>
|
||||
|
||||
//! One of the possible moCoolingSchedule
|
||||
/*!
|
||||
An another very simple cooling schedule, the temperature decrease according to a quantity while
|
||||
the temperature is greater than a threshold.
|
||||
*/
|
||||
class moLinearCoolingSchedule: public moCoolingSchedule
|
||||
{
|
||||
|
||||
public:
|
||||
//! Simple constructor
|
||||
/*!
|
||||
\param _threshold the threshold.
|
||||
\param _quantity the quantity used to descrease the temperature.
|
||||
*/
|
||||
moLinearCoolingSchedule (double _threshold, double _quantity):threshold (_threshold), quantity (_quantity)
|
||||
{}
|
||||
|
||||
//! Function which proceeds to the cooling.
|
||||
/*!
|
||||
It decreases the temperature and indicates if it is greater than the threshold.
|
||||
|
||||
\param _current_temperature The current temperature.
|
||||
\return true if the new temperature (current temperature - quantity) is greater than the threshold, false otherwise.
|
||||
*/
|
||||
bool operator() (double & _current_temperature)
|
||||
{
|
||||
return (_current_temperature -= quantity) > threshold;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! The temperature threhold.
|
||||
double threshold;
|
||||
|
||||
//! The quantity that allows the temperature to decrease.
|
||||
double quantity;
|
||||
};
|
||||
|
||||
#endif
|
||||
57
trunk/paradiseo-old-mo/src/moMove.h
Executable file
57
trunk/paradiseo-old-mo/src/moMove.h
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
<moMove.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 _moMove_h
|
||||
#define _moMove_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Definition of a move.
|
||||
|
||||
/*!
|
||||
A move transforms a solution to another close solution.
|
||||
It describes how a solution can be modified to another one.
|
||||
*/
|
||||
template < class EOT >
|
||||
class moMove:public eoUF < EOT &, void >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the type
|
||||
typedef EOT EOType;
|
||||
};
|
||||
|
||||
#endif
|
||||
49
trunk/paradiseo-old-mo/src/moMoveExpl.h
Executable file
49
trunk/paradiseo-old-mo/src/moMoveExpl.h
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
<moMoveExpl.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 _moMoveExpl_h
|
||||
#define _moMoveExpl_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Description of a move (moMove) explorer
|
||||
/*!
|
||||
Only a description...See moMoveLoopExpl.
|
||||
*/
|
||||
template < class M >
|
||||
class moMoveExpl : public eoBF < const typename M::EOType &, typename M::EOType &, void >
|
||||
{};
|
||||
|
||||
#endif
|
||||
52
trunk/paradiseo-old-mo/src/moMoveIncrEval.h
Executable file
52
trunk/paradiseo-old-mo/src/moMoveIncrEval.h
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
<moMoveIncrEval.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 _moMoveIncrEval_h
|
||||
#define _moMoveIncrEval_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! (generally) Efficient evaluation function based a move and a solution.
|
||||
|
||||
/*!
|
||||
From a move and a solution, it computes
|
||||
a new fitness that could be associated to
|
||||
the solution if this one is updated.
|
||||
*/
|
||||
template < class M, class Objective = typename M::EOType::Fitness>
|
||||
class moMoveIncrEval:public eoBF < const M &, const typename M::EOType &, Objective >
|
||||
{};
|
||||
|
||||
#endif
|
||||
50
trunk/paradiseo-old-mo/src/moMoveInit.h
Executable file
50
trunk/paradiseo-old-mo/src/moMoveInit.h
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
<moMoveInit.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 _moMoveInit_h
|
||||
#define _moMoveInit_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Move (moMove) initializer
|
||||
/*!
|
||||
Class which allows to initiase a move.
|
||||
Only a description... An object that herits from this class needs to be designed to be used.
|
||||
*/
|
||||
template < class M >
|
||||
class moMoveInit:public eoBF < M &, const typename M::EOType &, void >
|
||||
{};
|
||||
|
||||
#endif
|
||||
50
trunk/paradiseo-old-mo/src/moMoveLoopExpl.h
Executable file
50
trunk/paradiseo-old-mo/src/moMoveLoopExpl.h
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
<moMoveLoopExpl.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 _moMoveLoopExpl_h
|
||||
#define _moMoveLoopExpl_h
|
||||
|
||||
#include <moMoveExpl.h>
|
||||
|
||||
//! Class which describes an iterative explorer
|
||||
/*!
|
||||
Only a description... moHCMoveLoopExpl and moTSMoveLoopExpl are exemples of class that are a moMoveLoopExpl.
|
||||
*/
|
||||
template < class M >
|
||||
class moMoveLoopExpl:public moMoveExpl < M >
|
||||
{};
|
||||
|
||||
#endif
|
||||
76
trunk/paradiseo-old-mo/src/moMoveSelect.h
Executable file
76
trunk/paradiseo-old-mo/src/moMoveSelect.h
Executable file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
<moMoveSelect.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 _moMoveSelect_h
|
||||
#define _moMoveSelect_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
#include <stdexcept>
|
||||
|
||||
//! Class that describes a move selector (moMove).
|
||||
/*!
|
||||
It iteratively considers some moves (moMove) and their
|
||||
associated fitnesses. The best move is so regularly updated.
|
||||
At any time, it could be accessed.
|
||||
*/
|
||||
template < class M >
|
||||
class moMoveSelect:public eoBF < M &, typename M::EOType::Fitness &, void >
|
||||
{
|
||||
public:
|
||||
//! Alias for the fitness
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
||||
//! Procedure which initialises all that the move selector needs including the initial fitness.
|
||||
/*!
|
||||
In order to know the fitness of the solution,
|
||||
for which the neighborhood will
|
||||
be soon explored
|
||||
|
||||
\param _fitness the current fitness.
|
||||
*/
|
||||
virtual void init (const Fitness & _fitness) = 0;
|
||||
|
||||
//! Function which updates the best solutions.
|
||||
/*!
|
||||
\param _move a new move.
|
||||
\param _fitness a fitness linked to the new move.
|
||||
\return a boolean that expresses the need to resume the exploration.
|
||||
*/
|
||||
virtual bool update (const M & _move, const Fitness & _fitness) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
50
trunk/paradiseo-old-mo/src/moNextMove.h
Executable file
50
trunk/paradiseo-old-mo/src/moNextMove.h
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
<moNextMove.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 _moNextMove_h
|
||||
#define _moNextMove_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Class which allows to generate a new move (moMove).
|
||||
/*!
|
||||
Useful for the explorer (for moTS or moHC).
|
||||
Does nothing... An object that herits from this class needs to be designed for being used.
|
||||
*/
|
||||
template < class M >
|
||||
class moNextMove:public eoBF < M &, const typename M::EOType &, bool >
|
||||
{};
|
||||
|
||||
#endif
|
||||
77
trunk/paradiseo-old-mo/src/moNoAspirCrit.h
Executable file
77
trunk/paradiseo-old-mo/src/moNoAspirCrit.h
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
<moNoAspirCrit.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 _moNoAspirCrit_h
|
||||
#define _moNoAspirCrit_h
|
||||
|
||||
#include <moAspirCrit.h>
|
||||
|
||||
//! One of the possible aspiration criterion (moAspirCrit)
|
||||
/*!
|
||||
The simplest : never satisfied.
|
||||
*/
|
||||
template < class M >
|
||||
class moNoAspirCrit:public moAspirCrit < M >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Function which describes the aspiration criterion behaviour
|
||||
/*!
|
||||
Does nothing.
|
||||
|
||||
\param _move a move.
|
||||
\param _fitness a fitness.
|
||||
\return false.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
//! Procedure which initialises all that needs a moNoAspirCrit.
|
||||
/*!
|
||||
Nothing...
|
||||
*/
|
||||
void init ()
|
||||
{}
|
||||
};
|
||||
|
||||
#endif
|
||||
123
trunk/paradiseo-old-mo/src/moNoFitImprSolContinue.h
Normal file
123
trunk/paradiseo-old-mo/src/moNoFitImprSolContinue.h
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
<moNoFitImprSolContinue.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 _moNoFitImprSolContinue_h
|
||||
#define _moNoFitImprSolContinue_h
|
||||
|
||||
#include <moSolContinue.h>
|
||||
|
||||
//! One possible stop criterion for a solution-based heuristic.
|
||||
/*!
|
||||
The stop criterion corresponds to a maximum number of iterations without improvement.
|
||||
*/
|
||||
template < class EOT >
|
||||
class moNoFitImprSolContinue:public moSolContinue < EOT >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
//! Basic constructor.
|
||||
/*!
|
||||
\param _maxNumberOfIterationWithoutImprovement The number of iterations without fitness improvement to reach for stop.
|
||||
*/
|
||||
moNoFitImprSolContinue (unsigned int _maxNumberOfIterationWithoutImprovement)
|
||||
: maxNumberOfIterationsWithoutImprovement(_maxNumberOfIterationWithoutImprovement), firstFitnessSaved(true), counter(0)
|
||||
{}
|
||||
|
||||
//! Function that activates the stopping criterion.
|
||||
/*!
|
||||
Indicates if the fitness has not been improved since a given number of iterations (after a minimum of iterations).
|
||||
\param _solution the current solution.
|
||||
\return true or false.
|
||||
*/
|
||||
bool operator () (const EOT & _solution)
|
||||
{
|
||||
if (_solution.invalid())
|
||||
{
|
||||
throw std::runtime_error("[moNoFitImprSolContinue.h]: The current solution has not been evaluated.");
|
||||
}
|
||||
|
||||
if (firstFitnessSaved)
|
||||
{
|
||||
fitness=_solution.fitness();
|
||||
counter=0;
|
||||
firstFitnessSaved=false;
|
||||
return true;
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
if ( _solution.fitness() > fitness)
|
||||
{
|
||||
fitness=_solution.fitness();
|
||||
counter=0;
|
||||
}
|
||||
|
||||
if (counter==maxNumberOfIterationsWithoutImprovement)
|
||||
{
|
||||
std::cout << "[moNoFitImrpSolContinue.h]: Done [" << counter << "] iterations without improvement." << std::endl;
|
||||
}
|
||||
|
||||
return counter!=maxNumberOfIterationsWithoutImprovement;
|
||||
}
|
||||
|
||||
//! Procedure which allows to initialise all the stuff needed.
|
||||
/*!
|
||||
It can be also used to reinitialize all the needed things.
|
||||
*/
|
||||
void init ()
|
||||
{
|
||||
firstFitnessSaved=true;
|
||||
counter=0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Maximum number of iterations without improvement allowed.
|
||||
unsigned int maxNumberOfIterationsWithoutImprovement;
|
||||
|
||||
//! Flag that this is the first time that the fitness is used.
|
||||
bool firstFitnessSaved;
|
||||
|
||||
//! Current Fitness.
|
||||
Fitness fitness;
|
||||
|
||||
//! The iteration couter.
|
||||
unsigned int counter;
|
||||
};
|
||||
|
||||
#endif
|
||||
136
trunk/paradiseo-old-mo/src/moRandImprSelect.h
Executable file
136
trunk/paradiseo-old-mo/src/moRandImprSelect.h
Executable file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
<moRandImprSelect.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 _moRandImprSelect_h
|
||||
#define _moRandImprSelect_h
|
||||
|
||||
#include <vector>
|
||||
#include <utils/eoRNG.h>
|
||||
#include <moMoveSelect.h>
|
||||
|
||||
//! One of the possible moMove selector (moMoveSelect)
|
||||
/*!
|
||||
All the neighbors are considered.
|
||||
One of them that enables an improvment of the objective function is choosen.
|
||||
*/
|
||||
template < class M >
|
||||
class moRandImprSelect: public moMoveSelect < M >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
||||
//!Procedure which all that needs a moRandImprSelect
|
||||
/*!
|
||||
Give a value to the initialise fitness.
|
||||
Clean the move and fitness vectors.
|
||||
|
||||
\param _fitness the current best fitness
|
||||
*/
|
||||
void init (const Fitness & _fitness)
|
||||
{
|
||||
initial_fitness = _fitness;
|
||||
better_fitnesses.clear();
|
||||
better_moves.clear();
|
||||
firstTime=true;
|
||||
}
|
||||
|
||||
//! Function that updates the fitness and move vectors
|
||||
/*!
|
||||
if a move give a better fitness than the initial fitness,
|
||||
it is saved and the fitness too.
|
||||
|
||||
\param _move a new move.
|
||||
\param _fitness a new fitness associated to the new move.
|
||||
\return true.
|
||||
*/
|
||||
bool update (const M & _move, const Fitness & _fitness)
|
||||
{
|
||||
firstTime=false;
|
||||
|
||||
if (_fitness > initial_fitness)
|
||||
{
|
||||
better_fitnesses.push_back(_fitness);
|
||||
better_moves.push_back(_move);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! The move selection
|
||||
/*!
|
||||
One the saved move is randomly chosen.
|
||||
|
||||
\param _move the reference of the move that can be initialised by the function.
|
||||
\param _fitness the reference of the fitness that can be initialised by the function.
|
||||
*/
|
||||
void operator () (M & _move, Fitness & _fitness)
|
||||
{
|
||||
unsigned int index;
|
||||
|
||||
index=0;
|
||||
|
||||
if( (better_fitnesses.size()==0) || (better_moves.size()==0) )
|
||||
{
|
||||
if(firstTime)
|
||||
{
|
||||
throw std::runtime_error("[moRandImprSelect.h]: no move or/and no fitness already saved, update has to be called first.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
index = rng.random (better_fitnesses.size ());
|
||||
|
||||
_move = better_moves[index];
|
||||
_fitness = better_fitnesses[index];
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Fitness of the current solution.
|
||||
Fitness initial_fitness;
|
||||
|
||||
//! Candidate fitnesse vector.
|
||||
std::vector < Fitness > better_fitnesses;
|
||||
|
||||
//! Candidate move vector.
|
||||
std::vector < M > better_moves;
|
||||
|
||||
//! Indicate if update has been called or not.
|
||||
bool firstTime;
|
||||
};
|
||||
|
||||
#endif
|
||||
49
trunk/paradiseo-old-mo/src/moRandMove.h
Executable file
49
trunk/paradiseo-old-mo/src/moRandMove.h
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
<moRandMove.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 _moRandMove_h
|
||||
#define _moRandMove_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Random move generator
|
||||
/*!
|
||||
Only a description... An object that herits from this class needs to be designed in order to use a moSA.
|
||||
*/
|
||||
template < class M >
|
||||
class moRandMove:public eoUF < M &, void >
|
||||
{};
|
||||
|
||||
#endif
|
||||
163
trunk/paradiseo-old-mo/src/moSA.h
Executable file
163
trunk/paradiseo-old-mo/src/moSA.h
Executable file
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
<moSA.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 _moSA_h
|
||||
#define _moSA_h
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
#include <moAlgo.h>
|
||||
#include <moRandMove.h>
|
||||
#include <moMoveIncrEval.h>
|
||||
#include <moCoolingSchedule.h>
|
||||
#include <moSolContinue.h>
|
||||
|
||||
//! Simulated Annealing (SA)
|
||||
/*!
|
||||
Class that describes a Simulated Annealing algorithm.
|
||||
*/
|
||||
template < class M >
|
||||
class moSA:public moAlgo < typename M::EOType >
|
||||
{
|
||||
//! Alias for the type
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//! SA constructor
|
||||
/*!
|
||||
All the boxes used by a SA need to be given.
|
||||
|
||||
\param _random_move_generator The move generator (generally randomly).
|
||||
\param _incremental_evaluation The (generally) efficient evaluation function
|
||||
\param _continue The stopping criterion.
|
||||
\param _initial_temperature The initial temperature.
|
||||
\param _cooling_schedule The cooling schedule, describes how the temperature is modified.
|
||||
\param _full_evaluation The full evaluation function.
|
||||
*/
|
||||
moSA (moRandMove < M > & _random_move_generator, moMoveIncrEval < M > & _incremental_evaluation,
|
||||
moSolContinue < EOT > & _continue, double _initial_temperature, moCoolingSchedule & _cooling_schedule,
|
||||
eoEvalFunc < EOT > & _full_evaluation):
|
||||
random_move_generator(_random_move_generator), incremental_evaluation(_incremental_evaluation),
|
||||
continu(_continue), initial_temperature(_initial_temperature),
|
||||
cooling_schedule(_cooling_schedule), full_evaluation(_full_evaluation)
|
||||
{}
|
||||
|
||||
//! function that launches the SA algorithm.
|
||||
/*!
|
||||
As a moTS or a moHC, the SA can be used for HYBRIDATION in an evolutionary algorithm.
|
||||
|
||||
\param _solution A solution to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
bool operator ()(EOT & _solution)
|
||||
{
|
||||
Fitness incremental_fitness, delta_fit;
|
||||
EOT best_solution;
|
||||
double temperature;
|
||||
M move;
|
||||
|
||||
if (_solution.invalid())
|
||||
{
|
||||
full_evaluation (_solution);
|
||||
}
|
||||
|
||||
temperature = initial_temperature;
|
||||
|
||||
best_solution = _solution;
|
||||
|
||||
do
|
||||
{
|
||||
continu.init ();
|
||||
|
||||
do
|
||||
{
|
||||
random_move_generator(move);
|
||||
|
||||
incremental_fitness = incremental_evaluation (move, _solution);
|
||||
|
||||
delta_fit = incremental_fitness - _solution.fitness ();
|
||||
|
||||
if( (_solution.fitness() > incremental_fitness ) && (exp (delta_fit / temperature) > 1.0) )
|
||||
{
|
||||
delta_fit = -delta_fit;
|
||||
}
|
||||
|
||||
if ( (incremental_fitness > _solution.fitness()) || (rng.uniform () < exp (delta_fit / temperature)) )
|
||||
{
|
||||
move(_solution);
|
||||
_solution.fitness(incremental_fitness);
|
||||
|
||||
// Updating the best solution found until now ?
|
||||
if ( _solution.fitness() > best_solution.fitness() )
|
||||
{
|
||||
best_solution = _solution;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
while ( continu (_solution) );
|
||||
}
|
||||
while ( cooling_schedule (temperature) );
|
||||
|
||||
_solution = best_solution;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! A move generator (generally randomly)
|
||||
moRandMove < M > & random_move_generator;
|
||||
|
||||
//! A (generally) efficient evaluation function.
|
||||
moMoveIncrEval < M > & incremental_evaluation;
|
||||
|
||||
//! Stopping criterion before temperature update
|
||||
moSolContinue < EOT > & continu;
|
||||
|
||||
//! Initial temperature
|
||||
double initial_temperature;
|
||||
|
||||
//! The cooling schedule
|
||||
moCoolingSchedule & cooling_schedule;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & full_evaluation;
|
||||
};
|
||||
|
||||
#endif
|
||||
154
trunk/paradiseo-old-mo/src/moSimpleMoveTabuList.h
Executable file
154
trunk/paradiseo-old-mo/src/moSimpleMoveTabuList.h
Executable file
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
<moSimpleMoveTabuList.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 _moSimpleMoveTabuList_h
|
||||
#define _moSimpleMoveTabuList_h
|
||||
|
||||
#include <list>
|
||||
#include <iterator>
|
||||
|
||||
#include <moTabuList.h>
|
||||
|
||||
//! Class describing a move tabu list with a limited memory.
|
||||
template <class M>
|
||||
class moSimpleMoveTabuList: public moTabuList < M >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the type
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Alias for an iterator of a move list.
|
||||
typedef typename std::list<M>::iterator moveIterator;
|
||||
|
||||
//! Constructor
|
||||
/*
|
||||
\param _size The maximum size of the move tabu list.
|
||||
*/
|
||||
moSimpleMoveTabuList(unsigned int _memory_maximum_size): memory_maximum_size(_memory_maximum_size), memory_size(0)
|
||||
{}
|
||||
|
||||
//! Function that indicates if, in a given state, the _move is tabu or not.
|
||||
/*!
|
||||
\param _move A given moMove.
|
||||
\param _solution A solution.
|
||||
\return true or false.
|
||||
*/
|
||||
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
|
||||
// will write the "==" operator (I hope) but not necessary the "!=" operator.
|
||||
while ( it!=tabuList.end() && !((*it)==_move) )
|
||||
{
|
||||
it++;
|
||||
}
|
||||
|
||||
return it!=tabuList.end();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// Useful in the case of a move has been kept thanks to the moAspirCrit.
|
||||
// In this case, the move can already be in the tabuList.
|
||||
removeMove(_move);
|
||||
}
|
||||
|
||||
tabuList.push_back(_move);
|
||||
|
||||
if (memory_size == memory_maximum_size)
|
||||
{
|
||||
tabuList.erase(tabuList.begin());
|
||||
}
|
||||
else
|
||||
{
|
||||
memory_size++;
|
||||
}
|
||||
}
|
||||
|
||||
void update ()
|
||||
{
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
void init ()
|
||||
{
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Procedure that removes a given move from the tabu list (if it is into, else do nothing).
|
||||
/*!
|
||||
\param _move A given moMove.
|
||||
*/
|
||||
void removeMove(const M & _move)
|
||||
{
|
||||
moveIterator it;
|
||||
|
||||
it=tabuList.begin();
|
||||
// The code is !(*it)==_move instead of (*it)!=_move because people designing their specific move representation
|
||||
// will write the "==" operator (I hope) but not necessary the "!=" operator.
|
||||
while ( it!=tabuList.end() && (!((*it)==_move) ))
|
||||
{
|
||||
it++;
|
||||
}
|
||||
|
||||
if (it!=tabuList.end())
|
||||
{
|
||||
tabuList.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
//! The maximum size of the tabu list.
|
||||
unsigned int memory_maximum_size;
|
||||
|
||||
//! The current size of the tabu list.
|
||||
unsigned int memory_size;
|
||||
|
||||
//! The move tabu list.
|
||||
std::list<M> tabuList;
|
||||
};
|
||||
|
||||
#endif
|
||||
160
trunk/paradiseo-old-mo/src/moSimpleSolutionTabuList.h
Executable file
160
trunk/paradiseo-old-mo/src/moSimpleSolutionTabuList.h
Executable file
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
<moSimpleSolutionTabuList.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 _moSimpleSolutionTabuList_h
|
||||
#define _moSimpleSolutionTabuList_h
|
||||
|
||||
#include <list>
|
||||
#include <iterator>
|
||||
|
||||
#include <moTabuList.h>
|
||||
|
||||
//! Class describing a solution tabu list with limited length.
|
||||
template <class M>
|
||||
class moSimpleSolutionTabuList: public moTabuList < M >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the type
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Alias for an iterator of a solution list.
|
||||
typedef typename std::list<EOT>::iterator solutionIterator;
|
||||
|
||||
//! Constructor
|
||||
/*!
|
||||
\param _memory_maximum_size The maximum size of the solution tabu list.
|
||||
*/
|
||||
moSimpleSolutionTabuList(unsigned int _memory_maximum_size): memory_maximum_size(_memory_maximum_size), memory_size(0)
|
||||
{}
|
||||
|
||||
//! Function that indicates if, in a given state, the _move is tabu or not.
|
||||
/*!
|
||||
\param _move A given moMove.
|
||||
\param _solution A solution.
|
||||
\return true or false.
|
||||
*/
|
||||
bool operator () (const M & _move, const EOT & _solution)
|
||||
{
|
||||
M move((M)_move);
|
||||
EOT solution((EOT)_solution);
|
||||
|
||||
solutionIterator it;
|
||||
|
||||
move(solution);
|
||||
|
||||
it=tabuList.begin();
|
||||
// The code is !(*it)==_solution instead of (*it)!=_solution because people designing their specific solution representation
|
||||
// will write the "==" operator (I hope) but not necessary the "!=" operator.
|
||||
while (it!=tabuList.end()&&(!((*it)==solution)))
|
||||
{
|
||||
it++;
|
||||
}
|
||||
|
||||
return it!=tabuList.end();
|
||||
}
|
||||
|
||||
void add (const M & _move, const EOT & _solution)
|
||||
{
|
||||
M move=(M)_move;
|
||||
EOT solution=(EOT) _solution;
|
||||
|
||||
move(solution);
|
||||
|
||||
if (memory_size!=0)
|
||||
{
|
||||
// Useful in the case of a solution has been kept thanks to the moAspirCrit.
|
||||
// In this case, the solution can already be in the tabuList.
|
||||
removeSolution(_solution);
|
||||
}
|
||||
|
||||
tabuList.push_back(_solution);
|
||||
|
||||
if (memory_size == memory_maximum_size)
|
||||
{
|
||||
tabuList.erase(tabuList.begin());
|
||||
}
|
||||
else
|
||||
{
|
||||
memory_size++;
|
||||
}
|
||||
}
|
||||
|
||||
void update ()
|
||||
{
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
void init ()
|
||||
{
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Procedure that removes a given solution from the tabu list (if it is into, else does nothing).
|
||||
/*!
|
||||
\param _solution A given solution.
|
||||
*/
|
||||
void removeSolution(const EOT & _solution)
|
||||
{
|
||||
solutionIterator it;
|
||||
|
||||
it=tabuList.begin();
|
||||
// The code is !(*it)==_solution instead of (*it)!=_solution because people designing their specific solution representation
|
||||
// will write the "==" operator (I hope) but not necessary the "!=" operator.
|
||||
while ( it!=tabuList.end() && !((*it)==_solution) )
|
||||
{
|
||||
it++;
|
||||
}
|
||||
|
||||
if (it!=tabuList.end())
|
||||
{
|
||||
tabuList.erase(it);
|
||||
memory_size--;
|
||||
}
|
||||
}
|
||||
|
||||
//! The maximum size of the tabu list.
|
||||
unsigned int memory_maximum_size;
|
||||
|
||||
//! The current size of the tabu list.
|
||||
unsigned int memory_size;
|
||||
|
||||
//! The solution tabu list.
|
||||
std::list<EOT> tabuList;
|
||||
};
|
||||
|
||||
#endif
|
||||
58
trunk/paradiseo-old-mo/src/moSolContinue.h
Executable file
58
trunk/paradiseo-old-mo/src/moSolContinue.h
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
<moSolContinue.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 _moSolContinue_h
|
||||
#define _moSolContinue_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
#include <stdexcept>
|
||||
|
||||
//! Class that describes a stop criterion for a solution-based heuristic
|
||||
|
||||
/*!
|
||||
It allows to add an initialisation procedure to an object that is a unary function (eoUF).
|
||||
*/
|
||||
template < class EOT >
|
||||
class moSolContinue:public eoUF < const EOT &, bool >
|
||||
{
|
||||
public:
|
||||
//! Procedure which initialises all that the stop criterion needs
|
||||
/*!
|
||||
Generally, it allocates some data structures or initialises some counters.
|
||||
*/
|
||||
virtual void init () = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
142
trunk/paradiseo-old-mo/src/moSteadyFitSolContinue.h
Normal file
142
trunk/paradiseo-old-mo/src/moSteadyFitSolContinue.h
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
<moSteadyFitSolContinue.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 _moSteadyFitSolContinue_h
|
||||
#define _moSteadyFitSolContinue_h
|
||||
|
||||
#include <moSolContinue.h>
|
||||
|
||||
//! One possible stopping criterion for a solution-based heuristic.
|
||||
/*!
|
||||
The stop criterion corresponds to a maximum number of iterations without improvement (after a minimum number of iterations).
|
||||
*/
|
||||
template < class EOT >
|
||||
class moSteadyFitSolContinue:public moSolContinue < EOT >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
//! Basic constructor.
|
||||
/*!
|
||||
\param _maxNumberOfIterations The number of iterations to reach before looking for the fitness.
|
||||
\param _maxNumberOfIterationWithoutImprovement The number of iterations without fitness improvement to reach for stop.
|
||||
*/
|
||||
moSteadyFitSolContinue (unsigned int _maxNumberOfIterations, unsigned int _maxNumberOfIterationWithoutImprovement)
|
||||
: maxNumberOfIterations (_maxNumberOfIterations), maxNumberOfIterationsWithoutImprovement(_maxNumberOfIterationWithoutImprovement),
|
||||
maxNumberOfIterationsReached(false), firstFitnessSaved(true), counter(0)
|
||||
{}
|
||||
|
||||
//! Function that activates the stopping criterion.
|
||||
/*!
|
||||
Indicates if the fitness has not been improved since a number of iterations (after a minimum of iterations).
|
||||
|
||||
\param _solution the current solution.
|
||||
\return true or false.
|
||||
*/
|
||||
bool operator () (const EOT & _solution)
|
||||
{
|
||||
if (!maxNumberOfIterationsReached)
|
||||
{
|
||||
maxNumberOfIterationsReached=((++counter)==maxNumberOfIterations);
|
||||
if (maxNumberOfIterationsReached)
|
||||
{
|
||||
std::cout << "[moSteadyFitSolContinue.h]: Done the minimum number of iterations [" << counter << "]." << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_solution.invalid())
|
||||
{
|
||||
throw std::runtime_error("[moSteadyFitSolContinue.h]: The current solution has not been evaluated.");
|
||||
}
|
||||
|
||||
if (firstFitnessSaved)
|
||||
{
|
||||
fitness=_solution.fitness();
|
||||
counter=0;
|
||||
firstFitnessSaved=false;
|
||||
return true;
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
if ( _solution.fitness() > fitness )
|
||||
{
|
||||
fitness=_solution.fitness();
|
||||
counter=0;
|
||||
}
|
||||
|
||||
if (counter==maxNumberOfIterationsWithoutImprovement)
|
||||
{
|
||||
std::cout << "[moSteadyFitSolContinue.h]: Done [" << counter << "] iterations without improvement." << std::endl;
|
||||
}
|
||||
return counter!=maxNumberOfIterationsWithoutImprovement;
|
||||
}
|
||||
|
||||
//! Procedure which allows to initialise the stuff needed.
|
||||
/*!
|
||||
It can be also used to reinitialize the counter all the needed things.
|
||||
*/
|
||||
void init ()
|
||||
{
|
||||
maxNumberOfIterationsReached=false;
|
||||
counter=0;
|
||||
firstFitnessSaved=true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Maximum number of iterations before considering the fitness.
|
||||
unsigned int maxNumberOfIterations;
|
||||
|
||||
//! Maximum number of iterations without improvement allowed.
|
||||
unsigned int maxNumberOfIterationsWithoutImprovement;
|
||||
|
||||
//! Flag that indicates that the maxNumberIteration have been reached.
|
||||
bool maxNumberOfIterationsReached;
|
||||
|
||||
//! Flag that this is the first time that the fitness is used.
|
||||
bool firstFitnessSaved;
|
||||
|
||||
//! Current Fitness.
|
||||
Fitness fitness;
|
||||
|
||||
//! The iteration couter.
|
||||
unsigned int counter;
|
||||
};
|
||||
|
||||
#endif
|
||||
160
trunk/paradiseo-old-mo/src/moTA.h
Normal file
160
trunk/paradiseo-old-mo/src/moTA.h
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
<moTA.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2008-2009
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Salma Mesmoudi
|
||||
|
||||
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 _moTA_h
|
||||
#define _moTA_h
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
#include <moAlgo.h>
|
||||
#include <moRandMove.h>
|
||||
#include <moMoveIncrEval.h>
|
||||
#include <moCoolingSchedule.h>
|
||||
#include <moSolContinue.h>
|
||||
|
||||
//! Threshold Accepting (TA)
|
||||
/*!
|
||||
Class that describes a Threshold Accepting algorithm.
|
||||
*/
|
||||
template < class M >
|
||||
class moTA:public moAlgo < typename M::EOType >
|
||||
{
|
||||
//! Alias for the type
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//! TA constructor
|
||||
/*!
|
||||
All the boxes used by a TA need to be given. It is equivalent to a SA object.
|
||||
|
||||
\param _random_move_generator The move generator (generally randomly).
|
||||
\param _incremental_evaluation The (generally) efficient evaluation function
|
||||
\param _continue The stopping criterion.
|
||||
\param _initial_threshold The initial threshold.
|
||||
\param _cooling_schedule The cooling schedule, describes how the temperature is modified.
|
||||
\param _full_evaluation The full evaluation function.
|
||||
*/
|
||||
moTA (moRandMove < M > & _random_move_generator, moMoveIncrEval < M > & _incremental_evaluation,
|
||||
moSolContinue < EOT > & _continue, double _initial_threshold, moCoolingSchedule & _cooling_schedule,
|
||||
eoEvalFunc < EOT > & _full_evaluation):
|
||||
random_move_generator(_random_move_generator), incremental_evaluation(_incremental_evaluation),
|
||||
continu(_continue), initial_threshold(_initial_threshold),
|
||||
cooling_schedule(_cooling_schedule), full_evaluation(_full_evaluation)
|
||||
{}
|
||||
|
||||
//! function that launches the TA algorithm.
|
||||
/*!
|
||||
As a moSA the TA can be used for HYBRIDATION in an evolutionary algorithm.
|
||||
|
||||
\param _solution A solution to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
bool operator ()(EOT & _solution)
|
||||
{
|
||||
Fitness incremental_fitness, delta_fit;
|
||||
EOT best_solution;
|
||||
double threshold;
|
||||
M move;
|
||||
|
||||
if (_solution.invalid())
|
||||
{
|
||||
full_evaluation (_solution);
|
||||
}
|
||||
|
||||
threshold = initial_threshold;
|
||||
|
||||
best_solution = _solution;
|
||||
|
||||
do
|
||||
{
|
||||
continu.init ();
|
||||
|
||||
do
|
||||
{
|
||||
random_move_generator(move);
|
||||
|
||||
incremental_fitness = incremental_evaluation (move, _solution);
|
||||
|
||||
delta_fit = incremental_fitness - _solution.fitness ();
|
||||
|
||||
if ( threshold > delta_fit)
|
||||
|
||||
{
|
||||
move(_solution);
|
||||
_solution.fitness(incremental_fitness);
|
||||
|
||||
// Updating the best solution found until now ?
|
||||
if ( _solution.fitness() > best_solution.fitness() )
|
||||
{
|
||||
best_solution = _solution;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
while ( continu (_solution));
|
||||
}
|
||||
while ( cooling_schedule (threshold) );
|
||||
|
||||
_solution = best_solution;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! A move generator (generally randomly)
|
||||
moRandMove < M > & random_move_generator;
|
||||
|
||||
//! A (generally) efficient evaluation function.
|
||||
moMoveIncrEval < M > & incremental_evaluation;
|
||||
|
||||
//! Stopping criterion before threshold update
|
||||
moSolContinue < EOT > & continu;
|
||||
|
||||
//! Initial temperature
|
||||
double initial_threshold;
|
||||
|
||||
//! The cooling schedule
|
||||
moCoolingSchedule & cooling_schedule;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & full_evaluation;
|
||||
};
|
||||
|
||||
#endif
|
||||
163
trunk/paradiseo-old-mo/src/moTS.h
Executable file
163
trunk/paradiseo-old-mo/src/moTS.h
Executable file
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
<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,
|
||||
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 _moTS_h
|
||||
#define _moTS_h
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
#include <moAlgo.h>
|
||||
#include <moSolContinue.h>
|
||||
#include <moTSMoveLoopExpl.h>
|
||||
|
||||
//! Tabu Search (TS)
|
||||
/*!
|
||||
Generic algorithm that describes a tabu search.
|
||||
*/
|
||||
template < class M >
|
||||
class moTS:public moAlgo < typename M::EOType >
|
||||
{
|
||||
//!Alias for the type
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//!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.
|
||||
|
||||
\param _move_initializer The move initializer.
|
||||
\param _next_move_generator The neighbourhood explorer.
|
||||
\param _incremental_evaluation The (generally) efficient evaluation.
|
||||
\param _tabu_list The tabu list.
|
||||
\param _aspiration_criterion An aspiration criterion.
|
||||
\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):
|
||||
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.
|
||||
|
||||
\param _move_explorer The explorer (generally different that a moTSMoveLoopExpl).
|
||||
\param _continue The stopping criterion.
|
||||
\param _full_evaluation A full evaluation function.
|
||||
*/
|
||||
moTS (moMoveExpl < M > & _move_explorer, moSolContinue < EOT > & _continue, eoEvalFunc < EOT > & _full_evaluation):
|
||||
move_explorer (&_move_explorer), continu (_continue), full_evaluation (_full_evaluation), move_explorer_memory_allocation(false)
|
||||
{}
|
||||
|
||||
//! Destructor
|
||||
~moTS()
|
||||
{
|
||||
if(move_explorer_memory_allocation)
|
||||
{
|
||||
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.
|
||||
|
||||
\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())
|
||||
{
|
||||
best_solution = new_solution;
|
||||
}
|
||||
|
||||
_solution = new_solution;
|
||||
}
|
||||
while ( continu (_solution) );
|
||||
|
||||
_solution = best_solution;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Neighborhood explorer
|
||||
moMoveExpl < M > * move_explorer;
|
||||
|
||||
//! Stop criterion
|
||||
moSolContinue < EOT > & continu;
|
||||
|
||||
//! Full evaluation function
|
||||
eoEvalFunc < EOT > & full_evaluation;
|
||||
|
||||
//! Indicate if the memory has been allocated for the move_explorer.
|
||||
bool move_explorer_memory_allocation;
|
||||
};
|
||||
|
||||
#endif
|
||||
165
trunk/paradiseo-old-mo/src/moTSMoveLoopExpl.h
Executable file
165
trunk/paradiseo-old-mo/src/moTSMoveLoopExpl.h
Executable file
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
<moTSMoveLoopExpl.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 _moTSMoveLoopExpl_h
|
||||
#define _moTSMoveLoopExpl_h
|
||||
|
||||
#include <moMoveLoopExpl.h>
|
||||
#include <moMoveInit.h>
|
||||
#include <moNextMove.h>
|
||||
#include <moMoveIncrEval.h>
|
||||
#include <moMoveSelect.h>
|
||||
#include <moTabuList.h>
|
||||
#include <moAspirCrit.h>
|
||||
#include <moBestImprSelect.h>
|
||||
|
||||
//! Explorer for a Tabu Search algorithm
|
||||
/*!
|
||||
It is used by a moTS.
|
||||
*/
|
||||
template < class M >
|
||||
class moTSMoveLoopExpl:public moMoveLoopExpl < M >
|
||||
{
|
||||
//!Alias for the type
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//!Alias for the fitness
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//!Constructor
|
||||
/*!
|
||||
\param _move_initializer The move initializer.
|
||||
\param _next_move_generator The neighbourhood explorer.
|
||||
\param _incremental_evaluation A (generally) efficient evaluation.
|
||||
\param _tabu_list The tabu list.
|
||||
\param _aspiration_criterion An aspiration criterion.
|
||||
*/
|
||||
moTSMoveLoopExpl (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moTabuList < M > & _tabu_list,
|
||||
moAspirCrit < M > & _aspiration_criterion):
|
||||
move_initializer(_move_initializer), next_move_generator(_next_move_generator), incremental_evaluation(_incremental_evaluation),
|
||||
tabu_list(_tabu_list), aspiration_criterion(_aspiration_criterion)
|
||||
{
|
||||
tabu_list.init ();
|
||||
aspiration_criterion.init ();
|
||||
}
|
||||
|
||||
//!Procedure which lauches the exploration
|
||||
/*!
|
||||
The exploration continues while the chosen move is not in the tabu list
|
||||
or the aspiration criterion is true. If these 2 conditions are not true, the
|
||||
exploration stops if the move selector update function returns false.
|
||||
|
||||
\param _old_solution the initial solution
|
||||
\param _new_solution the new solution
|
||||
*/
|
||||
void operator () (const EOT & _old_solution, EOT & _new_solution)
|
||||
{
|
||||
M move, best_move;
|
||||
Fitness fitness, best_move_fitness;
|
||||
|
||||
bool move_is_tabu, aspiration_criterion_is_verified, selection_update_is_ok, has_next_move;
|
||||
|
||||
if( _old_solution.invalid() )
|
||||
{
|
||||
throw std::runtime_error("[moTSMoveLoopExpl.h]: The current solution has not been evaluated.");
|
||||
}
|
||||
|
||||
//At the begining, the new solution is equivalent to the old one.
|
||||
_new_solution=(EOT)_old_solution;
|
||||
|
||||
// Restarting the exploration of of the neighborhood !
|
||||
move_initializer (move, _old_solution);
|
||||
|
||||
move_selection.init( _old_solution.fitness() );
|
||||
|
||||
selection_update_is_ok=true;
|
||||
|
||||
do
|
||||
{
|
||||
fitness = incremental_evaluation(move, _old_solution);
|
||||
|
||||
move_is_tabu = tabu_list(move, _old_solution);
|
||||
|
||||
aspiration_criterion_is_verified = aspiration_criterion(move, fitness);
|
||||
|
||||
if( !move_is_tabu || aspiration_criterion_is_verified )
|
||||
{
|
||||
selection_update_is_ok = move_selection.update(move, fitness);
|
||||
}
|
||||
|
||||
has_next_move = next_move_generator(move, _old_solution);
|
||||
}
|
||||
while( has_next_move && selection_update_is_ok );
|
||||
|
||||
move_selection(best_move, best_move_fitness);
|
||||
|
||||
// Apply the best move.
|
||||
best_move(_new_solution);
|
||||
|
||||
// The fitness is set to avoid an additionnal fitness computation.
|
||||
_new_solution.fitness(best_move_fitness);
|
||||
|
||||
// Removing moves that are no more tabu.
|
||||
tabu_list.update ();
|
||||
|
||||
// Updating the tabu list
|
||||
tabu_list.add(best_move, _new_solution);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Move initialisation
|
||||
moMoveInit < M > & move_initializer;
|
||||
|
||||
//! Neighborhood explorer
|
||||
moNextMove < M > & next_move_generator;
|
||||
|
||||
//! Efficient evaluation
|
||||
moMoveIncrEval < M > & incremental_evaluation;
|
||||
|
||||
//! Move selector
|
||||
moBestImprSelect < M > move_selection;
|
||||
|
||||
//! Tabu list
|
||||
moTabuList < M > & tabu_list;
|
||||
|
||||
//! Aspiration criterion
|
||||
moAspirCrit < M > & aspiration_criterion;
|
||||
};
|
||||
|
||||
#endif
|
||||
75
trunk/paradiseo-old-mo/src/moTabuList.h
Executable file
75
trunk/paradiseo-old-mo/src/moTabuList.h
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
<moTabuList.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 _moTabuList_h
|
||||
#define _moTabuList_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Class describing a tabu list that a moTS uses.
|
||||
/*!
|
||||
It is only a description, does nothing... A new object that herits from this class has to be defined in order
|
||||
to be used in a moTS.
|
||||
*/
|
||||
template < class M > class moTabuList: public eoBF < const M &, const typename M::EOType &, bool >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the type
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Procedure to add a move in the tabu list
|
||||
/*!
|
||||
The two parameters have not to be modified so they are constant parameters.
|
||||
|
||||
\param _move a new tabu move.
|
||||
\param _solution the origianl solution associated to this move.
|
||||
*/
|
||||
virtual void add(const M & _move, const EOT & _solution) = 0;
|
||||
|
||||
//! Procedure that updates the tabu list content.
|
||||
/*!
|
||||
Generally, a counter associated to each saved move is decreased by one.
|
||||
*/
|
||||
virtual void update () = 0;
|
||||
|
||||
//! Procedure which initialises the tabu list.
|
||||
/*!
|
||||
Can be useful if the data structure needs to be allocated before being used.
|
||||
*/
|
||||
virtual void init () = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
131
trunk/paradiseo-old-mo/src/moVNS.h
Normal file
131
trunk/paradiseo-old-mo/src/moVNS.h
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
<moVNS.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Salma Mesmoudi (salma.mesmoudi@inria.fr), 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 _moVNS_h
|
||||
#define _moVNS_h
|
||||
|
||||
#include <moAlgo.h>
|
||||
|
||||
//! Variable Neighbors Search (VNS)
|
||||
/*!
|
||||
Class which describes the algorithm for a Variable Neighbors Search.
|
||||
*/
|
||||
|
||||
template < class EOT>
|
||||
class moVNS : public moAlgo < EOT>
|
||||
{
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//! Generic constructor
|
||||
/*!
|
||||
Generic constructor using a moExpl
|
||||
|
||||
\param _explorer Vector of Neighborhoods.
|
||||
\param _full_evaluation The evaluation function.
|
||||
*/
|
||||
moVNS(moExpl< EOT> & _explorer, eoEvalFunc < EOT> & _full_evaluation): explorer(_explorer), full_evaluation(_full_evaluation) {}
|
||||
|
||||
|
||||
//! Function which launches the VNS
|
||||
/*!
|
||||
The VNS has to improve a current solution.
|
||||
|
||||
\param _solution a current solution to improve.
|
||||
\return true.
|
||||
*/
|
||||
bool operator()(EOT & _solution)
|
||||
{
|
||||
bool change;
|
||||
unsigned int i;
|
||||
|
||||
EOT solution_prime, solution_second;
|
||||
EOT solution_initial=_solution;
|
||||
|
||||
change=false;
|
||||
i=0;
|
||||
explorer.setCurrentExplorer(i);
|
||||
|
||||
while( i<explorer.getExplorerNumber() )
|
||||
{
|
||||
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.fitness() > solution_initial.fitness() )
|
||||
{
|
||||
solution_initial=solution_second;
|
||||
change=true;
|
||||
if(i!= 0)
|
||||
{
|
||||
i=0;
|
||||
explorer.setCurrentExplorer(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
if( i<explorer.getExplorerNumber() )
|
||||
{
|
||||
explorer.setCurrentExplorer(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_solution=solution_initial;
|
||||
return change;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//!Neighborhoods vector
|
||||
moExpl<EOT> & explorer;
|
||||
|
||||
//!The full evaluation function
|
||||
eoEvalFunc<EOT> & full_evaluation;
|
||||
};
|
||||
|
||||
#endif
|
||||
93
trunk/paradiseo-old-mo/test/CMakeLists.txt
Normal file
93
trunk/paradiseo-old-mo/test/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
###############################################################################
|
||||
##
|
||||
## CMakeLists file for ParadisEO-MO/test
|
||||
##
|
||||
###############################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${ParadisEO-MO_SOURCE_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${ParadisEO-MO_BINARY_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your targets and link the librairies
|
||||
######################################################################################
|
||||
|
||||
SET (TEST_LIST t-moBestImprSelect
|
||||
t-moFirstImprSelect
|
||||
t-moFitComparator
|
||||
t-moFitSolContinue
|
||||
t-moGenSolContinue
|
||||
t-moGeometricCoolingSchedule
|
||||
t-moHC
|
||||
t-moHC_2
|
||||
t-moHCMoveLoopExpl
|
||||
t-moILS
|
||||
t-moILS_HC
|
||||
t-moILS_TS
|
||||
t-moILS_SA
|
||||
t-moImprBestFitAspirCrit
|
||||
t-moItRandNextMove
|
||||
t-moLinearCoolingSchedule
|
||||
t-moLSCheckPoint
|
||||
t-moNoAspirCrit
|
||||
t-moNoFitImprSolContinue
|
||||
t-moRandImprSelect
|
||||
t-moSA
|
||||
t-moSimpleMoveTabuList
|
||||
t-moSimpleSolutionTabuList
|
||||
t-moSteadyFitSolContinue
|
||||
t-moTS
|
||||
t-moTS_2
|
||||
t-moTSMoveLoopExpl
|
||||
t-moTA
|
||||
t-moVNS
|
||||
)
|
||||
|
||||
FOREACH (test ${TEST_LIST})
|
||||
SET ("T_${test}_SOURCES" "${test}.cpp")
|
||||
ENDFOREACH (test)
|
||||
|
||||
|
||||
IF(ENABLE_MINIMAL_CMAKE_TESTING)
|
||||
SET (MIN_TEST_LIST t-moHC)
|
||||
FOREACH (mintest ${MIN_TEST_LIST})
|
||||
SET ("T_${mintest}_SOURCES" "${mintest}.cpp")
|
||||
ADD_EXECUTABLE(${mintest} ${T_${mintest}_SOURCES})
|
||||
ADD_TEST(${mintest} ${mintest})
|
||||
ENDFOREACH (mintest)
|
||||
|
||||
ELSEIF(ENABLE_CMAKE_TESTING)
|
||||
|
||||
# Add the tests
|
||||
FOREACH (test ${TEST_LIST})
|
||||
ADD_EXECUTABLE(${test} ${T_${test}_SOURCES})
|
||||
ADD_TEST(${test} ${test})
|
||||
ENDFOREACH (test)
|
||||
|
||||
# Link the librairies
|
||||
FOREACH (test ${TEST_LIST})
|
||||
TARGET_LINK_LIBRARIES(${test} ga es eoutils eo)
|
||||
ENDFOREACH (test)
|
||||
|
||||
ENDIF(ENABLE_MINIMAL_CMAKE_TESTING)
|
||||
|
||||
######################################################################################
|
||||
|
||||
108
trunk/paradiseo-old-mo/test/t-moBestImprSelect.cpp
Normal file
108
trunk/paradiseo-old-mo/test/t-moBestImprSelect.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* <t-moBestImprSelect.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moBestImprSelect.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2;
|
||||
int return_value, value_1, value_2;
|
||||
|
||||
unsigned int i, fitness;
|
||||
|
||||
moBestImprSelect<testMove> selection;
|
||||
|
||||
solution solution;
|
||||
|
||||
testMove move;
|
||||
|
||||
cout << "[ moBestImprSelect ] ==> ";
|
||||
|
||||
i=fitness=0;
|
||||
|
||||
selection.init(0);
|
||||
|
||||
test_1="KO";
|
||||
|
||||
try
|
||||
{
|
||||
selection(move, fitness);
|
||||
}
|
||||
catch(std::runtime_error e)
|
||||
{
|
||||
test_1="OK";
|
||||
}
|
||||
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
test_2=((!selection.update(move, i))?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
selection(move, fitness);
|
||||
|
||||
move(solution);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
96
trunk/paradiseo-old-mo/test/t-moFirstImprSelect.cpp
Normal file
96
trunk/paradiseo-old-mo/test/t-moFirstImprSelect.cpp
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* <t-moFirstImprSelect.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moFirstImprSelect.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
unsigned int i, fitness;
|
||||
|
||||
moFirstImprSelect<testMove> selection;
|
||||
|
||||
solution solution;
|
||||
|
||||
testMove move;
|
||||
|
||||
cout << "[ moFirstImprSelect ] ==> ";
|
||||
|
||||
i=fitness=0;
|
||||
|
||||
selection.init(10);
|
||||
|
||||
while ( selection.update(move, i) && i<15 )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
selection(move, fitness);
|
||||
|
||||
move(solution);
|
||||
|
||||
test_result=((fitness!=11)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
74
trunk/paradiseo-old-mo/test/t-moFitComparator.cpp
Normal file
74
trunk/paradiseo-old-mo/test/t-moFitComparator.cpp
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* <t-moFitComparator.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moFitComparator.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
solution sol1, sol2;
|
||||
|
||||
moFitComparator<solution> comparator;
|
||||
|
||||
sol1.fitness(0);
|
||||
sol2.fitness(1);
|
||||
|
||||
cout << "[ moFitComparator ] ==> ";
|
||||
|
||||
test_result=((comparator(sol1,sol2))?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
101
trunk/paradiseo-old-mo/test/t-moFitSolContinue.cpp
Normal file
101
trunk/paradiseo-old-mo/test/t-moFitSolContinue.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* <t-moFitSolContinue.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moFitSolContinue.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2;
|
||||
int return_value, value_1, value_2;
|
||||
|
||||
unsigned int i;
|
||||
|
||||
moFitSolContinue<solution> continu(10);
|
||||
|
||||
solution solution;
|
||||
|
||||
cout << "[ moFitSolContinue ] ==> ";
|
||||
|
||||
continu.init();
|
||||
|
||||
test_1="KO";
|
||||
|
||||
try
|
||||
{
|
||||
continu(solution);
|
||||
}
|
||||
catch(std::runtime_error e)
|
||||
{
|
||||
test_1="OK";
|
||||
}
|
||||
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
|
||||
|
||||
i=0;
|
||||
solution.fitness(i);
|
||||
while( continu(solution) )
|
||||
{
|
||||
i++;
|
||||
solution.fitness(i);
|
||||
}
|
||||
|
||||
test_2=((i!=10)?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
92
trunk/paradiseo-old-mo/test/t-moGenSolContinue.cpp
Normal file
92
trunk/paradiseo-old-mo/test/t-moGenSolContinue.cpp
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* <t-moGenSolContinue.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moGenSolContinue.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2;
|
||||
int value_1, value_2, return_value;
|
||||
|
||||
unsigned int i;
|
||||
solution sol;
|
||||
|
||||
moGenSolContinue<solution> continu(10);
|
||||
|
||||
cout << "[ moGenSolContinue ] ==> ";
|
||||
|
||||
i=0;
|
||||
while( continu(sol) )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
test_1=((i!=9)?"KO":"OK");
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
continu.init();
|
||||
|
||||
i=0;
|
||||
while( continu(sol) )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
test_2=((i!=9)?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
79
trunk/paradiseo-old-mo/test/t-moGeometricCoolingSchedule.cpp
Normal file
79
trunk/paradiseo-old-mo/test/t-moGeometricCoolingSchedule.cpp
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* <t-moExponentialCoolingSchedule.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moExponentialCoolingSchedule.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
int return_value;
|
||||
std::string test_result;
|
||||
|
||||
unsigned int i;
|
||||
double temperature;
|
||||
|
||||
moGeometricCoolingSchedule coolingSchedule( 4.0, 0.5 );
|
||||
|
||||
temperature=10.0;
|
||||
|
||||
cout << "[ moExponentialCoolingSchedule ] ==> ";
|
||||
|
||||
i=0;
|
||||
while( coolingSchedule(temperature) )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
test_result=((i!=1)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
162
trunk/paradiseo-old-mo/test/t-moHC.cpp
Normal file
162
trunk/paradiseo-old-mo/test/t-moHC.cpp
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* <t-moHC.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moHC.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveInit : public moMoveInit <testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move=_move;
|
||||
const solution sol(_solution);
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveNext : public moNextMove <testMove>
|
||||
{
|
||||
public :
|
||||
bool operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move=_move;
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveIncrEval : public moMoveIncrEval <testMove>
|
||||
{
|
||||
public :
|
||||
unsigned int operator () (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution solution(_solution);
|
||||
|
||||
return 2;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveSelect : public moMoveSelect <testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move, unsigned int & _fitness)
|
||||
{
|
||||
testMove move;
|
||||
|
||||
move=_move;
|
||||
|
||||
_fitness=2;
|
||||
}
|
||||
|
||||
void init(const unsigned int & _fitness)
|
||||
{
|
||||
unsigned int fitness;
|
||||
fitness=(unsigned int)_fitness;
|
||||
}
|
||||
|
||||
bool update(const testMove & _move, const unsigned int & _fitness)
|
||||
{
|
||||
testMove move;
|
||||
unsigned int fitness;
|
||||
|
||||
move=(testMove)_move;
|
||||
fitness=(unsigned int)_fitness;
|
||||
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
class solutionEval : public eoEvalFunc <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(2);
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
solution solution;
|
||||
|
||||
testMoveInit init;
|
||||
testMoveNext next;
|
||||
testMoveIncrEval incrEval;
|
||||
testMoveSelect select;
|
||||
solutionEval eval;
|
||||
|
||||
moHC<testMove> hc(init, next, incrEval, select, eval);
|
||||
|
||||
cout << "[ moHC ] ==> ";
|
||||
|
||||
hc(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
170
trunk/paradiseo-old-mo/test/t-moHCMoveLoopExpl.cpp
Normal file
170
trunk/paradiseo-old-mo/test/t-moHCMoveLoopExpl.cpp
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* <t-moHCMoveLoopExpl.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moHCMoveLoopExpl.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveInit : public moMoveInit <testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move=_move;
|
||||
const solution sol(_solution);
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveNext : public moNextMove <testMove>
|
||||
{
|
||||
public :
|
||||
bool operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move=_move;
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveIncrEval : public moMoveIncrEval <testMove>
|
||||
{
|
||||
public :
|
||||
unsigned int operator () (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution solution(_solution);
|
||||
|
||||
return 2;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveSelect : public moMoveSelect <testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move, unsigned int & _fitness)
|
||||
{
|
||||
testMove move;
|
||||
|
||||
move=_move;
|
||||
|
||||
_fitness=2;
|
||||
}
|
||||
|
||||
void init(const unsigned int & _fitness)
|
||||
{
|
||||
unsigned int fitness;
|
||||
fitness=(unsigned int)_fitness;
|
||||
}
|
||||
|
||||
bool update(const testMove & _move, const unsigned int & _fitness)
|
||||
{
|
||||
testMove move;
|
||||
unsigned int fitness;
|
||||
|
||||
move=(testMove)_move;
|
||||
fitness=(unsigned int)_fitness;
|
||||
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2;
|
||||
int return_value, value_1, value_2;
|
||||
|
||||
solution solution_1, solution_2;
|
||||
|
||||
testMoveInit init;
|
||||
testMoveNext next;
|
||||
testMoveIncrEval incrEval;
|
||||
testMoveSelect select;
|
||||
|
||||
moHCMoveLoopExpl<testMove> explorer(init, next, incrEval, select);
|
||||
|
||||
cout << "[ moHCMoveLoopExpl ] ==> ";
|
||||
|
||||
test_1="KO";
|
||||
|
||||
try
|
||||
{
|
||||
explorer(solution_1, solution_2);
|
||||
}
|
||||
catch(std::runtime_error e)
|
||||
{
|
||||
test_1="OK";
|
||||
}
|
||||
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
solution_1.fitness(0);
|
||||
solution_2.fitness(0);
|
||||
|
||||
explorer(solution_1, solution_2);
|
||||
|
||||
test_2=((solution_2.fitness()!=2)?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
106
trunk/paradiseo-old-mo/test/t-moHC_2.cpp
Normal file
106
trunk/paradiseo-old-mo/test/t-moHC_2.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* <t-moHC_2.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moHC_2.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveExplorer : public moMoveExpl<testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (const solution & _solution_1, solution & _solution_2)
|
||||
{
|
||||
const solution sol(_solution_1);
|
||||
|
||||
_solution_2.fitness(2);
|
||||
}
|
||||
};
|
||||
|
||||
class solutionEval : public eoEvalFunc <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(0);
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
solution solution;
|
||||
|
||||
solutionEval eval;
|
||||
testMoveExplorer explorer;
|
||||
|
||||
moHC<testMove> hc(explorer, eval);
|
||||
|
||||
cout << "[ moHC_2 ] ==> ";
|
||||
|
||||
hc(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
169
trunk/paradiseo-old-mo/test/t-moILS.cpp
Normal file
169
trunk/paradiseo-old-mo/test/t-moILS.cpp
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* <t-moILS.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moILS.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class solutionAlgo : public moAlgo <solution>
|
||||
{
|
||||
public :
|
||||
bool operator () (solution & _solution)
|
||||
{
|
||||
solution solution(_solution);
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
class solutionContinue : public moSolContinue<solution>
|
||||
{
|
||||
public :
|
||||
solutionContinue(): counter(0)
|
||||
{}
|
||||
|
||||
bool operator () (const solution & _solution)
|
||||
{
|
||||
const solution sol(_solution);
|
||||
|
||||
if(counter<2)
|
||||
{
|
||||
counter++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
private :
|
||||
unsigned int counter;
|
||||
} ;
|
||||
|
||||
class solutionComparator : public moComparator<solution>
|
||||
{
|
||||
public :
|
||||
|
||||
solutionComparator() : counter(0)
|
||||
{}
|
||||
|
||||
bool operator () (const solution & _solution1 , const solution & _solution2)
|
||||
{
|
||||
const solution sol1(_solution1);
|
||||
const solution sol2(_solution2);
|
||||
|
||||
if(counter<2)
|
||||
{
|
||||
counter++;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private :
|
||||
unsigned int counter;
|
||||
} ;
|
||||
|
||||
class solutionPerturbation : public eoMonOp<solution>
|
||||
{
|
||||
public :
|
||||
bool operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(2);
|
||||
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
class solutionEval : public eoEvalFunc <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution solution(_solution);
|
||||
_solution.fitness(2);
|
||||
}
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
solution solution;
|
||||
|
||||
solutionAlgo algorithm;
|
||||
solutionContinue continu;
|
||||
solutionComparator comparator;
|
||||
solutionPerturbation perturbation;
|
||||
solutionEval eval;
|
||||
|
||||
moILS<testMove> ils(algorithm, continu, comparator, perturbation, eval);
|
||||
|
||||
cout << "[ moILS ] ==> ";
|
||||
|
||||
solution.fitness(0);
|
||||
|
||||
ils(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
211
trunk/paradiseo-old-mo/test/t-moILS_HC.cpp
Normal file
211
trunk/paradiseo-old-mo/test/t-moILS_HC.cpp
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
/*
|
||||
* <t-moILS_HC.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moILS_HC.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveInit : public moMoveInit <testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move=_move;
|
||||
const solution sol(_solution);
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveNext : public moNextMove <testMove>
|
||||
{
|
||||
public :
|
||||
bool operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move=_move;
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveIncrEval : public moMoveIncrEval <testMove>
|
||||
{
|
||||
public :
|
||||
unsigned int operator () (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution solution(_solution);
|
||||
|
||||
return 2;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveSelect : public moMoveSelect <testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move, unsigned int & _fitness)
|
||||
{
|
||||
testMove move;
|
||||
|
||||
move=_move;
|
||||
|
||||
_fitness=2;
|
||||
}
|
||||
|
||||
void init(const unsigned int & _fitness)
|
||||
{
|
||||
unsigned int fitness;
|
||||
fitness=(unsigned int)_fitness;
|
||||
}
|
||||
|
||||
bool update(const testMove & _move, const unsigned int & _fitness)
|
||||
{
|
||||
testMove move;
|
||||
unsigned int fitness;
|
||||
|
||||
move=(testMove)_move;
|
||||
fitness=(unsigned int)_fitness;
|
||||
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
class solutionEval : public eoEvalFunc <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(0);
|
||||
}
|
||||
} ;
|
||||
|
||||
class solutionContinue : public moSolContinue<solution>
|
||||
{
|
||||
public :
|
||||
solutionContinue(): counter(0)
|
||||
{}
|
||||
|
||||
bool operator () (const solution & _solution)
|
||||
{
|
||||
const solution sol(_solution);
|
||||
|
||||
if(counter==0)
|
||||
{
|
||||
counter++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
private :
|
||||
unsigned int counter;
|
||||
} ;
|
||||
|
||||
class solutionComparator : public moComparator<solution>
|
||||
{
|
||||
public :
|
||||
bool operator () (const solution & _solution1 , const solution & _solution2)
|
||||
{
|
||||
const solution sol1(_solution1);
|
||||
const solution sol2(_solution2);
|
||||
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
class solutionPerturbation : public eoMonOp<solution>
|
||||
{
|
||||
public :
|
||||
bool operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(2);
|
||||
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
solution solution;
|
||||
|
||||
testMoveInit init;
|
||||
testMoveNext next;
|
||||
testMoveIncrEval incrEval;
|
||||
testMoveSelect select;
|
||||
solutionEval eval;
|
||||
solutionContinue continu;
|
||||
solutionComparator comparator;
|
||||
solutionPerturbation perturbation;
|
||||
|
||||
moILS<testMove> ils(init, next, incrEval, select, continu, comparator, perturbation, eval);
|
||||
|
||||
cout << "[ moILS_HC ] ==> ";
|
||||
|
||||
ils(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
190
trunk/paradiseo-old-mo/test/t-moILS_SA.cpp
Normal file
190
trunk/paradiseo-old-mo/test/t-moILS_SA.cpp
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
/*
|
||||
* <t-moILS_SA.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moILS_SA.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testRandMove : public moRandMove<testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move)
|
||||
{
|
||||
_move=_move;
|
||||
}
|
||||
};
|
||||
|
||||
class testMoveIncrEval : public moMoveIncrEval <testMove>
|
||||
{
|
||||
public :
|
||||
int operator () (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution solution(_solution);
|
||||
|
||||
return 2;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testCooling : public moCoolingSchedule
|
||||
{
|
||||
public :
|
||||
bool operator () (double & _temperature)
|
||||
{
|
||||
double temperature;
|
||||
temperature=_temperature;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class solutionEval : public eoEvalFunc <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
const solution solution(_solution);
|
||||
}
|
||||
} ;
|
||||
|
||||
class solutionContinue : public moSolContinue<solution>
|
||||
{
|
||||
public :
|
||||
solutionContinue(): counter(0)
|
||||
{}
|
||||
|
||||
bool operator () (const solution & _solution)
|
||||
{
|
||||
const solution sol(_solution);
|
||||
|
||||
if(counter==0)
|
||||
{
|
||||
counter++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
private :
|
||||
unsigned int counter;
|
||||
} ;
|
||||
|
||||
class solutionComparator : public moComparator<solution>
|
||||
{
|
||||
public :
|
||||
|
||||
solutionComparator() : counter(0)
|
||||
{}
|
||||
|
||||
bool operator () (const solution & _solution1 , const solution & _solution2)
|
||||
{
|
||||
const solution solution1(_solution1);
|
||||
const solution solution2(_solution2);
|
||||
|
||||
return true;
|
||||
}
|
||||
private :
|
||||
unsigned int counter;
|
||||
} ;
|
||||
|
||||
class solutionPerturbation : public eoMonOp<solution>
|
||||
{
|
||||
public :
|
||||
bool operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(2);
|
||||
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
solution solution;
|
||||
|
||||
testRandMove rand;
|
||||
testMoveIncrEval incrEval;
|
||||
solutionContinue continu;
|
||||
solutionContinue continu_2;
|
||||
testCooling cooling;
|
||||
solutionEval eval;
|
||||
solutionComparator comparator;
|
||||
solutionPerturbation perturbation;
|
||||
|
||||
moILS<testMove> ils(rand, incrEval, continu, 10.0, cooling, continu_2, comparator, perturbation, eval);
|
||||
|
||||
cout << "[ moILS_SA ] ==> ";
|
||||
|
||||
solution.fitness(0);
|
||||
|
||||
eval(solution);
|
||||
|
||||
ils(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
223
trunk/paradiseo-old-mo/test/t-moILS_TS.cpp
Normal file
223
trunk/paradiseo-old-mo/test/t-moILS_TS.cpp
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
* <t-moILS_TS.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moILS_TS.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveInit : public moMoveInit <testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move=_move;
|
||||
const solution sol(_solution);
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveNext : public moNextMove <testMove>
|
||||
{
|
||||
public :
|
||||
bool operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move=_move;
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveIncrEval : public moMoveIncrEval <testMove>
|
||||
{
|
||||
public :
|
||||
unsigned int operator () (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution solution(_solution);
|
||||
|
||||
return 2;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testTabuList : public moTabuList<testMove>
|
||||
{
|
||||
public:
|
||||
bool operator() (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void add(const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution sol(_solution);
|
||||
}
|
||||
|
||||
void update()
|
||||
{}
|
||||
|
||||
void init()
|
||||
{}
|
||||
};
|
||||
|
||||
class testAspirCrit : public moAspirCrit<testMove>
|
||||
{
|
||||
public:
|
||||
bool operator() (const testMove & _move, const unsigned int & _fitness)
|
||||
{
|
||||
unsigned int fitness;
|
||||
const testMove move(_move);
|
||||
fitness=_fitness;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
};
|
||||
|
||||
class solutionContinue : public moSolContinue<solution>
|
||||
{
|
||||
public :
|
||||
solutionContinue(): counter(0)
|
||||
{}
|
||||
|
||||
bool operator () (const solution & _solution)
|
||||
{
|
||||
const solution sol(_solution);
|
||||
|
||||
if(counter==0)
|
||||
{
|
||||
counter++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
private :
|
||||
unsigned int counter;
|
||||
} ;
|
||||
|
||||
class solutionComparator : public moComparator<solution>
|
||||
{
|
||||
public :
|
||||
bool operator () (const solution & _solution1 , const solution & _solution2)
|
||||
{
|
||||
const solution sol1(_solution1);
|
||||
const solution sol2(_solution2);
|
||||
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
class solutionPerturbation : public eoMonOp<solution>
|
||||
{
|
||||
public :
|
||||
bool operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(2);
|
||||
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
class solutionEval : public eoEvalFunc <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(0);
|
||||
}
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
solution solution;
|
||||
|
||||
testMoveInit init;
|
||||
testMoveNext next;
|
||||
testMoveIncrEval incrEval;
|
||||
testTabuList tabuList;
|
||||
testAspirCrit aspirCrit;
|
||||
solutionEval eval;
|
||||
solutionContinue continu;
|
||||
solutionContinue continu_2;
|
||||
solutionComparator comparator;
|
||||
solutionPerturbation perturbation;
|
||||
|
||||
moILS<testMove> ils(init, next, incrEval, tabuList, aspirCrit, continu, continu_2, comparator, perturbation, eval);
|
||||
|
||||
cout << "[ moILS_TS ] ==> ";
|
||||
|
||||
ils(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
109
trunk/paradiseo-old-mo/test/t-moImprBestFitAspirCrit.cpp
Normal file
109
trunk/paradiseo-old-mo/test/t-moImprBestFitAspirCrit.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* <t-moImprBestFitAspirCrit.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moImprBestFitAspirCrit.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2;
|
||||
int return_value, value_1, value_2;
|
||||
|
||||
solution solution;
|
||||
|
||||
unsigned int i;
|
||||
|
||||
moImprBestFitAspirCrit<testMove> aspirCriterion;
|
||||
|
||||
testMove move;
|
||||
|
||||
cout << "[ moImprBestFitAspirCrit ] ==> ";
|
||||
|
||||
aspirCriterion(move, 10);
|
||||
|
||||
i=0;
|
||||
while ( !aspirCriterion(move,i) && i<15)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
test_1=((i!=11)?"KO":"OK");
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
aspirCriterion.init();
|
||||
aspirCriterion(move, i);
|
||||
|
||||
i=0;
|
||||
while ( !aspirCriterion(move,i) && i<15)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
move(solution);
|
||||
|
||||
test_2=((i!=12)?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
114
trunk/paradiseo-old-mo/test/t-moItRandNextMove.cpp
Normal file
114
trunk/paradiseo-old-mo/test/t-moItRandNextMove.cpp
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* <t-moItRandNextMove.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moItRandNextMove.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testRandMove : public moRandMove<testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move)
|
||||
{
|
||||
_move=_move;
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2;
|
||||
int value_1, value_2, return_value;
|
||||
|
||||
unsigned int i;
|
||||
|
||||
testMove move;
|
||||
solution solution;
|
||||
|
||||
testRandMove rand;
|
||||
|
||||
moItRandNextMove<testMove> next(rand, 10);
|
||||
|
||||
cout << "[ moItRandNextMove ] ==> ";
|
||||
|
||||
i=0;
|
||||
while( next(move, solution) && i<15 )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
test_1=((i!=11)?"KO":"OK");
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
i=0;
|
||||
while( next(move, solution) && i<15 )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
move(solution);
|
||||
|
||||
test_2=((i!=11)?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
116
trunk/paradiseo-old-mo/test/t-moLSCheckPoint.cpp
Normal file
116
trunk/paradiseo-old-mo/test/t-moLSCheckPoint.cpp
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* <t-moLSCheckPoint.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moLSCheckPoint.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testBF : public eoBF<const testMove & , const testMove::EOType &, void>
|
||||
{
|
||||
void operator () (const testMove & _move, const testMove::EOType & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const testMove::EOType sol(_solution);
|
||||
std::ofstream os("test.txt");
|
||||
os << "OK" << endl;
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2;
|
||||
int value_1, value_2, return_value;
|
||||
|
||||
unsigned int i;
|
||||
std::string result;
|
||||
|
||||
testBF test;
|
||||
moLSCheckPoint<testMove> checkpoint;
|
||||
|
||||
solution solution;
|
||||
|
||||
testMove move;
|
||||
|
||||
std::ifstream is;
|
||||
|
||||
cout << "[ moLSCheckPoint ] ==> ";
|
||||
|
||||
i=0;
|
||||
|
||||
checkpoint.add(test);
|
||||
checkpoint(move, solution);
|
||||
|
||||
move(solution);
|
||||
|
||||
is.open("test.txt");
|
||||
|
||||
test_1=((!is.is_open())?"KO":"OK");
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
is >> result;
|
||||
|
||||
test_2=((result.compare("OK")!=0)?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
79
trunk/paradiseo-old-mo/test/t-moLinearCoolingSchedule.cpp
Normal file
79
trunk/paradiseo-old-mo/test/t-moLinearCoolingSchedule.cpp
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* <t-moLinearCoolingSchedule.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moLinearCoolingSchedule.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
unsigned int i;
|
||||
double temperature;
|
||||
|
||||
moLinearCoolingSchedule coolingSchedule( 1.0, 0.5 );
|
||||
|
||||
cout << "[ moLinearCoolingSchedule ] ==> ";
|
||||
|
||||
temperature=2.0;
|
||||
|
||||
i=0;
|
||||
while( coolingSchedule(temperature) )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
test_result=((i!=1)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
85
trunk/paradiseo-old-mo/test/t-moNoAspirCrit.cpp
Normal file
85
trunk/paradiseo-old-mo/test/t-moNoAspirCrit.cpp
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* <t-moNoAspirCrit.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moNoAspirCrit.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
unsigned int i;
|
||||
moNoAspirCrit<testMove> aspirCriterion;
|
||||
testMove move;
|
||||
solution solution;
|
||||
|
||||
cout << "[ moNoAspirCrit ] ==> ";
|
||||
|
||||
move(solution);
|
||||
|
||||
aspirCriterion.init();
|
||||
|
||||
test_result=((aspirCriterion(move, i))?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
101
trunk/paradiseo-old-mo/test/t-moNoFitImprSolContinue.cpp
Normal file
101
trunk/paradiseo-old-mo/test/t-moNoFitImprSolContinue.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* <t-moNoFitImprSolContinue.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moNoFitImprSolContinue.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2;
|
||||
int return_value, value_1, value_2;
|
||||
|
||||
|
||||
unsigned int i;
|
||||
|
||||
moNoFitImprSolContinue<solution> continu(10);
|
||||
|
||||
solution solution;
|
||||
|
||||
cout << "[ moNoFitImprSolContinue ] ==> ";
|
||||
|
||||
continu.init();
|
||||
|
||||
test_1="KO";
|
||||
|
||||
try
|
||||
{
|
||||
continu(solution);
|
||||
}
|
||||
catch(std::runtime_error e)
|
||||
{
|
||||
test_1="OK";
|
||||
}
|
||||
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
solution.fitness(0);
|
||||
|
||||
i=0;
|
||||
while( continu(solution) )
|
||||
{
|
||||
i++;
|
||||
solution.fitness(2);
|
||||
}
|
||||
|
||||
test_2=((i!=11)?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
115
trunk/paradiseo-old-mo/test/t-moRandImprSelect.cpp
Normal file
115
trunk/paradiseo-old-mo/test/t-moRandImprSelect.cpp
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* <t-moRandImprSelect.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moRandImprSelect.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2, test_3;
|
||||
int value_1, value_2, value_3, return_value;
|
||||
|
||||
unsigned int i;
|
||||
|
||||
moRandImprSelect<testMove> selection;
|
||||
|
||||
solution solution;
|
||||
|
||||
testMove move;
|
||||
|
||||
cout << "[ moRandImprSelect ] ==> ";
|
||||
|
||||
selection.init(0);
|
||||
|
||||
test_1="KO";
|
||||
|
||||
i=0;
|
||||
|
||||
try
|
||||
{
|
||||
selection(move, i);
|
||||
}
|
||||
catch(std::runtime_error e)
|
||||
{
|
||||
test_1="OK";
|
||||
}
|
||||
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
move(solution);
|
||||
|
||||
test_2=((!selection.update(move, i))?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
selection(move, i);
|
||||
|
||||
i++;
|
||||
|
||||
test_3=((!selection.update(move, i))?"KO":"OK");
|
||||
value_3=((test_3.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
selection(move, i);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0)&&(test_3.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS)&&(value_3==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
168
trunk/paradiseo-old-mo/test/t-moSA.cpp
Normal file
168
trunk/paradiseo-old-mo/test/t-moSA.cpp
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* <t-moSA.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moSA.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testRandMove : public moRandMove<testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move)
|
||||
{
|
||||
_move=_move;
|
||||
}
|
||||
};
|
||||
|
||||
class testMoveIncrEval : public moMoveIncrEval <testMove>
|
||||
{
|
||||
public :
|
||||
|
||||
testMoveIncrEval() : counter(0)
|
||||
{}
|
||||
|
||||
int operator () (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution solution(_solution);
|
||||
|
||||
if(counter==0)
|
||||
{
|
||||
counter++;
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private :
|
||||
unsigned int counter;
|
||||
} ;
|
||||
|
||||
class solutionContinue : public moSolContinue<solution>
|
||||
{
|
||||
public :
|
||||
|
||||
solutionContinue() : counter(0)
|
||||
{}
|
||||
|
||||
bool operator () (const solution & _solution)
|
||||
{
|
||||
const solution sol(_solution);
|
||||
|
||||
if(counter==0)
|
||||
{
|
||||
counter++;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
private :
|
||||
unsigned int counter;
|
||||
} ;
|
||||
|
||||
class testCooling : public moCoolingSchedule
|
||||
{
|
||||
public :
|
||||
bool operator () (double & _temperature)
|
||||
{
|
||||
double temperature;
|
||||
temperature=_temperature;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class solutionEval : public eoEvalFunc <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(0);
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
solution solution;
|
||||
|
||||
testRandMove rand;
|
||||
testMoveIncrEval incrEval;
|
||||
solutionContinue continu;
|
||||
testCooling cooling;
|
||||
solutionEval eval;
|
||||
|
||||
moSA<testMove> sa(rand, incrEval, continu, 10.0, cooling, eval);
|
||||
|
||||
cout << "[ moSA ] ==> ";
|
||||
|
||||
sa(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
104
trunk/paradiseo-old-mo/test/t-moSimpleMoveTabuList.cpp
Normal file
104
trunk/paradiseo-old-mo/test/t-moSimpleMoveTabuList.cpp
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* <t-moSimpleMoveTabuList.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moSimpleMoveTabuList.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
testMove(unsigned int _value): value(_value)
|
||||
{}
|
||||
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution=_solution;
|
||||
}
|
||||
|
||||
bool operator == (const testMove & _move)
|
||||
{
|
||||
return (value==_move.value);
|
||||
}
|
||||
private :
|
||||
unsigned int value;
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
moSimpleMoveTabuList<testMove> tabuList(1);
|
||||
|
||||
solution solution;
|
||||
|
||||
testMove move_1(1), move_2(2);
|
||||
|
||||
cout << "[ moSimpleMoveTabuList ] ==> ";
|
||||
|
||||
tabuList.init();
|
||||
tabuList.update();
|
||||
|
||||
tabuList.add(move_1, solution);
|
||||
|
||||
tabuList(move_2, solution);
|
||||
|
||||
move_1(solution);
|
||||
|
||||
tabuList.add(move_2, solution);
|
||||
tabuList.add(move_2, solution);
|
||||
|
||||
test_result=((tabuList(move_1, solution))?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
106
trunk/paradiseo-old-mo/test/t-moSimpleSolutionTabuList.cpp
Normal file
106
trunk/paradiseo-old-mo/test/t-moSimpleSolutionTabuList.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* <t-moSimpleSolutionTabuList.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moSimpleSolutionTabuList.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class solution : public EO<unsigned int>
|
||||
{
|
||||
public:
|
||||
solution(unsigned int _value): value(_value)
|
||||
{}
|
||||
|
||||
bool operator == (const solution & _solution)
|
||||
{
|
||||
return (value==_solution.value);
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int value;
|
||||
};
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution solution(_solution);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
moSimpleSolutionTabuList<testMove> tabuList(1);
|
||||
|
||||
solution solution_1(1), solution_2(2);
|
||||
|
||||
testMove move;
|
||||
|
||||
cout << "[ moSimpleSolutionTabuList ] ==> ";
|
||||
|
||||
tabuList.init();
|
||||
tabuList.update();
|
||||
|
||||
tabuList.add(move, solution_1);
|
||||
|
||||
move(solution_1);
|
||||
|
||||
tabuList.add(move, solution_2);
|
||||
|
||||
tabuList.add(move, solution_2);
|
||||
|
||||
test_result=((tabuList(move, solution_1))?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
108
trunk/paradiseo-old-mo/test/t-moSteadyFitSolContinue.cpp
Normal file
108
trunk/paradiseo-old-mo/test/t-moSteadyFitSolContinue.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* <t-moSteadyFitSolContinue.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moSteadyFitSolContinue.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2;
|
||||
int return_value, value_1, value_2;
|
||||
|
||||
unsigned int i;
|
||||
solution solution_1, solution_2;
|
||||
|
||||
moSteadyFitSolContinue<solution> continu(10,10);
|
||||
|
||||
cout << "[ moSteadyFitSolContinue ] ==> ";
|
||||
|
||||
continu.init();
|
||||
|
||||
i=0;
|
||||
solution_1.fitness(i);
|
||||
while( continu(solution_1) && i<50)
|
||||
{
|
||||
i++;
|
||||
|
||||
if(i<11)
|
||||
{
|
||||
solution_1.fitness(i);
|
||||
}
|
||||
|
||||
if(i==11)
|
||||
{
|
||||
test_1="KO";
|
||||
try
|
||||
{
|
||||
continu(solution_2);
|
||||
}
|
||||
catch(std::runtime_error e)
|
||||
{
|
||||
test_1="OK";
|
||||
}
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if(i==15)
|
||||
{
|
||||
solution_1.fitness(i);
|
||||
}
|
||||
}
|
||||
|
||||
test_2=((i!=25)?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
168
trunk/paradiseo-old-mo/test/t-moTA.cpp
Normal file
168
trunk/paradiseo-old-mo/test/t-moTA.cpp
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* <t-moTA.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2007-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Salma Mesmoudi
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moTA.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testRandMove : public moRandMove<testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move)
|
||||
{
|
||||
_move=_move;
|
||||
}
|
||||
};
|
||||
|
||||
class testMoveIncrEval : public moMoveIncrEval <testMove>
|
||||
{
|
||||
public :
|
||||
|
||||
testMoveIncrEval() : counter(0)
|
||||
{}
|
||||
|
||||
int operator () (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution solution(_solution);
|
||||
|
||||
if(counter==0)
|
||||
{
|
||||
counter++;
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private :
|
||||
unsigned int counter;
|
||||
} ;
|
||||
|
||||
class solutionContinue : public moSolContinue<solution>
|
||||
{
|
||||
public :
|
||||
|
||||
solutionContinue() : counter(0)
|
||||
{}
|
||||
|
||||
bool operator () (const solution & _solution)
|
||||
{
|
||||
const solution sol(_solution);
|
||||
|
||||
if(counter==0)
|
||||
{
|
||||
counter++;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
private :
|
||||
unsigned int counter;
|
||||
} ;
|
||||
|
||||
class testCooling : public moCoolingSchedule
|
||||
{
|
||||
public :
|
||||
bool operator () (double & _threeshold)
|
||||
{
|
||||
double threeshold;
|
||||
threeshold=_threeshold;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class solutionEval : public eoEvalFunc <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(0);
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
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 ] ==> ";
|
||||
|
||||
ta(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
188
trunk/paradiseo-old-mo/test/t-moTS.cpp
Normal file
188
trunk/paradiseo-old-mo/test/t-moTS.cpp
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
* <t-moTS.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moTS.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveInit : public moMoveInit <testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move=_move;
|
||||
const solution sol(_solution);
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveNext : public moNextMove <testMove>
|
||||
{
|
||||
public :
|
||||
bool operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move(_move);
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveIncrEval : public moMoveIncrEval <testMove>
|
||||
{
|
||||
public :
|
||||
unsigned int operator () (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution solution(_solution);
|
||||
|
||||
return 2;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testTabuList : public moTabuList<testMove>
|
||||
{
|
||||
public:
|
||||
bool operator() (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void add(const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution sol(_solution);
|
||||
}
|
||||
|
||||
void update()
|
||||
{}
|
||||
|
||||
void init()
|
||||
{}
|
||||
};
|
||||
|
||||
class testAspirCrit : public moAspirCrit<testMove>
|
||||
{
|
||||
public:
|
||||
bool operator() (const testMove & _move, const unsigned int & _fitness)
|
||||
{
|
||||
unsigned int fitness;
|
||||
const testMove move(_move);
|
||||
fitness=_fitness;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
};
|
||||
|
||||
class solutionContinue : public moSolContinue<solution>
|
||||
{
|
||||
public :
|
||||
bool operator () (const solution & _solution)
|
||||
{
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
} ;
|
||||
|
||||
class solutionEval : public eoEvalFunc <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(2);
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
solution solution;
|
||||
|
||||
testMoveInit init;
|
||||
testMoveNext next;
|
||||
testMoveIncrEval incrEval;
|
||||
testTabuList tabuList;
|
||||
testAspirCrit aspirCrit;
|
||||
solutionContinue continu;
|
||||
solutionEval eval;
|
||||
|
||||
moTS<testMove> ts(init, next, incrEval, tabuList, aspirCrit, continu, eval);
|
||||
|
||||
cout << "[ moTS ] ==> ";
|
||||
|
||||
ts(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
180
trunk/paradiseo-old-mo/test/t-moTSMoveLoopExpl.cpp
Normal file
180
trunk/paradiseo-old-mo/test/t-moTSMoveLoopExpl.cpp
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* <t-moTSMoveLoopExpl.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moTSMoveLoopExpl.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveInit : public moMoveInit <testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move=_move;
|
||||
const solution sol(_solution);
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveNext : public moNextMove <testMove>
|
||||
{
|
||||
public :
|
||||
bool operator () (testMove & _move, const solution & _solution)
|
||||
{
|
||||
testMove move(_move);
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveIncrEval : public moMoveIncrEval <testMove>
|
||||
{
|
||||
public :
|
||||
unsigned int operator () (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution solution(_solution);
|
||||
|
||||
return 2;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testTabuList : public moTabuList<testMove>
|
||||
{
|
||||
public:
|
||||
bool operator() (const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void add(const testMove & _move, const solution & _solution)
|
||||
{
|
||||
const testMove move(_move);
|
||||
const solution sol(_solution);
|
||||
}
|
||||
|
||||
void update()
|
||||
{}
|
||||
|
||||
void init()
|
||||
{}
|
||||
};
|
||||
|
||||
class testAspirCrit : public moAspirCrit<testMove>
|
||||
{
|
||||
public:
|
||||
bool operator() (const testMove & _move, const unsigned int & _fitness)
|
||||
{
|
||||
unsigned int fitness;
|
||||
const testMove move(_move);
|
||||
fitness=_fitness;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result, test_1, test_2;
|
||||
int return_value, value_1, value_2;
|
||||
|
||||
solution solution_1 ,solution_2;
|
||||
|
||||
testMoveInit init;
|
||||
testMoveNext next;
|
||||
testMoveIncrEval incrEval;
|
||||
testTabuList tabuList;
|
||||
testAspirCrit aspirCrit;
|
||||
|
||||
moTSMoveLoopExpl<testMove> explorer(init, next, incrEval, tabuList, aspirCrit);
|
||||
|
||||
cout << "[ moTSMoveLoopExpl ] ==> ";
|
||||
|
||||
test_1="KO";
|
||||
|
||||
try
|
||||
{
|
||||
explorer(solution_1, solution_2);
|
||||
}
|
||||
catch(std::runtime_error e)
|
||||
{
|
||||
test_1="OK";
|
||||
}
|
||||
|
||||
value_1=((test_1.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
solution_1.fitness(0);
|
||||
|
||||
explorer(solution_1, solution_2);
|
||||
|
||||
test_2=((solution_2.fitness()!=2)?"KO":"OK");
|
||||
value_2=((test_2.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
test_result=(((test_1.compare("OK")==0)&&(test_2.compare("OK")==0))?"OK":"KO");
|
||||
return_value=(((value_1==EXIT_SUCCESS)&&(value_2==EXIT_SUCCESS))?EXIT_SUCCESS:EXIT_FAILURE);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
123
trunk/paradiseo-old-mo/test/t-moTS_2.cpp
Normal file
123
trunk/paradiseo-old-mo/test/t-moTS_2.cpp
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* <t-moTS_2.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moTS_2.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
class testMoveExplorer : public moMoveExpl<testMove>
|
||||
{
|
||||
public :
|
||||
void operator () (const solution & _solution_1, solution & _solution_2)
|
||||
{
|
||||
const solution solution(_solution_1);
|
||||
_solution_2.fitness(2);
|
||||
}
|
||||
};
|
||||
|
||||
class solutionContinue : public moSolContinue<solution>
|
||||
{
|
||||
public :
|
||||
bool operator () (const solution & _solution)
|
||||
{
|
||||
const solution sol(_solution);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void init()
|
||||
{}
|
||||
} ;
|
||||
|
||||
class solutionEval : public eoEvalFunc <solution>
|
||||
{
|
||||
public :
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
_solution.fitness(0);
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
int return_value;
|
||||
|
||||
solution solution;
|
||||
|
||||
testMoveExplorer explorer;
|
||||
solutionContinue continu;
|
||||
solutionEval eval;
|
||||
testMove move;
|
||||
|
||||
moTS<testMove> ts(explorer, continu, eval);
|
||||
|
||||
cout << "[ moTS_2 ] ==> ";
|
||||
|
||||
ts(solution);
|
||||
|
||||
move(solution);
|
||||
|
||||
test_result=((solution.fitness()!=2)?"KO":"OK");
|
||||
return_value=((test_result.compare("KO")==0)?EXIT_FAILURE:EXIT_SUCCESS);
|
||||
|
||||
cout << test_result << endl;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
140
trunk/paradiseo-old-mo/test/t-moVNS.cpp
Normal file
140
trunk/paradiseo-old-mo/test/t-moVNS.cpp
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* <t-moVNS.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2007-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Salma Mesmoudi (salma.mesmoudi@inria.fr), Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||
* Jeremie Humeau (jeremie.humeau@inria.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
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
// t-moVNS.cpp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <eo> // EO
|
||||
#include <mo> // MO
|
||||
#include <cassert>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef EO<unsigned int> solution;
|
||||
typedef eoScalarFitness< float, std::greater<float> > tspFitness ;
|
||||
typedef eoVector <tspFitness, unsigned int> Route ;
|
||||
|
||||
int cpt=0;
|
||||
int tableau[7]={10.0, 9.0, 8.0, 8.0, 7.0, 7.0, 7.0};
|
||||
|
||||
class testMove : public moMove <solution>
|
||||
{
|
||||
public :
|
||||
|
||||
void operator () (solution & _solution)
|
||||
{
|
||||
solution sol=_solution;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
class solutionAlgo : public moAlgo <solution>
|
||||
{
|
||||
public :
|
||||
bool operator () (solution & _solution)
|
||||
{
|
||||
solution solution(_solution);
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
class Voisinage : public eoMonOp<Route>
|
||||
{
|
||||
public :
|
||||
bool operator () (Route & _solution)
|
||||
{
|
||||
_solution.invalidate();
|
||||
//_solution.fitness();
|
||||
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
class Explorer : public moExpl<Route>
|
||||
{
|
||||
public:
|
||||
Explorer(eoMonOp<Route> & expl): moExpl<Route>( expl)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class solutionEval : public eoEvalFunc <Route>
|
||||
{
|
||||
public :
|
||||
void operator () (Route & _solution)
|
||||
{
|
||||
_solution.fitness(tableau[cpt]);
|
||||
cpt++;
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string test_result;
|
||||
|
||||
//solution solution;
|
||||
Route so ;
|
||||
|
||||
Voisinage sol1;
|
||||
Voisinage sol2;
|
||||
Explorer explorer(sol1);
|
||||
explorer.addExplorer(sol2);
|
||||
solutionEval eval;
|
||||
|
||||
moVNS<Route> vns(explorer, eval);
|
||||
|
||||
cout << "[moVNS] ==> ";
|
||||
|
||||
so.fitness(20.0);
|
||||
|
||||
vns(so);
|
||||
|
||||
assert(so.fitness()==7.0);
|
||||
|
||||
cout << "OK" << endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
222
trunk/paradiseo-old-mo/tutorial/CMakeLists.txt
Normal file
222
trunk/paradiseo-old-mo/tutorial/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
IF(COMMAND cmake_policy)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
ENDIF(COMMAND cmake_policy)
|
||||
######################################################################################
|
||||
### 1) Definitions (required for tsp target)
|
||||
######################################################################################
|
||||
|
||||
SET(TSP_SRC_DIR ${MO_SRC_DIR}/tutorial/examples/tsp CACHE PATH "TSP src directory")
|
||||
SET(TSP_BIN_DIR ${MO_BIN_DIR}/tutorial/examples/tsp CACHE PATH "TSP binary directory")
|
||||
|
||||
SET(FUNCTION_SRC_DIR ${MO_SRC_DIR}/tutorial/examples/function CACHE PATH "FUNCTION src directory")
|
||||
SET(FUNCTION_BIN_DIR ${MO_BIN_DIR}/tutorial/examples/function CACHE PATH "FUNCTION binary directory")
|
||||
|
||||
######################################################################################
|
||||
|
||||
######################################################################################
|
||||
### 2) How to manage copy of benchs ?
|
||||
######################################################################################
|
||||
|
||||
IF(ENABLE_CMAKE_EXAMPLE OR CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SET(BENCH_LIST
|
||||
berlin52.tsp
|
||||
eil101.tsp
|
||||
pr2392.tsp
|
||||
rl5915.tsp
|
||||
usa13509.tsp
|
||||
)
|
||||
|
||||
FOREACH (bench ${BENCH_LIST})
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/${bench}
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/${bench}
|
||||
)
|
||||
ENDFOREACH (bench)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson1/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson1/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson2/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson2/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson3/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson3/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson4/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson4/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson5/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson5/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/HybridLesson/param
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson/param
|
||||
)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE OR CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
######################################################################################
|
||||
### 3) Where must cmake go now ?
|
||||
######################################################################################
|
||||
|
||||
MACRO(ADD_COMMANDS_MO)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson1/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson1/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson1
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson2/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson2/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson2
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson3/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson3/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson3
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson4/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson4/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson4
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson5/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/Lesson5/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson5
|
||||
)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${MO_BIN_DIR}/tutorial/Lesson6/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${MO_SRC_DIR}/tutorial/HybridLesson/param
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson
|
||||
)
|
||||
ENDMACRO(ADD_COMMANDS_MO)
|
||||
|
||||
MACRO(ADD_TARGET_MO n)
|
||||
IF(${n} STREQUAL "lesson1")
|
||||
ADD_CUSTOM_TARGET(lesson1 DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson1/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson1/hill_climbing
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "lesson2")
|
||||
ADD_CUSTOM_TARGET(lesson2 DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson2/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson2/tabu_search
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "lesson3")
|
||||
ADD_CUSTOM_TARGET(lesson3 DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson3/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson3/simulated_annealing
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "lesson4")
|
||||
ADD_CUSTOM_TARGET(lesson4 DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson4/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson4/iterated_local_search
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "lesson5")
|
||||
ADD_CUSTOM_TARGET(lesson5 DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson5/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson5/variable_neighborhood_search
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "hybridlesson")
|
||||
ADD_CUSTOM_TARGET(hybridlesson DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson/param
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson/hybrid_ga
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "install")
|
||||
ADD_CUSTOM_TARGET(install DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/Lesson1/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson2/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson3/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson4/param
|
||||
${MO_BIN_DIR}/tutorial/Lesson5/param
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson/param
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ELSEIF(${n} STREQUAL "benchs")
|
||||
ADD_CUSTOM_TARGET(benchs DEPENDS
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/berlin52.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/eil101.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/pr2392.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/rl5915.tsp
|
||||
${MO_BIN_DIR}/tutorial/examples/tsp/benchs/usa13509.tsp
|
||||
)
|
||||
ENDIF(${n} STREQUAL "lesson1")
|
||||
ENDMACRO(ADD_TARGET_MO)
|
||||
|
||||
IF(NOT CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" AND NOT CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
ADD_COMMANDS_MO()
|
||||
ADD_TARGET_MO(install)
|
||||
ADD_TARGET_MO(benchs)
|
||||
ENDIF(NOT CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" AND NOT CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_SUBDIRECTORY(examples)
|
||||
ADD_SUBDIRECTORY(Lesson1)
|
||||
ADD_SUBDIRECTORY(Lesson2)
|
||||
ADD_SUBDIRECTORY(Lesson3)
|
||||
ADD_SUBDIRECTORY(Lesson4)
|
||||
ADD_SUBDIRECTORY(Lesson5)
|
||||
ADD_SUBDIRECTORY(HybridLesson)
|
||||
65
trunk/paradiseo-old-mo/tutorial/HybridLesson/CMakeLists.txt
Normal file
65
trunk/paradiseo-old-mo/tutorial/HybridLesson/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES hybrid_ga.cpp)
|
||||
|
||||
SOURCE_GROUP(benchs FILES
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(hybrid_ga
|
||||
hybrid_ga.cpp
|
||||
${MO_BIN_DIR}/tutorial/HybridLesson/param
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
ELSE(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
ADD_COMMANDS_MO()
|
||||
ADD_TARGET_MO(lesson6)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(hybrid_ga hybrid_ga.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(hybrid_ga EXCLUDE_FROM_ALL hybrid_ga.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(hybrid_ga tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(HYBRIDGA_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(hybrid_ga PROPERTIES VERSION "${HYBRIDGA_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(hybrid_ga tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
194
trunk/paradiseo-old-mo/tutorial/HybridLesson/hybrid_ga.cpp
Normal file
194
trunk/paradiseo-old-mo/tutorial/HybridLesson/hybrid_ga.cpp
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* <tsp.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Sébastien Cahon, Thomas Legrand
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath, crossoverType, selectionType;
|
||||
unsigned int seed, populationSize, maxIterations, selectedParentNumber;
|
||||
double crossoverRate, mutationRate, elitismRate, tournamentRate;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
populationSize=atoi( (parser.getParamWithLongName("popSize")->getValue()).c_str() );
|
||||
maxIterations=atoi( (parser.getParamWithLongName("maxIter")->getValue()).c_str() );
|
||||
crossoverRate=atof( (parser.getParamWithLongName("crossRate")->getValue()).c_str() );
|
||||
mutationRate=atof( (parser.getParamWithLongName("mutRate")->getValue()).c_str() );
|
||||
selectedParentNumber=atoi( (parser.getParamWithLongName("nbSelPar")->getValue()).c_str() );
|
||||
elitismRate=atof( (parser.getParamWithLongName("elitismRate")->getValue()).c_str() );
|
||||
tournamentRate=atof( (parser.getParamWithLongName("tournRate")->getValue()).c_str() );
|
||||
crossoverType=parser.getParamWithLongName("crossType")->getValue();
|
||||
selectionType=parser.getParamWithLongName("selectionType")->getValue();
|
||||
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
RouteInit init ;
|
||||
|
||||
RouteEval full_evaluation ;
|
||||
|
||||
eoPop <Route> population (populationSize, init) ;
|
||||
apply <Route> (full_evaluation, population) ;
|
||||
|
||||
std :: cout << "[From] " << population.best_element () << std :: endl ;
|
||||
|
||||
eoGenContinue <Route> continu (maxIterations) ;
|
||||
|
||||
eoStochTournamentSelect <Route> select_one ;
|
||||
|
||||
eoSelectNumber <Route> select (select_one, selectedParentNumber) ;
|
||||
|
||||
eoQuadOp <Route>*crossover;
|
||||
|
||||
if(crossoverType.compare("Partial")==0)
|
||||
{
|
||||
crossover=new PartialMappedXover();
|
||||
}
|
||||
else if (crossoverType.compare("Order")==0)
|
||||
{
|
||||
crossover=new OrderXover();
|
||||
}
|
||||
else if (crossoverType.compare("Edge")==0)
|
||||
{
|
||||
crossover=new EdgeXover();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[tsp.cpp]: the crossover type '"+crossoverType+"' is not correct.");
|
||||
}
|
||||
|
||||
TwoOptInit two_opt_initializer;
|
||||
|
||||
TwoOptNext two_opt_next_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moMoveSelect<TwoOpt>* two_opt_selection;
|
||||
|
||||
if(selectionType.compare("Best")==0)
|
||||
{
|
||||
two_opt_selection= new moBestImprSelect<TwoOpt>();
|
||||
}
|
||||
else if (selectionType.compare("First")==0)
|
||||
{
|
||||
two_opt_selection= new moFirstImprSelect<TwoOpt>();
|
||||
}
|
||||
else if (selectionType.compare("Random")==0)
|
||||
{
|
||||
two_opt_selection= new moRandImprSelect<TwoOpt>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[hill_climbing.cpp]: the type of selection '"+selectionType+"' is not correct.");
|
||||
}
|
||||
|
||||
moHC <TwoOpt> hill_climbing_mutation (two_opt_initializer, two_opt_next_move_generator, two_opt_incremental_evaluation,
|
||||
*two_opt_selection, full_evaluation);
|
||||
|
||||
eoSGATransform <Route> transform (*crossover, crossoverRate, hill_climbing_mutation, mutationRate) ;
|
||||
|
||||
eoElitism <Route> merge (elitismRate) ;
|
||||
|
||||
eoStochTournamentTruncate <Route> reduce (tournamentRate) ;
|
||||
|
||||
eoEasyEA <Route> ea (continu, full_evaluation, select, transform, merge, reduce) ;
|
||||
|
||||
ea (population) ;
|
||||
|
||||
std :: cout << "[To] " << population.best_element () << std :: endl ;
|
||||
|
||||
delete(crossover);
|
||||
delete(two_opt_selection);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
manage_configuration_file(eoParser & _parser)
|
||||
{
|
||||
std::ofstream os;
|
||||
|
||||
_parser.createParam(std::string("../examples/tsp/benchs/berlin52.tsp"), "instancePath", "Path to the instance.",
|
||||
0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)time(0), "seed", "Seed for rand.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)100, "popSize", "Size of the population.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)1000, "maxIter", "Maximum number of iterations.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)1.0, "crossRate", "Probability of crossover.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)0.01, "mutRate", "Probability of mutation.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)100, "nbSelPar", "Number of selected parents.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)1.0, "elitismRate", "Percentage of the best individuals kept.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)0.7, "tournRate", "Percentage of the individuals used during the tournament.",
|
||||
0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam(std::string("Partial"), "crossType", "Crossover to use, it can be 'Partial', 'Order' or 'Edge'.",
|
||||
0, "Configuration", false);
|
||||
|
||||
|
||||
_parser.getORcreateParam(std::string("Best"), "selectionType", "Type of the selection: 'Best', 'First' or 'Random'.",
|
||||
0, "Configuration", false);
|
||||
|
||||
if (_parser.userNeedsHelp())
|
||||
{
|
||||
_parser.printHelp(std::cout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
os.open("current_param");
|
||||
if(!os.is_open())
|
||||
{
|
||||
throw std::runtime_error("[tsp.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
17
trunk/paradiseo-old-mo/tutorial/HybridLesson/param
Normal file
17
trunk/paradiseo-old-mo/tutorial/HybridLesson/param
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
|
||||
###### Configuration ######
|
||||
# --instancePath=../examples/tsp/benchs/berlin52.tsp # Path to the instance.
|
||||
# --seed=1224599328 # Seed for rand.
|
||||
# --popSize=100 # Size of the population.
|
||||
# --maxIter=1000 # Maximum number of iterations.
|
||||
# --crossRate=1 # Probability of crossover.
|
||||
# --mutRate=0.01 # Probability of mutation.
|
||||
# --nbSelPar=100 # Number of selected parents.
|
||||
# --elitismRate=1 # Percentage of the best individuals kept.
|
||||
# --tournRate=0.7 # Percentage of the individuals used during the tournament.
|
||||
# --crossType=Partial # Crossover to use, it can be 'Partial', 'Order' or 'Edge'.
|
||||
# --selectionType=Best # Type of the selection: 'Best', 'First' or 'Random'.
|
||||
67
trunk/paradiseo-old-mo/tutorial/Lesson1/CMakeLists.txt
Normal file
67
trunk/paradiseo-old-mo/tutorial/Lesson1/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES hill_climbing.cpp)
|
||||
|
||||
SOURCE_GROUP(benchs FILES
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(hill_climbing
|
||||
hill_climbing.cpp
|
||||
${MO_BIN_DIR}/tutorial/Lesson1/param
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
ELSE(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
ADD_COMMANDS_MO()
|
||||
ADD_TARGET_MO(lesson1)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(hill_climbing hill_climbing.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(hill_climbing EXCLUDE_FROM_ALL hill_climbing.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
|
||||
ADD_DEPENDENCIES(hill_climbing tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(HILLCLIMBING_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(hill_climbing PROPERTIES VERSION "${HILLCLIMBING_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(hill_climbing tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
|
||||
134
trunk/paradiseo-old-mo/tutorial/Lesson1/hill_climbing.cpp
Normal file
134
trunk/paradiseo-old-mo/tutorial/Lesson1/hill_climbing.cpp
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
<hill_climbing.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, Jean-Charles Boisson
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath, selectionType;
|
||||
unsigned int seed;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
selectionType=parser.getParamWithLongName("selectionType")->getValue();
|
||||
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
RouteInit initializer;
|
||||
initializer (solution);
|
||||
|
||||
RouteEval full_evaluation;
|
||||
full_evaluation (solution);
|
||||
|
||||
std :: cout << "[From] " << solution << std :: endl;
|
||||
|
||||
/* Tools for an efficient (? :-))
|
||||
local search ! */
|
||||
|
||||
TwoOptInit two_opt_initializer;
|
||||
|
||||
TwoOptNext two_opt_next_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moMoveSelect<TwoOpt>* two_opt_selection;
|
||||
|
||||
if(selectionType.compare("Best")==0)
|
||||
{
|
||||
two_opt_selection= new moBestImprSelect<TwoOpt>();
|
||||
}
|
||||
else if (selectionType.compare("First")==0)
|
||||
{
|
||||
two_opt_selection= new moFirstImprSelect<TwoOpt>();
|
||||
}
|
||||
else if (selectionType.compare("Random")==0)
|
||||
{
|
||||
two_opt_selection= new moRandImprSelect<TwoOpt>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[hill_climbing.cpp]: the type of selection '"+selectionType+"' is not correct.");
|
||||
}
|
||||
|
||||
moHC <TwoOpt> hill_climbing (two_opt_initializer, two_opt_next_move_generator, two_opt_incremental_evaluation,
|
||||
*two_opt_selection, full_evaluation);
|
||||
hill_climbing (solution) ;
|
||||
|
||||
std :: cout << "[To] " << solution << std :: endl;
|
||||
|
||||
delete(two_opt_selection);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
manage_configuration_file(eoParser & _parser)
|
||||
{
|
||||
std::ofstream os;
|
||||
|
||||
_parser.createParam(std::string("../examples/tsp/benchs/berlin52.tsp"), "instancePath", "Path to the instance.",
|
||||
0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)time(0), "seed", "Seed for rand.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam(std::string("Best"), "selectionType", "Type of the selection: 'Best', 'First' or 'Random'.",
|
||||
0, "Configuration", false);
|
||||
|
||||
if (_parser.userNeedsHelp())
|
||||
{
|
||||
_parser.printHelp(std::cout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
os.open("current_param");
|
||||
if(!os.is_open())
|
||||
{
|
||||
throw std::runtime_error("[hill_climbing.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
9
trunk/paradiseo-old-mo/tutorial/Lesson1/param
Normal file
9
trunk/paradiseo-old-mo/tutorial/Lesson1/param
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
|
||||
###### Configuration ######
|
||||
# --instancePath=../examples/tsp/benchs/berlin52.tsp # Path to the instance.
|
||||
# --seed=1203517190 # Seed for rand.
|
||||
# --selectionType=Best # Type of the selection: 'Best', 'First' or 'Random'.
|
||||
66
trunk/paradiseo-old-mo/tutorial/Lesson2/CMakeLists.txt
Normal file
66
trunk/paradiseo-old-mo/tutorial/Lesson2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES tabu_search.cpp)
|
||||
|
||||
SOURCE_GROUP(benchs FILES
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(tabu_search
|
||||
tabu_search.cpp
|
||||
${MO_BIN_DIR}/tutorial/Lesson2/param
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
ELSE(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
ADD_COMMANDS_MO()
|
||||
ADD_TARGET_MO(lesson2)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(tabu_search tabu_search.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(tabu_search EXCLUDE_FROM_ALL tabu_search.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(tabu_search tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(TABUSEARCH_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(tabu_search PROPERTIES VERSION "${TABUSEARCH_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(tabu_search tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
|
||||
11
trunk/paradiseo-old-mo/tutorial/Lesson2/param
Normal file
11
trunk/paradiseo-old-mo/tutorial/Lesson2/param
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
|
||||
###### Configuration ######
|
||||
# --instancePath=../examples/tsp/benchs/berlin52.tsp # Path to the instance
|
||||
# --seed=1202917905 # Seed for rand
|
||||
# --tabuListSize=10 # Size of the tabu list
|
||||
# --maxIter=1000 # Maximum number of iterations
|
||||
# --tabuListType=TwoOpt # Type of the tabu list: 'TwoOpt', 'SimpleMove' or 'SimpleSolution'
|
||||
145
trunk/paradiseo-old-mo/tutorial/Lesson2/tabu_search.cpp
Normal file
145
trunk/paradiseo-old-mo/tutorial/Lesson2/tabu_search.cpp
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
<tabu_search.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, Jean-Charles Boisson
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath, value;
|
||||
unsigned int seed, maxIterations, tabuListSize;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
maxIterations=atoi( (parser.getParamWithLongName("maxIter")->getValue()).c_str() );
|
||||
tabuListSize=atoi( (parser.getParamWithLongName("tabuListSize")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
value=parser.getParamWithLongName("tabuListType")->getValue();
|
||||
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
RouteInit initializer;
|
||||
initializer(solution);
|
||||
|
||||
RouteEval full_evaluation;
|
||||
full_evaluation(solution);
|
||||
|
||||
std :: cout << "[From] " << solution << std :: endl;
|
||||
|
||||
/* Tools for an efficient (? :-))
|
||||
local search ! */
|
||||
|
||||
TwoOptInit two_opt_initializer;
|
||||
|
||||
TwoOptNext two_opt_next_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moTabuList<TwoOpt> *tabuList;
|
||||
|
||||
if(value.compare("TwoOpt")==0)
|
||||
{
|
||||
tabuList=new TwoOptTabuList();
|
||||
}
|
||||
else if (value.compare("SimpleMove")==0)
|
||||
{
|
||||
tabuList=new moSimpleMoveTabuList<TwoOpt>(tabuListSize);
|
||||
}
|
||||
else if (value.compare("SimpleSolution")==0)
|
||||
{
|
||||
tabuList=new moSimpleSolutionTabuList<TwoOpt>(tabuListSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[tabu_search.cpp]: the type of tabu list '"+value+"' is not correct.");
|
||||
}
|
||||
|
||||
moNoAspirCrit <TwoOpt> aspiration_criterion;
|
||||
|
||||
moGenSolContinue <Route> continu (maxIterations);
|
||||
|
||||
moTS <TwoOpt> tabu_search (two_opt_initializer, two_opt_next_move_generator,
|
||||
two_opt_incremental_evaluation, *tabuList, aspiration_criterion, continu, full_evaluation);
|
||||
tabu_search(solution);
|
||||
|
||||
std :: cout << "[To] " << solution << std :: endl;
|
||||
|
||||
delete(tabuList);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
manage_configuration_file(eoParser & _parser)
|
||||
{
|
||||
std::ofstream os;
|
||||
|
||||
_parser.createParam(std::string("../examples/tsp/benchs/berlin52.tsp"), "instancePath", "Path to the instance.",
|
||||
0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)time(0), "seed", "Seed for rand.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)10, "tabuListSize", "Size of the tabu list.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)1000, "maxIter", "Maximum number of iterations.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam(std::string("TwoOpt"), "tabuListType", "Type of the tabu list: 'TwoOpt', 'SimpleMove' or 'SimpleSolution'.",
|
||||
0, "Configuration", false);
|
||||
|
||||
if (_parser.userNeedsHelp())
|
||||
{
|
||||
_parser.printHelp(std::cout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
os.open("current_param");
|
||||
if(!os.is_open())
|
||||
{
|
||||
throw std::runtime_error("[tabu_search.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
66
trunk/paradiseo-old-mo/tutorial/Lesson3/CMakeLists.txt
Normal file
66
trunk/paradiseo-old-mo/tutorial/Lesson3/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES simulated_annealing.cpp)
|
||||
|
||||
SOURCE_GROUP(benchs FILES
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(simulated_annealing
|
||||
simulated_annealing.cpp
|
||||
${MO_BIN_DIR}/tutorial/Lesson3/param
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
ELSE(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
ADD_COMMANDS_MO()
|
||||
ADD_TARGET_MO(lesson3)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(simulated_annealing simulated_annealing.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(simulated_annealing EXCLUDE_FROM_ALL simulated_annealing.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(simulated_annealing tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(SIMULATEDANNEALING_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(simulated_annealing PROPERTIES VERSION "${SIMULATEDANNEALING_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(simulated_annealing tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
|
||||
14
trunk/paradiseo-old-mo/tutorial/Lesson3/param
Normal file
14
trunk/paradiseo-old-mo/tutorial/Lesson3/param
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
|
||||
###### Configuration ######
|
||||
# --instancePath=../examples/tsp/benchs/berlin52.tsp # Path to the instance.
|
||||
# --seed=1202919978 # Seed for rand.
|
||||
# --maxIter=1000 # Maximum number of iterations.
|
||||
# --initialTemp=1000 # Initial temperature.
|
||||
# --threshold=0.1 # Minimum temperature allowed.
|
||||
# --expoRatio=0.98 # Ratio used if exponential cooling schedule is chosen.
|
||||
# --lineaRatio=0.5 # Ratio used if linear cooling schedule is chosen.
|
||||
# --coolSchedType=Expo # Type the cooling schedule: 'Expo' or 'Linear'.
|
||||
148
trunk/paradiseo-old-mo/tutorial/Lesson3/simulated_annealing.cpp
Normal file
148
trunk/paradiseo-old-mo/tutorial/Lesson3/simulated_annealing.cpp
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
<simulated_annealing.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, Jean-Charles Boisson
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath, value;
|
||||
unsigned int seed, maxIterations;
|
||||
double threshold, geometricRatio, linearRatio, initialTemperature;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
maxIterations=atoi( (parser.getParamWithLongName("maxIter")->getValue()).c_str() );
|
||||
initialTemperature=atof( (parser.getParamWithLongName("initialTemp")->getValue()).c_str() );
|
||||
threshold=atof( (parser.getParamWithLongName("threshold")->getValue()).c_str() );
|
||||
geometricRatio=atof( (parser.getParamWithLongName("geometricRatio")->getValue()).c_str() );
|
||||
linearRatio=atof( (parser.getParamWithLongName("lineaRatio")->getValue()).c_str() );
|
||||
value=parser.getParamWithLongName("coolSchedType")->getValue();
|
||||
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
RouteInit initializer;
|
||||
initializer (solution);
|
||||
|
||||
RouteEval full_evaluation;
|
||||
full_evaluation (solution);
|
||||
|
||||
std :: cout << "[From] " << solution << std :: endl;
|
||||
|
||||
/* Tools for an efficient (? :-))
|
||||
local search ! */
|
||||
|
||||
TwoOptRand two_opt_random_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
TwoOpt move;
|
||||
|
||||
moCoolingSchedule* coolingSchedule;
|
||||
|
||||
if(value.compare("Geometric")==0)
|
||||
{
|
||||
coolingSchedule=new moGeometricCoolingSchedule(threshold, geometricRatio);
|
||||
}
|
||||
else if (value.compare("Linear")==0)
|
||||
{
|
||||
coolingSchedule=new moLinearCoolingSchedule(threshold, linearRatio);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[simulated_annealing.cpp]: the type of cooling schedule '"+value+"' is not correct.");
|
||||
}
|
||||
|
||||
moGenSolContinue <Route> continu (maxIterations);
|
||||
|
||||
moSA <TwoOpt> simulated_annealing (two_opt_random_move_generator, two_opt_incremental_evaluation,
|
||||
continu, initialTemperature, *coolingSchedule, full_evaluation);
|
||||
simulated_annealing (solution);
|
||||
|
||||
std :: cout << "[To] " << solution << std :: endl;
|
||||
|
||||
delete(coolingSchedule);
|
||||
|
||||
return EXIT_SUCCESS ;
|
||||
}
|
||||
|
||||
void
|
||||
manage_configuration_file(eoParser & _parser)
|
||||
{
|
||||
std::ofstream os;
|
||||
|
||||
_parser.createParam(std::string("../examples/tsp/benchs/berlin52.tsp"), "instancePath", "Path to the instance.",
|
||||
0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)time(0), "seed", "Seed for rand.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)1000, "maxIter", "Maximum number of iterations.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)1000, "initialTemp", "Initial temperature.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)0.1, "threshold", "Minimum temperature allowed.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)0.98, "geometricRatio", "Ratio used if exponential cooling schedule is chosen.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((double)0.5, "lineaRatio", "Ratio used if linear cooling schedule is chosen.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam(std::string("Geometric"), "coolSchedType", "Type the cooling schedule: 'Geometric' or 'Linear'.",
|
||||
0, "Configuration", false);
|
||||
|
||||
if (_parser.userNeedsHelp())
|
||||
{
|
||||
_parser.printHelp(std::cout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
os.open("current_param");
|
||||
if(!os.is_open())
|
||||
{
|
||||
throw std::runtime_error("[simulated_annealing.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
65
trunk/paradiseo-old-mo/tutorial/Lesson4/CMakeLists.txt
Normal file
65
trunk/paradiseo-old-mo/tutorial/Lesson4/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES iterated_local_search.cpp)
|
||||
|
||||
SOURCE_GROUP(benchs FILES
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(iterated_local_search
|
||||
iterated_local_search.cpp
|
||||
${MO_BIN_DIR}/tutorial/Lesson4/param
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
ELSE(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
ADD_COMMANDS_MO()
|
||||
ADD_TARGET_MO(lesson4)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(iterated_local_search iterated_local_search.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(iterated_local_search EXCLUDE_FROM_ALL iterated_local_search.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(iterated_local_search tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(ITERATEDLOCALSEARCH_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(iterated_local_search PROPERTIES VERSION "${ITERATEDLOCALSEARCH_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(iterated_local_search tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
<iterated_local_search.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Sébastien Cahon, Jean-Charles Boisson
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath;
|
||||
unsigned int seed, maxIterations;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
maxIterations=atoi( (parser.getParamWithLongName("maxIter")->getValue()).c_str() );
|
||||
|
||||
srand(seed);
|
||||
Graph::load (instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
RouteInit initializer;
|
||||
initializer (solution);
|
||||
|
||||
RouteEval full_evaluation;
|
||||
full_evaluation (solution);
|
||||
|
||||
std :: cout << "[From] " << solution << std :: endl;
|
||||
|
||||
TwoOptInit two_opt_initializer;
|
||||
|
||||
TwoOptNext two_opt_next_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moBestImprSelect <TwoOpt> two_opt_selection;
|
||||
|
||||
moGenSolContinue <Route> continu(maxIterations);
|
||||
|
||||
moFitComparator<Route> comparator;
|
||||
|
||||
CitySwap perturbation;
|
||||
|
||||
moILS<TwoOpt> iterated_local_search (two_opt_initializer, two_opt_next_move_generator, two_opt_incremental_evaluation,
|
||||
two_opt_selection, continu, comparator, perturbation, full_evaluation) ;
|
||||
iterated_local_search(solution);
|
||||
|
||||
std :: cout << "[To] " << solution << std :: endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
manage_configuration_file(eoParser & _parser)
|
||||
{
|
||||
std::ofstream os;
|
||||
|
||||
_parser.createParam(std::string("../examples/tsp/benchs/berlin52.tsp"), "instancePath", "Path to the instance.",
|
||||
0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)time(0), "seed", "Seed for rand.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)1000, "maxIter", "Maximum number of iterations.", 0, "Configuration", false);
|
||||
|
||||
if (_parser.userNeedsHelp())
|
||||
{
|
||||
_parser.printHelp(std::cout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
os.open("current_param");
|
||||
if(!os.is_open())
|
||||
{
|
||||
throw std::runtime_error("[iterated_local_search.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
9
trunk/paradiseo-old-mo/tutorial/Lesson4/param
Normal file
9
trunk/paradiseo-old-mo/tutorial/Lesson4/param
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
|
||||
###### Configuration ######
|
||||
# --instancePath=../examples/tsp/benchs/berlin52.tsp # Path to the instance.
|
||||
# --seed=1203080388 # Seed for rand.
|
||||
# --maxIter=1000 # Maximum number of iterations.
|
||||
65
trunk/paradiseo-old-mo/tutorial/Lesson5/CMakeLists.txt
Normal file
65
trunk/paradiseo-old-mo/tutorial/Lesson5/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src/utils)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${TSP_SRC_DIR})
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${TSP_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your target(s): just an executable here
|
||||
######################################################################################
|
||||
|
||||
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
SOURCE_GROUP(src FILES variable_neighborhood_search.cpp)
|
||||
|
||||
SOURCE_GROUP(benchs FILES
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(variable_neighborhood_search
|
||||
variable_neighborhood_search.cpp
|
||||
${MO_BIN_DIR}/tutorial/Lesson5/param
|
||||
${TSP_BIN_DIR}/benchs/berlin52.tsp
|
||||
${TSP_BIN_DIR}/benchs/eil101.tsp
|
||||
${TSP_BIN_DIR}/benchs/pr2392.tsp
|
||||
${TSP_BIN_DIR}/benchs/rl5915.tsp
|
||||
${TSP_BIN_DIR}/benchs/usa13509.tsp
|
||||
)
|
||||
ELSE(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
ADD_COMMANDS_MO()
|
||||
ADD_TARGET_MO(lesson5)
|
||||
IF(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(variable_neighborhood_search variable_neighborhood_search.cpp)
|
||||
ELSE(ENABLE_CMAKE_EXAMPLE)
|
||||
ADD_EXECUTABLE(variable_neighborhood_search EXCLUDE_FROM_ALL variable_neighborhood_search.cpp)
|
||||
ENDIF(ENABLE_CMAKE_EXAMPLE)
|
||||
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
|
||||
|
||||
ADD_DEPENDENCIES(variable_neighborhood_search tsp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal: define your target(s)'s version: no effect for windows
|
||||
######################################################################################
|
||||
|
||||
SET(ITERATEDLOCALSEARCH_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(variable_neighborhood_search PROPERTIES VERSION "${ITERATEDLOCALSEARCH_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for your target(s)
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(variable_neighborhood_search tsp eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
8
trunk/paradiseo-old-mo/tutorial/Lesson5/param
Normal file
8
trunk/paradiseo-old-mo/tutorial/Lesson5/param
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
|
||||
###### Configuration ######
|
||||
# --instancePath=../examples/tsp/benchs/berlin52.tsp # Path to the instance.
|
||||
# --seed=1231949999 # Seed for rand.
|
||||
# --selectionType=Best # Type of the selection: 'Best', 'First' or 'Random'.
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
<variable_neighborhood_search.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
Salma Mesmoudi (salma.mesmoudi@inria.fr), Jean-Charles Boisson
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can use,
|
||||
modify and/ or redistribute the software under the terms of the CeCILL
|
||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
"http://www.cecill.info".
|
||||
|
||||
As a counterpart to the access to the source code and rights to copy,
|
||||
modify and redistribute granted by the license, users are provided only
|
||||
with a limited warranty and the software's author, the holder of the
|
||||
economic rights, and the successive licensors have only limited liability.
|
||||
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
requirements in conditions enabling the security of their systems and/or
|
||||
data to be ensured and, more generally, to use and operate it in the
|
||||
same conditions as regards security.
|
||||
The fact that you are presently reading this means that you have had
|
||||
knowledge of the CeCILL license and that you accept its terms.
|
||||
|
||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
#include <tsp>
|
||||
#include <vector>
|
||||
|
||||
|
||||
//template <class T, class P>void add(T& var, P& vect);
|
||||
void manage_configuration_file(eoParser & _parser);
|
||||
//void ajouter (std::vector<moMoveInit<moMove<Route> > >& V, moMove<Route>& K)const ;
|
||||
|
||||
int
|
||||
main (int _argc, char* _argv [])
|
||||
{
|
||||
std::string instancePath, selectionType;
|
||||
unsigned int seed;
|
||||
|
||||
eoParser parser(_argc, _argv);
|
||||
|
||||
manage_configuration_file(parser);
|
||||
|
||||
seed=atoi( (parser.getParamWithLongName("seed")->getValue()).c_str() );
|
||||
instancePath=parser.getParamWithLongName("instancePath")->getValue();
|
||||
selectionType=parser.getParamWithLongName("selectionType")->getValue();
|
||||
|
||||
srand (seed);
|
||||
Graph::load(instancePath.c_str());
|
||||
|
||||
Route solution;
|
||||
|
||||
RouteInit initializer;
|
||||
initializer (solution);
|
||||
|
||||
RouteEval full_evaluation;
|
||||
full_evaluation (solution);
|
||||
|
||||
std :: cout << "[From] " << solution << std :: endl;
|
||||
//A neighbor is a local search or mutation
|
||||
|
||||
/*Tools for an efficient (? :-))
|
||||
local search ! */
|
||||
//---------------------first neighbor----------------------------------
|
||||
|
||||
TwoOptInit two_opt_initializer;
|
||||
|
||||
TwoOptNext two_opt_next_move_generator;
|
||||
|
||||
TwoOptIncrEval two_opt_incremental_evaluation;
|
||||
|
||||
moMoveSelect<TwoOpt>* two_opt_selection;
|
||||
|
||||
if(selectionType.compare("Best")==0)
|
||||
{
|
||||
two_opt_selection= new moBestImprSelect<TwoOpt>();
|
||||
}
|
||||
else if (selectionType.compare("First")==0)
|
||||
{
|
||||
two_opt_selection= new moFirstImprSelect<TwoOpt>();
|
||||
}
|
||||
else if (selectionType.compare("Random")==0)
|
||||
{
|
||||
two_opt_selection= new moRandImprSelect<TwoOpt>();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("[hill_climbing.cpp]: the type of selection '"+selectionType+"' is not correct.");
|
||||
}
|
||||
|
||||
|
||||
moHC <TwoOpt> hill_climbing (two_opt_initializer, two_opt_next_move_generator, two_opt_incremental_evaluation,
|
||||
*two_opt_selection, full_evaluation);
|
||||
|
||||
|
||||
//--------------------second neighbor-----------------
|
||||
|
||||
CitySwap perturbation;
|
||||
|
||||
//-----------neighbor vector--------------------------
|
||||
|
||||
moExpl<Route> explorer(perturbation);
|
||||
explorer.addExplorer(hill_climbing);
|
||||
explorer.addExplorer(perturbation);
|
||||
|
||||
//------------VNS application--------------------------
|
||||
|
||||
moVNS<Route> vns(explorer, full_evaluation);
|
||||
vns(solution);
|
||||
//hill_climbing(solution);
|
||||
std :: cout << "[To] " << solution << std :: endl;
|
||||
|
||||
delete(two_opt_selection);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
manage_configuration_file(eoParser & _parser)
|
||||
{
|
||||
std::ofstream os;
|
||||
|
||||
_parser.createParam(std::string("../examples/tsp/benchs/berlin52.tsp"), "instancePath", "Path to the instance.",
|
||||
0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam((unsigned int)time(0), "seed", "Seed for rand.", 0, "Configuration", false);
|
||||
|
||||
_parser.getORcreateParam(std::string("Best"), "selectionType", "Type of the selection: 'Best', 'First' or 'Random'.",
|
||||
0, "Configuration", false);
|
||||
|
||||
if (_parser.userNeedsHelp())
|
||||
{
|
||||
_parser.printHelp(std::cout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
os.open("current_param");
|
||||
if(!os.is_open())
|
||||
{
|
||||
throw std::runtime_error("[hill_climbing.cpp]: the file current_param cannot be created.");
|
||||
}
|
||||
os <<_parser;
|
||||
os.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue