paradiseo new mo added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1712 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
e2546ca8d5
commit
d7496cafff
116 changed files with 12034 additions and 0 deletions
4
trunk/paradiseo-mo/AUTHORS
Normal file
4
trunk/paradiseo-mo/AUTHORS
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Authors:
|
||||
Sebastien Verel
|
||||
Arnaud Liefooghe
|
||||
Jérémie Humeau
|
||||
41
trunk/paradiseo-mo/CMakeLists.txt
Normal file
41
trunk/paradiseo-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.3" CACHE STRING "MO Package string full name" FORCE)
|
||||
SET(PACKAGE_VERSION "1.3" CACHE STRING "Package version" FORCE)
|
||||
SET(GLOBAL_VERSION "1.3" CACHE STRING "Global version" FORCE)
|
||||
SET(VERSION "1.3.0" 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-mo/CTestConfig.cmake
Normal file
7
trunk/paradiseo-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)
|
||||
26
trunk/paradiseo-mo/doc/CMakeLists.txt
Executable file
26
trunk/paradiseo-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)
|
||||
|
||||
##########################################################################################
|
||||
1523
trunk/paradiseo-mo/doc/mo.doxyfile.cmake
Normal file
1523
trunk/paradiseo-mo/doc/mo.doxyfile.cmake
Normal file
File diff suppressed because it is too large
Load diff
22
trunk/paradiseo-mo/install.cmake
Normal file
22
trunk/paradiseo-mo/install.cmake
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#########################################################################################################
|
||||
# 1) ParadisEO install: SIMPLE Configuration
|
||||
#########################################################################################################
|
||||
|
||||
|
||||
# Here, just specify PARADISEO_DIR : the directory where ParadisEO has been installed
|
||||
SET(PARADISEO_DIR "${paradis}" CACHE PATH "ParadisEO directory" FORCE)
|
||||
|
||||
#########################################################################################################
|
||||
|
||||
|
||||
#########################################################################################################
|
||||
# 2) ParadisEO install: ADVANCED Configuration
|
||||
#########################################################################################################
|
||||
|
||||
SET(PARADISEO_EO_SRC_DIR "${PARADISEO_DIR}/paradiseo-eo" CACHE PATH "ParadisEO-EO source directory" FORCE)
|
||||
SET(PARADISEO_EO_BIN_DIR "${PARADISEO_DIR}/paradiseo-eo/build" CACHE PATH "ParadisEO-EO binary directory" FORCE)
|
||||
|
||||
SET(NEWMO_SRC_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "ParadisEO-EO source directory" FORCE)
|
||||
SET(NEWMO_BIN_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "ParadisEO-EO binary directory" FORCE)
|
||||
|
||||
|
||||
3
trunk/paradiseo-mo/src/CMakeLists.txt
Normal file
3
trunk/paradiseo-mo/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
###############################################################
|
||||
# This is a dummy file
|
||||
###############################################################
|
||||
112
trunk/paradiseo-mo/src/algo/moLocalSearch.h
Normal file
112
trunk/paradiseo-mo/src/algo/moLocalSearch.h
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
<moLocalSearch.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moLocalSearch_h
|
||||
#define _moLocalSearch_h
|
||||
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
/**
|
||||
* the main algorithm of the local search
|
||||
*/
|
||||
template<class NHE>
|
||||
class moLocalSearch: public eoMonOp<typename NHE::EOT>
|
||||
{
|
||||
public:
|
||||
typedef NHE NeighborhoodExplorer ;
|
||||
typedef typename NeighborhoodExplorer::EOT EOT ;
|
||||
typedef typename NeighborhoodExplorer::Neighborhood Neighborhood ;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor of a moLocalSearch needs a NeighborhooExplorer and a Continuator
|
||||
*/
|
||||
moLocalSearch(NeighborhoodExplorer& _searchExpl, moContinuator<Neighborhood> & _continuator, eoEvalFunc<EOT>& _fullEval) : searchExplorer(_searchExpl), continuator(_continuator), fullEval(_fullEval) { } ;
|
||||
|
||||
/**
|
||||
* Run the local search on a solution
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
virtual bool operator() (EOT & _solution) {
|
||||
|
||||
if(_solution.invalid())
|
||||
fullEval(_solution);
|
||||
|
||||
// initialization of the parameter of the search (for example fill empty the tabu list)
|
||||
searchExplorer.initParam(_solution);
|
||||
|
||||
// initialization of the external continuator (for example the time, or the number of generations)
|
||||
continuator.init(_solution);
|
||||
|
||||
bool b=continuator(_solution);
|
||||
|
||||
do {
|
||||
// explore the neighborhood of the solution
|
||||
searchExplorer(_solution);
|
||||
// if a solution in the neighborhood can be accepted
|
||||
if (searchExplorer.accept(_solution)){
|
||||
searchExplorer.move(_solution);
|
||||
searchExplorer.moveApplied(true);
|
||||
}
|
||||
else
|
||||
searchExplorer.moveApplied(false);
|
||||
|
||||
// update the parameter of the search (for ex. Temperature of the SA)
|
||||
searchExplorer.updateParam(_solution);
|
||||
|
||||
b=continuator(_solution);
|
||||
} while (b && searchExplorer.isContinue(_solution));
|
||||
|
||||
searchExplorer.terminate(_solution);
|
||||
|
||||
continuator.lastCall(_solution);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
private:
|
||||
// make the exploration of the neighborhood according to a local search heuristic
|
||||
NeighborhoodExplorer& searchExplorer ;
|
||||
|
||||
// external continuator
|
||||
moContinuator<Neighborhood>& continuator ;
|
||||
|
||||
//full evaluation function
|
||||
eoEvalFunc<EOT>& fullEval;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
73
trunk/paradiseo-mo/src/comparator/moComparator.h
Normal file
73
trunk/paradiseo-mo/src/comparator/moComparator.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
<moComparator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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
|
||||
|
||||
#include <EO.h>
|
||||
#include <eoFunctor.h>
|
||||
|
||||
// moComparator => comparer deux solutions
|
||||
// idée :
|
||||
// - eoComparator
|
||||
// - moComparator qui hérite de eoComparator ?
|
||||
// - moeoComparator qui hérite de eoComparator
|
||||
// idée J :
|
||||
// - eoComparator<TYPE> : eoBF <const TYPE & , const TYPE & , bool>
|
||||
// - eoSolComparator : eoComparator<EOT> ?
|
||||
// - moNeighborCompartor : : eoComparator<Neighbor>
|
||||
//
|
||||
// une instantiation possible !!
|
||||
|
||||
|
||||
/**
|
||||
* Comparator of two types
|
||||
*/
|
||||
template< class T1, class T2 >
|
||||
class moComparator : public eoBF<const T1 & , const T2 & , bool>
|
||||
{
|
||||
public:
|
||||
virtual bool equals(const T1&, const T2&) = 0;
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moComparator";
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
83
trunk/paradiseo-mo/src/comparator/moNeighborComparator.h
Normal file
83
trunk/paradiseo-mo/src/comparator/moNeighborComparator.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
<moNeighborComparator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moNeighborComparator_h
|
||||
#define _moNeighborComparator_h
|
||||
|
||||
#include <EO.h>
|
||||
#include <eoFunctor.h>
|
||||
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
#include <comparator/moComparator.h>
|
||||
|
||||
|
||||
/**
|
||||
* Comparator of two neighbors
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moNeighborComparator : public moComparator<Neighbor, Neighbor>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Compare two neighbors
|
||||
* @param _neighbor1 the first neighbor
|
||||
* @param _neighbor2 the second neighbor
|
||||
* @return true if the neighbor2 is better than neighbor1
|
||||
*/
|
||||
virtual bool operator()(const Neighbor& _neighbor1, const Neighbor& _neighbor2) {
|
||||
return (_neighbor1.fitness() < _neighbor2.fitness());
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two neighbors
|
||||
* @param _neighbor1 the first neighbor
|
||||
* @param _neighbor2 the second neighbor
|
||||
* @return true if the neighbor2 is equal to neighbor1
|
||||
*/
|
||||
virtual bool equals(const Neighbor& _neighbor1, const Neighbor& _neighbor2) {
|
||||
return (_neighbor1.fitness() == _neighbor2.fitness());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moNeighborComparator";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
84
trunk/paradiseo-mo/src/comparator/moSolNeighborComparator.h
Normal file
84
trunk/paradiseo-mo/src/comparator/moSolNeighborComparator.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
<moSolNeighborComparator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moSolNeighborComparator_h
|
||||
#define _moSolNeighborComparator_h
|
||||
|
||||
#include <EO.h>
|
||||
#include <eoFunctor.h>
|
||||
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
#include <comparator/moComparator.h>
|
||||
|
||||
|
||||
/**
|
||||
* Comparator of two neighbors
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moSolNeighborComparator : public moComparator<typename Neighbor::EOT, Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Compare two neighbors
|
||||
* @param _sol the solution
|
||||
* @param _neighbor the neighbor
|
||||
* @return true if the neighbor is better than sol
|
||||
*/
|
||||
virtual bool operator()(const EOT& _sol, const Neighbor& _neighbor) {
|
||||
return (_sol.fitness() < _neighbor.fitness());
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two neighbors
|
||||
* @param _sol the solution
|
||||
* @param _neighbor the neighbor
|
||||
* @return true if the neighbor is equal to the solution
|
||||
*/
|
||||
virtual bool equals(const EOT& _sol, const Neighbor& _neighbor) {
|
||||
return (_sol.fitness() == _neighbor.fitness());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moSolNeighborComparator";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
170
trunk/paradiseo-mo/src/continuator/moCheckpoint.h
Normal file
170
trunk/paradiseo-mo/src/continuator/moCheckpoint.h
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
<moCheckpoint.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moCheckpoint_h
|
||||
#define moCheckpoint_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <utils/eoMonitor.h>
|
||||
#include <continuator/moStatBase.h>
|
||||
#include <utils/eoUpdater.h>
|
||||
|
||||
/**
|
||||
* Continuator allowing to add others (continuators, stats, monitors or updaters)
|
||||
*/
|
||||
template <class NH>
|
||||
class moCheckpoint : public moContinuator<NH> {
|
||||
public :
|
||||
|
||||
typedef NH Neighborhood ;
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Default constructor (moCheckpoint must have at least one continuator)
|
||||
* @param _cont a continuator
|
||||
* @param _interval frequency to compute statistical operators
|
||||
*/
|
||||
moCheckpoint(moContinuator<Neighborhood>& _cont, unsigned int _interval=1):interval(_interval), counter(0){
|
||||
continuators.push_back(&_cont);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a continuator to the checkpoint
|
||||
* @param _cont a continuator
|
||||
*/
|
||||
void add(moContinuator<Neighborhood>& _cont) {
|
||||
continuators.push_back(&_cont);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a statistic operator to the checkpoint
|
||||
* @param _stat a statistic operator
|
||||
*/
|
||||
void add(moStatBase<EOT>& _stat) {
|
||||
stats.push_back(&_stat);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a monitor to the checkpoint
|
||||
* @param _mon a monitor
|
||||
*/
|
||||
void add(eoMonitor& _mon) {
|
||||
monitors.push_back(&_mon);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a updater to the checkpoint
|
||||
* @param _upd an updater
|
||||
*/
|
||||
void add(eoUpdater& _upd) {
|
||||
updaters.push_back(&_upd);
|
||||
}
|
||||
|
||||
/**
|
||||
* init all continuators containing in the checkpoint regarding a solution
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void init(EOT& _sol) {
|
||||
for(unsigned i = 0; i < continuators.size(); ++i)
|
||||
continuators[i]->init(_sol);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class name
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moCheckpoint";
|
||||
}
|
||||
|
||||
/**
|
||||
* apply operator of checkpoint's containers
|
||||
* @param _sol reference of the solution
|
||||
* @return true if all continuator return true
|
||||
*/
|
||||
bool operator()(EOT & _sol) {
|
||||
unsigned i;
|
||||
bool bContinue = true;
|
||||
|
||||
for (i = 0; i < stats.size(); ++i){
|
||||
if(counter % interval == 0)
|
||||
(*stats[i])(_sol);
|
||||
counter++;
|
||||
}
|
||||
|
||||
for (i = 0; i < updaters.size(); ++i)
|
||||
(*updaters[i])();
|
||||
|
||||
for (i = 0; i < monitors.size(); ++i)
|
||||
(*monitors[i])();
|
||||
|
||||
for (i = 0; i < continuators.size(); ++i)
|
||||
if ( !(*continuators[i])(_sol) )
|
||||
bContinue = false;
|
||||
|
||||
return bContinue;
|
||||
}
|
||||
|
||||
/**
|
||||
* last call of statistic operators, monitors and updaters
|
||||
* @param _sol reference of the solution
|
||||
*/
|
||||
void lastCall(EOT& _sol){
|
||||
unsigned int i;
|
||||
for (i = 0; i < stats.size(); ++i)
|
||||
stats[i]->lastCall(_sol);
|
||||
|
||||
for (i = 0; i < updaters.size(); ++i)
|
||||
updaters[i]->lastCall();
|
||||
|
||||
for (i = 0; i < monitors.size(); ++i)
|
||||
monitors[i]->lastCall();
|
||||
}
|
||||
|
||||
private :
|
||||
/** continuators vector */
|
||||
std::vector<moContinuator<Neighborhood>*> continuators;
|
||||
/** statistic operators vector */
|
||||
std::vector<moStatBase<EOT>*> stats;
|
||||
/** monitors vector */
|
||||
std::vector<eoMonitor*> monitors;
|
||||
/** updaters vector */
|
||||
std::vector<eoUpdater*> updaters;
|
||||
|
||||
unsigned int interval;
|
||||
unsigned int counter;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
63
trunk/paradiseo-mo/src/continuator/moContinuator.h
Normal file
63
trunk/paradiseo-mo/src/continuator/moContinuator.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
<moContinuator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moContinuator_h
|
||||
#define _moContinuator_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
/**
|
||||
* To make specific continuator from a solution
|
||||
*/
|
||||
template< class NH >
|
||||
class moContinuator : public eoUF<typename NH::EOT &, bool>
|
||||
{
|
||||
public:
|
||||
typedef NH Neighborhood ;
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Init Continuator parameters
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
virtual void init(EOT& _solution){};
|
||||
|
||||
/**
|
||||
* Last Call to terminate the checkpoint
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
virtual void lastCall(EOT& _solution){};
|
||||
};
|
||||
|
||||
#endif
|
||||
97
trunk/paradiseo-mo/src/continuator/moCounterMonitorSaver.h
Normal file
97
trunk/paradiseo-mo/src/continuator/moCounterMonitorSaver.h
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
<moCounterMonitorSaver.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moCounterMonitorSaver_h
|
||||
#define moCounterMonitorSaver_h
|
||||
|
||||
#include <utils/eoUpdater.h>
|
||||
#include <utils/eoMonitor.h>
|
||||
|
||||
/**
|
||||
* The actual class that will be used as base for all statistics
|
||||
* that need to be calculated over the solution
|
||||
* It is a moStatBase AND an eoValueParam so it can be used in Monitors.
|
||||
*/
|
||||
class moCounterMonitorSaver : public eoUpdater {
|
||||
public :
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _interval frequency to call monitors
|
||||
* @param _mon a monitor
|
||||
*/
|
||||
moCounterMonitorSaver(unsigned _interval, eoMonitor& _mon) : interval(_interval), counter(0) {
|
||||
monitors.push_back(&_mon);
|
||||
}
|
||||
|
||||
/**
|
||||
* call monitors if interval is reach by a counter
|
||||
*/
|
||||
void operator()(void) {
|
||||
if (counter++ % interval == 0)
|
||||
for (unsigned i = 0; i < monitors.size(); i++)
|
||||
(*monitors[i])();
|
||||
}
|
||||
|
||||
/**
|
||||
* last call of monitors
|
||||
*/
|
||||
void lastCall(void) {
|
||||
for (unsigned i = 0; i < monitors.size(); i++)
|
||||
monitors[i]->lastCall();
|
||||
}
|
||||
|
||||
/**
|
||||
* attach another monitor to this class
|
||||
* @param _mon the monitor to attach
|
||||
*/
|
||||
void add(eoMonitor& _mon) {
|
||||
monitors.push_back(&_mon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const { return "moCounterMonitorSaver"; }
|
||||
|
||||
private :
|
||||
/** interval and counter value */
|
||||
unsigned int interval, counter;
|
||||
|
||||
/** monitor's vector */
|
||||
std::vector<eoMonitor*> monitors;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
83
trunk/paradiseo-mo/src/continuator/moDistanceStat.h
Normal file
83
trunk/paradiseo-mo/src/continuator/moDistanceStat.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
<moDistanceStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moDistanceStat_h
|
||||
#define moDistanceStat_h
|
||||
|
||||
#include <utils/eoDistance.h>
|
||||
#include <continuator/moStat.h>
|
||||
|
||||
/**
|
||||
* The statistic gives the distance to a reference solution
|
||||
* The reference solution could be the global optimum, or the best knowed solution
|
||||
* It allows to compute the Fitness-Distance correlation (FDC)
|
||||
*/
|
||||
template <class EOT, class T = double>
|
||||
class moDistanceStat : public moStat<EOT, T>
|
||||
{
|
||||
public :
|
||||
using moStat< EOT, T >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _dist a distance
|
||||
* @param _ref the reference solution
|
||||
*/
|
||||
moDistanceStat(eoDistance<EOT> & _dist, EOT & _ref): moStat<EOT, T>(0, "distance"), dist(_dist), refSolution(_ref){}
|
||||
|
||||
/**
|
||||
* Compute distance between a solution and the reference solution
|
||||
* @param _sol a solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol){
|
||||
value() = dist(_sol, refSolution);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const { return "moDistanceStat"; }
|
||||
|
||||
private:
|
||||
/** the distance */
|
||||
eoDistance<EOT> & dist;
|
||||
/**
|
||||
* the reference solution does not change during the run
|
||||
* it could be the best solution knowed of the problem
|
||||
*/
|
||||
EOT refSolution;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
74
trunk/paradiseo-mo/src/continuator/moFitnessStat.h
Normal file
74
trunk/paradiseo-mo/src/continuator/moFitnessStat.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
<moFitnessStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moFitnessStat_h
|
||||
#define moFitnessStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
|
||||
/**
|
||||
* The actual class that will be used as base for all statistics
|
||||
* that need to be calculated over the solution
|
||||
* It is a moStatBase AND an eoValueParam so it can be used in Monitors.
|
||||
*/
|
||||
template <class EOT, class T=typename EOT::Fitness>
|
||||
class moFitnessStat : public moStat<EOT, T>
|
||||
{
|
||||
public :
|
||||
typedef T Fitness;
|
||||
using moStat< EOT, Fitness >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _description a description of the stat
|
||||
*/
|
||||
moFitnessStat(std::string _description = "fitness"):
|
||||
moStat<EOT, Fitness>(Fitness(), _description){}
|
||||
|
||||
/**
|
||||
* store fitness value
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol)
|
||||
{
|
||||
value() = _sol.fitness();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the class
|
||||
*/
|
||||
virtual std::string className(void) const { return "moFitnessStat"; }
|
||||
};
|
||||
|
||||
#endif
|
||||
78
trunk/paradiseo-mo/src/continuator/moMaxNeighborStat.h
Normal file
78
trunk/paradiseo-mo/src/continuator/moMaxNeighborStat.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
<moMaxNeighborStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moMaxNeighborStat_h
|
||||
#define moMaxNeighborStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
|
||||
/**
|
||||
* From moNeighborhoodStat, to compute the max fitness in the neighborhood
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moMaxNeighborStat : public moStat<typename Neighborhood::EOT, typename Neighborhood::EOT::Fitness>
|
||||
{
|
||||
public :
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, Fitness >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moMaxNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
|
||||
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat){}
|
||||
|
||||
/**
|
||||
* Set the max fitness in the neighborhood
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol){
|
||||
value() = nhStat.getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the class name
|
||||
*/
|
||||
virtual std::string className(void) const { return "moMaxNeighborStat"; }
|
||||
|
||||
private:
|
||||
/** moNeighborhoodStat */
|
||||
moNeighborhoodStat<Neighborhood> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
78
trunk/paradiseo-mo/src/continuator/moMinNeighborStat.h
Normal file
78
trunk/paradiseo-mo/src/continuator/moMinNeighborStat.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
<moMinNeighborStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moMinNeighborStat_h
|
||||
#define moMinNeighborStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
|
||||
/**
|
||||
* From moNeighborhoodStat, to compute the min fitness in the neighborhood
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moMinNeighborStat : public moStat<typename Neighborhood::EOT, typename Neighborhood::EOT::Fitness>
|
||||
{
|
||||
public :
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, Fitness >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moMinNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
|
||||
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat){}
|
||||
|
||||
/**
|
||||
* Set the worst fitness in the neighborhood
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol){
|
||||
value() = nhStat.getMin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the class name
|
||||
*/
|
||||
virtual std::string className(void) const { return "moMinNeighborStat"; }
|
||||
|
||||
private:
|
||||
/** moNeighborhoodStat */
|
||||
moNeighborhoodStat<Neighborhood> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
81
trunk/paradiseo-mo/src/continuator/moNbInfNeighborStat.h
Normal file
81
trunk/paradiseo-mo/src/continuator/moNbInfNeighborStat.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
<moNbInfNeighborStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moNbInfNeighborStat_h
|
||||
#define moNbInfNeighborStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
|
||||
/**
|
||||
*
|
||||
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
|
||||
* with (strictly) lower fitness than the current solution
|
||||
*
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moNbInfNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
|
||||
{
|
||||
public :
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, unsigned >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moNbInfNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
|
||||
moStat<EOT, unsigned>(0, "nb inf"), nhStat(_nhStat){}
|
||||
|
||||
/**
|
||||
* Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol){
|
||||
value() = nhStat.getNbInf();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the class name
|
||||
*/
|
||||
virtual std::string className(void) const { return "moNbInfNeighborStat"; }
|
||||
|
||||
private:
|
||||
/** moNeighborhoodStat */
|
||||
moNeighborhoodStat<Neighborhood> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
81
trunk/paradiseo-mo/src/continuator/moNbSupNeighborStat.h
Normal file
81
trunk/paradiseo-mo/src/continuator/moNbSupNeighborStat.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
<moNbSupNeighborStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moNbSupNeighborStat_h
|
||||
#define moNbSupNeighborStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
|
||||
/**
|
||||
*
|
||||
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
|
||||
* with higher fitness than the current solution
|
||||
*
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moNbSupNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
|
||||
{
|
||||
public :
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, unsigned >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moNbSupNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
|
||||
moStat<EOT, unsigned>(0, "nb sup"), nhStat(_nhStat){}
|
||||
|
||||
/**
|
||||
* Set the number of solutions in the neighborhood with better fitness than the current solution
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol){
|
||||
value() = nhStat.getNbSup();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the class name
|
||||
*/
|
||||
virtual std::string className(void) const { return "moNbSupNeighborStat"; }
|
||||
|
||||
private:
|
||||
/** moNeighborhoodStat */
|
||||
moNeighborhoodStat<Neighborhood> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
235
trunk/paradiseo-mo/src/continuator/moNeighborhoodStat.h
Normal file
235
trunk/paradiseo-mo/src/continuator/moNeighborhoodStat.h
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
<moNeighborhoodStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moNeighborhoodStat_h
|
||||
#define moNeighborhoodStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
/**
|
||||
* All possible statitic on the neighborhood fitness
|
||||
* to combine with other specific statistic to print them
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moNeighborhoodStat : public moStat<typename Neighborhood::EOT, bool>
|
||||
{
|
||||
public :
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, bool >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _neighborhood a neighborhood
|
||||
* @param _eval an evaluation function
|
||||
* @param _neighborComparator a neighbor Comparator
|
||||
* @param _solNeighborComparator a comparator between a solution and a neighbor
|
||||
*/
|
||||
moNeighborhoodStat(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator):
|
||||
moStat<EOT, bool>(true, "neighborhood"),
|
||||
neighborhood(_neighborhood), eval(_eval),
|
||||
neighborComparator(_neighborComparator),
|
||||
solNeighborComparator(_solNeighborComparator)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Compute classical statistics of a solution's neighborhood
|
||||
* @param _solution the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _solution){
|
||||
Neighbor current ;
|
||||
Neighbor best ;
|
||||
Neighbor lowest ;
|
||||
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
//init the first neighbor
|
||||
neighborhood.init(_solution, current);
|
||||
|
||||
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
||||
eval(_solution, current);
|
||||
|
||||
// init the statistics
|
||||
value() = true;
|
||||
|
||||
mean = current.fitness();
|
||||
sd = mean * mean;
|
||||
nb = 1;
|
||||
nbInf = 0;
|
||||
nbEqual = 0;
|
||||
nbSup = 0;
|
||||
|
||||
if (solNeighborComparator.equals(_solution, current))
|
||||
nbEqual++;
|
||||
else if (solNeighborComparator(_solution, current))
|
||||
nbSup++;
|
||||
else
|
||||
nbInf++;
|
||||
|
||||
//initialize the best neighbor
|
||||
best = current;
|
||||
lowest = current;
|
||||
|
||||
//test all others neighbors
|
||||
while (neighborhood.cont(_solution)) {
|
||||
//next neighbor
|
||||
neighborhood.next(_solution, current);
|
||||
//eval
|
||||
eval(_solution, current);
|
||||
|
||||
mean += current.fitness();
|
||||
sd += current.fitness() * current.fitness();
|
||||
nb++;
|
||||
|
||||
if (solNeighborComparator.equals(_solution, current))
|
||||
nbEqual++;
|
||||
else if (solNeighborComparator(_solution, current))
|
||||
nbSup++;
|
||||
else
|
||||
nbInf++;
|
||||
|
||||
//if we found a better neighbor, update the best
|
||||
if (neighborComparator(best, current))
|
||||
best = current;
|
||||
|
||||
if (neighborComparator(current, lowest))
|
||||
lowest = current;
|
||||
}
|
||||
|
||||
max = best.fitness();
|
||||
min = lowest.fitness();
|
||||
|
||||
mean /= nb;
|
||||
if (nb > 1)
|
||||
sd = sqrt( (sd - nb * mean * mean) / (nb - 1.0) );
|
||||
else
|
||||
sd = 0.0;
|
||||
}
|
||||
else{
|
||||
//if _solution hasn't neighbor,
|
||||
value() = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the worst fitness value found in the neighborhood
|
||||
*/
|
||||
Fitness getMin(){
|
||||
return min;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the best fitness value found in the neighborhood
|
||||
*/
|
||||
Fitness getMax(){
|
||||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mean fitness value of the neighborhood
|
||||
*/
|
||||
double getMean(){
|
||||
return mean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the standard deviation value of the neighborhood
|
||||
*/
|
||||
double getSD(){
|
||||
return sd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the size of the neighborhood
|
||||
*/
|
||||
unsigned getSize(){
|
||||
return nb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of neighbors having a better fitness than the current solution
|
||||
*/
|
||||
unsigned getNbSup(){
|
||||
return nbSup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of neighbors having the same fitness than the current solution
|
||||
*/
|
||||
unsigned getNbEqual(){
|
||||
return nbEqual;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of neighbors having a worst fitness than the current solution
|
||||
*/
|
||||
unsigned getNbInf() {
|
||||
return nbInf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the class name
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moNeighborhoodStat";
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// to explore the neighborhood
|
||||
Neighborhood& neighborhood ;
|
||||
moEval<Neighbor>& eval;
|
||||
|
||||
// comparator betwenn solution and neighbor or between neighbors
|
||||
moNeighborComparator<Neighbor>& neighborComparator;
|
||||
moSolNeighborComparator<Neighbor>& solNeighborComparator;
|
||||
|
||||
// the stastics of the fitness
|
||||
Fitness max, min;
|
||||
//mean and standard deviation
|
||||
double mean, sd ;
|
||||
|
||||
// number of neighbors in the neighborhood;
|
||||
unsigned int nb;
|
||||
|
||||
// number of neighbors with lower, equal and higher fitness
|
||||
unsigned int nbInf, nbEqual, nbSup ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
<moNeutralDegreeNeighborStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moNeutralDegreeNeighborStat_h
|
||||
#define moNeutralDegreeNeighborStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
|
||||
/**
|
||||
* From moNeighborhoodStat, to compute the neutral degree of the solution
|
||||
* which is the number of solutions in the neighborhood
|
||||
* with equals fitness
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moNeutralDegreeNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
|
||||
{
|
||||
public :
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, unsigned >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moNeutralDegreeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
|
||||
moStat<EOT, unsigned>(0, "neutral degree"), nhStat(_nhStat){}
|
||||
|
||||
/**
|
||||
* Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol){
|
||||
value() = nhStat.getNbEqual();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the class name
|
||||
*/
|
||||
virtual std::string className(void) const { return "moNeutralDegreeNeighborStat"; }
|
||||
|
||||
private:
|
||||
/** moNeighborhoodStat */
|
||||
moNeighborhoodStat<Neighborhood> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
<moSecondMomentNeighborStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moSecondMomentNeighborStat_h
|
||||
#define moSecondMomentNeighborStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
|
||||
/**
|
||||
* From moNeighborhoodStat, to compute the average and the standard deviation of fitness in the neighborhood
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moSecondMomentNeighborStat : public moStat<typename Neighborhood::EOT, std::pair<double, double> >
|
||||
{
|
||||
public :
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, std::pair<double, double> >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moSecondMomentNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
|
||||
moStat<EOT, std::pair<double, double> >(std::make_pair(0.0,0.0), "average and stdev"), nhStat(_nhStat){}
|
||||
|
||||
/**
|
||||
* Set the average and the standard deviation of fitness in the neighborhood
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol){
|
||||
value().first = nhStat.getMean();
|
||||
value().second = nhStat.getSD();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the class name
|
||||
*/
|
||||
virtual std::string className(void) const { return "moSecondMomentNeighborStat"; }
|
||||
|
||||
private:
|
||||
/** moNeighborhoodStat */
|
||||
moNeighborhoodStat<Neighborhood> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
79
trunk/paradiseo-mo/src/continuator/moSizeNeighborStat.h
Normal file
79
trunk/paradiseo-mo/src/continuator/moSizeNeighborStat.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
<moSizeNeighborStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moSizeNeighborStat_h
|
||||
#define moSizeNeighborStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
|
||||
/**
|
||||
* From moNeighborhoodStat, to compute the number of solutions in the neighborhood
|
||||
*
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moSizeNeighborStat : public moStat<typename Neighborhood::EOT, unsigned>
|
||||
{
|
||||
public :
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename EOT::Fitness Fitness ;
|
||||
|
||||
using moStat< EOT, unsigned >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _nhStat a neighborhoodStat
|
||||
*/
|
||||
moSizeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
|
||||
moStat<EOT, unsigned>(0, "size"), nhStat(_nhStat){}
|
||||
|
||||
/**
|
||||
* Set the number of solutions in the neighborhood
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol){
|
||||
value() = nhStat.getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the class name
|
||||
*/
|
||||
virtual std::string className(void) const { return "moSizeNeighborStat"; }
|
||||
|
||||
private:
|
||||
/** moNeighborhoodStat */
|
||||
moNeighborhoodStat<Neighborhood> & nhStat;
|
||||
};
|
||||
|
||||
#endif
|
||||
74
trunk/paradiseo-mo/src/continuator/moSolutionStat.h
Normal file
74
trunk/paradiseo-mo/src/continuator/moSolutionStat.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
<moSolutionStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moSolutionStat_h
|
||||
#define moSolutionStat_h
|
||||
|
||||
#include <continuator/moStat.h>
|
||||
|
||||
/**
|
||||
* The statistic which only give the current solution
|
||||
* be careful, the solution is given by copy
|
||||
*
|
||||
*/
|
||||
template <class EOT>
|
||||
class moSolutionStat : public moStat<EOT, EOT>
|
||||
{
|
||||
public :
|
||||
using moStat< EOT, EOT >::value;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _description a description of the parameter
|
||||
*/
|
||||
moSolutionStat(std::string _description = "solution"):
|
||||
moStat<EOT, EOT>(EOT(), _description){}
|
||||
|
||||
/**
|
||||
* Set the solution by copy
|
||||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol){
|
||||
value() = _sol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const{
|
||||
return "moSolutionStat";
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
67
trunk/paradiseo-mo/src/continuator/moStat.h
Normal file
67
trunk/paradiseo-mo/src/continuator/moStat.h
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
<moStat.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moStat_h
|
||||
#define moStat_h
|
||||
|
||||
#include <continuator/moStatBase.h>
|
||||
|
||||
/**
|
||||
* The actual class that will be used as base for all statistics
|
||||
* that need to be calculated over the solution
|
||||
* It is a moStatBase AND an eoValueParam so it can be used in Monitors.
|
||||
*/
|
||||
template <class EOT, class T>
|
||||
class moStat : public eoValueParam<T>, public moStatBase<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _value a default parameter's value
|
||||
* @param _description a description of the parameter
|
||||
*/
|
||||
moStat(T _value, std::string _description):
|
||||
eoValueParam<T>(_value, _description){}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const{
|
||||
return "moStat";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
65
trunk/paradiseo-mo/src/continuator/moStatBase.h
Normal file
65
trunk/paradiseo-mo/src/continuator/moStatBase.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
<moStatBase.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moStatBase_h
|
||||
#define moStatBase_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
#include <utils/eoParam.h>
|
||||
|
||||
/**
|
||||
* Base class for all statistics that need to be calculated
|
||||
* over the solution
|
||||
* (I guess it is not really necessary? MS.
|
||||
* Depstd::ends, there might be reasons to have a stat that is not an eoValueParam,
|
||||
* but maybe I'm just kidding myself, MK)
|
||||
*/
|
||||
template <class EOT>
|
||||
class moStatBase : public eoUF<EOT &, void>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* last call of a statistical operator
|
||||
*/
|
||||
virtual void lastCall(EOT &) {}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const{
|
||||
return "moStatBase";
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
68
trunk/paradiseo-mo/src/continuator/moTrueContinuator.h
Normal file
68
trunk/paradiseo-mo/src/continuator/moTrueContinuator.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
<moTrueContinuator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moTrueContinuator_h
|
||||
#define _moTrueContinuator_h
|
||||
|
||||
#include <continuator/moContinuator.h>
|
||||
|
||||
/**
|
||||
* Continuator always return True
|
||||
*/
|
||||
template< class NH >
|
||||
class moTrueContinuator : public moContinuator<NH>
|
||||
{
|
||||
public:
|
||||
typedef typename NH::EOT EOT ;
|
||||
|
||||
// empty constructor
|
||||
moTrueContinuator() {} ;
|
||||
|
||||
/**
|
||||
*@param _solution a solution
|
||||
*@return always true
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTHING TO DO
|
||||
* @param _solution a solution
|
||||
*/
|
||||
virtual void init(EOT & _solution) {}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
51
trunk/paradiseo-mo/src/eval/moEval.h
Normal file
51
trunk/paradiseo-mo/src/eval/moEval.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
<moEval.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moEval_H
|
||||
#define moEval_H
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
/**
|
||||
* Abstract class for the evaluation
|
||||
*/
|
||||
template<class Neighbor>
|
||||
class moEval : public eoBF<typename Neighbor::EOT &, Neighbor&, void>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
};
|
||||
|
||||
#endif
|
||||
82
trunk/paradiseo-mo/src/eval/moFullEvalByCopy.h
Normal file
82
trunk/paradiseo-mo/src/eval/moFullEvalByCopy.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
<moFullEvalByCopy.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moFullEvalByCopy_H
|
||||
#define moFullEvalByCopy_H
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
#include <eval/moEval.h>
|
||||
|
||||
/**
|
||||
* Evaluation by copy
|
||||
*/
|
||||
template<class Neighbor>
|
||||
class moFullEvalByCopy : public moEval<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename moEval<Neighbor>::EOT EOT;
|
||||
typedef typename moEval<Neighbor>::Fitness Fitness;
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
* @param _eval the full evaluation object
|
||||
*/
|
||||
moFullEvalByCopy(eoEvalFunc<EOT> & _eval) : eval(_eval) {}
|
||||
|
||||
/**
|
||||
* Full evaluation of the neighbor by copy
|
||||
* @param _sol current solution
|
||||
* @param _neighbor the neighbor to be evaluated
|
||||
*/
|
||||
void operator()(EOT & _sol, Neighbor & _neighbor)
|
||||
{
|
||||
// tmp solution
|
||||
EOT tmp(_sol);
|
||||
// move tmp solution wrt _neighbor
|
||||
_neighbor.move(tmp);
|
||||
// eval copy
|
||||
tmp.invalidate();
|
||||
eval(tmp);
|
||||
// set the fitness value to the neighbor
|
||||
_neighbor.fitness(tmp.fitness());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** the full evaluation object */
|
||||
eoEvalFunc<EOT> & eval;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
95
trunk/paradiseo-mo/src/eval/moFullEvalByModif.h
Normal file
95
trunk/paradiseo-mo/src/eval/moFullEvalByModif.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
<moFullEvalByModif.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 moFullEvalByModif_H
|
||||
#define moFullEvalByModif_H
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
#include <eval/moEval.h>
|
||||
|
||||
/**
|
||||
* Full evaluation to use with a moBackableNeighbor
|
||||
*/
|
||||
template<class BackableNeighbor>
|
||||
class moFullEvalByModif : public moEval<BackableNeighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename moEval<BackableNeighbor>::EOT EOT;
|
||||
typedef typename moEval<BackableNeighbor>::Fitness Fitness;
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
* @param _eval the full evaluation object
|
||||
*/
|
||||
moFullEvalByModif(eoEvalFunc<EOT>& _eval) : eval(_eval) {}
|
||||
|
||||
/**
|
||||
* Full evaluation of the neighbor by copy
|
||||
* @param _sol current solution
|
||||
* @param _neighbor the neighbor to be evaluated
|
||||
*/
|
||||
void operator()(EOT & _sol, BackableNeighbor & _neighbor)
|
||||
{
|
||||
// tmp fitness value of the current solution
|
||||
Fitness tmpFit;
|
||||
|
||||
|
||||
// save current fitness value
|
||||
tmpFit = _sol.fitness();
|
||||
|
||||
// move the current solution wrt _neighbor
|
||||
_neighbor.move(_sol);
|
||||
|
||||
// eval the modified solution
|
||||
_sol.invalidate();
|
||||
eval(_sol);
|
||||
|
||||
// set the fitness value to the neighbor
|
||||
_neighbor.fitness(_sol.fitness());
|
||||
|
||||
// move the current solution back
|
||||
_neighbor.moveBack(_sol);
|
||||
|
||||
// set the fitness back
|
||||
_sol.fitness(tmpFit);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** the full evaluation object */
|
||||
eoEvalFunc<EOT> & eval;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
162
trunk/paradiseo-mo/src/explorer/moFirstImprExplorer.h
Normal file
162
trunk/paradiseo-mo/src/explorer/moFirstImprExplorer.h
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
<moFirstImprExplorer.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moFirstImprexplorer_h
|
||||
#define _moFirstImprexplorer_h
|
||||
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
/**
|
||||
* Explorer for a first imporvement heuristic
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moFirstImprExplorer : public moNeighborhoodExplorer<Neighborhood>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
|
||||
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
|
||||
using moNeighborhoodExplorer<Neighborhood>::eval;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhood the neighborhood
|
||||
* @param _eval the evaluation function
|
||||
* @param _neighborComparator a neighbor comparator
|
||||
* @param _solNeighborComparator a solution vs neighbor comparator
|
||||
*/
|
||||
moFirstImprExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) {
|
||||
isAccept = false;
|
||||
current=new Neighbor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moFirstImprExplorer(){
|
||||
delete current;
|
||||
}
|
||||
|
||||
/**
|
||||
* initParam: NOTHING TO DO
|
||||
*/
|
||||
virtual void initParam(EOT & solution){};
|
||||
|
||||
/**
|
||||
* updateParam: NOTHING TO DO
|
||||
*/
|
||||
virtual void updateParam(EOT & solution){};
|
||||
|
||||
/**
|
||||
* terminate: NOTHING TO DO
|
||||
*/
|
||||
virtual void terminate(EOT & solution){};
|
||||
|
||||
/**
|
||||
* Explore the neighborhood of a solution
|
||||
* @param _solution
|
||||
*/
|
||||
virtual void operator()(EOT & _solution){
|
||||
|
||||
//Test if _solution has a Neighbor
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
//init the first neighbor
|
||||
neighborhood.init(_solution, (*current));
|
||||
|
||||
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
||||
eval(_solution, (*current));
|
||||
|
||||
//test all others neighbors
|
||||
while (! solNeighborComparator(_solution, *current) && neighborhood.cont(_solution)) {
|
||||
//next neighbor
|
||||
neighborhood.next(_solution, (*current));
|
||||
//eval
|
||||
eval(_solution, (*current));
|
||||
}
|
||||
}
|
||||
else{
|
||||
//if _solution hasn't neighbor,
|
||||
isAccept=false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* continue if a move is accepted
|
||||
* @param _solution the solution
|
||||
* @return true if an ameliorated neighbor was be found
|
||||
*/
|
||||
virtual bool isContinue(EOT & _solution) {
|
||||
return isAccept ;
|
||||
};
|
||||
|
||||
/**
|
||||
* move the solution with the best neighbor
|
||||
* @param _solution the solution to move
|
||||
*/
|
||||
virtual void move(EOT & _solution) {
|
||||
//move the solution
|
||||
(*current).move(_solution);
|
||||
//update its fitness
|
||||
_solution.fitness((*current).fitness());
|
||||
};
|
||||
|
||||
/**
|
||||
* accept test if an amelirated neighbor was be found
|
||||
* @param _solution the solution
|
||||
* @return true if the best neighbor ameliorate the fitness
|
||||
*/
|
||||
virtual bool accept(EOT & _solution) {
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
isAccept = solNeighborComparator(_solution, (*current)) ;
|
||||
}
|
||||
return isAccept;
|
||||
};
|
||||
|
||||
private:
|
||||
// comparator betwenn solution and neighbor or between neighbors
|
||||
moNeighborComparator<Neighbor>& neighborComparator;
|
||||
moSolNeighborComparator<Neighbor>& solNeighborComparator;
|
||||
|
||||
//Pointer on the best and the current neighbor
|
||||
Neighbor* current;
|
||||
|
||||
// true if the move is accepted
|
||||
bool isAccept ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
134
trunk/paradiseo-mo/src/explorer/moHCneutralExplorer.h
Normal file
134
trunk/paradiseo-mo/src/explorer/moHCneutralExplorer.h
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
<moHCneutralExplorer.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moHCneutralExplorer_h
|
||||
#define _moHCneutralExplorer_h
|
||||
|
||||
#include <explorer/moSimpleHCneutralExplorer.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
/**
|
||||
* Explorer for a neutral Hill-climbing
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moHCneutralExplorer : public moSimpleHCneutralExplorer<Neighborhood>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
|
||||
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
|
||||
using moSimpleHCneutralExplorer<Neighborhood>::solNeighborComparator;
|
||||
using moSimpleHCneutralExplorer<Neighborhood>::isAccept;
|
||||
using moSimpleHCneutralExplorer<Neighborhood>::bestVector;
|
||||
using moSimpleHCneutralExplorer<Neighborhood>::initParam;
|
||||
using moSimpleHCneutralExplorer<Neighborhood>::updateParam;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhood the neighborhood
|
||||
* @param _eval the evaluation function
|
||||
* @param _neighborComparator a neighbor comparator
|
||||
* @param _solNeighborComparator a solution vs neighbor comparator
|
||||
* @param _nbStep maximum step to do
|
||||
*/
|
||||
moHCneutralExplorer(Neighborhood& _neighborhood,
|
||||
moEval<Neighbor>& _eval,
|
||||
moNeighborComparator<Neighbor>& _neighborComparator,
|
||||
moSolNeighborComparator<Neighbor>& _solNeighborComparator,
|
||||
unsigned _nbStep) :
|
||||
moSimpleHCneutralExplorer<Neighborhood>(_neighborhood, _eval, _neighborComparator, _solNeighborComparator),
|
||||
nbStep(_nbStep){
|
||||
//Some cycle is possible with equals fitness solutions if the neighborhood is not random
|
||||
if(!neighborhood.isRandom()){
|
||||
std::cout << "moHCneutralExplorer::Warning -> the neighborhood used is not random" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moHCneutralExplorer(){
|
||||
}
|
||||
|
||||
/**
|
||||
* initial number of step
|
||||
*/
|
||||
virtual void initParam(EOT & solution){
|
||||
moSimpleHCneutralExplorer<Neighborhood>::initParam(solution);
|
||||
|
||||
step = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* one more step
|
||||
*/
|
||||
virtual void updateParam(EOT & solution){
|
||||
moSimpleHCneutralExplorer<Neighborhood>::updateParam(solution);
|
||||
|
||||
step++;
|
||||
};
|
||||
|
||||
/**
|
||||
* continue if there is a neighbor and it is remainds some steps to do
|
||||
* @param _solution the solution
|
||||
* @return true there is some steps to do
|
||||
*/
|
||||
virtual bool isContinue(EOT & _solution) {
|
||||
return (step < nbStep) && isAccept ;
|
||||
};
|
||||
|
||||
/**
|
||||
* accept test if an ameliorated neighbor was be found
|
||||
* @param _solution the solution
|
||||
* @return true if the best neighbor ameliorate the fitness or is equals
|
||||
*/
|
||||
virtual bool accept(EOT & _solution) {
|
||||
if(neighborhood.hasNeighbor(_solution))
|
||||
isAccept = solNeighborComparator(_solution, bestVector[0]) || solNeighborComparator.equals(_solution, bestVector[0]) ;
|
||||
return isAccept;
|
||||
};
|
||||
|
||||
private:
|
||||
// current number of step
|
||||
unsigned int step;
|
||||
|
||||
// maximum number of steps to do
|
||||
unsigned int nbStep;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
194
trunk/paradiseo-mo/src/explorer/moMetropolisHastingExplorer.h
Normal file
194
trunk/paradiseo-mo/src/explorer/moMetropolisHastingExplorer.h
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
<moMetropolisHastingExplorer.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moMetropolisHastingExplorer_h
|
||||
#define _moMetropolisHastingExplorer_h
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
* Explorer for the Metropolis-Hasting Sampling
|
||||
* Only the symetric case is considered when Q(x,y) = Q(y,x)
|
||||
* Fitness must be > 0
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moMetropolisHastingExplorer : public moNeighborhoodExplorer<Neighborhood>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
|
||||
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
|
||||
using moNeighborhoodExplorer<Neighborhood>::eval;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhood the neighborhood
|
||||
* @param _eval the evaluation function
|
||||
* @param _neighborComparator a neighbor comparator
|
||||
* @param _solNeighborComparator a solution vs neighbor comparator
|
||||
* @param _nbStep maximum number of step to do
|
||||
*/
|
||||
moMetropolisHastingExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator, unsigned int _nbStep) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator), nbStep(_nbStep) {
|
||||
isAccept = false;
|
||||
current=new Neighbor();
|
||||
if(!neighborhood.isRandom()){
|
||||
std::cout << "moMetropolisHastingExplorer::Warning -> the neighborhood used is not random" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moMetropolisHastingExplorer(){
|
||||
delete current;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialization of the number of step to be done
|
||||
* @param _solution the solution (unused here)
|
||||
*/
|
||||
virtual void initParam(EOT & _solution){
|
||||
step = 0;
|
||||
isAccept = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* increase the number of step
|
||||
* @param _solution the solution (unused here)
|
||||
*/
|
||||
virtual void updateParam(EOT & _solution){
|
||||
step++;
|
||||
};
|
||||
|
||||
/**
|
||||
* terminate: NOTHING TO DO
|
||||
* @param _solution the solution (unused here)
|
||||
*/
|
||||
virtual void terminate(EOT & _solution){};
|
||||
|
||||
/**
|
||||
* Explore the neighborhood of a solution
|
||||
* @param _solution
|
||||
*/
|
||||
virtual void operator()(EOT & _solution){
|
||||
//Test if _solution has a Neighbor
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
//init the first neighbor
|
||||
neighborhood.init(_solution, (*current));
|
||||
|
||||
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
||||
eval(_solution, (*current));
|
||||
}
|
||||
else{
|
||||
//if _solution hasn't neighbor,
|
||||
isAccept=false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* continue if there is a neighbor and it is remainds some steps to do
|
||||
* @param _solution the solution
|
||||
* @return true there is some steps to do
|
||||
*/
|
||||
virtual bool isContinue(EOT & _solution) {
|
||||
return (step < nbStep) ;
|
||||
};
|
||||
|
||||
/**
|
||||
* move the solution with the best neighbor
|
||||
* @param _solution the solution to move
|
||||
*/
|
||||
virtual void move(EOT & _solution) {
|
||||
//move the solution
|
||||
(*current).move(_solution);
|
||||
//update its fitness
|
||||
_solution.fitness((*current).fitness());
|
||||
};
|
||||
|
||||
/**
|
||||
* accept test if an ameliorated neighbor was be found
|
||||
* @param _solution the solution
|
||||
* @return true if the best neighbor ameliorate the fitness
|
||||
*/
|
||||
virtual bool accept(EOT & _solution) {
|
||||
double alpha=0.0;
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
if (solNeighborComparator(_solution, *current))
|
||||
isAccept = true;
|
||||
else{
|
||||
if(_solution.fitness() != 0){
|
||||
if( (double)current->fitness() < (double)_solution.fitness()) // maximizing
|
||||
alpha = (double) current->fitness() / (double) _solution.fitness();
|
||||
else //minimizing
|
||||
alpha = (double) _solution.fitness() / (double) current->fitness();
|
||||
isAccept = (rng.uniform() < alpha) ;
|
||||
}
|
||||
else{
|
||||
if( (double)current->fitness() < (double)_solution.fitness()) // maximizing
|
||||
isAccept = true;
|
||||
else
|
||||
isAccept = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isAccept;
|
||||
};
|
||||
|
||||
private:
|
||||
// comparator betwenn solution and neighbor or between neighbors
|
||||
moNeighborComparator<Neighbor>& neighborComparator;
|
||||
moSolNeighborComparator<Neighbor>& solNeighborComparator;
|
||||
|
||||
// current number of step
|
||||
unsigned int step;
|
||||
|
||||
// maximum number of steps to do
|
||||
unsigned int nbStep;
|
||||
|
||||
//Pointer on the best and the current neighbor
|
||||
Neighbor* current;
|
||||
|
||||
// true if the move is accepted
|
||||
bool isAccept ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
131
trunk/paradiseo-mo/src/explorer/moNeighborhoodExplorer.h
Normal file
131
trunk/paradiseo-mo/src/explorer/moNeighborhoodExplorer.h
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
<moNeighborhoodExplorer.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _neighborhoodExplorer_h
|
||||
#define _neighborhoodExplorer_h
|
||||
|
||||
//EO inclusion
|
||||
#include <eoFunctor.h>
|
||||
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eval/moEval.h>
|
||||
|
||||
/**
|
||||
* Explore the neighborhood
|
||||
*/
|
||||
template< class NH >
|
||||
class moNeighborhoodExplorer : public eoUF<typename NH::EOT&, void>
|
||||
{
|
||||
public:
|
||||
typedef NH Neighborhood ;
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
|
||||
/**
|
||||
* Constructor with a Neighborhood and evaluation function
|
||||
* @param _neighborhood the neighborhood
|
||||
* @param _eval the evaluation function
|
||||
*/
|
||||
moNeighborhoodExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval):neighborhood(_neighborhood), eval(_eval), isMoved(false) {}
|
||||
|
||||
/**
|
||||
* Init Search parameters
|
||||
* @param _solution the solution to explore
|
||||
*/
|
||||
virtual void initParam (EOT& _solution) = 0 ;
|
||||
|
||||
/**
|
||||
* Update Search parameters
|
||||
* @param _solution the solution to explore
|
||||
*/
|
||||
virtual void updateParam (EOT& _solution) = 0 ;
|
||||
|
||||
/**
|
||||
* Test if the exploration continue or not
|
||||
* @param _solution the solution to explore
|
||||
* @return true if the exploration continue, else return false
|
||||
*/
|
||||
virtual bool isContinue(EOT& _solution) = 0 ;
|
||||
|
||||
/**
|
||||
* Move a solution
|
||||
* @param _solution the solution to explore
|
||||
*/
|
||||
virtual void move(EOT& _solution) = 0 ;
|
||||
|
||||
/**
|
||||
* Test if a solution is accepted
|
||||
* @param _solution the solution to explore
|
||||
* @return true if the solution is accepted, else return false
|
||||
*/
|
||||
virtual bool accept(EOT& _solution) = 0 ;
|
||||
|
||||
/**
|
||||
* Terminate the search
|
||||
* @param _solution the solution to explore
|
||||
*/
|
||||
virtual void terminate(EOT& _solution) = 0 ;
|
||||
|
||||
|
||||
/**
|
||||
* Getter for variable "isMoved"
|
||||
* @return true if move is applied
|
||||
*/
|
||||
bool moveApplied(){
|
||||
return isMoved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for variable "isMoved"
|
||||
* @param _isMoved
|
||||
*/
|
||||
void moveApplied(bool _isMoved){
|
||||
isMoved=_isMoved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moNeighborhoodExplorer";
|
||||
}
|
||||
|
||||
protected:
|
||||
Neighborhood & neighborhood;
|
||||
moEval<Neighbor>& eval;
|
||||
bool isMoved;
|
||||
};
|
||||
|
||||
#endif
|
||||
180
trunk/paradiseo-mo/src/explorer/moRandomNeutralWalkExplorer.h
Normal file
180
trunk/paradiseo-mo/src/explorer/moRandomNeutralWalkExplorer.h
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
<moRandomNeutralWalkExplorer.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moRandomNeutralWalkexplorer_h
|
||||
#define _moRandomNeutralWalkexplorer_h
|
||||
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
/**
|
||||
* Explorer for a random neutral walk
|
||||
* accept the movement when the neighbor has the same fitnes
|
||||
* To sample the neutral networks by random walk, there is no memory
|
||||
* neighborhood must be explored in random order
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moRandomNeutralWalkExplorer : public moNeighborhoodExplorer<Neighborhood>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
|
||||
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
|
||||
using moNeighborhoodExplorer<Neighborhood>::eval;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhood the neighborhood
|
||||
* @param _eval the evaluation function
|
||||
* @param _solNeighborComparator a solution vs neighbor comparator
|
||||
* @param _nbStep maximum number of step to do
|
||||
*/
|
||||
moRandomNeutralWalkExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval,
|
||||
moSolNeighborComparator<Neighbor>& _solNeighborComparator,
|
||||
unsigned _nbStep):
|
||||
moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval),
|
||||
solNeighborComparator(_solNeighborComparator),
|
||||
nbStep(_nbStep) {
|
||||
isAccept = false;
|
||||
current=new Neighbor();
|
||||
if(!neighborhood.isRandom()){
|
||||
std::cout << "moRandomNeutralWalkExplorer::Warning -> the neighborhood used is not random" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moRandomNeutralWalkExplorer(){
|
||||
delete current;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialization of the number of step to be done
|
||||
*/
|
||||
virtual void initParam(EOT & solution){
|
||||
step = 0;
|
||||
isAccept = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* increase the number of step
|
||||
*/
|
||||
virtual void updateParam(EOT & solution){
|
||||
step++;
|
||||
};
|
||||
|
||||
/**
|
||||
* terminate: NOTHING TO DO
|
||||
*/
|
||||
virtual void terminate(EOT & solution){};
|
||||
|
||||
/**
|
||||
* Explore the neighborhood of a solution
|
||||
* @param _solution
|
||||
*/
|
||||
virtual void operator()(EOT & _solution){
|
||||
//Test if _solution has a Neighbor
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
//init the first neighbor
|
||||
neighborhood.init(_solution, (*current));
|
||||
|
||||
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
||||
eval(_solution, (*current));
|
||||
|
||||
//test all others neighbors
|
||||
while (! solNeighborComparator.equals(_solution, *current) && neighborhood.cont(_solution)) {
|
||||
//next neighbor
|
||||
neighborhood.next(_solution, (*current));
|
||||
//eval
|
||||
eval(_solution, (*current));
|
||||
}
|
||||
}
|
||||
else{
|
||||
//if _solution hasn't neighbor,
|
||||
isAccept=false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* continue if there is a neighbor and it is remainds some steps to do
|
||||
* @param _solution the solution
|
||||
* @return true there is some steps to do
|
||||
*/
|
||||
virtual bool isContinue(EOT & _solution) {
|
||||
return (step < nbStep) && isAccept ;
|
||||
};
|
||||
|
||||
/**
|
||||
* move the solution with the best neighbor
|
||||
* @param _solution the solution to move
|
||||
*/
|
||||
virtual void move(EOT & _solution) {
|
||||
//move the solution
|
||||
(*current).move(_solution);
|
||||
//update its fitness
|
||||
_solution.fitness((*current).fitness());
|
||||
};
|
||||
|
||||
/**
|
||||
* accept test if an ameliorated neighbor was be found
|
||||
* @param _solution the solution
|
||||
* @return true if the best neighbor ameliorate the fitness
|
||||
*/
|
||||
virtual bool accept(EOT & _solution) {
|
||||
if(neighborhood.hasNeighbor(_solution))
|
||||
isAccept = solNeighborComparator.equals(_solution, (*current)) ;
|
||||
return isAccept;
|
||||
};
|
||||
|
||||
private:
|
||||
// comparator betwenn solution and neighbor or between neighbors
|
||||
moSolNeighborComparator<Neighbor>& solNeighborComparator;
|
||||
|
||||
// current number of step
|
||||
unsigned int step;
|
||||
|
||||
// maximum number of steps to do
|
||||
unsigned int nbStep;
|
||||
|
||||
//Pointer on the best and the current neighbor
|
||||
Neighbor* current;
|
||||
|
||||
// true if the move is accepted
|
||||
bool isAccept ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
166
trunk/paradiseo-mo/src/explorer/moRandomWalkExplorer.h
Normal file
166
trunk/paradiseo-mo/src/explorer/moRandomWalkExplorer.h
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
<moRandomWalkExplorer.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moRandomWalkexplorer_h
|
||||
#define _moRandomWalkexplorer_h
|
||||
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
/**
|
||||
* Explorer for a random walk explorer
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moRandomWalkExplorer : public moNeighborhoodExplorer<Neighborhood>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
|
||||
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
|
||||
using moNeighborhoodExplorer<Neighborhood>::eval;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhood the neighborhood
|
||||
* @param _eval the evaluation function
|
||||
* @param _nbStep maximum number of step to do
|
||||
*/
|
||||
moRandomWalkExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, unsigned _nbStep) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), nbStep(_nbStep) {
|
||||
isAccept = false;
|
||||
current=new Neighbor();
|
||||
// number of step done
|
||||
step = 0;
|
||||
if(!neighborhood.isRandom()){
|
||||
std::cout << "moRandomWalkExplorer::Warning -> the neighborhood used is not random" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moRandomWalkExplorer(){
|
||||
delete current;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialization of the number of step to be done
|
||||
*/
|
||||
virtual void initParam(EOT & solution){
|
||||
step = 0;
|
||||
isAccept = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* increase the number of step
|
||||
*/
|
||||
virtual void updateParam(EOT & solution){
|
||||
step++;
|
||||
};
|
||||
|
||||
/**
|
||||
* terminate: NOTHING TO DO
|
||||
*/
|
||||
virtual void terminate(EOT & solution){};
|
||||
|
||||
/**
|
||||
* Explore the neighborhood with only one random solution
|
||||
* @param _solution
|
||||
*/
|
||||
virtual void operator()(EOT & _solution){
|
||||
|
||||
//Test if _solution has a Neighbor
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
//init the first neighbor
|
||||
neighborhood.init(_solution, (*current));
|
||||
|
||||
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
||||
eval(_solution, (*current));
|
||||
|
||||
isAccept = true;
|
||||
}
|
||||
else{
|
||||
//if _solution hasn't neighbor,
|
||||
isAccept=false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* continue if there is a neighbor and it is remainds some steps to do
|
||||
* @param _solution the solution
|
||||
* @return true there is some steps to do
|
||||
*/
|
||||
virtual bool isContinue(EOT & _solution) {
|
||||
return (step < nbStep) && isAccept ;
|
||||
};
|
||||
|
||||
/**
|
||||
* move the solution with the best neighbor
|
||||
* @param _solution the solution to move
|
||||
*/
|
||||
virtual void move(EOT & _solution) {
|
||||
//move the solution
|
||||
(*current).move(_solution);
|
||||
//update its fitness
|
||||
_solution.fitness((*current).fitness());
|
||||
};
|
||||
|
||||
/**
|
||||
* accept test if an amelirated neighbor was be found
|
||||
* @param _solution the solution
|
||||
* @return true if the best neighbor ameliorate the fitness
|
||||
*/
|
||||
virtual bool accept(EOT & _solution) {
|
||||
if(neighborhood.hasNeighbor(_solution))
|
||||
isAccept = true ;
|
||||
return isAccept;
|
||||
};
|
||||
|
||||
private:
|
||||
// current number of step
|
||||
unsigned int step;
|
||||
|
||||
// maximum number of steps to do
|
||||
unsigned int nbStep;
|
||||
|
||||
//Pointer on the best and the current neighbor
|
||||
Neighbor* current;
|
||||
|
||||
// true if the move is accepted
|
||||
bool isAccept ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
182
trunk/paradiseo-mo/src/explorer/moSimpleHCexplorer.h
Normal file
182
trunk/paradiseo-mo/src/explorer/moSimpleHCexplorer.h
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
<moSimpleHCExplorer.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moSimpleHCexplorer_h
|
||||
#define _moSimpleHCexplorer_h
|
||||
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
/**
|
||||
* Explorer for a simple Hill-climbing
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moSimpleHCexplorer : public moNeighborhoodExplorer<Neighborhood>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
|
||||
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
|
||||
using moNeighborhoodExplorer<Neighborhood>::eval;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhood the neighborhood
|
||||
* @param _eval the evaluation function
|
||||
* @param _neighborComparator a neighbor comparator
|
||||
* @param _solNeighborComparator solution vs neighbor comparator
|
||||
*/
|
||||
moSimpleHCexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) {
|
||||
isAccept = false;
|
||||
current=new Neighbor();
|
||||
best=new Neighbor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moSimpleHCexplorer(){
|
||||
delete current;
|
||||
delete best;
|
||||
}
|
||||
|
||||
/**
|
||||
* initParam: NOTHING TO DO
|
||||
*/
|
||||
virtual void initParam(EOT & solution){};
|
||||
|
||||
/**
|
||||
* updateParam: NOTHING TO DO
|
||||
*/
|
||||
virtual void updateParam(EOT & solution){};
|
||||
|
||||
/**
|
||||
* terminate: NOTHING TO DO
|
||||
*/
|
||||
virtual void terminate(EOT & solution){};
|
||||
|
||||
/**
|
||||
* Explore the neighborhood of a solution
|
||||
* @param _solution
|
||||
*/
|
||||
virtual void operator()(EOT & _solution){
|
||||
|
||||
//est qu'on peut initializer
|
||||
//Test if _solution has a Neighbor
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
//init the first neighbor
|
||||
neighborhood.init(_solution, (*current));
|
||||
|
||||
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
||||
eval(_solution, (*current));
|
||||
|
||||
//initialize the best neighbor
|
||||
(*best) = (*current);
|
||||
|
||||
//test all others neighbors
|
||||
while (neighborhood.cont(_solution)) {
|
||||
//next neighbor
|
||||
neighborhood.next(_solution, (*current));
|
||||
//eval
|
||||
eval(_solution, (*current));
|
||||
//if we found a better neighbor, update the best
|
||||
if (neighborComparator((*best), (*current))) {
|
||||
(*best) = (*current);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
//if _solution hasn't neighbor,
|
||||
isAccept=false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* continue if a move is accepted
|
||||
* @param _solution the solution
|
||||
* @return true if an ameliorated neighbor was be found
|
||||
*/
|
||||
virtual bool isContinue(EOT & _solution) {
|
||||
return isAccept ;
|
||||
};
|
||||
|
||||
/**
|
||||
* move the solution with the best neighbor
|
||||
* @param _solution the solution to move
|
||||
*/
|
||||
virtual void move(EOT & _solution) {
|
||||
//move the solution
|
||||
(*best).move(_solution);
|
||||
//update its fitness
|
||||
_solution.fitness((*best).fitness());
|
||||
};
|
||||
|
||||
/**
|
||||
* accept test if an amelirated neighbor was be found
|
||||
* @param _solution the solution
|
||||
* @return true if the best neighbor ameliorate the fitness
|
||||
*/
|
||||
virtual bool accept(EOT & _solution) {
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
isAccept = solNeighborComparator(_solution, (*best)) ;
|
||||
}
|
||||
return isAccept;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moSimpleHCexplorer";
|
||||
}
|
||||
|
||||
private:
|
||||
// comparator betwenn solution and neighbor or between neighbors
|
||||
moNeighborComparator<Neighbor>& neighborComparator;
|
||||
moSolNeighborComparator<Neighbor>& solNeighborComparator;
|
||||
|
||||
//Pointer on the best and the current neighbor
|
||||
Neighbor* best;
|
||||
Neighbor* current;
|
||||
|
||||
// true if the move is accepted
|
||||
bool isAccept ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
193
trunk/paradiseo-mo/src/explorer/moSimpleHCneutralExplorer.h
Normal file
193
trunk/paradiseo-mo/src/explorer/moSimpleHCneutralExplorer.h
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
<moSimpleHCneutralExplorer.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moSimpleHCneutralExplorer_h
|
||||
#define _moSimpleHCneutralExplorer_h
|
||||
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
#include <vector>
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
* Explorer for a simple neutral Hill-climbing
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moSimpleHCneutralExplorer : public moNeighborhoodExplorer<Neighborhood>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
|
||||
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
|
||||
using moNeighborhoodExplorer<Neighborhood>::eval;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhood the neighborhood
|
||||
* @param _eval the evaluation function
|
||||
* @param _neighborComparator a neighbor comparator
|
||||
* @param _solNeighborComparator solution vs neighbor comparator
|
||||
*/
|
||||
moSimpleHCneutralExplorer(Neighborhood& _neighborhood,
|
||||
moEval<Neighbor>& _eval,
|
||||
moNeighborComparator<Neighbor>& _neighborComparator,
|
||||
moSolNeighborComparator<Neighbor>& _solNeighborComparator) :
|
||||
moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval),
|
||||
neighborComparator(_neighborComparator),
|
||||
solNeighborComparator(_solNeighborComparator) {
|
||||
isAccept = false;
|
||||
current=new Neighbor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moSimpleHCneutralExplorer(){
|
||||
delete current;
|
||||
}
|
||||
|
||||
/**
|
||||
* empty the vector of best solutions
|
||||
*/
|
||||
virtual void initParam(EOT & solution){
|
||||
// delete all the best solutions
|
||||
bestVector.clear();
|
||||
};
|
||||
|
||||
/**
|
||||
* empty the vector of best solutions
|
||||
*/
|
||||
virtual void updateParam(EOT & solution){
|
||||
// delete all the best solutions
|
||||
bestVector.clear();
|
||||
};
|
||||
|
||||
/**
|
||||
* terminate: NOTHING TO DO
|
||||
*/
|
||||
virtual void terminate(EOT & solution){};
|
||||
|
||||
/**
|
||||
* Explore the neighborhood of a solution
|
||||
* @param _solution
|
||||
*/
|
||||
virtual void operator()(EOT & _solution){
|
||||
|
||||
//Test if _solution has a Neighbor
|
||||
if(neighborhood.hasNeighbor(_solution)){
|
||||
//init the first neighbor
|
||||
neighborhood.init(_solution, (*current));
|
||||
|
||||
//eval the _solution moved with the neighbor and stock the result in the neighbor
|
||||
eval(_solution, (*current));
|
||||
|
||||
//initialize the best neighbor
|
||||
bestVector.push_back(*current);
|
||||
|
||||
//test all others neighbors
|
||||
while (neighborhood.cont(_solution)) {
|
||||
//next neighbor
|
||||
neighborhood.next(_solution, (*current));
|
||||
|
||||
//eval
|
||||
eval(_solution, (*current));
|
||||
|
||||
//if we found a better neighbor, update the best
|
||||
if (neighborComparator(bestVector[0], (*current))) {
|
||||
bestVector.clear();
|
||||
bestVector.push_back(*current);
|
||||
}
|
||||
else if (neighborComparator.equals((*current), bestVector[0])) //if the current is equals to previous best solutions then update vector of the best solution
|
||||
bestVector.push_back(*current);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//if _solution hasn't neighbor,
|
||||
isAccept=false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* continue if a move is accepted
|
||||
* @param _solution the solution
|
||||
* @return true if an ameliorated neighbor was be found
|
||||
*/
|
||||
virtual bool isContinue(EOT & _solution) {
|
||||
return isAccept ;
|
||||
};
|
||||
|
||||
/**
|
||||
* move the solution with the best neighbor
|
||||
* @param _solution the solution to move
|
||||
*/
|
||||
virtual void move(EOT & _solution) {
|
||||
// choose randomly one of the best solutions
|
||||
unsigned int i = rng.random(bestVector.size());
|
||||
|
||||
//move the solution
|
||||
bestVector[i].move(_solution);
|
||||
|
||||
//update its fitness
|
||||
_solution.fitness(bestVector[i].fitness());
|
||||
};
|
||||
|
||||
/**
|
||||
* accept test if an amelirated neighbor was be found
|
||||
* @param _solution the solution
|
||||
* @return true if the best neighbor ameliorate the fitness
|
||||
*/
|
||||
virtual bool accept(EOT & _solution) {
|
||||
if(neighborhood.hasNeighbor(_solution))
|
||||
isAccept = solNeighborComparator(_solution, bestVector[0]) ;
|
||||
return isAccept;
|
||||
};
|
||||
|
||||
protected:
|
||||
// comparator betwenn solution and neighbor or between neighbors
|
||||
moNeighborComparator<Neighbor>& neighborComparator;
|
||||
moSolNeighborComparator<Neighbor>& solNeighborComparator;
|
||||
|
||||
// the best solutions in the neighborhood
|
||||
std::vector<Neighbor> bestVector;
|
||||
//Pointer on the current neighbor
|
||||
Neighbor* current;
|
||||
|
||||
// true if the move is accepted
|
||||
bool isAccept ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
255
trunk/paradiseo-mo/src/explorer/moTSExplorer.h
Normal file
255
trunk/paradiseo-mo/src/explorer/moTSExplorer.h
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
/*
|
||||
<moTSExplorer.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moTSExplorer_h
|
||||
#define _moTSExplorer_h
|
||||
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
#include <memory/moAspiration.h>
|
||||
#include <memory/moTabuList.h>
|
||||
#include <memory/moIntensification.h>
|
||||
#include <memory/moDiversification.h>
|
||||
|
||||
|
||||
/**
|
||||
* Explorer for a Tabu Search
|
||||
*/
|
||||
template< class Neighborhood >
|
||||
class moTSExplorer : public moNeighborhoodExplorer<Neighborhood>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighborhood::EOT EOT ;
|
||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhood the neighborhood
|
||||
* @param _eval the evaluation function
|
||||
* @param _neighborComparator a neighbor comparator
|
||||
* @param _solNeighborComparator a comparator between a solution and a neighbor
|
||||
* @param _tabuList the tabu list
|
||||
* @param _intensification the intensification box
|
||||
* @param _diversification the diversification box
|
||||
* @param _aspiration the aspiration criteria
|
||||
*/
|
||||
moTSExplorer(Neighborhood& _neighborhood,
|
||||
moEval<Neighbor>& _eval,
|
||||
moNeighborComparator<Neighbor>& _neighborComparator,
|
||||
moSolNeighborComparator<Neighbor>& _solNeighborComparator,
|
||||
moTabuList<Neighbor> & _tabuList,
|
||||
moIntensification<Neighbor> & _intensification,
|
||||
moDiversification<Neighbor> & _diversification,
|
||||
moAspiration<Neighbor> & _aspiration
|
||||
) :
|
||||
moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator),
|
||||
tabuList(_tabuList), intensification(_intensification), diversification(_diversification), aspiration(_aspiration)
|
||||
{
|
||||
isAccept = false;
|
||||
current=new Neighbor();
|
||||
best=new Neighbor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~moTSExplorer(){
|
||||
delete current;
|
||||
delete best;
|
||||
}
|
||||
|
||||
/**
|
||||
* init tabu list, intensification box, diversification box and aspiration criteria
|
||||
* @param _solution
|
||||
*/
|
||||
virtual void initParam(EOT& _solution)
|
||||
{
|
||||
tabuList.init(_solution);
|
||||
intensification.init(_solution);
|
||||
diversification.init(_solution);
|
||||
aspiration.init(_solution);
|
||||
bestSoFar=_solution;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* update params of tabu list, intensification box, diversification box and aspiration criteria
|
||||
* @param _solution
|
||||
*/
|
||||
virtual void updateParam(EOT& _solution)
|
||||
{
|
||||
if ((*this).moveApplied()){
|
||||
tabuList.add(_solution, *best);
|
||||
intensification.add(_solution, *best);
|
||||
diversification.add(_solution, *best);
|
||||
if(_solution.fitness() > bestSoFar.fitness())
|
||||
bestSoFar = _solution;
|
||||
}
|
||||
tabuList.update(_solution, *best);
|
||||
intensification.update(_solution, *best);
|
||||
diversification.update(_solution, *best);
|
||||
aspiration.update(_solution, *best);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* terminate : _solution becomes the best so far
|
||||
*/
|
||||
virtual void terminate(EOT & _solution){
|
||||
_solution= bestSoFar;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Explore the neighborhood of a solution
|
||||
* @param _solution
|
||||
*/
|
||||
virtual void operator()(EOT & _solution)
|
||||
{
|
||||
bool found=false;
|
||||
intensification(_solution);
|
||||
diversification(_solution);
|
||||
if(neighborhood.hasNeighbor(_solution))
|
||||
{
|
||||
//init the current neighbor
|
||||
neighborhood.init(_solution, *current);
|
||||
//eval the current neighbor
|
||||
eval(_solution, *current);
|
||||
|
||||
//Find the first non-tabu element
|
||||
if ( (!tabuList.check(_solution, *current)) || aspiration(_solution, *current) ){
|
||||
// set best
|
||||
(*best)= (*current);
|
||||
found=true;
|
||||
}
|
||||
while(neighborhood.cont(_solution) && !found){
|
||||
//next neighbor
|
||||
neighborhood.next(_solution, (*current));
|
||||
//eval
|
||||
eval(_solution, (*current));
|
||||
|
||||
if ( (!tabuList.check(_solution, *current)) || aspiration(_solution, *current) ){
|
||||
// set best
|
||||
(*best)=(*current);
|
||||
found=true;
|
||||
}
|
||||
}
|
||||
//Explore the neighborhood
|
||||
if(found){
|
||||
isAccept=true;
|
||||
while(neighborhood.cont(_solution)){
|
||||
//next neighbor
|
||||
neighborhood.next(_solution, (*current));
|
||||
//eval
|
||||
eval(_solution, (*current));
|
||||
//check if the current is better than the best and is not tabu or if it is aspirat (by the aspiration criteria of course)
|
||||
if ( (!tabuList.check(_solution, *current) || aspiration(_solution, (*current))) && neighborComparator((*best),(*current))){
|
||||
// set best
|
||||
(*best)=(*current);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
isAccept=false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
isAccept=false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* always continue
|
||||
* @param _solution the solution
|
||||
* @return true
|
||||
*/
|
||||
virtual bool isContinue(EOT & _solution){
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* move the solution with the best neighbor
|
||||
* @param _solution the solution to move
|
||||
*/
|
||||
virtual void move(EOT & _solution) {
|
||||
//move the solution
|
||||
best->move(_solution);
|
||||
//update its fitness
|
||||
_solution.fitness(best->fitness());
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* accept test if an ameliorated neighbor was be found
|
||||
* @param _solution the solution
|
||||
* @return true if the best neighbor ameliorate the fitness
|
||||
*/
|
||||
virtual bool accept(EOT & _solution){
|
||||
return isAccept;
|
||||
};
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
|
||||
using moNeighborhoodExplorer<Neighborhood>::eval;
|
||||
|
||||
// comparator between solution and neighbor or between neighbors
|
||||
moNeighborComparator<Neighbor>& neighborComparator;
|
||||
moSolNeighborComparator<Neighbor>& solNeighborComparator;
|
||||
|
||||
// Tabu components
|
||||
moTabuList<Neighbor> & tabuList;
|
||||
moIntensification<Neighbor> & intensification;
|
||||
moDiversification<Neighbor> & diversification;
|
||||
moAspiration<Neighbor> & aspiration;
|
||||
|
||||
//Current and best neighbor
|
||||
Neighbor* best;
|
||||
Neighbor* current;
|
||||
|
||||
//Best so far Solution
|
||||
EOT bestSoFar;
|
||||
|
||||
// true if the move is accepted
|
||||
bool isAccept ;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
19
trunk/paradiseo-mo/src/memory/moAspiration.h
Normal file
19
trunk/paradiseo-mo/src/memory/moAspiration.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef _moAspiration_h
|
||||
#define _moAspiration_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
/**
|
||||
* Abstract class for Aspiration Criteria
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moAspiration : public eoBF<typename Neighbor::EOT &, Neighbor &, bool>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
virtual void init(EOT & _sol) = 0;
|
||||
virtual void update(EOT & _sol, Neighbor & _neighbor) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
57
trunk/paradiseo-mo/src/memory/moBestImprAspiration.h
Normal file
57
trunk/paradiseo-mo/src/memory/moBestImprAspiration.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#ifndef _moBestImprAspiration_h
|
||||
#define _moBestImprAspiration_h
|
||||
|
||||
#include <memory/moAspiration.h>
|
||||
|
||||
/**
|
||||
* Aspiration criteria accepts a solution better than the best so far
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moBestImprAspiration : public moAspiration<Neighbor>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* init the best solution
|
||||
* @param _sol the best solution found
|
||||
*/
|
||||
void init(EOT & _sol){
|
||||
bestFoundSoFar = _sol;
|
||||
}
|
||||
|
||||
/**
|
||||
* update the "bestFoundSoFar" if a best solution is found
|
||||
* @param _sol a solution
|
||||
* @param _neighbor a neighbor
|
||||
*/
|
||||
void update(EOT & _sol, Neighbor & _neighbor){
|
||||
if (bestFoundSoFar.fitness() < _sol.fitness())
|
||||
bestFoundSoFar = _sol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the tabu feature of the neighbor:
|
||||
* test if the neighbor's fitness is better than the "bestFoundSoFar" fitness
|
||||
* @param _sol a solution
|
||||
* @param _neighbor a neighbor
|
||||
* @return true if _neighbor fitness is better than the "bestFoundSoFar"
|
||||
*/
|
||||
bool operator()(EOT & _sol, Neighbor & _neighbor){
|
||||
return (bestFoundSoFar.fitness() < _neighbor.fitness());
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter
|
||||
* @return a reference on the best found so far solution
|
||||
*/
|
||||
EOT& getBest(){
|
||||
return bestFoundSoFar;
|
||||
}
|
||||
|
||||
private:
|
||||
EOT bestFoundSoFar;
|
||||
};
|
||||
|
||||
#endif
|
||||
14
trunk/paradiseo-mo/src/memory/moDiversification.h
Normal file
14
trunk/paradiseo-mo/src/memory/moDiversification.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef _moDiversification_h
|
||||
#define _moDiversification_h
|
||||
|
||||
#include <memory/moMemory.h>
|
||||
#include <eoFunctor.h>
|
||||
|
||||
/**
|
||||
* Abstract class for diversification strategy
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moDiversification : public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool>
|
||||
{};
|
||||
|
||||
#endif
|
||||
43
trunk/paradiseo-mo/src/memory/moDummyDiversification.h
Normal file
43
trunk/paradiseo-mo/src/memory/moDummyDiversification.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef _moDummyDiversification_h
|
||||
#define _moDummyDiversification_h
|
||||
|
||||
#include <memory/moDiversification.h>
|
||||
|
||||
/**
|
||||
* Dummy diversification strategy
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moDummyDiversification : public moDiversification<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Init : NOTHIING TO DO
|
||||
*/
|
||||
void init(EOT & _sol) {}
|
||||
|
||||
/**
|
||||
* Add : NOTHIING TO DO
|
||||
*/
|
||||
void add(EOT & _sol, Neighbor & _neighbor) {}
|
||||
|
||||
/**
|
||||
* Update : NOTHIING TO DO
|
||||
*/
|
||||
void update(EOT & _sol, Neighbor & _neighbor) {}
|
||||
|
||||
/**
|
||||
* ClearMemory : NOTHIING TO DO
|
||||
*/
|
||||
void clearMemory() {}
|
||||
|
||||
/**
|
||||
* @return always false
|
||||
*/
|
||||
bool operator()(EOT &){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
43
trunk/paradiseo-mo/src/memory/moDummyIntensification.h
Normal file
43
trunk/paradiseo-mo/src/memory/moDummyIntensification.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef _moDummyIntensification_h
|
||||
#define _moDummyIntensification_h
|
||||
|
||||
#include <memory/moIntensification.h>
|
||||
|
||||
/**
|
||||
* Dummy intensification strategy
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moDummyIntensification : public moIntensification<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Init : NOTHIING TO DO
|
||||
*/
|
||||
void init(EOT & _sol) {}
|
||||
|
||||
/**
|
||||
* Add : NOTHIING TO DO
|
||||
*/
|
||||
void add(EOT & _sol, Neighbor & _neighbor) {}
|
||||
|
||||
/**
|
||||
* Update : NOTHIING TO DO
|
||||
*/
|
||||
void update(EOT & _sol, Neighbor & _neighbor) {}
|
||||
|
||||
/**
|
||||
* ClearMemory : NOTHIING TO DO
|
||||
*/
|
||||
void clearMemory() {}
|
||||
|
||||
/**
|
||||
* @return always false
|
||||
*/
|
||||
bool operator()(EOT &){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
14
trunk/paradiseo-mo/src/memory/moIntensification.h
Normal file
14
trunk/paradiseo-mo/src/memory/moIntensification.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef _moIntensification_h
|
||||
#define _moIntensification_h
|
||||
|
||||
#include <memory/moMemory.h>
|
||||
#include <eoFunctor.h>
|
||||
|
||||
/**
|
||||
* Abstract class for intensification strategy
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moIntensification : public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool>
|
||||
{};
|
||||
|
||||
#endif
|
||||
40
trunk/paradiseo-mo/src/memory/moMemory.h
Normal file
40
trunk/paradiseo-mo/src/memory/moMemory.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef _moMemory_h
|
||||
#define _moMemory_h
|
||||
|
||||
/**
|
||||
* Abstract class for different memory
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moMemory //: public eoObject
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Init the memory
|
||||
* @param _sol the current solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) = 0;
|
||||
|
||||
/**
|
||||
* Add data in the memory
|
||||
* @param _sol the current solution
|
||||
* @param _neighbor the current neighbor
|
||||
*/
|
||||
virtual void add(EOT & _sol, Neighbor & _neighbor) = 0;
|
||||
|
||||
/**
|
||||
* update the memory
|
||||
* @param _sol the current solution
|
||||
* @param _neighbor the current neighbor
|
||||
*/
|
||||
virtual void update(EOT & _sol, Neighbor & _neighbor) = 0;
|
||||
|
||||
/**
|
||||
* clear the memory
|
||||
*/
|
||||
virtual void clearMemory() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
103
trunk/paradiseo-mo/src/memory/moSolVectorTabuList.h
Normal file
103
trunk/paradiseo-mo/src/memory/moSolVectorTabuList.h
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#ifndef _moSolVectorTabuList_h
|
||||
#define _moSolVectorTabuList_h
|
||||
|
||||
#include <memory/moTabuList.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* Tabu List of solution stocked in a vector
|
||||
*/
|
||||
template<class Neighbor >
|
||||
class moSolVectorTabuList : public moTabuList<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _maxSize maximum size of the tabu list
|
||||
* @param _howlong how many iteration a move is tabu
|
||||
*/
|
||||
moSolVectorTabuList(unsigned int _maxSize, unsigned int _howlong) : maxSize(_maxSize), howlong(_howlong){
|
||||
tabuList.reserve(_maxSize);
|
||||
tabuList.resize(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* init the tabuList by clearing the memory
|
||||
* @param _sol the current solution
|
||||
*/
|
||||
virtual void init(EOT & _sol){
|
||||
clearMemory();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add a new solution in the tabuList
|
||||
* @param _sol the current solution
|
||||
* @param _neighbor the current neighbor (unused)
|
||||
*/
|
||||
virtual void add(EOT & _sol, Neighbor & _neighbor){
|
||||
|
||||
if(tabuList.size() < maxSize){
|
||||
std::pair<EOT, unsigned int> tmp;
|
||||
tmp.first=_sol;
|
||||
tmp.second=howlong;
|
||||
tabuList.push_back(tmp);
|
||||
}
|
||||
else{
|
||||
tabuList[index%maxSize].first = _sol;
|
||||
tabuList[index%maxSize].second = howlong;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* update the tabulist: NOTHING TO DO
|
||||
* @param _sol the current solution
|
||||
* @param _neighbor the current neighbor (unused)
|
||||
*/
|
||||
virtual void update(EOT & _sol, Neighbor & _neighbor){
|
||||
for(unsigned int i=0; i<tabuList.size(); i++)
|
||||
tabuList[i].second--;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the solution is tabu
|
||||
* @param _sol the current solution
|
||||
* @param _neighbor the current neighbor (unused)
|
||||
* @return true if tabuList contains _sol
|
||||
*/
|
||||
virtual bool check(EOT & _sol, Neighbor & _neighbor){
|
||||
EOT tmp=_sol;
|
||||
_neighbor.move(tmp);
|
||||
for(unsigned int i=0; i<tabuList.size(); i++){
|
||||
if ((howlong > 0 && tabuList[i].second > 0 && tabuList[i].first == tmp) || (howlong==0 && tabuList[i].first==tmp))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* clearMemory: remove all solution of the tabuList
|
||||
*/
|
||||
virtual void clearMemory(){
|
||||
tabuList.resize(0);
|
||||
index = 0;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//tabu list
|
||||
std::vector< std::pair<EOT, unsigned int> > tabuList;
|
||||
//maximum size of the tabu list
|
||||
unsigned int maxSize;
|
||||
//how many iteration a move is tabu
|
||||
unsigned int howlong;
|
||||
//index on the tabulist
|
||||
unsigned long index;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
24
trunk/paradiseo-mo/src/memory/moTabuList.h
Normal file
24
trunk/paradiseo-mo/src/memory/moTabuList.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef _moTabuList_h
|
||||
#define _moTabuList_h
|
||||
|
||||
#include <memory/moMemory.h>
|
||||
|
||||
/**
|
||||
* Abstract class for the Tabu List
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moTabuList : public moMemory<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Check if a neighbor is tabu or not
|
||||
* @param _sol the current solution
|
||||
* @param _neighbor the neighbor
|
||||
* @return true if the neighbor is tabu
|
||||
*/
|
||||
virtual bool check(EOT & _sol, Neighbor & _neighbor) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
56
trunk/paradiseo-mo/src/neighborhood/moBackableNeighbor.h
Normal file
56
trunk/paradiseo-mo/src/neighborhood/moBackableNeighbor.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
<moBackableNeighbor.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _BackableNeighbor_h
|
||||
#define _BackableNeighbor_h
|
||||
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
|
||||
/**
|
||||
* Neighbor with a move back function to use in a moFullEvalByModif
|
||||
*/
|
||||
template< class EOT , class Fitness >
|
||||
class moBackableNeighbor : virtual public moNeighbor<EOT, Fitness>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* the move back function
|
||||
* @param _solution the solution to moveBack
|
||||
*/
|
||||
virtual void moveBack(EOT & _solution)=0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
111
trunk/paradiseo-mo/src/neighborhood/moBitNeighbor.h
Normal file
111
trunk/paradiseo-mo/src/neighborhood/moBitNeighbor.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
<moBitNeighbor.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _bitNeighbor_h
|
||||
#define _bitNeighbor_h
|
||||
|
||||
#include <ga/eoBit.h>
|
||||
#include <neighborhood/moBackableNeighbor.h>
|
||||
#include <neighborhood/moIndexNeighbor.h>
|
||||
|
||||
/**
|
||||
* Neighbor related to a vector of Bit
|
||||
*/
|
||||
template< class Fitness >
|
||||
class moBitNeighbor : public moBackableNeighbor<eoBit<Fitness>, Fitness>, public moIndexNeighbor<eoBit<Fitness>, Fitness>
|
||||
{
|
||||
public:
|
||||
typedef eoBit<Fitness> EOT ;
|
||||
|
||||
using moBackableNeighbor<eoBit<Fitness>, Fitness>::fitness;
|
||||
using moIndexNeighbor<eoBit<Fitness>, Fitness>::key;
|
||||
|
||||
/**
|
||||
* move the solution
|
||||
* @param _solution the solution to move
|
||||
*/
|
||||
virtual void move(EOT & _solution) {
|
||||
_solution[key] = !_solution[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* move back the solution (useful for the evaluation by modif)
|
||||
* @param _solution the solution to move back
|
||||
*/
|
||||
virtual void moveBack(EOT & _solution) {
|
||||
_solution[key] = !_solution[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moBitNeighbor";
|
||||
}
|
||||
|
||||
/**
|
||||
* Read object.\ \
|
||||
* Calls base class, just in case that one had something to do.
|
||||
* The read and print methods should be compatible and have the same format.
|
||||
* In principle, format is "plain": they just print a number
|
||||
* @param _is a std::istream.
|
||||
* @throw runtime_std::exception If a valid object can't be read.
|
||||
*/
|
||||
virtual void readFrom(std::istream& _is) {
|
||||
std::string fitness_str;
|
||||
int pos = _is.tellg();
|
||||
_is >> fitness_str;
|
||||
if (fitness_str == "INVALID"){
|
||||
throw std::runtime_error("invalid fitness");
|
||||
}
|
||||
else{
|
||||
Fitness repFit ;
|
||||
_is.seekg(pos); // rewind
|
||||
_is >> repFit;
|
||||
_is >> key;
|
||||
fitness(repFit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object. Called printOn since it prints the object _on_ a stream.
|
||||
* @param _os A std::ostream.
|
||||
*/
|
||||
virtual void printOn(std::ostream& _os) const {
|
||||
_os << fitness() << ' ' << key << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
101
trunk/paradiseo-mo/src/neighborhood/moIndexNeighbor.h
Normal file
101
trunk/paradiseo-mo/src/neighborhood/moIndexNeighbor.h
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
<moIndexNeighbor.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _IndexNeighbor_h
|
||||
#define _IndexNeighbor_h
|
||||
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
|
||||
/**
|
||||
* Index Neighbor
|
||||
*/
|
||||
template< class EOT , class Fitness >
|
||||
class moIndexNeighbor : virtual public moNeighbor<EOT, Fitness>
|
||||
{
|
||||
public:
|
||||
|
||||
using moNeighbor<EOT, Fitness>::fitness;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moIndexNeighbor() : moNeighbor<EOT, Fitness>(), key(0){}
|
||||
|
||||
/**
|
||||
* Copy Constructor
|
||||
*/
|
||||
moIndexNeighbor(const moIndexNeighbor& _n) : moNeighbor<EOT, Fitness>(_n) {
|
||||
this->key = _n.key ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
*/
|
||||
virtual moIndexNeighbor<EOT, Fitness> & operator=(const moIndexNeighbor<EOT, Fitness> & _source) {
|
||||
moNeighbor<EOT, Fitness>::operator=(_source);
|
||||
this->key = _source.key ;
|
||||
return *this ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moIndexNeighbor";
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter
|
||||
* @return index of the IndexNeighbor
|
||||
*/
|
||||
unsigned int index(){
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter
|
||||
* @param _key index of the IndexNeighbor
|
||||
*/
|
||||
void index(unsigned int _key){
|
||||
key=_key;
|
||||
}
|
||||
|
||||
protected:
|
||||
// key allowing to describe the neighbor
|
||||
unsigned int key;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
70
trunk/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h
Normal file
70
trunk/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
<moIndexNeighborhood.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moIndexNeighborhood_h
|
||||
#define _moIndexNeighborhood_h
|
||||
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* A Indexed Neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moIndexNeighborhood : virtual public moNeighborhood<Neighbor>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moIndexNeighborhood(unsigned int _neighborhoodSize):neighborhoodSize(_neighborhoodSize){}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moIndexNeighborhood";
|
||||
}
|
||||
|
||||
protected:
|
||||
unsigned int neighborhoodSize;
|
||||
};
|
||||
|
||||
#endif
|
||||
136
trunk/paradiseo-mo/src/neighborhood/moNeighbor.h
Normal file
136
trunk/paradiseo-mo/src/neighborhood/moNeighbor.h
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
<moNeighbor.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moNeighbor_h
|
||||
#define _moNeighbor_h
|
||||
|
||||
//EO inclusion
|
||||
#include <EO.h>
|
||||
#include <eoObject.h>
|
||||
#include <eoPersistent.h>
|
||||
|
||||
/**
|
||||
* Container of the neighbor informations
|
||||
*/
|
||||
template< class EOType , class Fitness >
|
||||
class moNeighbor : public eoObject, public eoPersistent
|
||||
{
|
||||
public:
|
||||
typedef EOType EOT;
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moNeighbor(){}
|
||||
|
||||
/**
|
||||
* Copy Constructor
|
||||
* @param _neighbor to copy
|
||||
*/
|
||||
moNeighbor(const moNeighbor<EOT, Fitness>& _neighbor) {
|
||||
repFitness = _neighbor.fitness();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
* @param _neighbor the neighbor to assign
|
||||
* @return a neighbor equal to the other
|
||||
*/
|
||||
virtual moNeighbor<EOT, Fitness>& operator=(const moNeighbor<EOT, Fitness>& _neighbor) {
|
||||
repFitness = _neighbor.fitness();
|
||||
return (*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a solution
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
virtual void move(EOT & _solution) = 0 ;
|
||||
|
||||
/**
|
||||
* Get the fitness of the neighbor
|
||||
* @return fitness of the neighbor
|
||||
*/
|
||||
const Fitness fitness() const {
|
||||
return repFitness;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get fitness as reference, useful when fitness is set in a multi-stage way, e.g., MOFitness gets performance information, is subsequently ranked
|
||||
* @return fitness as reference of the neighbor
|
||||
*/
|
||||
Fitness& fitnessReference() {
|
||||
return repFitness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fitness. At the same time, validates it.
|
||||
* @param _fitness new fitness value.
|
||||
*/
|
||||
void fitness(const Fitness& _fitness){
|
||||
repFitness = _fitness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const { return "moNeighbor"; }
|
||||
|
||||
/**
|
||||
* Read object.
|
||||
* Calls base class, just in case that one had something to do.
|
||||
* The read and print methods should be compatible and have the same format.
|
||||
* In principle, format is "plain": they just print a number
|
||||
* @param _is a std::istream.
|
||||
*/
|
||||
virtual void readFrom(std::istream& _is) {
|
||||
_is >> repFitness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object. Called printOn since it prints the object _on_ a stream.
|
||||
* @param _os A std::ostream.
|
||||
*/
|
||||
virtual void printOn(std::ostream& _os) const {
|
||||
_os << repFitness << std::endl;
|
||||
}
|
||||
|
||||
protected:
|
||||
// minimal information on the neighbor : fitness
|
||||
Fitness repFitness ;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
101
trunk/paradiseo-mo/src/neighborhood/moNeighborhood.h
Normal file
101
trunk/paradiseo-mo/src/neighborhood/moNeighborhood.h
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
<moNeighborhood.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moNeighborhood_h
|
||||
#define _moNeighborhood_h
|
||||
|
||||
#include <eoObject.h>
|
||||
|
||||
/**
|
||||
* A Neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moNeighborhood : public eoObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moNeighborhood(){}
|
||||
|
||||
/**
|
||||
* @return if the neighborhood is random
|
||||
*/
|
||||
virtual bool isRandom(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a solution has (again) a Neighbor
|
||||
* @param _solution the related solution
|
||||
* @return if _solution has a Neighbor
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT & _solution) = 0 ;
|
||||
|
||||
/**
|
||||
* Initialization of the neighborhood
|
||||
* @param _solution the solution to explore
|
||||
* @param _current the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _current) = 0 ;
|
||||
|
||||
/**
|
||||
* Give the next neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @param _current the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _current) = 0 ;
|
||||
|
||||
/**
|
||||
* Test if there is again a neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @return if there is again a neighbor not explored
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) = 0 ;
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moNeighborhood";
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
125
trunk/paradiseo-mo/src/neighborhood/moOrderNeighborhood.h
Normal file
125
trunk/paradiseo-mo/src/neighborhood/moOrderNeighborhood.h
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
<moOrderNeighborhood.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moOrderNeighborhood_h
|
||||
#define _moOrderNeighborhood_h
|
||||
|
||||
#include <neighborhood/moIndexNeighborhood.h>
|
||||
|
||||
/**
|
||||
* A Ordered Neighborhood
|
||||
*/
|
||||
template< class N >
|
||||
class moOrderNeighborhood : public moIndexNeighborhood<N>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef N Neighbor;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moOrderNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), currentIndex(0){}
|
||||
|
||||
/**
|
||||
* Test if it exist a neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @return true if the neighborhood was not empty
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT& _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization of the neighborhood
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _neighbor) {
|
||||
currentIndex = 0 ;
|
||||
_neighbor.index(currentIndex) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the next neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _neighbor) {
|
||||
currentIndex++ ;
|
||||
_neighbor.index(currentIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* test if all neighbors are explore or not,if false, there is no neighbor left to explore
|
||||
* currentIndex is the index which have been used before, it is not the next neighbor which can be possibly evaluated
|
||||
*
|
||||
* @param _solution the solution to explore
|
||||
* @return true if there is again a neighbor to explore
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return (currentIndex < neighborhoodSize - 1) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter
|
||||
* @return the position in the Neighborhood
|
||||
*/
|
||||
unsigned int position(){
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moOrderNeighborhood";
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int currentIndex;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
45
trunk/paradiseo-mo/src/neighborhood/moRndNeighborhood.h
Normal file
45
trunk/paradiseo-mo/src/neighborhood/moRndNeighborhood.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
<moRndNeighborhood.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 _moRndNeighborhood_h
|
||||
#define _moRndNeighborhood_h
|
||||
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
template< class Neighbor >
|
||||
class moRndNeighborhood : virtual public moNeighborhood<Neighbor>{
|
||||
|
||||
public:
|
||||
|
||||
bool isRandom(){
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
111
trunk/paradiseo-mo/src/neighborhood/moRndWithReplNeighborhood.h
Normal file
111
trunk/paradiseo-mo/src/neighborhood/moRndWithReplNeighborhood.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
<moRndWithReplNeighborhood.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moRndWithReplNeighborhood_h
|
||||
#define _moRndWithReplNeighborhood_h
|
||||
|
||||
#include <neighborhood/moIndexNeighborhood.h>
|
||||
#include <neighborhood/moRndNeighborhood.h>
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
* A Random With replacement Neighborhood
|
||||
*/
|
||||
template< class N >
|
||||
class moRndWithReplNeighborhood : public moIndexNeighborhood<N>, public moRndNeighborhood<N>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef N Neighbor;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moRndWithReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize){}
|
||||
|
||||
/**
|
||||
* Test if it exist a neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @return true if the neighborhood was not empty
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT& _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization of the neighborhood
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _neighbor) {
|
||||
_neighbor.index(rng.random(neighborhoodSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the next neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _neighbor) {
|
||||
_neighbor.index(rng.random(neighborhoodSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* test if all neighbors are explore or not,if false, there is no neighbor left to explore
|
||||
* @param _solution the solution to explore
|
||||
* @return true if there is again a neighbor to explore
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moRndWithReplNeighborhood";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
<moRndWithoutReplNeighborhood.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moRndWithoutReplNeighborhood_h
|
||||
#define _moRndWithoutReplNeighborhood_h
|
||||
|
||||
#include <neighborhood/moIndexNeighborhood.h>
|
||||
#include <neighborhood/moRndNeighborhood.h>
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
* A Random without replacement Neighborhood
|
||||
*/
|
||||
template< class N >
|
||||
class moRndWithoutReplNeighborhood : public moIndexNeighborhood<N>, public moRndNeighborhood<N>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef N Neighbor;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moRndWithoutReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), maxIndex(0){
|
||||
for(unsigned int i=0; i < neighborhoodSize; i++)
|
||||
indexVector.push_back(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if it exist a neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @return true if the neighborhood was not empty
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT& _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization of the neighborhood
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _neighbor) {
|
||||
unsigned int i, tmp;
|
||||
maxIndex = neighborhoodSize ;
|
||||
i = rng.random(maxIndex);
|
||||
_neighbor.index(indexVector[i]);
|
||||
tmp=indexVector[i];
|
||||
indexVector[i]=indexVector[maxIndex-1];
|
||||
indexVector[maxIndex-1]=tmp;
|
||||
maxIndex--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the next neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _neighbor) {
|
||||
unsigned int i, tmp;
|
||||
i = rng.random(maxIndex);
|
||||
_neighbor.index(indexVector[i]);
|
||||
tmp=indexVector[i];
|
||||
indexVector[i]=indexVector[maxIndex-1];
|
||||
indexVector[maxIndex-1]=tmp;
|
||||
maxIndex--;
|
||||
}
|
||||
|
||||
/**
|
||||
* test if all neighbors are explore or not,if false, there is no neighbor left to explore
|
||||
* maxIndex is number of neighbors
|
||||
* @param _solution the solution to explore
|
||||
* @return true if there is again a neighbor to explore
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return (maxIndex > 0) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter
|
||||
* @return the position in the Neighborhood
|
||||
*/
|
||||
unsigned int position(){
|
||||
return indexVector[maxIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moRndWithoutReplNeighborhood";
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int maxIndex;
|
||||
std::vector<unsigned int> indexVector;
|
||||
};
|
||||
|
||||
#endif
|
||||
40
trunk/paradiseo-mo/src/newmo
Executable file
40
trunk/paradiseo-mo/src/newmo
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
<newmo>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 __newmo
|
||||
#define __newmo
|
||||
|
||||
#include "newmo.h"
|
||||
|
||||
#endif
|
||||
104
trunk/paradiseo-mo/src/newmo.h
Executable file
104
trunk/paradiseo-mo/src/newmo.h
Executable file
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
<newmo.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _newmo_h
|
||||
#define _newmo_h
|
||||
|
||||
#include <algo/moLocalSearch.h>
|
||||
|
||||
#include <comparator/moComparator.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
#include <continuator/moCheckpoint.h>
|
||||
#include <continuator/moContinuator.h>
|
||||
#include <continuator/moCounterMonitorSaver.h>
|
||||
#include <continuator/moDistanceStat.h>
|
||||
#include <continuator/moFitnessStat.h>
|
||||
#include <continuator/moMaxNeighborStat.h>
|
||||
#include <continuator/moMinNeighborStat.h>
|
||||
#include <continuator/moNbInfNeighborStat.h>
|
||||
#include <continuator/moNbSupNeighborStat.h>
|
||||
#include <continuator/moNeighborhoodStat.h>
|
||||
#include <continuator/moNeutralDegreeNeighborStat.h>
|
||||
#include <continuator/moSecondMomentNeighborStat.h>
|
||||
#include <continuator/moSizeNeighborStat.h>
|
||||
#include <continuator/moSolutionStat.h>
|
||||
#include <continuator/moStat.h>
|
||||
#include <continuator/moStatBase.h>
|
||||
#include <continuator/moTrueContinuator.h>
|
||||
|
||||
#include <eval/moEval.h>
|
||||
#include <eval/moFullEvalByCopy.h>
|
||||
#include <eval/moFullEvalByModif.h>
|
||||
|
||||
#include <explorer/moFirstImprExplorer.h>
|
||||
#include <explorer/moHCneutralExplorer.h>
|
||||
#include <explorer/moMetropolisHastingExplorer.h>
|
||||
#include <explorer/moNeighborhoodExplorer.h>
|
||||
#include <explorer/moRandomNeutralWalkExplorer.h>
|
||||
#include <explorer/moRandomWalkExplorer.h>
|
||||
#include <explorer/moSimpleHCexplorer.h>
|
||||
#include <explorer/moSimpleHCneutralExplorer.h>
|
||||
#include <explorer/moTSExplorer.h>
|
||||
|
||||
#include <memory/moAspiration.h>
|
||||
#include <memory/moBestImprAspiration.h>
|
||||
#include <memory/moDiversification.h>
|
||||
#include <memory/moDummyDiversification.h>
|
||||
#include <memory/moDummyIntensification.h>
|
||||
#include <memory/moIntensification.h>
|
||||
#include <memory/moMemory.h>
|
||||
#include <memory/moSolVectorTabuList.h>
|
||||
#include <memory/moTabuList.h>
|
||||
|
||||
#include <neighborhood/moBackableNeighbor.h>
|
||||
#include <neighborhood/moBitNeighbor.h>
|
||||
#include <neighborhood/moIndexNeighbor.h>
|
||||
#include <neighborhood/moIndexNeighborhood.h>
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <neighborhood/moOrderNeighborhood.h>
|
||||
#include <neighborhood/moRndNeighborhood.h>
|
||||
#include <neighborhood/moRndWithoutReplNeighborhood.h>
|
||||
#include <neighborhood/moRndWithReplNeighborhood.h>
|
||||
|
||||
//#include <old/moMove.h>
|
||||
//#include <old/moMoveIncrEval.h>
|
||||
//#include <old/moMoveInit.h>
|
||||
//#include <old/moNextMove.h>
|
||||
//#include <old/moMoveNeighbor.h>
|
||||
//#include <old/moMoveNeighborhood.h>
|
||||
|
||||
#endif
|
||||
34
trunk/paradiseo-mo/src/old/moIncrEvalWrapper.h
Normal file
34
trunk/paradiseo-mo/src/old/moIncrEvalWrapper.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef moIncrEvalWrapper_H
|
||||
#define moIncrEvalWrapper_H
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
#include <moEval.h>
|
||||
|
||||
/*
|
||||
* (Old fashioned) Incremental evaluation to use with a moMoveNeighbor
|
||||
* WARNING: Don't use this class unless you are an moMove user.
|
||||
*/
|
||||
template<class MoveNeighbor, class M>
|
||||
class moIncrEvalWrapper : public moEval<MoveNeighbor>
|
||||
{
|
||||
public:
|
||||
using moEval<BackableNeighbor>::EOT EOT;
|
||||
using moEval<BackableNeighbor>::Fitness Fitness;
|
||||
|
||||
moIncrEvalWrapper(moIncrEval<M>& _incr):incr(_incr){}
|
||||
|
||||
/*
|
||||
* make the evaluation of the current neighbor and update the information on this neighbor
|
||||
* the evaluation could be incremental
|
||||
*/
|
||||
virtual void eval(MoveNeighbor& _neighbor,EOT & _solution){
|
||||
_neighbor.fitness(incrEval(*(_neighbor.getMove()), _solution));
|
||||
}
|
||||
|
||||
private:
|
||||
/** the full evaluation object */
|
||||
moIncrEval<M> & incrEval;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
57
trunk/paradiseo-mo/src/old/moMove.h
Normal file
57
trunk/paradiseo-mo/src/old/moMove.h
Normal 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
|
||||
52
trunk/paradiseo-mo/src/old/moMoveIncrEval.h
Normal file
52
trunk/paradiseo-mo/src/old/moMoveIncrEval.h
Normal 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-mo/src/old/moMoveInit.h
Normal file
50
trunk/paradiseo-mo/src/old/moMoveInit.h
Normal 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
|
||||
69
trunk/paradiseo-mo/src/old/moMoveNeighbor.h
Normal file
69
trunk/paradiseo-mo/src/old/moMoveNeighbor.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#ifndef _moMoveNeighbor_h
|
||||
#define _moMoveNeighbor_h
|
||||
|
||||
#include <eo>
|
||||
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
#include <move/moMoveIncrEval.h>
|
||||
#include <move/moMove.h>
|
||||
|
||||
|
||||
/*
|
||||
contener of the neighbor informations
|
||||
*/
|
||||
template< class M , class Fitness >
|
||||
class moMoveNeighbor : public moNeighbor <typename M::EOType, Fitness>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
// empty constructor
|
||||
moMoveNeighbor() {
|
||||
move=new M();
|
||||
};
|
||||
|
||||
~moMoveNeighbor() {
|
||||
delete move;
|
||||
};
|
||||
|
||||
// copy constructeur
|
||||
moMoveNeighbor(const moMoveNeighbor<M, Fitness> & _n) {
|
||||
moNeighbor<EOT, Fitness>::operator=(_n);
|
||||
(*move) = *(_n.getMove());
|
||||
}
|
||||
|
||||
// assignment operator
|
||||
virtual moMoveNeighbor<M, Fitness> & operator=(const moMoveNeighbor<M, Fitness> & _n) {
|
||||
moNeighbor <EOT, Fitness>::operator=(_n);
|
||||
(*move) = *(_n.getMove());
|
||||
return *this ;
|
||||
}
|
||||
|
||||
/*
|
||||
* move the solution
|
||||
*/
|
||||
virtual void move(EOT & _solution){
|
||||
(*move)(_solution);
|
||||
}
|
||||
|
||||
/** Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const { return "moMoveNeighbor"; }
|
||||
|
||||
void setMove(M* _move){
|
||||
move=_move;
|
||||
}
|
||||
|
||||
M* getMove(){
|
||||
return move;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
M* move;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
59
trunk/paradiseo-mo/src/old/moMoveNeighborhood.h
Normal file
59
trunk/paradiseo-mo/src/old/moMoveNeighborhood.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#ifndef _moMoveNeighborhood_h
|
||||
#define _moMoveNeighborhood_h
|
||||
|
||||
#include <neighborhood/moMoveNeighbor.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
#include <move/moMoveInit.h>
|
||||
#include <move/moNextMove.h>
|
||||
|
||||
template< class M, class Fitness >
|
||||
class moMoveNeighborhood : public moNeighborhood <moMoveNeighbor<M, Fitness> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef moMoveNeighbor<M, Fitness> Neighbor;
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
moMoveNeighborhood(moMoveInit<M>& i, moNextMove<M>& n):_init(i), _next(n), isContinue(true) {}
|
||||
|
||||
virtual bool hasNeighbor(EOT & solution){
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
initialisation of the neighborhood
|
||||
*/
|
||||
virtual void init(EOT & solution, Neighbor & current){
|
||||
_init(*(current._move), solution);
|
||||
isContinue=true;
|
||||
}
|
||||
|
||||
/*
|
||||
Give the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & solution, Neighbor & current){
|
||||
isContinue=_next(*(current._move), solution);
|
||||
}
|
||||
|
||||
/*
|
||||
if false, there is no neighbor left to explore
|
||||
*/
|
||||
virtual bool cont(EOT & solution){
|
||||
return isContinue;
|
||||
}
|
||||
|
||||
/** Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const { return "moMoveNeighborhood"; }
|
||||
|
||||
private:
|
||||
moMoveInit<M>& _init;
|
||||
moNextMove<M>& _next;
|
||||
bool isContinue;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
50
trunk/paradiseo-mo/src/old/moNextMove.h
Normal file
50
trunk/paradiseo-mo/src/old/moNextMove.h
Normal 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
|
||||
84
trunk/paradiseo-mo/test/CMakeLists.txt
Normal file
84
trunk/paradiseo-mo/test/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
###############################################################################
|
||||
##
|
||||
## CMakeLists file for ParadisEO-MO/test
|
||||
##
|
||||
###############################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib)
|
||||
|
||||
######################################################################################
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your targets and link the librairies
|
||||
######################################################################################
|
||||
|
||||
|
||||
|
||||
SET (TEST_LIST
|
||||
t-moNeighbor
|
||||
t-moBitNeighbor
|
||||
t-moOrderNeighborhood
|
||||
t-moFullEvalByCopy
|
||||
t-moFullEvalByModif
|
||||
t-moNeighborComparator
|
||||
t-moSolNeighborComparator
|
||||
t-moTrueContinuator
|
||||
t-moRndWithoutReplNeighborhood
|
||||
t-moRndWithReplNeighborhood
|
||||
t-moFitnessStat
|
||||
t-moDistanceStat
|
||||
t-moNeighborhoodStat
|
||||
t-moCounterMonitorSaver
|
||||
t-moSolutionStat
|
||||
t-moCheckpoint
|
||||
t-moDummyMemory
|
||||
t-moSolVectorTabuList
|
||||
t-moBestImprAspiration
|
||||
t-moSimpleHCexplorer
|
||||
t-moSimpleHCneutralExplorer
|
||||
t-moHCneutralExplorer
|
||||
t-moFirstImprExplorer
|
||||
t-moRandomWalkExplorer
|
||||
t-moMetropolisHastingExplorer
|
||||
t-moRandomNeutralWalkExplorer
|
||||
t-moTSExplorer
|
||||
)
|
||||
|
||||
FOREACH (test ${TEST_LIST})
|
||||
SET ("T_${test}_SOURCES" "${test}.cpp")
|
||||
ENDFOREACH (test)
|
||||
|
||||
|
||||
IF(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_CMAKE_TESTING)
|
||||
|
||||
######################################################################################
|
||||
|
||||
204
trunk/paradiseo-mo/test/moTestClass.h
Normal file
204
trunk/paradiseo-mo/test/moTestClass.h
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
/*
|
||||
<moTestClass.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 _moTestClass_h
|
||||
#define _moTestClass_h
|
||||
|
||||
#include <EO.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
#include <neighborhood/moBackableNeighbor.h>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <neighborhood/moRndNeighborhood.h>
|
||||
#include <eval/moEval.h>
|
||||
|
||||
#include <ga/eoBit.h>
|
||||
#include <eoScalarFitness.h>
|
||||
#include <neighborhood/moOrderNeighborhood.h>
|
||||
#include <neighborhood/moBitNeighbor.h>
|
||||
|
||||
#include <utils/eoMonitor.h>
|
||||
#include <utils/eoUpdater.h>
|
||||
|
||||
typedef eoBit<eoMinimizingFitness> bitVector;
|
||||
typedef moBitNeighbor<eoMinimizingFitness> bitNeighbor ;
|
||||
|
||||
class moDummyRndNeighborhood: public moOrderNeighborhood<bitNeighbor>/*, public moRndNeighborhood<bitNeighbor>*/{
|
||||
public:
|
||||
moDummyRndNeighborhood(unsigned int a): moOrderNeighborhood<bitNeighbor>(a){}
|
||||
};
|
||||
|
||||
typedef moDummyRndNeighborhood bitNeighborhood ;
|
||||
|
||||
typedef EO<int> Solution;
|
||||
|
||||
class moDummyNeighbor : public moNeighbor<Solution,int>{
|
||||
public:
|
||||
virtual void move(Solution & _solution){}
|
||||
};
|
||||
|
||||
class moDummyBackableNeighbor : public moBackableNeighbor<Solution,int>{
|
||||
public:
|
||||
virtual void move(Solution & _solution){}
|
||||
virtual void moveBack(Solution & _solution){}
|
||||
};
|
||||
|
||||
class moDummyNeighborhood : public moNeighborhood<moDummyNeighbor>{
|
||||
public:
|
||||
typedef moDummyNeighbor Neighbor;
|
||||
|
||||
moDummyNeighborhood():i(0),j(0){}
|
||||
|
||||
virtual bool hasNeighbor(EOT & _solution){
|
||||
bool res;
|
||||
if(i%3==0)
|
||||
res=false;
|
||||
else
|
||||
res=true;
|
||||
i++;
|
||||
return res;
|
||||
}
|
||||
virtual void init(EOT & _solution, Neighbor & _current){}
|
||||
virtual void next(EOT & _solution, Neighbor & _current){}
|
||||
virtual bool cont(EOT & _solution){
|
||||
j++;
|
||||
return (j%10!=0);
|
||||
}
|
||||
|
||||
private:
|
||||
int i,j;
|
||||
};
|
||||
|
||||
class moDummyEval: public eoEvalFunc<Solution>{
|
||||
public:
|
||||
void operator()(Solution& _sol){
|
||||
if(_sol.invalid())
|
||||
_sol.fitness(100);
|
||||
else
|
||||
_sol.fitness(_sol.fitness()+50);
|
||||
}
|
||||
};
|
||||
|
||||
class evalOneMax : public moEval< bitNeighbor >
|
||||
{
|
||||
private:
|
||||
unsigned size;
|
||||
|
||||
public:
|
||||
evalOneMax(unsigned _size) : size(_size) {};
|
||||
|
||||
~evalOneMax(void) {} ;
|
||||
|
||||
void operator() (bitVector& _sol, bitNeighbor& _n) {
|
||||
unsigned int fit = _sol.fitness();
|
||||
if(_sol[_n.index()])
|
||||
fit--;
|
||||
else
|
||||
fit++;
|
||||
_n.fitness(fit);
|
||||
}
|
||||
};
|
||||
|
||||
class dummyEvalOneMax : public moEval< bitNeighbor >
|
||||
{
|
||||
private:
|
||||
unsigned size;
|
||||
|
||||
public:
|
||||
dummyEvalOneMax(unsigned _size) : size(_size) {};
|
||||
|
||||
~dummyEvalOneMax(void) {} ;
|
||||
|
||||
void operator() (bitVector& _sol, bitNeighbor& _n) {
|
||||
unsigned int fit = _sol.fitness();
|
||||
_n.fitness(fit);
|
||||
}
|
||||
};
|
||||
|
||||
class monitor1 : public eoMonitor
|
||||
{
|
||||
public:
|
||||
|
||||
monitor1(unsigned int& _a): a(_a){}
|
||||
|
||||
eoMonitor& operator()(){
|
||||
a++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void lastCall(){
|
||||
a++;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int& a;
|
||||
};
|
||||
|
||||
class monitor2 : public eoMonitor
|
||||
{
|
||||
public:
|
||||
|
||||
monitor2(unsigned int& _a): a(_a){}
|
||||
|
||||
eoMonitor& operator()(){
|
||||
a++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void lastCall(){
|
||||
a++;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int& a;
|
||||
};
|
||||
|
||||
class updater1: public eoUpdater
|
||||
{
|
||||
public:
|
||||
updater1(unsigned int& _a): a(_a){}
|
||||
|
||||
void operator()(){
|
||||
a++;
|
||||
}
|
||||
|
||||
void lastCall(){
|
||||
a++;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int& a;
|
||||
};
|
||||
|
||||
#endif
|
||||
78
trunk/paradiseo-mo/test/t-moBestImprAspiration.cpp
Normal file
78
trunk/paradiseo-mo/test/t-moBestImprAspiration.cpp
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
<t-moBestImprAspiration.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <memory/moBestImprAspiration.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moBestImprAspiration] => START" << std::endl;
|
||||
|
||||
moBestImprAspiration<bitNeighbor> test;
|
||||
eoBit<eoMinimizingFitness> sol1(4);
|
||||
eoBit<eoMinimizingFitness> sol2(4);
|
||||
eoBit<eoMinimizingFitness> sol3(4);
|
||||
eoBit<eoMinimizingFitness> sol4(4);
|
||||
bitNeighbor n1;
|
||||
bitNeighbor n2;
|
||||
bitNeighbor n3;
|
||||
bitNeighbor n4;
|
||||
|
||||
sol3[0]=true;
|
||||
sol4[3]=true;
|
||||
|
||||
sol1.fitness(4);
|
||||
sol2.fitness(5);
|
||||
sol3.fitness(3);
|
||||
sol4.fitness(3);
|
||||
n1.fitness(4);
|
||||
n2.fitness(5);
|
||||
n3.fitness(3);
|
||||
n4.fitness(3);
|
||||
|
||||
|
||||
//verification qu'on update bien le best so far quand il faut
|
||||
test.init(sol1);
|
||||
assert(test.getBest()==sol1);
|
||||
assert(!test(sol2,n2));
|
||||
assert(test(sol3,n3));
|
||||
test.update(sol3,n3);
|
||||
assert(test.getBest()==sol3);
|
||||
assert(!test(sol4,n4));
|
||||
test.update(sol4,n4);
|
||||
assert(test.getBest()==sol3);
|
||||
|
||||
std::cout << "[t-moBestImprAspiration] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
85
trunk/paradiseo-mo/test/t-moBitNeighbor.cpp
Normal file
85
trunk/paradiseo-mo/test/t-moBitNeighbor.cpp
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
<t-moBitNeighborh.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 <neighborhood/moBitNeighbor.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moBitNeighbor] => START" << std::endl;
|
||||
|
||||
//init sol
|
||||
eoBit<int> sol;
|
||||
sol.push_back(true);
|
||||
sol.push_back(false);
|
||||
sol.push_back(true);
|
||||
|
||||
//verif du constructeur vide
|
||||
moBitNeighbor<int> test1;
|
||||
assert(test1.index()==0);
|
||||
|
||||
//verif du setter d'index et du constructeur de copy
|
||||
test1.index(6);
|
||||
test1.fitness(2);
|
||||
moBitNeighbor<int> test2(test1);
|
||||
assert(test2.index()==6);
|
||||
assert(test2.fitness()==2);
|
||||
|
||||
//verif du getter
|
||||
assert(test1.index()==6);
|
||||
|
||||
//verif de l'operateur=
|
||||
test1.fitness(8);
|
||||
test1.index(2);
|
||||
test2=test1;
|
||||
assert(test2.fitness()==8);
|
||||
assert(test2.index()==2);
|
||||
|
||||
//verif de move
|
||||
test2.move(sol);
|
||||
assert(!sol[2]);
|
||||
|
||||
//verif de moveBack
|
||||
test2.moveBack(sol);
|
||||
assert(sol[2]);
|
||||
|
||||
test1.printOn(std::cout);
|
||||
test2.printOn(std::cout);
|
||||
|
||||
assert(test1.className()=="moBitNeighbor");
|
||||
std::cout << "[t-moBitNeighbor] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
122
trunk/paradiseo-mo/test/t-moCheckpoint.cpp
Normal file
122
trunk/paradiseo-mo/test/t-moCheckpoint.cpp
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
<t-moCheckpoint.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <continuator/moCheckpoint.h>
|
||||
#include <continuator/moTrueContinuator.h>
|
||||
#include <continuator/moSolutionStat.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moCheckpoint] => START" << std::endl;
|
||||
|
||||
unsigned int a=2;
|
||||
unsigned int b=15;
|
||||
unsigned int c= 10;
|
||||
unsigned int d= 47;
|
||||
|
||||
eoBit<eoMinimizingFitness> s(3);
|
||||
s[0]=true;
|
||||
s[1]=true;
|
||||
s[2]=false;
|
||||
|
||||
s.fitness(17);
|
||||
|
||||
|
||||
//verification que toutes les operateurs sont bien apellés
|
||||
moSolutionStat< eoBit< eoMinimizingFitness > > stat;
|
||||
updater1 up1(a);
|
||||
updater1 up2(b);
|
||||
monitor1 mon1(c);
|
||||
monitor2 mon2(d);
|
||||
moTrueContinuator< bitNeighborhood > cont;
|
||||
|
||||
moCheckpoint< bitNeighborhood> test1(cont);
|
||||
moCheckpoint< bitNeighborhood> test2(cont, 3);
|
||||
|
||||
test1.add(up1);
|
||||
test1.add(up2);
|
||||
test1.add(mon1);
|
||||
test1.add(mon2);
|
||||
test1.add(stat);
|
||||
|
||||
test2.add(up1);
|
||||
test2.add(up2);
|
||||
test2.add(mon1);
|
||||
test2.add(mon2);
|
||||
test2.add(stat);
|
||||
|
||||
test1.init(s);
|
||||
test1(s);
|
||||
assert(a==3 && b==16 && c==11 && d==48);
|
||||
assert(stat.value()[0]);
|
||||
assert(stat.value()[1]);
|
||||
assert(!stat.value()[2]);
|
||||
assert(stat.value().fitness()==17);
|
||||
|
||||
test1(s);
|
||||
assert(a==4 && b==17 && c==12 && d==49);
|
||||
assert(stat.value()[0]);
|
||||
assert(stat.value()[1]);
|
||||
assert(!stat.value()[2]);
|
||||
assert(stat.value().fitness()==17);
|
||||
|
||||
s.fitness(4);
|
||||
|
||||
test2.init(s);
|
||||
test2(s);
|
||||
assert(a==5 && b==18 && c==13 && d==50);
|
||||
assert(stat.value()[0]);
|
||||
assert(stat.value()[1]);
|
||||
assert(!stat.value()[2]);
|
||||
assert(stat.value().fitness()==4);
|
||||
|
||||
s.fitness(6);
|
||||
test2(s);
|
||||
assert(stat.value().fitness()==4);
|
||||
test2(s);
|
||||
assert(stat.value().fitness()==4);
|
||||
test2(s);
|
||||
assert(stat.value().fitness()==6);
|
||||
|
||||
test1.lastCall(s);
|
||||
assert(a==9 && b==22 && c==17 && d==54);
|
||||
test2.lastCall(s);
|
||||
assert(a==10 && b==23 && c==18 && d==55);
|
||||
|
||||
assert(test1.className()=="moCheckpoint");
|
||||
std::cout << "[t-moCheckpoint] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
71
trunk/paradiseo-mo/test/t-moCounterMonitorSaver.cpp
Normal file
71
trunk/paradiseo-mo/test/t-moCounterMonitorSaver.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
<t-moCounterMonitorSaver.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <continuator/moCounterMonitorSaver.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moCounterMonitorSaver] => START" << std::endl;
|
||||
|
||||
unsigned int a=1;
|
||||
unsigned int b=10;
|
||||
|
||||
monitor1 mon1(a);
|
||||
monitor2 mon2(b);
|
||||
|
||||
moCounterMonitorSaver test(3, mon1);
|
||||
test.add(mon2);
|
||||
|
||||
//on verifie qu'on apelle les moniteurs seulement tout les 3 itération
|
||||
|
||||
test();
|
||||
assert(a==2 && b==11);
|
||||
test();
|
||||
assert(a==2 && b==11);
|
||||
test();
|
||||
assert(a==2 && b==11);
|
||||
test();
|
||||
assert(a==3 && b==12);
|
||||
|
||||
//test du lastCall
|
||||
test.lastCall();
|
||||
assert(a==4 && b==13);
|
||||
|
||||
assert(test.className()=="moCounterMonitorSaver");
|
||||
std::cout << "[t-moCounterMonitorSaver] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
73
trunk/paradiseo-mo/test/t-moDistanceStat.cpp
Normal file
73
trunk/paradiseo-mo/test/t-moDistanceStat.cpp
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
<t-moDistanceStat.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <neighborhood/moBitNeighbor.h>
|
||||
#include <continuator/moDistanceStat.h>
|
||||
#include <utils/eoDistance.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moDistanceStat] => START" << std::endl;
|
||||
|
||||
eoBit<int> sol1;
|
||||
eoBit<int> sol2;
|
||||
eoBit<int> sol3;
|
||||
sol1.push_back(true);
|
||||
sol1.push_back(false);
|
||||
sol1.push_back(true);
|
||||
|
||||
sol2.push_back(true);
|
||||
sol2.push_back(true);
|
||||
sol2.push_back(false);
|
||||
|
||||
sol3.push_back(true);
|
||||
sol3.push_back(true);
|
||||
sol3.push_back(true);
|
||||
|
||||
//verification de la stat avec une distance de Hamming
|
||||
|
||||
eoHammingDistance< eoBit<int> > dist;
|
||||
|
||||
moDistanceStat< eoBit<int> > test(dist, sol1);
|
||||
|
||||
test(sol2);
|
||||
assert(test.value()==2);
|
||||
test(sol3);
|
||||
assert(test.value()==1);
|
||||
|
||||
assert(test.className()=="moDistanceStat");
|
||||
std::cout << "[t-moDistanceStat] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
63
trunk/paradiseo-mo/test/t-moDummyMemory.cpp
Normal file
63
trunk/paradiseo-mo/test/t-moDummyMemory.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
<t-moDummyMemory.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <memory/moDummyIntensification.h>
|
||||
#include <memory/moDummyDiversification.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moDummyMemory] => START" << std::endl;
|
||||
|
||||
eoBit<eoMinimizingFitness> sol(4);
|
||||
bitNeighbor n;
|
||||
moDummyDiversification<bitNeighbor> test1;
|
||||
test1.init(sol);
|
||||
test1.add(sol, n);
|
||||
test1.update(sol, n);
|
||||
test1.clearMemory();
|
||||
assert(!test1(sol));
|
||||
|
||||
moDummyIntensification<bitNeighbor> test2;
|
||||
test2.init(sol);
|
||||
test2.add(sol, n);
|
||||
test2.update(sol, n);
|
||||
test2.clearMemory();
|
||||
assert(!test2(sol));
|
||||
|
||||
|
||||
std::cout << "[t-moDummyMemory] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
93
trunk/paradiseo-mo/test/t-moFirstImprExplorer.cpp
Normal file
93
trunk/paradiseo-mo/test/t-moFirstImprExplorer.cpp
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
<t-moFirstImprExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
#include <explorer/moFirstImprExplorer.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moFirstImprExplorer] => START" << std::endl;
|
||||
|
||||
//Instanciation
|
||||
eoBit<eoMinimizingFitness> sol(4, true);
|
||||
sol.fitness(4);
|
||||
bitNeighborhood nh(4);
|
||||
evalOneMax eval(4);
|
||||
moNeighborComparator<bitNeighbor> ncomp;
|
||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||
|
||||
moFirstImprExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp);
|
||||
|
||||
//on verifie qu'on améliore peut continuer à explorer tant qu'on améliore la solution
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==3);
|
||||
assert(!sol[0]);
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==2);
|
||||
assert(!sol[1]);
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==1);
|
||||
assert(!sol[2]);
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==0);
|
||||
assert(!sol[3]);
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
test(sol);
|
||||
assert(!test.accept(sol));
|
||||
assert(sol.fitness()==0);
|
||||
assert(!test.isContinue(sol));
|
||||
|
||||
std::cout << "[t-moFirstImprExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
57
trunk/paradiseo-mo/test/t-moFitnessStat.cpp
Normal file
57
trunk/paradiseo-mo/test/t-moFitnessStat.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
<t-moFitnessStat.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <continuator/moFitnessStat.h>
|
||||
#include <neighborhood/moBitNeighbor.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moFitnessStat] => START" << std::endl;
|
||||
|
||||
eoBit<int> sol;
|
||||
|
||||
moFitnessStat< eoBit<int> > test;
|
||||
sol.fitness(3);
|
||||
test(sol);
|
||||
assert(test.value()==3);
|
||||
|
||||
sol.fitness(12);
|
||||
test(sol);
|
||||
assert(test.value()==12);
|
||||
|
||||
assert(test.className()=="moFitnessStat");
|
||||
std::cout << "[t-moFitnessStat] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
63
trunk/paradiseo-mo/test/t-moFullEvalByCopy.cpp
Normal file
63
trunk/paradiseo-mo/test/t-moFullEvalByCopy.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
<t-moFullEvalByCopy.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 "moTestClass.h"
|
||||
#include <eval/moFullEvalByCopy.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
|
||||
|
||||
std::cout << "[t-moFullEvalByCopy] => START" << std::endl;
|
||||
|
||||
Solution sol;
|
||||
moDummyNeighbor neighbor;
|
||||
moDummyEval eval;
|
||||
|
||||
//verif constructor
|
||||
moFullEvalByCopy<moDummyNeighbor> test(eval);
|
||||
|
||||
sol.fitness(3);
|
||||
|
||||
//verif operator()
|
||||
test(sol,neighbor);
|
||||
assert(sol.fitness()==3);
|
||||
|
||||
std::cout << "[t-moFullEvalByCopy] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
63
trunk/paradiseo-mo/test/t-moFullEvalByModif.cpp
Normal file
63
trunk/paradiseo-mo/test/t-moFullEvalByModif.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
<t-moFullEvalByModif.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 "moTestClass.h"
|
||||
#include <eval/moFullEvalByModif.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
|
||||
|
||||
std::cout << "[t-moFullEvalByModif] => START" << std::endl;
|
||||
|
||||
Solution sol;
|
||||
moDummyBackableNeighbor neighbor;
|
||||
moDummyEval eval;
|
||||
|
||||
//verif constructor
|
||||
moFullEvalByModif<moDummyBackableNeighbor> test(eval);
|
||||
|
||||
sol.fitness(3);
|
||||
|
||||
//verif operator()
|
||||
test(sol,neighbor);
|
||||
assert(sol.fitness()==3);
|
||||
|
||||
std::cout << "[t-moFullEvalByModif] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
92
trunk/paradiseo-mo/test/t-moHCneutralExplorer.cpp
Normal file
92
trunk/paradiseo-mo/test/t-moHCneutralExplorer.cpp
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
<t-moHCneutralExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
#include <explorer/moHCneutralExplorer.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moHCneutralExplorer] => START" << std::endl;
|
||||
|
||||
//Instanciation
|
||||
eoBit<eoMinimizingFitness> sol(4, true);
|
||||
sol.fitness(4);
|
||||
bitNeighborhood nh(4);
|
||||
evalOneMax eval(4);
|
||||
moNeighborComparator<bitNeighbor> ncomp;
|
||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||
|
||||
moHCneutralExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp,3);
|
||||
|
||||
//on verifie qu'on ameliore bien la solution et que l'exploration dure 3 itérations
|
||||
|
||||
test.initParam(sol);
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==3);
|
||||
test.updateParam(sol);
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
//les affichages permettent de voir qu'on prend pas toujours les mm voisins(lancer plusieurs fois l'exe)
|
||||
std::cout << sol << std::endl;
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==2);
|
||||
test.updateParam(sol);
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
|
||||
std::cout << sol << std::endl;
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==1);
|
||||
test.updateParam(sol);
|
||||
assert(!test.isContinue(sol));
|
||||
|
||||
|
||||
std::cout << sol << std::endl;
|
||||
|
||||
|
||||
|
||||
std::cout << "[t-moHCneutralExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
97
trunk/paradiseo-mo/test/t-moMetropolisHastingExplorer.cpp
Normal file
97
trunk/paradiseo-mo/test/t-moMetropolisHastingExplorer.cpp
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
<t-moMetropolisHastingExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <explorer/moMetropolisHastingExplorer.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moMetropolisHastingExplorer] => START" << std::endl;
|
||||
|
||||
//Instanciation
|
||||
eoBit<eoMinimizingFitness> sol(4, true);
|
||||
sol.fitness(4);
|
||||
bitNeighborhood nh(4);
|
||||
evalOneMax eval(4);
|
||||
moNeighborComparator<bitNeighbor> ncomp;
|
||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||
|
||||
moMetropolisHastingExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp, 3);
|
||||
|
||||
//test de l'acceptation d'un voisin améliorant
|
||||
test.initParam(sol);
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==3);
|
||||
test.updateParam(sol);
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
unsigned int oui=0, non=0;
|
||||
|
||||
//test de l'acceptation d'un voisin non améliorant
|
||||
for(unsigned int i=0; i<1000; i++){
|
||||
test(sol);
|
||||
if(test.accept(sol))
|
||||
oui++;
|
||||
else
|
||||
non++;
|
||||
}
|
||||
std::cout << "Attention test en fonction d'une proba \"p\" uniforme dans [0,1] , oui si p < 3/4, non sinon -> resultat sur 1000 essai" << std::endl;
|
||||
std::cout << "oui: " << oui << std::endl;
|
||||
std::cout << "non: " << non << std::endl;
|
||||
|
||||
assert(oui > 700 && oui < 800); //verification grossiere
|
||||
|
||||
//test du critere d'arret
|
||||
test.updateParam(sol);
|
||||
assert(test.isContinue(sol));
|
||||
test.updateParam(sol);
|
||||
assert(!test.isContinue(sol));
|
||||
|
||||
//test de l'acceptation d'un voisin
|
||||
sol[0]=false;
|
||||
sol[1]=false;
|
||||
sol[2]=false;
|
||||
sol[3]=false;
|
||||
sol.fitness(0);
|
||||
|
||||
test.initParam(sol);
|
||||
test(sol);
|
||||
assert(!test.accept(sol));
|
||||
|
||||
std::cout << "[t-moMetropolisHastingExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
64
trunk/paradiseo-mo/test/t-moNeighbor.cpp
Normal file
64
trunk/paradiseo-mo/test/t-moNeighbor.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
<t-moNeighbor.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 "moTestClass.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moNeighbor] => START" << std::endl;
|
||||
|
||||
//test constructor
|
||||
moDummyNeighbor test1, test2;
|
||||
|
||||
test1.fitness(3);
|
||||
//test operateur d'affectation
|
||||
test2=test1;
|
||||
assert(test1.fitness()==test2.fitness());
|
||||
|
||||
//test operateur de copy
|
||||
moDummyNeighbor test3(test1);
|
||||
assert(test1.fitness()==test3.fitness());
|
||||
|
||||
test1.printOn(std::cout);
|
||||
test2.printOn(std::cout);
|
||||
test3.printOn(std::cout);
|
||||
|
||||
assert(test1.className()=="moNeighbor");
|
||||
std::cout << "[t-moNeighbor] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
68
trunk/paradiseo-mo/test/t-moNeighborComparator.cpp
Normal file
68
trunk/paradiseo-mo/test/t-moNeighborComparator.cpp
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
<t-moNeighborComparator.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 <neighborhood/moBitNeighbor.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <ga/eoBit.h>
|
||||
#include <eoScalarFitness.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moNeighborComparator] => START" << std::endl;
|
||||
|
||||
|
||||
moBitNeighbor<eoMinimizingFitness> neighbor1;
|
||||
moBitNeighbor<eoMinimizingFitness> neighbor2;
|
||||
|
||||
moNeighborComparator< moBitNeighbor<eoMinimizingFitness> > test;
|
||||
|
||||
neighbor1.fitness(3);
|
||||
neighbor2.fitness(2);
|
||||
//test with a minimizing fitness neighbor2 must be better than neighbor1 and reversly
|
||||
assert(test(neighbor1, neighbor2));
|
||||
assert(!test(neighbor2, neighbor1));
|
||||
|
||||
//test equals
|
||||
assert(!test.equals(neighbor1,neighbor2));
|
||||
|
||||
neighbor2.fitness(3);
|
||||
assert(test.equals(neighbor1,neighbor2));
|
||||
|
||||
assert(test.className()=="moNeighborComparator");
|
||||
std::cout << "[t-moNeighborComparator] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
152
trunk/paradiseo-mo/test/t-moNeighborhoodStat.cpp
Normal file
152
trunk/paradiseo-mo/test/t-moNeighborhoodStat.cpp
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
<t-moNeighborhoodStat.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <continuator/moNeighborhoodStat.h>
|
||||
#include <continuator/moMaxNeighborStat.h>
|
||||
#include <continuator/moMinNeighborStat.h>
|
||||
#include <continuator/moNbInfNeighborStat.h>
|
||||
#include <continuator/moNbSupNeighborStat.h>
|
||||
#include <continuator/moNeutralDegreeNeighborStat.h>
|
||||
#include <continuator/moSecondMomentNeighborStat.h>
|
||||
#include <continuator/moSizeNeighborStat.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
/*
|
||||
* Tests all classes depending of moNeighborhoodStat.h
|
||||
*/
|
||||
int main(){
|
||||
|
||||
//test de moNeighborhoodStat.h
|
||||
std::cout << "[t-moNeighborhoodStat] => START" << std::endl;
|
||||
|
||||
moNeighborComparator<bitNeighbor> neighborComp;
|
||||
moSolNeighborComparator<bitNeighbor> solNeighborComp;
|
||||
evalOneMax eval(10);
|
||||
|
||||
bitNeighborhood n(10);
|
||||
|
||||
bitVector sol;
|
||||
|
||||
sol.push_back(true);
|
||||
sol.push_back(false);
|
||||
sol.push_back(true);
|
||||
sol.push_back(true);
|
||||
sol.push_back(false);
|
||||
sol.push_back(true);
|
||||
sol.push_back(false);
|
||||
sol.push_back(true);
|
||||
sol.push_back(true);
|
||||
sol.push_back(true);
|
||||
|
||||
sol.fitness(7);
|
||||
|
||||
|
||||
moNeighborhoodStat<bitNeighborhood> test(n, eval, neighborComp, solNeighborComp);
|
||||
|
||||
test(sol);
|
||||
|
||||
assert(test.getMin()==8);
|
||||
assert(test.getMax()==6);
|
||||
assert(test.getMean()==6.6);
|
||||
double sd=test.getSD();
|
||||
assert(test.getSD()>0.966 && test.getSD()<0.967);
|
||||
assert(test.getSize()==10);
|
||||
assert(test.getNbSup()==7);
|
||||
assert(test.getNbInf()==3);
|
||||
assert(test.getNbEqual()==0);
|
||||
|
||||
assert(test.className()=="moNeighborhoodStat");
|
||||
std::cout << "[t-moNeighborhoodStat] => OK" << std::endl;
|
||||
|
||||
//test of moMaxNeighborStat.h
|
||||
std::cout << "[t-moMaxNeighborStat] => START" << std::endl;
|
||||
moMaxNeighborStat<bitNeighborhood> test2(test);
|
||||
test2(sol);
|
||||
assert(test2.value()==6);
|
||||
assert(test2.className()=="moMaxNeighborStat");
|
||||
std::cout << "[t-moMaxNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moMinNeighborStat.h
|
||||
std::cout << "[t-moMinNeighborStat] => START" << std::endl;
|
||||
moMinNeighborStat<bitNeighborhood> test3(test);
|
||||
test3(sol);
|
||||
assert(test3.value()==8);
|
||||
assert(test3.className()=="moMinNeighborStat");
|
||||
std::cout << "[t-moMinNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moNbInfNeighborStat.h
|
||||
std::cout << "[t-moNbInfNeighborStat] => START" << std::endl;
|
||||
moNbInfNeighborStat<bitNeighborhood> test4(test);
|
||||
test4(sol);
|
||||
assert(test4.value()==3);
|
||||
assert(test4.className()=="moNbInfNeighborStat");
|
||||
std::cout << "[t-moNbInfNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moNbSupNeighborStat.h
|
||||
std::cout << "[t-moNbSupNeighborStat] => START" << std::endl;
|
||||
moNbSupNeighborStat<bitNeighborhood> test5(test);
|
||||
test5(sol);
|
||||
assert(test5.value()==7);
|
||||
assert(test5.className()=="moNbSupNeighborStat");
|
||||
std::cout << "[t-moNbSupNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moNeutralDegreeNeighborStat.h
|
||||
std::cout << "[t-moNeutralDegreeNeighborStat] => START" << std::endl;
|
||||
moNeutralDegreeNeighborStat<bitNeighborhood> test6(test);
|
||||
test6(sol);
|
||||
assert(test6.value()==0);
|
||||
assert(test6.className()=="moNeutralDegreeNeighborStat");
|
||||
std::cout << "[t-moNeutralDegreeNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moSecondMomentNeighborStat.h
|
||||
std::cout << "[t-moSecondMomentNeighborStat] => START" << std::endl;
|
||||
moSecondMomentNeighborStat<bitNeighborhood> test7(test);
|
||||
test7(sol);
|
||||
assert(test7.value().first==6.6);
|
||||
assert(test7.value().second > 0.966 && test7.value().second < 0.967);
|
||||
assert(test7.className()=="moSecondMomentNeighborStat");
|
||||
std::cout << "[t-moSecondMomentNeighborStat] => OK" << std::endl;
|
||||
|
||||
//test of moSizeNeighborStat.h
|
||||
std::cout << "[t-moSizeNeighborStat] => START" << std::endl;
|
||||
moSizeNeighborStat<bitNeighborhood> test8(test);
|
||||
test8(sol);
|
||||
assert(test8.value()==10);
|
||||
assert(test8.className()=="moSizeNeighborStat");
|
||||
std::cout << "[t-moSizeNeighborStat] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
80
trunk/paradiseo-mo/test/t-moOrderNeighborhood.cpp
Normal file
80
trunk/paradiseo-mo/test/t-moOrderNeighborhood.cpp
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
<t-moOrderNeighborhood.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 <neighborhood/moOrderNeighborhood.h>
|
||||
#include <neighborhood/moBitNeighbor.h>
|
||||
#include <ga/eoBit.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moOrderNeighborhood] => START" << std::endl;
|
||||
|
||||
//init sol
|
||||
eoBit<int> sol;
|
||||
sol.push_back(true);
|
||||
sol.push_back(false);
|
||||
sol.push_back(true);
|
||||
|
||||
moBitNeighbor<int> neighbor;
|
||||
|
||||
//verif du constructeur vide
|
||||
moOrderNeighborhood<moBitNeighbor<int> > test(3);
|
||||
assert(test.position()==0);
|
||||
|
||||
//verif du hasneighbor
|
||||
assert(test.hasNeighbor(sol));
|
||||
|
||||
//verif de init
|
||||
test.init(sol, neighbor);
|
||||
assert(neighbor.index()==0);
|
||||
assert(test.position()==0);
|
||||
|
||||
//verif du next
|
||||
test.next(sol, neighbor);
|
||||
assert(neighbor.index()==1);
|
||||
assert(test.position()==1);
|
||||
|
||||
//verif du cont
|
||||
assert(test.cont(sol));
|
||||
test.next(sol, neighbor);
|
||||
assert(!test.cont(sol));
|
||||
|
||||
assert(test.className()=="moOrderNeighborhood");
|
||||
|
||||
std::cout << "[t-moOrderNeighborhood] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
88
trunk/paradiseo-mo/test/t-moRandomNeutralWalkExplorer.cpp
Normal file
88
trunk/paradiseo-mo/test/t-moRandomNeutralWalkExplorer.cpp
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
<t-moRandomNeutralWalkExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <explorer/moRandomNeutralWalkExplorer.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moRandomNeutralWalkExplorer] => START" << std::endl;
|
||||
|
||||
eoBit<eoMinimizingFitness> sol(4, true);
|
||||
sol.fitness(4);
|
||||
bitNeighborhood nh(4);
|
||||
evalOneMax eval(4);
|
||||
dummyEvalOneMax eval2(4);
|
||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||
|
||||
//test avec la fonction d'eval classique
|
||||
//on verifie qu'on ne trouve pas de voisin de mm fitness
|
||||
moRandomNeutralWalkExplorer<bitNeighborhood> test(nh, eval, sncomp, 3);
|
||||
|
||||
test.initParam(sol);
|
||||
test(sol);
|
||||
assert(!test.accept(sol));
|
||||
assert(!test.isContinue(sol));
|
||||
|
||||
//test avec une fonction d'eval bidon qui renvoie toujours la mm fitness
|
||||
//on peut donc verifier qu'on s'arette au bout des 3 itérations.
|
||||
moRandomNeutralWalkExplorer<bitNeighborhood> test2(nh, eval2, sncomp, 3);
|
||||
|
||||
sol.fitness(2);
|
||||
test2.initParam(sol);
|
||||
test2(sol);
|
||||
assert(test2.accept(sol));
|
||||
test2.move(sol);
|
||||
assert(sol.fitness()==2);
|
||||
test2.updateParam(sol);
|
||||
assert(test2.isContinue(sol));
|
||||
|
||||
test2(sol);
|
||||
assert(test2.accept(sol));
|
||||
test2.move(sol);
|
||||
assert(sol.fitness()==2);
|
||||
test2.updateParam(sol);
|
||||
assert(test2.isContinue(sol));
|
||||
|
||||
test2(sol);
|
||||
assert(test2.accept(sol));
|
||||
test2.move(sol);
|
||||
assert(sol.fitness()==2);
|
||||
test2.updateParam(sol);
|
||||
assert(!test2.isContinue(sol));
|
||||
|
||||
std::cout << "[t-moRandomNeutralWalkExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
79
trunk/paradiseo-mo/test/t-moRandomWalkExplorer.cpp
Normal file
79
trunk/paradiseo-mo/test/t-moRandomWalkExplorer.cpp
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
<t-moRandomWalkExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <explorer/moRandomWalkExplorer.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moRandomWalkExplorer] => START" << std::endl;
|
||||
|
||||
eoBit<eoMinimizingFitness> sol(4, true);
|
||||
sol.fitness(4);
|
||||
bitNeighborhood nh(4);
|
||||
evalOneMax eval(4);
|
||||
|
||||
//test avec un neighbordhood ordonné
|
||||
//Du coup on verifie juste qu'on a bien une evolution de la solution et qu'on fait 3 pas avant d'arreter l'exploration
|
||||
moRandomWalkExplorer<bitNeighborhood> test(nh, eval, 3);
|
||||
|
||||
test.initParam(sol);
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==3);
|
||||
test.updateParam(sol);
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==4);
|
||||
test.updateParam(sol);
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==3);
|
||||
assert(!sol[0]);
|
||||
test.updateParam(sol);
|
||||
assert(!test.isContinue(sol));
|
||||
|
||||
std::cout << "[t-moRandomWalkExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
75
trunk/paradiseo-mo/test/t-moRndWithReplNeighborhood.cpp
Normal file
75
trunk/paradiseo-mo/test/t-moRndWithReplNeighborhood.cpp
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
<t-moRndWithReplNeighborhood.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <neighborhood/moRndWithReplNeighborhood.h>
|
||||
#include <neighborhood/moBitNeighbor.h>
|
||||
|
||||
#include "moTestClass.h"
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moRndWithReplNeighborhood] => START" << std::endl;
|
||||
|
||||
unsigned int a, b;
|
||||
eoBit<int> sol;
|
||||
moBitNeighbor<int> n;
|
||||
|
||||
moRndWithReplNeighborhood< moBitNeighbor<int> > test(3);
|
||||
moRndWithReplNeighborhood< moBitNeighbor<int> > test2(0);
|
||||
|
||||
assert(test.hasNeighbor(sol));
|
||||
assert(!test2.hasNeighbor(sol));
|
||||
|
||||
test.init(sol,n);
|
||||
|
||||
//on s'assure qu'on a bien toujours bien l'index 0, 1 ou 2 qui est renvoyé
|
||||
for(unsigned int i=0; i<100; i++){
|
||||
|
||||
a=n.index();
|
||||
test.next(sol,n);
|
||||
b=n.index();
|
||||
|
||||
assert(a==0 || a==1 || a==2);
|
||||
assert(b==0 || b==1 || b==2);
|
||||
assert(test.cont(sol));
|
||||
assert(!test2.cont(sol));
|
||||
assert(test.cont(sol));
|
||||
|
||||
}
|
||||
|
||||
assert(test.className()=="moRndWithReplNeighborhood");
|
||||
|
||||
std::cout << "[t-moRndWithReplNeighborhood] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
76
trunk/paradiseo-mo/test/t-moRndWithoutReplNeighborhood.cpp
Normal file
76
trunk/paradiseo-mo/test/t-moRndWithoutReplNeighborhood.cpp
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
<t-moRndWithoutReplNeighborhood.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <neighborhood/moRndWithoutReplNeighborhood.h>
|
||||
#include <neighborhood/moBitNeighbor.h>
|
||||
|
||||
#include "moTestClass.h"
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moRndWithoutReplNeighborhood] => START" << std::endl;
|
||||
|
||||
unsigned int a, b, c;
|
||||
eoBit<int> sol;
|
||||
moBitNeighbor<int> n;
|
||||
|
||||
//instanciation
|
||||
moRndWithoutReplNeighborhood< moBitNeighbor<int> > test(3);
|
||||
moRndWithoutReplNeighborhood< moBitNeighbor<int> > test2(0);
|
||||
|
||||
//on verifie que test a bien des voisins et que test2 n'en a pas
|
||||
assert(test.hasNeighbor(sol));
|
||||
assert(!test2.hasNeighbor(sol));
|
||||
|
||||
//on recupere successivement les index
|
||||
test.init(sol, n);
|
||||
assert(test.cont(sol));
|
||||
a=test.position();
|
||||
test.next(sol, n);
|
||||
assert(test.cont(sol));
|
||||
b=test.position();
|
||||
test.next(sol,n);
|
||||
assert(!test.cont(sol));
|
||||
c=test.position();
|
||||
|
||||
//on s'assure qu'on a bien 0, 1 et 2 (dans un ordre aléatoire)
|
||||
assert(a==0 || b==0 || c==0);
|
||||
assert(a==1 || b==1 || c==1);
|
||||
assert(a==2 || b==2 || c==2);
|
||||
|
||||
assert(test.className()=="moRndWithoutReplNeighborhood");
|
||||
|
||||
std::cout << "[t-moRndWithoutReplNeighborhood] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
92
trunk/paradiseo-mo/test/t-moSimpleHCexplorer.cpp
Normal file
92
trunk/paradiseo-mo/test/t-moSimpleHCexplorer.cpp
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
<t-moSimpleHCexplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 "moTestClass.h"
|
||||
#include <eval/moFullEvalByCopy.h>
|
||||
#include <explorer/moSimpleHCexplorer.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval
|
||||
|
||||
std::cout << "[t-moSimpleHCexplorer] => START" << std::endl;
|
||||
|
||||
Solution sol;
|
||||
moDummyNeighbor neighbor;
|
||||
moDummyEval eval;
|
||||
moDummyNeighborhood nh;
|
||||
moFullEvalByCopy<moDummyNeighbor> fulleval(eval);
|
||||
moNeighborComparator<moDummyNeighbor> comp;
|
||||
moSolNeighborComparator<moDummyNeighbor> solNeighborComp;
|
||||
|
||||
//verif constructor
|
||||
moSimpleHCexplorer<moDummyNeighborhood> test(nh, fulleval, comp, solNeighborComp);
|
||||
|
||||
//verif operator() et accept: le neigorhood est construit pour qu'on tombe dans les 3 cas suivants:
|
||||
//hasNeighbor() retourne faux a l'entrée de l'operator() donc on doit pas continuer
|
||||
sol.fitness(3);
|
||||
test(sol);
|
||||
test.accept(sol);
|
||||
assert(!test.isContinue(sol));
|
||||
|
||||
//hasNeighbor() retourne faux a l'entrée de accept() donc on doit pas continuer
|
||||
test(sol);
|
||||
test.accept(sol);
|
||||
assert(!test.isContinue(sol));
|
||||
|
||||
//hasNeighbor() retourne vrai et on ameliore la fitness donc on doit continuer
|
||||
test(sol);
|
||||
test.accept(sol);
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
//verif de move -> on affecte la fitness du best d'avant
|
||||
test.move(sol);
|
||||
|
||||
//hasNeighbor() retourne vrai et on ameliore pas la fitness donc on doit pas continuer
|
||||
test(sol);
|
||||
test(sol);
|
||||
test.accept(sol);
|
||||
assert(!test.isContinue(sol));
|
||||
|
||||
assert(test.className()=="moSimpleHCexplorer");
|
||||
|
||||
std::cout << "[t-moSimpleHCexplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
101
trunk/paradiseo-mo/test/t-moSimpleHCneutralExplorer.cpp
Normal file
101
trunk/paradiseo-mo/test/t-moSimpleHCneutralExplorer.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
<t-moSimpleHCneutralExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
#include <explorer/moSimpleHCneutralExplorer.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moSimpleHCneutralExplorer] => START" << std::endl;
|
||||
|
||||
//instanciation
|
||||
eoBit<eoMinimizingFitness> sol(4, true);
|
||||
sol.fitness(4);
|
||||
bitNeighborhood nh(4);
|
||||
evalOneMax eval(4);
|
||||
moNeighborComparator<bitNeighbor> ncomp;
|
||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||
|
||||
moSimpleHCneutralExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp);
|
||||
|
||||
//test qu'on ameliore bien a chaque itération
|
||||
test.initParam(sol);
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==3);
|
||||
assert(test.isContinue(sol));
|
||||
test.updateParam(sol);
|
||||
|
||||
//les affichages permettent de voir qu'on choisit pas toujours les mm voisins améliorant (lancer plusieurs fois l'exe)
|
||||
std::cout << sol << std::endl;
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==2);
|
||||
assert(test.isContinue(sol));
|
||||
test.updateParam(sol);
|
||||
|
||||
std::cout << sol << std::endl;
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==1);
|
||||
assert(test.isContinue(sol));
|
||||
test.updateParam(sol);
|
||||
|
||||
std::cout << sol << std::endl;
|
||||
|
||||
test(sol);
|
||||
assert(test.accept(sol));
|
||||
test.move(sol);
|
||||
assert(sol.fitness()==0);
|
||||
assert(test.isContinue(sol));
|
||||
test.updateParam(sol);
|
||||
|
||||
test(sol);
|
||||
assert(!test.accept(sol));
|
||||
assert(sol.fitness()==0);
|
||||
assert(!test.isContinue(sol));
|
||||
test.updateParam(sol);
|
||||
|
||||
|
||||
std::cout << "[t-moSimpleHCneutralExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
72
trunk/paradiseo-mo/test/t-moSolNeighborComparator.cpp
Normal file
72
trunk/paradiseo-mo/test/t-moSolNeighborComparator.cpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
<t-moSolNeighborComparator.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 <neighborhood/moBitNeighbor.h>
|
||||
#include <eoScalarFitness.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
#include <ga/eoBit.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moSolNeighborComparator] => START" << std::endl;
|
||||
|
||||
moBitNeighbor<eoMinimizingFitness> neighbor;
|
||||
eoBit<eoMinimizingFitness> sol;
|
||||
|
||||
moSolNeighborComparator< moBitNeighbor<eoMinimizingFitness> > test;
|
||||
|
||||
neighbor.fitness(3);
|
||||
sol.fitness(2);
|
||||
//test with a minimizing fitness, neighbor must not be better than sol
|
||||
assert(!test(sol, neighbor));
|
||||
|
||||
//reversly
|
||||
neighbor.fitness(2);
|
||||
sol.fitness(3);
|
||||
assert(test(sol, neighbor));
|
||||
|
||||
//test equals
|
||||
assert(!test.equals(sol, neighbor));
|
||||
|
||||
neighbor.fitness(3);
|
||||
assert(test.equals(sol, neighbor));
|
||||
|
||||
assert(test.className()=="moSolNeighborComparator");
|
||||
|
||||
std::cout << "[t-moSolNeighborComparator] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
154
trunk/paradiseo-mo/test/t-moSolVectorTabuList.cpp
Normal file
154
trunk/paradiseo-mo/test/t-moSolVectorTabuList.cpp
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
<t-moSolVectorTabuList.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <memory/moSolVectorTabuList.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moSolVectorTabuList] => START" << std::endl;
|
||||
|
||||
//test without countdown
|
||||
moSolVectorTabuList<bitNeighbor> test(2,0);
|
||||
bitNeighbor n1;
|
||||
bitNeighbor n2;
|
||||
bitNeighbor n3;
|
||||
bitNeighbor n4;
|
||||
n1.index(0);
|
||||
n2.index(1);
|
||||
n3.index(2);
|
||||
n4.index(3);
|
||||
|
||||
eoBit<eoMinimizingFitness> sol1(4, true);
|
||||
eoBit<eoMinimizingFitness> sol2(4, true);
|
||||
eoBit<eoMinimizingFitness> sol3(4, true);
|
||||
eoBit<eoMinimizingFitness> sol4(4, true);
|
||||
|
||||
sol2[0]=false;
|
||||
sol3[1]=false;
|
||||
sol4[0]=false;
|
||||
sol4[1]=false;
|
||||
|
||||
//init
|
||||
test.init(sol1);
|
||||
|
||||
//ajout d'une sol tabu
|
||||
test.add(sol1,n1);
|
||||
|
||||
//verification des voisins de chaques sol
|
||||
assert(test.check(sol2,n1));
|
||||
assert(!test.check(sol2,n2));
|
||||
assert(!test.check(sol2,n3));
|
||||
assert(!test.check(sol2,n4));
|
||||
|
||||
assert(!test.check(sol3,n1));
|
||||
assert(test.check(sol3,n2));
|
||||
assert(!test.check(sol3,n3));
|
||||
assert(!test.check(sol3,n4));
|
||||
|
||||
assert(!test.check(sol4,n1));
|
||||
assert(!test.check(sol4,n2));
|
||||
assert(!test.check(sol4,n3));
|
||||
assert(!test.check(sol4,n4));
|
||||
|
||||
test.init(sol1);
|
||||
assert(!test.check(sol2,n1));
|
||||
assert(!test.check(sol3,n2));
|
||||
|
||||
test.update(sol1,n1);
|
||||
|
||||
test.add(sol1,n1);
|
||||
test.add(sol2,n1);
|
||||
assert(test.check(sol2,n1));
|
||||
test.add(sol4,n1);
|
||||
assert(!test.check(sol2,n1));
|
||||
assert(test.check(sol2,n2));
|
||||
|
||||
//test with a countdown at 3
|
||||
moSolVectorTabuList<bitNeighbor> test2(2,2);
|
||||
test2.init(sol1);
|
||||
test2.add(sol1,n1);
|
||||
assert(test2.check(sol2,n1));
|
||||
assert(!test2.check(sol2,n2));
|
||||
assert(!test2.check(sol2,n3));
|
||||
assert(!test2.check(sol2,n4));
|
||||
|
||||
assert(!test2.check(sol3,n1));
|
||||
assert(test2.check(sol3,n2));
|
||||
assert(!test2.check(sol3,n3));
|
||||
assert(!test2.check(sol3,n4));
|
||||
|
||||
assert(!test2.check(sol4,n1));
|
||||
assert(!test2.check(sol4,n2));
|
||||
assert(!test2.check(sol4,n3));
|
||||
assert(!test2.check(sol4,n4));
|
||||
|
||||
//coutdown sol1 -> 1
|
||||
test2.update(sol1,n1);
|
||||
assert(test2.check(sol2,n1));
|
||||
assert(!test2.check(sol2,n2));
|
||||
assert(!test2.check(sol2,n3));
|
||||
assert(!test2.check(sol2,n4));
|
||||
|
||||
assert(!test2.check(sol3,n1));
|
||||
assert(test2.check(sol3,n2));
|
||||
assert(!test2.check(sol3,n3));
|
||||
assert(!test2.check(sol3,n4));
|
||||
|
||||
assert(!test2.check(sol4,n1));
|
||||
assert(!test2.check(sol4,n2));
|
||||
assert(!test2.check(sol4,n3));
|
||||
assert(!test2.check(sol4,n4));
|
||||
|
||||
//coutdown sol1 -> 0 : sol1 is no longer tabu
|
||||
test2.update(sol1,n1);
|
||||
assert(!test2.check(sol2,n1));
|
||||
assert(!test2.check(sol2,n2));
|
||||
assert(!test2.check(sol2,n3));
|
||||
assert(!test2.check(sol2,n4));
|
||||
|
||||
assert(!test2.check(sol3,n1));
|
||||
assert(!test2.check(sol3,n2));
|
||||
assert(!test2.check(sol3,n3));
|
||||
assert(!test2.check(sol3,n4));
|
||||
|
||||
assert(!test2.check(sol4,n1));
|
||||
assert(!test2.check(sol4,n2));
|
||||
assert(!test2.check(sol4,n3));
|
||||
assert(!test2.check(sol4,n4));
|
||||
|
||||
std::cout << "[t-moSolVectorTabuList] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
64
trunk/paradiseo-mo/test/t-moSolutionStat.cpp
Normal file
64
trunk/paradiseo-mo/test/t-moSolutionStat.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
<t-moSolutionStat.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <continuator/moSolutionStat.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moSolutionStat] => START" << std::endl;
|
||||
|
||||
eoBit<unsigned int> s(3);
|
||||
s[0]=true;
|
||||
s[1]=true;
|
||||
s[2]=false;
|
||||
|
||||
s.fitness(17);
|
||||
|
||||
moSolutionStat< eoBit<unsigned int > > test;
|
||||
|
||||
test(s);
|
||||
//on verifie que la solution est bien enregistré
|
||||
|
||||
assert(test.value()[0]);
|
||||
assert(test.value()[1]);
|
||||
assert(!test.value()[2]);
|
||||
assert(test.value().fitness()==17);
|
||||
|
||||
assert(test.className()=="moSolutionStat");
|
||||
|
||||
std::cout << "[t-moSolutionStat] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
165
trunk/paradiseo-mo/test/t-moTSExplorer.cpp
Normal file
165
trunk/paradiseo-mo/test/t-moTSExplorer.cpp
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
<t-moTSExplorer.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
This software is governed by the CeCILL license under French law and
|
||||
abiding by the rules of distribution of free software. You can ue,
|
||||
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".
|
||||
|
||||
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 <memory/moSolVectorTabuList.h>
|
||||
#include <memory/moDummyIntensification.h>
|
||||
#include <memory/moDummyDiversification.h>
|
||||
#include <memory/moBestImprAspiration.h>
|
||||
#include <explorer/moTSExplorer.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moTSExplorer] => START" << std::endl;
|
||||
|
||||
//instansiation
|
||||
eoBit<eoMinimizingFitness> sol(4, true);
|
||||
sol.fitness(4);
|
||||
bitNeighborhood nh(4);
|
||||
bitNeighborhood emptyNH(0);
|
||||
evalOneMax eval(4);
|
||||
moNeighborComparator<bitNeighbor> ncomp;
|
||||
moSolNeighborComparator<bitNeighbor> sncomp;
|
||||
moDummyIntensification<bitNeighbor> intens;
|
||||
moDummyDiversification<bitNeighbor> diver;
|
||||
moSolVectorTabuList<bitNeighbor> tabuList(4,0);
|
||||
moBestImprAspiration<bitNeighbor> aspir;
|
||||
|
||||
moTSExplorer<bitNeighborhood> test(nh, eval, ncomp, sncomp, tabuList, intens, diver, aspir);
|
||||
moTSExplorer<bitNeighborhood> test2(emptyNH, eval, ncomp, sncomp, tabuList, intens, diver, aspir);
|
||||
|
||||
//test d'un voisinage vide
|
||||
test2.initParam(sol);
|
||||
test2(sol);
|
||||
assert(!test2.accept(sol));
|
||||
|
||||
//test le comportement classique de la taboo
|
||||
test.initParam(sol);
|
||||
assert(aspir.getBest()==sol);
|
||||
|
||||
test(sol);
|
||||
test.updateParam(sol);
|
||||
assert(aspir.getBest()==sol);
|
||||
|
||||
//on ameliore et on stock une sol tabou 0111
|
||||
test(sol);
|
||||
test.move(sol);
|
||||
test.moveApplied(true);
|
||||
test.updateParam(sol);
|
||||
assert(aspir.getBest()==sol);
|
||||
|
||||
//on ameliore et on stock une autre sol tabou 0011
|
||||
test(sol);
|
||||
test.move(sol);
|
||||
test.moveApplied(true);
|
||||
test.updateParam(sol);
|
||||
assert(aspir.getBest()==sol);
|
||||
|
||||
//pareil on stock 0001 met pdt la recherche on se rend compte que 0111 est tabou
|
||||
test(sol);
|
||||
test.move(sol);
|
||||
test.moveApplied(true);
|
||||
test.updateParam(sol);
|
||||
assert(aspir.getBest()==sol);
|
||||
|
||||
//on modifie la sol en 1001(fitness 2) pour que la 1er sol exploré(0001) soit tabou
|
||||
//De plus on change la solution mais elle est pas meilleure que la best so Far
|
||||
sol[0]=true;
|
||||
std::cout << sol << std::endl;
|
||||
sol.fitness(2);
|
||||
test(sol);
|
||||
test.move(sol);
|
||||
test.moveApplied(true);
|
||||
test.updateParam(sol);
|
||||
assert( sol[0] && !sol[1] && !sol[2] && !sol[3]);
|
||||
sol[0]=false;
|
||||
sol[3]=true;
|
||||
assert(aspir.getBest()==sol);
|
||||
|
||||
//test du isContinue
|
||||
assert(test.isContinue(sol));
|
||||
|
||||
//test du terminate
|
||||
test.initParam(sol);
|
||||
sol[0]=true;
|
||||
sol[1]=true;
|
||||
sol[2]=true;
|
||||
sol[3]=true;
|
||||
sol.fitness(4);
|
||||
test(sol);
|
||||
test.move(sol);
|
||||
test.moveApplied(true);
|
||||
test.updateParam(sol);
|
||||
assert( !sol[0] && sol[1] && sol[2] && sol[3]);
|
||||
test.terminate(sol);
|
||||
assert( !sol[0] && !sol[1] && !sol[2] && sol[3]);
|
||||
|
||||
//test pour avoir que des mouvement taboo
|
||||
eoBit<eoMinimizingFitness> sol2(2, true);
|
||||
sol2.fitness(2);
|
||||
bitNeighborhood nh2(2);
|
||||
evalOneMax eval2(2);
|
||||
|
||||
moTSExplorer<bitNeighborhood> test3(nh2, eval2, ncomp, sncomp, tabuList, intens, diver, aspir);
|
||||
|
||||
test3.initParam(sol2);
|
||||
test3(sol2);
|
||||
test3.move(sol2);
|
||||
test3.moveApplied(true);
|
||||
test3.updateParam(sol2);
|
||||
|
||||
test3(sol2);
|
||||
test3.move(sol2);
|
||||
test3.moveApplied(true);
|
||||
test3.updateParam(sol2);
|
||||
|
||||
test3(sol2);
|
||||
test3.move(sol2);
|
||||
test3.moveApplied(true);
|
||||
test3.updateParam(sol2);
|
||||
|
||||
test3(sol2);
|
||||
test3.move(sol2);
|
||||
test3.moveApplied(true);
|
||||
test3.updateParam(sol2);
|
||||
|
||||
//on a rempli la liste tabu pour que tout les voisins soit tabu
|
||||
test3(sol2);
|
||||
assert(!test3.accept(sol2));
|
||||
|
||||
|
||||
std::cout << "[t-moTSExplorer] => OK" << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
53
trunk/paradiseo-mo/test/t-moTrueContinuator.cpp
Normal file
53
trunk/paradiseo-mo/test/t-moTrueContinuator.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
<t-moTrueContinuator.cpp>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||
|
||||
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||
|
||||
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 <continuator/moTrueContinuator.h>
|
||||
#include "moTestClass.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
int main(){
|
||||
|
||||
std::cout << "[t-moTrueContinuator] => START" << std::endl;
|
||||
|
||||
moTrueContinuator<moDummyNeighborhood> test;
|
||||
Solution s;
|
||||
|
||||
assert(test(s));
|
||||
|
||||
std::cout << "[t-moTrueContinuator] => OK" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
1
trunk/paradiseo-mo/tutorial/CMakeLists.txt
Normal file
1
trunk/paradiseo-mo/tutorial/CMakeLists.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
ADD_SUBDIRECTORY(oneMax)
|
||||
1
trunk/paradiseo-mo/tutorial/oneMax/CMakeLists.txt
Normal file
1
trunk/paradiseo-mo/tutorial/oneMax/CMakeLists.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
ADD_SUBDIRECTORY(application)
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src
|
||||
${MO_SRC_DIR}/src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
||||
|
||||
LINK_DIRECTORIES(${EO_BIN_DIR}/lib)
|
||||
|
||||
ADD_EXECUTABLE(testSimpleHC testSimpleHC.cpp)
|
||||
ADD_EXECUTABLE(testFirstImpr testFirstImpr.cpp)
|
||||
ADD_EXECUTABLE(testRandomWalk testRandomWalk.cpp)
|
||||
ADD_EXECUTABLE(testSimpleHCneutral testSimpleHCneutral.cpp)
|
||||
ADD_EXECUTABLE(testHCneutral testHCneutral.cpp)
|
||||
ADD_EXECUTABLE(testMetropolisHasting testMetropolisHasting.cpp)
|
||||
#ADD_EXECUTABLE(testWithMove testWithMove.cpp)
|
||||
ADD_EXECUTABLE(testSimpleTS testSimpleTS.cpp)
|
||||
ADD_EXECUTABLE(testRandomNeutralWalk testRandomNeutralWalk.cpp)
|
||||
|
||||
TARGET_LINK_LIBRARIES(testSimpleHC eoutils ga eo)
|
||||
TARGET_LINK_LIBRARIES(testFirstImpr eoutils ga eo)
|
||||
TARGET_LINK_LIBRARIES(testRandomWalk eoutils ga eo)
|
||||
TARGET_LINK_LIBRARIES(testSimpleHCneutral eoutils ga eo)
|
||||
TARGET_LINK_LIBRARIES(testHCneutral eoutils ga eo)
|
||||
TARGET_LINK_LIBRARIES(testMetropolisHasting eoutils ga eo)
|
||||
#TARGET_LINK_LIBRARIES(testWithMove eoutils ga eo)
|
||||
TARGET_LINK_LIBRARIES(testSimpleTS eoutils ga eo)
|
||||
TARGET_LINK_LIBRARIES(testRandomNeutralWalk eoutils ga eo)
|
||||
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