diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/CTestCustom.cmake b/tags/ParadisEO-GPU-1.1/paradiseo-mo/CTestCustom.cmake new file mode 100644 index 000000000..61bcd9133 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/CTestCustom.cmake @@ -0,0 +1,7 @@ +SET(CTEST_CUSTOM_COVERAGE_EXCLUDE + ${CTEST_CUSTOM_COVERAGE_EXCLUDE} +"test/" +"paradiseo-eo/" +"problems/" +"tutorial/" +) diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/install.cmake b/tags/ParadisEO-GPU-1.1/paradiseo-mo/install.cmake new file mode 100644 index 000000000..8113a6dd7 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/install.cmake @@ -0,0 +1,130 @@ +###################################################################################### +### CMake basic configuration +###################################################################################### + +# check cmake version compatibility +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +# regular expression checking +INCLUDE_REGULAR_EXPRESSION("^.*$" "^$") + +# set a language for the entire project. +ENABLE_LANGUAGE(CXX) +ENABLE_LANGUAGE(C) + +#################################################################################### + + +##################################################################################### +### Include required modules & utilities +##################################################################################### +INCLUDE(CMakeBackwardCompatibilityCXX) + +INCLUDE(FindDoxygen) + +INCLUDE(FindGnuplot) + +INCLUDE(CheckLibraryExists) + +INCLUDE(Dart OPTIONAL) + +INCLUDE(CPack) + +# Set a special flag if the environment is windows (should do the same in a config.g file) +IF (WIN32) + ADD_DEFINITIONS(-D_WINDOWS=1) +ENDIF (WIN32) +###################################################################################### + + +##################################################################################### +### Manage the build type +##################################################################################### + +# the user should choose the build type on windows environments,excepted under cygwin (default=none) +SET(CMAKE_DEFAULT_BUILD_TYPE "Release" CACHE STRING "Variable that stores the default CMake build type" FORCE) + +FIND_PROGRAM(MEMORYCHECK_COMMAND + NAMES purify valgrind + PATHS + "/usr/local/bin /usr/bin [HKEY_LOCAL_MACHINE\\SOFTWARE\\Rational Software\\Purify\\Setup;InstallFolder]" + DOC "Path to the memory checking command, used for memory error detection.") + +IF(NOT CMAKE_BUILD_TYPE) + SET( CMAKE_BUILD_TYPE + ${CMAKE_DEFAULT_BUILD_TYPE} CACHE STRING + "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." + FORCE) +ENDIF(NOT CMAKE_BUILD_TYPE) + +IF(WIN32 AND NOT CYGWIN) + IF(CMAKE_CXX_COMPILER MATCHES cl) + IF(NOT WITH_SHARED_LIBS) + IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008" OR CMAKE_GENERATOR STREQUAL "Visual Studio 10") + SET(CMAKE_CXX_FLAGS "/nologo /Gy") + SET(CMAKE_CXX_FLAGS_DEBUG "/W3 /MTd /Z7 /Od") + SET(CMAKE_CXX_FLAGS_RELEASE "/w /MT /O2 /wd4530") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") + ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008" OR CMAKE_GENERATOR STREQUAL "Visual Studio 10") + ENDIF(NOT WITH_SHARED_LIBS) + ENDIF(CMAKE_CXX_COMPILER MATCHES cl) +ELSE(WIN32 AND NOT CYGWIN) + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -fprofile-arcs -ftest-coverage -Wall -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -O6") + ENDIF(CMAKE_COMPILER_IS_GNUCXX) +ENDIF(WIN32 AND NOT CYGWIN) + +IF(CMAKE_BUILD_TYPE MATCHES Debug) + ADD_DEFINITIONS(-DCMAKE_VERBOSE_MAKEFILE=ON) +ENDIF(CMAKE_BUILD_TYPE MATCHES Debug) + +##################################################################################### + +###################################################################################### +### compilation of examples? +###################################################################################### + +SET(ENABLE_CMAKE_EXAMPLE TRUE CACHE BOOL "Enable copy of benchs and parameters file?") + +###################################################################################### +### Test config +###################################################################################### + +IF (ENABLE_CMAKE_TESTING OR ENABLE_MINIMAL_CMAKE_TESTING) + ENABLE_TESTING() +ENDIF (ENABLE_CMAKE_TESTING OR ENABLE_MINIMAL_CMAKE_TESTING) +###################################################################################### + +####################################################################################### +### Paths to EO, MO and MOEO must be specified above. +####################################################################################### + +SET(EO_SRC_DIR "${CMAKE_SOURCE_DIR}/../paradiseo-eo" CACHE PATH "ParadisEO-EO source directory" FORCE) +SET(EO_BIN_DIR "${CMAKE_BINARY_DIR}/../../paradiseo-eo/build" CACHE PATH "ParadisEO-EO binary directory" FORCE) + +SET(MO_SRC_DIR "${CMAKE_SOURCE_DIR}/../paradiseo-mo" CACHE PATH "ParadisMO-MO source directory" FORCE) +SET(MO_BIN_DIR "${CMAKE_BINARY_DIR}/../../paradiseo-mo/build" CACHE PATH "ParadisMO-MO binary directory" FORCE) + +SET(OLDMO_SRC_DIR "${CMAKE_SOURCE_DIR}/../paradiseo-old-mo" CACHE PATH "ParadisMO-MO source directory" FORCE) +SET(OLDMO_BIN_DIR "${CMAKE_BINARY_DIR}/../../paradiseo-old-mo/build" CACHE PATH "ParadisMO-MO binary directory" FORCE) + +SET(MOEO_SRC_DIR "${CMAKE_SOURCE_DIR}/../paradiseo-moeo" CACHE PATH "ParadisMOEO-MOEO source directory" FORCE) +SET(MOEO_BIN_DIR "${CMAKE_BINARY_DIR}/../../paradiseo-moeo/build" CACHE PATH "ParadisMOEO-MOEO binary directory" FORCE) + +SET(PROBLEMS_SRC_DIR "${CMAKE_SOURCE_DIR}/../problems" CACHE PATH "Problems dependant source directory" FORCE) + +###################################################################################### +###################################################################################### +### Subdirectories that CMake should process for MO, MOEO and PEO +###################################################################################### + +ADD_SUBDIRECTORY(doc) +ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(test) +ADD_SUBDIRECTORY(tutorial) +###################################################################################### + diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moAverageFitnessNeighborStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moAverageFitnessNeighborStat.h new file mode 100644 index 000000000..4c268d6d3 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moAverageFitnessNeighborStat.h @@ -0,0 +1,88 @@ +/* + + 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 moAverageFitnessNeighborStat_h +#define moAverageFitnessNeighborStat_h + +#include +#include + +/** + * From moNeighborhoodStat, to compute the average of fitness in the neighborhood + */ +template< class Neighbor > +class moAverageFitnessNeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, double >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moAverageFitnessNeighborStat(moNeighborhoodStat & _nhStat): + moStat(0.0, "average"), nhStat(_nhStat) {} + + /** + * Set the average of fitness in the neighborhood + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getMean(); + } + + /** + * Set the average of fitness in the neighborhood + * @param _sol the corresponding solution + */ + virtual void operator()(EOT & _sol) { + value() = nhStat.getMean(); + } + + /** + * @return the class name + */ + virtual std::string className(void) const { + return "moAverageFitnessNeighborStat"; + } + +private: + /** moNeighborhoodStat */ + moNeighborhoodStat & nhStat; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBestFitnessStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBestFitnessStat.h new file mode 100644 index 000000000..192919c88 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBestFitnessStat.h @@ -0,0 +1,95 @@ +/* + + 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 moBestFitnessStat_h +#define moBestFitnessStat_h + +#include + +/** + * The statistic which save the best solution found during the search + */ +template +class moBestFitnessStat : public moStat +{ +public : + typedef typename EOT::Fitness Fitness; + using moStat< EOT , typename EOT::Fitness >::value; + + /** + * Default Constructor + * @param _reInitSol when true the best so far is reinitialized + */ + moBestFitnessStat(bool _reInitSol = true): moStat(Fitness(), "best"), reInitSol(_reInitSol), firstTime(true) { + } + + /** + * Initialization of the best solution on the first one + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + if (reInitSol) + value() = _sol.fitness(); + else if (firstTime) + { + value() = _sol.fitness(); + firstTime = false; + } + } + + /** + * Update the best solution + * @param _sol the current solution + */ + virtual void operator()(EOT & _sol) { + if (value() < _sol.fitness()) + { + value() = _sol.fitness(); + } + } + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moBestFitnessStat"; + } + +protected: + bool reInitSol; + bool firstTime; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBestNoImproveContinuator.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBestNoImproveContinuator.h new file mode 100644 index 000000000..86981bef4 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBestNoImproveContinuator.h @@ -0,0 +1,118 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moBestNoImproveContinuator_h +#define _moBestNoImproveContinuator_h + +#include +#include +#include + +/** + * Stop when the best solution cannot be improved + * within a given number of iterations + */ +template< class Neighbor > +class moBestNoImproveContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + + /** + * Constructor + * + * @param _bestSol the best solution + * @param _maxNoImprove number maximum of iterations + * @param _solComparator a comparator between solutions + * @param _verbose true/false : verbose mode on/off + */ + moBestNoImproveContinuator(const EOT & _bestSol, + unsigned int _maxNoImprove, + moSolComparator& _solComparator, + bool _verbose = true): bestSol(_bestSol), maxNoImprove(_maxNoImprove), solComparator(_solComparator), verbose(_verbose) {} + + /** + * Constructor where the comparator of solutions is the default comparator + * + * @param _bestSol the best solution + * @param _maxNoImprove number maximum of iterations + * @param _verbose true/false : verbose mode on/off + */ + moBestNoImproveContinuator(const EOT & _bestSol, + unsigned int _maxNoImprove, + bool _verbose = true): bestSol(_bestSol), maxNoImprove(_maxNoImprove), solComparator(defaultSolComp), verbose(_verbose) {} + + /** + * Count and test the number of non improvement of the best solution + * improvement: if the current solution is STRICTLY better than the current best solution + * + *@param _solution a solution + *@return true if counter < maxNoImprove + */ + virtual bool operator()(EOT & _solution) { + if (solComparator(_solution, bestSol) || solComparator.equals(_solution, bestSol)) + cpt++; + else + cpt = 0; + + bool res = (cpt < maxNoImprove); + + if (!res && verbose) + std::cout << "STOP in moBestNoImproveContinuator: Reached maximum number of iterations without improvement [" << cpt << "/" << maxNoImprove << "]" << std::endl; + + return res; + } + + /** + * reset the counter of iteration + * @param _solution a solution + */ + virtual void init(EOT & _solution) { + cpt = 0; + } + + /** + * the current number of iteration without improvement + * @return the number of iteration + */ + unsigned int value() { + return cpt ; + } + +private: + const EOT & bestSol; + unsigned int maxNoImprove; + unsigned int cpt; + // comparator between solutions + moSolComparator& solComparator; + bool verbose; + moSolComparator defaultSolComp; + +}; +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBestSoFarStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBestSoFarStat.h new file mode 100644 index 000000000..fa5797139 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBestSoFarStat.h @@ -0,0 +1,94 @@ +/* + + 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 moBestSoFarStat_h +#define moBestSoFarStat_h + +#include + +/** + * The statistic which save the best solution found during the search + */ +template +class moBestSoFarStat : public moStat +{ +public : + using moStat< EOT , EOT >::value; + + /** + * Default Constructor + * @param _reInitSol when true the best so far is reinitialized + */ + moBestSoFarStat(bool _reInitSol = true): moStat(EOT(), "best"), reInitSol(_reInitSol), firstTime(true) { + } + + /** + * Initialization of the best solution on the first one + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + if (reInitSol) + value() = _sol; + else if (firstTime) + { + value() = _sol; + firstTime = false; + } + } + + /** + * Update the best solution + * @param _sol the current solution + */ + virtual void operator()(EOT & _sol) { + if (value().fitness() < _sol.fitness()) + { + value() = _sol; + } + } + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moBestSoFarStat"; + } + +protected: + bool reInitSol; + bool firstTime; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBooleanStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBooleanStat.h new file mode 100644 index 000000000..a098efc23 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moBooleanStat.h @@ -0,0 +1,82 @@ +/* + + 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 moBooleanStat_h +#define moBooleanStat_h + +#include + +/** + * The statistic gives from a boolean variable + */ +template +class moBooleanStat : public moStat +{ +public : + using moStat< EOT, bool>::value; + + /** + * Default Constructor + */ + moBooleanStat(bool * _b): moStat(*_b, "boolean"), b(_b) { + } + + /** + * Init the number of iteration + * @param _sol a solution + */ + virtual void init(EOT & _sol) { + value() = *b; + } + + /** + * Set the number of iteration + * @param _sol a solution + */ + virtual void operator()(EOT & _sol) { + value() = *b; + } + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moBooleanStat"; + } + +private: + bool * b; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCheckpoint.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCheckpoint.h new file mode 100644 index 000000000..37b5cd610 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCheckpoint.h @@ -0,0 +1,197 @@ +/* + + 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 +#include +#include +#include +#include +#include + +/** + * Continuator allowing to add others (continuators, stats, monitors or updaters) + */ +template +class moCheckpoint : public moContinuator { +public : + + typedef typename Neighbor::EOT EOT ; + + /** + * Constructor (moCheckpoint must have at least one continuator) + * @param _cont a continuator + * @param _interval frequency to compute statistical operators + */ + moCheckpoint(moContinuator& _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& _cont) { + continuators.push_back(&_cont); + } + + /** + * add a statistic operator to the checkpoint + * @param _stat a statistic operator + */ + void add(moStatBase& _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); + } + + /** + * add a MO updater to the checkpoint + * @param _moupd an mo updater + */ + void add(moUpdater& _moupd) { + moupdaters.push_back(&_moupd); + } + + /** + * 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 < stats.size(); ++i) + stats[i]->init(_sol); + counter=1; + + for (unsigned i = 0; i < moupdaters.size(); ++i) + moupdaters[i]->init(); + + for (unsigned int i = 0; i < monitors.size(); ++i) + (*monitors[i])(); + + 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 < moupdaters.size(); ++i) + (*moupdaters[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 < moupdaters.size(); ++i) + moupdaters[i]->lastCall(); + + for (i = 0; i < monitors.size(); ++i) + monitors[i]->lastCall(); + } + +private : + /** continuators vector */ + std::vector*> continuators; + /** statistic operators vector */ + std::vector*> stats; + /** monitors vector */ + std::vector monitors; + /** updaters vector */ + std::vector updaters; + /** MO updaters vector */ + std::vector moupdaters; + + unsigned int interval; + unsigned int counter; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCombinedContinuator.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCombinedContinuator.h new file mode 100644 index 000000000..7533bd4fa --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCombinedContinuator.h @@ -0,0 +1,93 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moCombinedContinuator_h +#define _moCombinedContinuator_h + +#include +#include +#include + +/** + * Combined several continuators. + * Continue until one of the continuators returns false + */ +template< class Neighbor > +class moCombinedContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + + /** + * Constructor (moCheckpoint must have at least one continuator) + * @param _cont a continuator + */ + moCombinedContinuator(moContinuator& _cont) { + continuators.push_back(&_cont); + } + + /** + * add a continuator to the combined continuator + * @param _cont a continuator + */ + void add(moContinuator& _cont) { + continuators.push_back(&_cont); + } + + /** + * init all continuators + * @param _solution a solution + */ + virtual void init(EOT & _solution) { + for (unsigned int i = 0; i < continuators.size(); ++i) + continuators[i]->init(_solution); + } + + /** + *@param _solution a solution + *@return true all the continuators are true + */ + virtual bool operator()(EOT & _solution) { + bool bContinue = true; + + // some data may be update in each continuator. + // So, all continuators are tested + for (unsigned int i = 0; i < continuators.size(); ++i) + if ( !(*continuators[i])(_solution) ) + bContinue = false; + + return bContinue; + } + +private: + /** continuators vector */ + std::vector< moContinuator* > continuators; + +}; +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moContinuator.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moContinuator.h new file mode 100644 index 000000000..cec268038 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moContinuator.h @@ -0,0 +1,64 @@ +/* + + 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 +#include + +/** + * To make specific continuator from a solution + */ +template< class Neighbor > +class moContinuator : public eoUF +{ +public: + + typedef typename Neighbor::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 diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCounterMonitorSaver.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCounterMonitorSaver.h new file mode 100644 index 000000000..f57e05d2d --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCounterMonitorSaver.h @@ -0,0 +1,97 @@ +/* + + 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 +#include + +/** + * Class calling monitors with a given frequency + */ +class moCounterMonitorSaver : public eoUpdater { +public : + + /** + * 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 monitors; +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCounterStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCounterStat.h new file mode 100644 index 000000000..85534e67e --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moCounterStat.h @@ -0,0 +1,80 @@ +/* + + 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 moCounterStat_h +#define moCounterStat_h + +#include + +/** + * The statistic gives the number of iteration + */ +template +class moCounterStat : public moStat +{ +public : + using moStat< EOT, unsigned int>::value; + + /** + * Default Constructor + */ + moCounterStat(): moStat(0, "counter") { + } + + /** + * Init the number of iteration + * @param _sol a solution + */ + virtual void init(EOT & _sol) { + value() = 0; + } + + /** + * Set the number of iteration + * @param _sol a solution + */ + virtual void operator()(EOT & _sol) { + value() = value() + 1; + } + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moCounterStat"; + } + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moDistanceStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moDistanceStat.h new file mode 100644 index 000000000..06cfe0007 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moDistanceStat.h @@ -0,0 +1,93 @@ +/* + + 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 +#include + +/** + * 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 moDistanceStat : public moStat +{ +public : + using moStat< EOT, T >::value; + + /** + * Constructor + * @param _dist a distance + * @param _ref the reference solution + */ + moDistanceStat(eoDistance & _dist, EOT & _ref): moStat(0, "distance"), dist(_dist), refSolution(_ref) {} + + /** + * Compute distance between the first solution and the reference solution + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value() = dist(_sol, refSolution); + } + + /** + * 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 & dist; + /** + * the reference solution does not change during the run + * it could be the best solution knowed of the problem + */ + EOT refSolution; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moEvalsContinuator.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moEvalsContinuator.h new file mode 100644 index 000000000..1a020da6c --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moEvalsContinuator.h @@ -0,0 +1,99 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moEvalsContinuator_h +#define _moEvalsContinuator_h + +#include +#include +#include +#include + +/** + * Continue until a maximum fixed number of full evaluation and neighbor evaluation is reached (total number of evaluation = full evaluation + incremental evaluation) + * + * + * Becareful 1: if restartCounter is true, then the number of neighbor evaluations (for example incremental evaluations) is considered during the local search (not before it) + * + * Becareful 2: Can not be used if the evaluation function is used in parallel + * + * Becareful 3: Check if the incremental does not use full evaluation, otherwise the total number of evaluations is not correct + */ +template< class Neighbor > +class moEvalsContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + + /** + * Constructor + * @param _fullEval full evaluation function to count + * @param _neighborEval neighbor evaluation function to count + * @param _maxEvals number maximum of evaluations (full and incremental evaluations) + * @param _restartCounter if true the counter of number of evaluations restarts to "zero" at initialization, if false, the number is cumulative + */ + moEvalsContinuator(eoEvalFuncCounter & _fullEval, moEvalCounter & _neighborEval, unsigned int _maxEvals, bool _restartCounter = true): fullEval(_fullEval), neighborEval(_neighborEval), maxEvals(_maxEvals), restartCounter(_restartCounter) {} + + /** + * Test if continue + * @param _solution a solution + * @return true if number of evaluations < maxEvals + */ + virtual bool operator()(EOT & _solution) { + return (fullEval.value() + neighborEval.value() - nbEval_start < maxEvals); + } + + /** + * Reset the number of evaluations + * @param _solution a solution + */ + virtual void init(EOT & _solution) { + if (restartCounter) + nbEval_start = fullEval.value() + neighborEval.value(); + else + nbEval_start = 0; + } + + /** + * the current number of evaluation from the begining + * @return the number of evaluation + */ + unsigned int value() { + return fullEval.value() + neighborEval.value() - nbEval_start ; + } + +private: + eoEvalFuncCounter & fullEval; + moEvalCounter & neighborEval; + unsigned int maxEvals; + bool restartCounter; + unsigned int nbEval_start ; + +}; +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moFitContinuator.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moFitContinuator.h new file mode 100644 index 000000000..03ac6b686 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moFitContinuator.h @@ -0,0 +1,63 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moFitContinuator_h +#define _moFitContinuator_h + +#include +#include + +/** + * Continue until a maximum fitness is reached + */ +template< class Neighbor > +class moFitContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + /** + * @param _maxFit maximum fitness to reach + */ + moFitContinuator(Fitness _maxFit): maxFit(_maxFit) {} + + /** + *@param _solution a solution + *@return true if counter < maxFit + */ + virtual bool operator()(EOT & _solution) { + return (_solution.fitness() < maxFit); + } + +private: + Fitness maxFit; + +}; +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moFitnessStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moFitnessStat.h new file mode 100644 index 000000000..d4f2f4bea --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moFitnessStat.h @@ -0,0 +1,83 @@ +/* + + 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 + +/** + * Stat given the fitness of the current solution + */ +template +class moFitnessStat : public moStat +{ +public : + typedef typename EOT::Fitness Fitness; + using moStat< EOT, Fitness >::value; + + /** + * Constructor + * @param _description a description of the stat + */ + moFitnessStat(std::string _description = "fitness"): + moStat(Fitness(), _description) {} + + /** + * store the initial fitness value + * @param _sol the initial solution + */ + virtual void init(EOT & _sol) + { + value() = _sol.fitness(); + } + + /** + * 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 diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moFullEvalContinuator.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moFullEvalContinuator.h new file mode 100644 index 000000000..5239c1dea --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moFullEvalContinuator.h @@ -0,0 +1,96 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moFullEvalContinuator_h +#define _moFullEvalContinuator_h + +#include +#include +#include + +/** + * Continue until a maximum fixed number of full evaluation is reached + * + * + * Becareful 1: if restartCounter is true, then the number of full evaluations is considered during the local search (not before it) + * + * Becareful 2: Can not be used if the evaluation function is used in parallel + */ +template< class Neighbor > +class moFullEvalContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + + /** + * Constructor + * @param _eval evaluation function to count + * @param _maxFullEval number maximum of iterations + * @param _restartCounter if true the counter of number of evaluations restarts to "zero" at initialization, if false, the number is cumulative + */ + moFullEvalContinuator(eoEvalFuncCounter & _eval, unsigned int _maxFullEval, bool _restartCounter = true): eval(_eval), maxFullEval(_maxFullEval), restartCounter(_restartCounter) { + nbEval_start = eval.value(); + } + + /** + * Test if continue + * @param _solution a solution + * @return true if number of evaluations < maxFullEval + */ + virtual bool operator()(EOT & _solution) { + return (eval.value() - nbEval_start < maxFullEval); + } + + /** + * Reset the number of evaluations + * @param _solution a solution + */ + virtual void init(EOT & _solution) { + if (restartCounter) + nbEval_start = eval.value(); + else + nbEval_start = 0; + } + + /** + * the current number of evaluation from the begining + * @return the number of evaluation + */ + unsigned int value() { + return eval.value() - nbEval_start ; + } + +private: + eoEvalFuncCounter & eval; + unsigned int nbEval_start ; + bool restartCounter; + unsigned int maxFullEval ; + +}; +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moIterContinuator.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moIterContinuator.h new file mode 100644 index 000000000..f10db39f5 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moIterContinuator.h @@ -0,0 +1,86 @@ +/* + +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 _moIterContinuator_h +#define _moIterContinuator_h + +#include +#include + +/** + * Continue until a maximum fixed number of iterations is reached + */ +template< class Neighbor > +class moIterContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + + /** + * @param _maxIter number maximum of iterations + * @param _verbose true/false : verbose mode on/off + */ + moIterContinuator(unsigned int _maxIter, bool _verbose=true): maxIter(_maxIter), verbose(_verbose) {} + + /** + *@param _solution a solution + *@return true if counter < maxIter + */ + virtual bool operator()(EOT & _solution) { + bool res; + cpt++; + res = (cpt < maxIter); + if (!res && verbose) + std::cout << "STOP in moIterContinuator: Reached maximum number of iterations [" << cpt << "/" << maxIter << "]" << std::endl; + return res; + } + + /** + * reset the counter of iteration + * @param _solution a solution + */ + virtual void init(EOT & _solution) { + cpt = 0; + } + + /** + * the current number of iteration + * @return the number of iteration + */ + unsigned int value() { + return cpt ; + } + +private: + unsigned int maxIter; + unsigned int cpt; + bool verbose; + +}; +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moMaxNeighborStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moMaxNeighborStat.h new file mode 100644 index 000000000..d0dbd8136 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moMaxNeighborStat.h @@ -0,0 +1,89 @@ +/* + + 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 +#include +#include + +/** + * From moNeighborhoodStat, to compute the max fitness in the neighborhood + */ +template< class Neighbor > +class moMaxNeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, Fitness >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moMaxNeighborStat(moNeighborhoodStat & _nhStat): + moStat(Fitness(), "min"), nhStat(_nhStat) {} + + /** + * Set the max fitness in the neighborhood + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getMax(); + } + + /** + * 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 & nhStat; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moMinNeighborStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moMinNeighborStat.h new file mode 100644 index 000000000..bd1cae1f9 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moMinNeighborStat.h @@ -0,0 +1,89 @@ +/* + + 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 +#include +#include + +/** + * From moNeighborhoodStat, to compute the min fitness in the neighborhood + */ +template< class Neighbor > +class moMinNeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, Fitness >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moMinNeighborStat(moNeighborhoodStat & _nhStat): + moStat(Fitness(), "min"), nhStat(_nhStat) {} + + /** + * Set the worst fitness in the neighborhood + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getMin(); + } + + /** + * 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 & nhStat; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moMinusOneCounterStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moMinusOneCounterStat.h new file mode 100644 index 000000000..dfb9be881 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moMinusOneCounterStat.h @@ -0,0 +1,90 @@ +/* + + 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 moMinusOneCounterStat_h +#define moMinusOneCounterStat_h + +#include + +/** + * The statistic gives the number of iteration minus 1 + * then the last iteration is not counted (for example for length of adaptive walk) + */ +template +class moMinusOneCounterStat : public moStat +{ +public : + using moStat< EOT, unsigned int>::value; + + /** + * Default Constructor + */ + moMinusOneCounterStat(): moStat(0, "counter") { + counter = 0; + } + + /** + * Init the number of iteration + * @param _sol a solution + */ + virtual void init(EOT & _sol) { + counter = 0; + value() = 0; + } + + /** + * Set the number of iteration + * @param _sol a solution + */ + virtual void operator()(EOT & _sol) { + counter++; + if (counter > 0) + value() = counter - 1; + else + value() = 0; + } + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moMinusOneCounterStat"; + } + +private: + unsigned int counter; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNbInfNeighborStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNbInfNeighborStat.h new file mode 100644 index 000000000..1fa6783bb --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNbInfNeighborStat.h @@ -0,0 +1,90 @@ +/* + + 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 +#include +#include + +/** + * From moNeighborhoodStat, to compute the number of solutions in the neighborhood + * with (strictly) lower fitness than the current solution +*/ +template< class Neighbor > +class moNbInfNeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, unsigned >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moNbInfNeighborStat(moNeighborhoodStat & _nhStat): + moStat(0, "nb inf"), nhStat(_nhStat) {} + + /** + * Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getNbInf(); + } + + /** + * 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 & nhStat; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNbSupNeighborStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNbSupNeighborStat.h new file mode 100644 index 000000000..027d8f1e8 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNbSupNeighborStat.h @@ -0,0 +1,90 @@ +/* + + 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 +#include +#include + +/** + * From moNeighborhoodStat, to compute the number of solutions in the neighborhood + * with higher fitness than the current solution + */ +template< class Neighbor > +class moNbSupNeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, unsigned >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moNbSupNeighborStat(moNeighborhoodStat & _nhStat): + moStat(0, "nb sup"), nhStat(_nhStat) {} + + /** + * Set the number of solutions in the neighborhood with better fitness than the current solution + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getNbSup(); + } + + /** + * 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 & nhStat; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborBestStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborBestStat.h new file mode 100644 index 000000000..7aa4b2ed6 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborBestStat.h @@ -0,0 +1,167 @@ +/* + + 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 moNeighborBestStat_h +#define moNeighborBestStat_h + +#include + +#include +#include +#include +#include + +/** + * Compute the fitness of the best solution among k neighbor or all neighbors + */ +template< class Neighbor > +class moNeighborBestStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef moNeighborhood Neighborhood ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, Fitness >::value; + + /** + * 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 + * @param _k number of neighbors visited + */ + moNeighborBestStat(Neighborhood& _neighborhood, moEval& _eval, moNeighborComparator& _neighborComparator, moSolNeighborComparator& _solNeighborComparator, unsigned int _k = 0): + moStat(true, "neighborhood"), + neighborhood(_neighborhood), eval(_eval), + neighborComparator(_neighborComparator), + solNeighborComparator(_solNeighborComparator), + kmax(_k) + {} + + /** + * Default Constructor + * where the comparators are basic, there only compare the fitness values + * + * @param _neighborhood a neighborhood + * @param _eval an evaluation function + * @param _k number of neighbors visited (default all) + */ + moNeighborBestStat(Neighborhood& _neighborhood, moEval& _eval, unsigned _k = 0): + moStat(Fitness(), "best"), + neighborhood(_neighborhood), eval(_eval), + neighborComparator(defaultNeighborComp), + solNeighborComparator(defaultSolNeighborComp), + kmax(_k) + {} + + /** + * Compute classical statistics of the first solution's neighborhood + * @param _solution the first solution + */ + virtual void init(EOT & _solution) { + operator()(_solution); + } + + /** + * Compute the best fitness amoung all neighbors or k neighbors + * @param _solution the corresponding solution + */ + virtual void operator()(EOT & _solution) { + Neighbor current ; + Neighbor best ; + + 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; + + // number of visited neighbors + unsigned int k = 1; + + //test all others neighbors + while ( ( (kmax == 0) || (k < kmax) ) && 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; + + k++; + } + + value() = best.fitness(); + } + else { + //if _solution hasn't neighbor, + value() = Fitness(); + } + } + + /** + * @return the class name + */ + virtual std::string className(void) const { + return "moNeighborBestStat"; + } + +private: + // to explore the neighborhood + Neighborhood& neighborhood ; + moEval& eval; + + // comparator betwenn solution and neighbor or between neighbors + moNeighborComparator& neighborComparator; + moSolNeighborComparator& solNeighborComparator; + + // default comparators + // compare the fitness values of neighbors + moNeighborComparator defaultNeighborComp; + // compare the fitness values of the solution and the neighbor + moSolNeighborComparator defaultSolNeighborComp; + + // number of neighbor to explore + unsigned int kmax; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborEvalContinuator.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborEvalContinuator.h new file mode 100644 index 000000000..ba3a41a9d --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborEvalContinuator.h @@ -0,0 +1,94 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moNeighborEvalContinuator_h +#define _moNeighborEvalContinuator_h + +#include +#include +#include + +/** + * Continue until a maximum fixed number of neighbor evaluation is reached + * + * + * Becareful 1: if restartCounter is true, then the number of neighbor evaluations (for example incremental evaluations) is considered during the local search (not before it) + * + * Becareful 2: Can not be used if the evaluation function is used in parallel + */ +template< class Neighbor > +class moNeighborEvalContinuator : public moContinuator +{ +public: + typedef typename Neighbor::EOT EOT ; + + /** + * Constructor + * @param _eval neighbor evaluation function to count + * @param _maxNeighborEval number maximum of iterations + * @param _restartCounter if true the counter of number of evaluations restarts to "zero" at initialization, if false, the number is cumulative + */ + moNeighborEvalContinuator(moEvalCounter & _eval, unsigned int _maxNeighborEval, bool _restartCounter = true): eval(_eval), maxNeighborEval(_maxNeighborEval), restartCounter(_restartCounter) {} + + /** + * Test if continue + * @param _solution a solution + * @return true if number of evaluations < maxNeighborEval + */ + virtual bool operator()(EOT & _solution) { + return (eval.value() - nbEval_start < maxNeighborEval); + } + + /** + * Reset the number of evaluations + * @param _solution a solution + */ + virtual void init(EOT & _solution) { + if (restartCounter) + nbEval_start = eval.value(); + else + nbEval_start = 0; + } + + /** + * the current number of evaluation from the begining + * @return the number of evaluation + */ + unsigned int value() { + return eval.value() - nbEval_start ; + } + +private: + moEvalCounter & eval; + unsigned int maxNeighborEval; + bool restartCounter; + unsigned int nbEval_start ; + +}; +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborFitnessStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborFitnessStat.h new file mode 100644 index 000000000..ab0d3bcb9 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborFitnessStat.h @@ -0,0 +1,113 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moNeighborFitnessStat_h +#define moNeighborFitnessStat_h + +#include +#include +#include + +/** + * Compute the fitness of one random neighbor + */ +template< class Neighbor > +class moNeighborFitnessStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef moNeighborhood Neighborhood ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, Fitness >::value; + + /** + * Constructor + * @param _neighborhood a neighborhood + * @param _eval an evaluation function + */ + moNeighborFitnessStat(Neighborhood& _neighborhood, moEval& _eval): + moStat(Fitness(), "neighborhood"), + neighborhood(_neighborhood), eval(_eval) + { + if (!neighborhood.isRandom()) { + std::cout << "moNeighborFitnessStat::Warning -> the neighborhood used is not random, the neighbor will not be random" << std::endl; + } + } + + /** + * Compute the fitness of one random neighbor + * @param _solution the first solution + */ + virtual void init(EOT & _solution) { + operator()(_solution); + } + + /** + * Compute the fitness of one random neighbor + * @param _solution the corresponding solution + */ + virtual void operator()(EOT & _solution) { + if (neighborhood.hasNeighbor(_solution)) { + Neighbor current ; + + //init the first neighbor which is supposed to be random + neighborhood.init(_solution, current); + + //eval the _solution moved with the neighbor and stock the result in the neighbor + eval(_solution, current); + + // the fitness value is collected + value() = current.fitness(); + } else { + //if _solution hasn't neighbor, + value() = Fitness(); + } + } + + /** + * @return the class name + */ + virtual std::string className(void) const { + return "moNeighborFitnessStat"; + } + +private: + // the neighborhood + Neighborhood& neighborhood ; + moEval& eval; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborhoodStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborhoodStat.h new file mode 100644 index 000000000..c3fdc278e --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeighborhoodStat.h @@ -0,0 +1,264 @@ +/* + + 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 + +#include +#include +#include +#include + +/** + * All possible statitic on the neighborhood fitness + * to combine with other specific statistic to print them + */ +template< class Neighbor > +class moNeighborhoodStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef moNeighborhood Neighborhood ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, bool >::value; + + /** + * 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& _eval, moNeighborComparator& _neighborComparator, moSolNeighborComparator& _solNeighborComparator): + moStat(true, "neighborhood"), + neighborhood(_neighborhood), eval(_eval), + neighborComparator(_neighborComparator), + solNeighborComparator(_solNeighborComparator) + {} + + /** + * Default Constructor + * where the comparators are basic, there only compare the fitness values + * + * @param _neighborhood a neighborhood + * @param _eval an evaluation function + */ + moNeighborhoodStat(Neighborhood& _neighborhood, moEval& _eval): + moStat(true, "neighborhood"), + neighborhood(_neighborhood), eval(_eval), + neighborComparator(defaultNeighborComp), + solNeighborComparator(defaultSolNeighborComp) + {} + + /** + * Compute classical statistics of the first solution's neighborhood + * @param _solution the first solution + */ + virtual void init(EOT & _solution) { + operator()(_solution); + } + + /** + * 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"; + } + +protected: + + //the neighborhood + Neighborhood& neighborhood ; + moEval& eval; + + // comparator betwenn solution and neighbor or between neighbors + moNeighborComparator& neighborComparator; + moSolNeighborComparator& solNeighborComparator; + + // default comparators + // compare the fitness values of neighbors + moNeighborComparator defaultNeighborComp; + // compare the fitness values of the solution and the neighbor + moSolNeighborComparator defaultSolNeighborComp; + + // 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 diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeutralDegreeNeighborStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeutralDegreeNeighborStat.h new file mode 100644 index 000000000..88ab663b4 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moNeutralDegreeNeighborStat.h @@ -0,0 +1,90 @@ +/* + + 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 +#include + +/** + * From moNeighborhoodStat, to compute the neutral degree of the solution + * which is the number of solutions in the neighborhood + * with equals fitness + */ +template< class Neighbor > +class moNeutralDegreeNeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, unsigned >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moNeutralDegreeNeighborStat(moNeighborhoodStat & _nhStat): + moStat(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 first solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getNbEqual(); + } + + /** + * 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 & nhStat; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moSecondMomentNeighborStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moSecondMomentNeighborStat.h new file mode 100644 index 000000000..c5b1009f7 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moSecondMomentNeighborStat.h @@ -0,0 +1,90 @@ +/* + + 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 +#include + +/** + * From moNeighborhoodStat, to compute the average and the standard deviation of fitness in the neighborhood + */ +template< class Neighbor > +class moSecondMomentNeighborStat : public moStat > +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, std::pair >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moSecondMomentNeighborStat(moNeighborhoodStat & _nhStat): + moStat >(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 first solution + */ + virtual void init(EOT & _sol) { + value().first = nhStat.getMean(); + value().second = nhStat.getSD(); + } + + /** + * 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 & nhStat; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moSizeNeighborStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moSizeNeighborStat.h new file mode 100644 index 000000000..6e7ae60f1 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moSizeNeighborStat.h @@ -0,0 +1,89 @@ +/* + + 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 +#include + +/** + * From moNeighborhoodStat, to compute the number of solutions in the neighborhood + * + */ +template< class Neighbor > +class moSizeNeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, unsigned >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moSizeNeighborStat(moNeighborhoodStat & _nhStat): + moStat(0, "size"), nhStat(_nhStat) {} + + /** + * Set the number of solutions in the neighborhood + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getSize(); + } + + /** + * 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 & nhStat; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moSolutionStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moSolutionStat.h new file mode 100644 index 000000000..17a997e25 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moSolutionStat.h @@ -0,0 +1,82 @@ +/* + + 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 + +/** + * The statistic which only give the current solution. + * Be careful, the solution is given by copy + * + */ +template +class moSolutionStat : public moStat +{ +public : + using moStat< EOT, EOT >::value; + + /** + * Constructor + * @param _description a description of the parameter + */ + moSolutionStat(std::string _description = "solution"): + moStat(EOT(), _description) { } + + /** + * Initialization the solution by copy + * @param _sol the intial solution + */ + virtual void init(EOT & _sol) { + value() = _sol; + } + + /** + * 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 diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStat.h new file mode 100644 index 000000000..b986166f3 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStat.h @@ -0,0 +1,61 @@ +/* + + 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 + +/** + * 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 moStat : public eoValueParam, public moStatBase +{ +public: + + /** + * Constructor + * @param _value a default parameter's value + * @param _description a description of the parameter + */ + moStat(T _value, std::string _description): + eoValueParam(_value, _description) {} + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStatBase.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStatBase.h new file mode 100644 index 000000000..f0553ee1f --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStatBase.h @@ -0,0 +1,61 @@ +/* + + 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 +#include + +/** + * Base class for all statistics that need to be calculated + * over the solution +*/ +template +class moStatBase : public eoUF +{ +public: + /** + * last call of a statistical operator + */ + virtual void lastCall(EOT &) {} + + /** + * first call of a statistical operator + */ + virtual void init(EOT &) {} + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStatFromStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStatFromStat.h new file mode 100644 index 000000000..e8da634ad --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStatFromStat.h @@ -0,0 +1,83 @@ +/* + + 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 moStatFromStat_h +#define moStatFromStat_h + +#include + +/** + * The statistic which copy another statistic + */ +template +class moStatFromStat : public moStat +{ +public : + using moStat< EOT , T >::value; + + /** + * Constructor + * @param _stat a stat + */ + moStatFromStat(moStat & _stat): moStat(0, _stat.description()), stat(_stat) { + } + + /** + * The value of this stat is a copy of the value of the initial stat + * @param _sol a solution + */ + virtual void init(EOT & _sol) { + value() = stat.value(); + } + + /** + * The value of this stat is a copy of the value of the initial stat + * @param _sol a solution + */ + virtual void operator()(EOT & _sol) { + value() = stat.value(); + } + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moStatFromStat"; + } + +private: + moStat & stat; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStdFitnessNeighborStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStdFitnessNeighborStat.h new file mode 100644 index 000000000..b9a547954 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moStdFitnessNeighborStat.h @@ -0,0 +1,88 @@ +/* + + 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 moStdFitnessNeighborStat_h +#define moStdFitnessNeighborStat_h + +#include +#include + +/** + * From moNeighborhoodStat, to compute the average and the standard deviation of fitness in the neighborhood + */ +template< class Neighbor > +class moStdFitnessNeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, double >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moStdFitnessNeighborStat(moNeighborhoodStat & _nhStat): + moStat(0.0, "stdev"), nhStat(_nhStat) {} + + /** + * Set the average and the standard deviation of fitness in the neighborhood + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getSD(); + } + + /** + * Set the average and the standard deviation of fitness in the neighborhood + * @param _sol the corresponding solution + */ + virtual void operator()(EOT & _sol) { + value() = nhStat.getSD(); + } + + /** + * @return the class name + */ + virtual std::string className(void) const { + return "moStdFitnessNeighborStat"; + } + +private: + /** moNeighborhoodStat */ + moNeighborhoodStat & nhStat; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moTimeContinuator.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moTimeContinuator.h new file mode 100644 index 000000000..c393a07ec --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moTimeContinuator.h @@ -0,0 +1,131 @@ +/* + +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 _moTimeContinuator_h +#define _moTimeContinuator_h + +#include + +/** + * Termination condition until a running time is reached. + */ +template < class Neighbor > +class moTimeContinuator: public moContinuator +{ +public: + + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _max maximum running time + * @param _verbose verbose mode true/false -> on/off + */ + moTimeContinuator(time_t _max, bool _verbose = true): max(_max), verbose(_verbose) { + external = false; + start = time(NULL); + } + + + /** + * Synchronize the whole time with an external starting time + * @param _externalStart external starting time + */ + virtual void setStartingTime(time_t _externalStart) { + external = true; + start = _externalStart; + } + + + /** + * To get the starting time + * @return starting time + */ + virtual time_t getStartingTime() { + return start; + } + + + /** + * To set the maximum running time + * + * @param _maxTime maximum running time + */ + virtual void maxTime(time_t _maxTime) { + max = _maxTime; + } + + + /** + * Returns false when the running time is reached. + * @param _sol the current solution + */ + virtual bool operator() (EOT& _sol) + { + bool res; + time_t elapsed = (time_t) difftime(time(NULL), start); + res = (elapsed < max); + if (!res && verbose) + std::cout << "STOP in moTimeContinuator: Reached maximum time [" << elapsed << "/" << max << "]" << std::endl; + return res; + } + + /** + * reset the start time + * @param _solution a solution + */ + virtual void init(EOT & _solution) { + if (!external) + start = time(NULL); + } + + + /** + * Class name + */ + virtual std::string className(void) const + { + return "moTimeContinuator"; + } + + +private: + + /** maximum running time */ + time_t max; + /** starting time */ + time_t start; + /** external start flag */ + bool external; + /** verbose mode */ + bool verbose; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moTrueContinuator.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moTrueContinuator.h new file mode 100644 index 000000000..88feb91a3 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moTrueContinuator.h @@ -0,0 +1,68 @@ +/* + + 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 always return True + */ +template< class Neighbor > +class moTrueContinuator : public moContinuator +{ +public: + typedef typename Neighbor::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 diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moUnsignedStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moUnsignedStat.h new file mode 100644 index 000000000..c1f8342cd --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moUnsignedStat.h @@ -0,0 +1,82 @@ +/* + + 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 moUnsignedStat_h +#define moUnsignedStat_h + +#include + +/** + * The statistic gives from a boolean variable + */ +template +class moUnsignedStat : public moStat +{ +public : + using moStat< EOT, unsigned int>::value; + + /** + * Default Constructor + */ + moUnsignedStat(unsigned int * _b): moStat(*_b, "unsigned"), b(_b) { + } + + /** + * Init the number of iteration + * @param _sol a solution + */ + virtual void init(EOT & _sol) { + value() = *b; + } + + /** + * Set the number of iteration + * @param _sol a solution + */ + virtual void operator()(EOT & _sol) { + value() = *b; + } + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moUnsignedStat"; + } + +private: + unsigned int * b; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moUpdater.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moUpdater.h new file mode 100644 index 000000000..0be846d38 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moUpdater.h @@ -0,0 +1,67 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moUpdater_h +#define moUpdater_h + +#include +#include + +/** + * Base class for to update what ever you want + * similar to eoUpdater + * But there is an init method ! +*/ +class moUpdater : public eoF +{ +public: + /** + * first call of the updater + */ + virtual void init() {} + + /** + * last call of the updater + */ + virtual void lastCall() {} + + /** + * class name + */ + virtual std::string className(void) const + { return "moUpdater"; } + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moValueStat.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moValueStat.h new file mode 100644 index 000000000..6c8806e87 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moValueStat.h @@ -0,0 +1,84 @@ +/* + + 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 moValueStat_h +#define moValueStat_h + +#include +#include + +/** + * The statistic gives the number of iteration + */ +template +class moValueStat : public moStat +{ +public : + using moStat< EOT, double>::value; + + /** + * Default Constructor + */ + moValueStat(eoValueParam & _valueParam): moStat(0, "value"), valueParam(_valueParam) { + } + + /** + * Init the number of iteration + * @param _sol a solution + */ + virtual void init(EOT & _sol) { + value() = (double) valueParam.value(); + } + + /** + * Set the number of iteration + * @param _sol a solution + */ + virtual void operator()(EOT & _sol) { + value() = (double) valueParam.value() ; + } + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moValueStat"; + } + +private: + eoValueParam & valueParam; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moVectorMonitor.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moVectorMonitor.h new file mode 100644 index 000000000..b04eb8adf --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/continuator/moVectorMonitor.h @@ -0,0 +1,241 @@ +/* + + 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 moVectorMonitor_h +#define moVectorMonitor_h + +#include +#include +#include + +/** + * To save the values of the same type (double, unsigned int, or EOT) in a vector + * It is similar to eoFileMonitor + * + */ +template +class moVectorMonitor : public eoMonitor +{ +public: + + /** + * Constructor + * @param _param the parameter of type double to save in the vector + */ + moVectorMonitor(eoValueParam & _param) : doubleParam(&_param), intParam(NULL), eotParam(NULL) + { + // precision of the output by default + precisionOutput = std::cout.precision(); + } + + /** + * Default Constructor + * @param _param the parameter of type unsigned int to save in the vector + */ + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(&_param), eotParam(NULL) + { + // precision of the output by default + precisionOutput = std::cout.precision(); + } + + /** + * Default Constructor + * @param _param the parameter of type EOT to save in the vector + */ + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), eotParam(&_param) + { + // precision of the output by default + precisionOutput = std::cout.precision(); + } + + /** + * Default Constructor + * @param _param the parameter of type eoScalarFitness to save in the vector + */ + template + moVectorMonitor(eoValueParam > & _param) : doubleParam( & (eoValueParam&)_param), intParam(NULL), eotParam(NULL) + { + // precision of the output by default + precisionOutput = std::cout.precision(); + } + + /** + * Default Constructor + * @param _param unvalid Parameter + */ + template + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), eotParam(NULL) + { + std::cerr << "Sorry the type can not be in a vector of moVectorMonitor" << std::endl; + } + + /** + * To test if the value are basic type (double or unsigned int), or EOT type + * + * @return true if the type is a EOT type + */ + bool solutionType() { + return eotParam != NULL; + } + + /** + * To "print" the value of the parameter in the vector + * + * @return this monitor (sorry I don't why, but it is like this in EO) + */ + eoMonitor& operator()(void) { + if (doubleParam != NULL) + valueVec.push_back(doubleParam->value()); + else + if (intParam != NULL) + valueVec.push_back((double) intParam->value()); + else + eotVec.push_back(eotParam->value()); + return *this ; + } + + /** + * To have all the values + * + * @return the vector of values + */ + const std::vector& getValues() const { + return valueVec; + } + + /** + * To have all the solutions + * + * @return the vector of solutions + */ + const std::vector& getSolutions() const { + return eotVec; + } + + /** + * to get the value out. + * @return the string of the value + */ + std::string getValue(unsigned int i) const { + std::ostringstream os; + + // set the precision of the output + os.precision(precisionOutput); + + if (eotParam == NULL) + os << (valueVec[i]) ; + else + os << (eotVec[i]) ; + + return os.str(); + } + + /** + * clear the vector + */ + void clear() { + valueVec.clear(); + eotVec.clear(); + } + + /** + * number of value + * @return size of the vector + */ + unsigned int size() { + if (eotParam == NULL) + return valueVec.size(); + else + return eotVec.size(); + } + + /** + * to set the precision of the output file + * @param _precision precision of the output (number of digit) + */ + void precision(unsigned int _precision) { + precisionOutput = _precision; + } + + /** + * to export the vector of values into one file + * @param _filename file name + * @param _openFile to specify if it writes at the following of the file + */ + void fileExport(std::string _filename, bool _openFile=false) { + // create file + std::ofstream os; + + if(! _openFile) + os.open(_filename.c_str()); + + else + os.open(_filename.c_str(),std::ios::app); + + + if (!os) { + std::string str = "moVectorMonitor: Could not open " + _filename; + throw std::runtime_error(str); + } + + for (unsigned int i = 0; i < size(); i++) { + os << getValue(i); + + os << std::endl ; + } + + } + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moVectorMonitor"; + } + +protected: + eoValueParam * doubleParam ; + eoValueParam * intParam ; + eoValueParam * eotParam ; + + std::vector valueVec; + std::vector eotVec; + + // precision of the output + unsigned int precisionOutput; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moDoubleIncrEvaluation.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moDoubleIncrEvaluation.h new file mode 100644 index 000000000..c7027e2b8 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moDoubleIncrEvaluation.h @@ -0,0 +1,104 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moDoubleIncrEvaluation_H +#define moDoubleIncrEvaluation_H + +#include +#include + +/** + * Base class for the double incremental evaluation of the neighborhood + * + * The sizes of the neighborhoods are equal + */ +template +class moDoubleIncrEvaluation : public moNeighborhoodEvaluation, public moUpdater +{ +public: + typedef typename Neighbor::EOT EOT; + typedef typename EOT::Fitness Fitness; + + /** + * Constructor + * + * @param _neighborhoodSize the size of the neighborhood + */ + moDoubleIncrEvaluation(unsigned int _neighborhoodSize) : moNeighborhoodEvaluation(), moUpdater(), neighborhoodSize(_neighborhoodSize), firstEval(true) { + deltaFitness = new Fitness[neighborhoodSize]; + } + + /** + * Destructor + */ + ~moDoubleIncrEvaluation() { + if (deltaFitness != NULL) + delete [] deltaFitness; + } + + /** + * Initialisation of the evaluation process + * The first evaluation will be a simple incremental evaluation + * + */ + virtual void init() { + firstEval = true; + } + + virtual void operator()() { + } + + /** + * Evaluation of the neighborhood + * Here nothing to do + * + * @param _solution the current solution + */ + virtual void operator()(EOT & _solution) { + } + + /** the delta of fitness for each neighbors + * The fitness of the neighbor i is given by : fitness(solution) + deltaFitness[i] + */ + Fitness * deltaFitness; + +protected: + /** the neighborhood size */ + unsigned int neighborhoodSize; + + /** flag : true when it is the first evaluation */ + bool firstEval; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moDoubleIncrNeighborhoodEval.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moDoubleIncrNeighborhoodEval.h new file mode 100644 index 000000000..61ef09176 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moDoubleIncrNeighborhoodEval.h @@ -0,0 +1,76 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moDoubleIncrNeighborhoodEval_H +#define moDoubleIncrNeighborhoodEval_H + +#include +#include + +/** + * Evaluation of a neighbor from the full evaluation f the neighborhood + * + * + */ +template +class moDoubleIncrNeighborhoodEval : public moEval +{ +public: + typedef typename moEval::EOT EOT; + + /** + * Ctor + * @param _evaluation the double incremental evaluation of the neighborhood + */ + moDoubleIncrNeighborhoodEval(moDoubleIncrEvaluation& _evaluation) : evaluation(_evaluation) {} + + /** + * evaluation of a neighbor with the double incremental evaluation + * + * @param _sol current solution + * @param _neighbor the neighbor to be evaluated + */ + void operator()(EOT & _sol, Neighbor & _neighbor) + { + _neighbor.fitness(_sol.fitness() + evaluation.deltaFitness[_neighbor.index()]); + } + + +private: + /** the evaluation of the neighborhood */ + moDoubleIncrEvaluation & evaluation; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moDummyEval.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moDummyEval.h new file mode 100644 index 000000000..2809f12a3 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moDummyEval.h @@ -0,0 +1,53 @@ +/* + +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 _moDummyEval_h +#define _moDummyEval_h + +#include + +/** + * Dummy Evaluation function + */ +template +class moDummyEval : public moEval { +public: + typedef typename Neighbor::EOT EOT; + typedef typename EOT::Fitness Fitness; + + /** + * NOTHING TO DO + * @param _sol unused solution + * @param _n unused neighbor + */ + void operator()(EOT& _sol, Neighbor& _n) {} + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moEval.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moEval.h new file mode 100644 index 000000000..835a8ae8e --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moEval.h @@ -0,0 +1,51 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 + +/** + * Abstract class for the evaluation + */ +template +class moEval : public eoBF +{ +public: + typedef typename Neighbor::EOT EOT; + typedef typename EOT::Fitness Fitness; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moEvalCounter.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moEvalCounter.h new file mode 100644 index 000000000..e795f4384 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moEvalCounter.h @@ -0,0 +1,66 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moEvalCounter_h +#define _moEvalCounter_h + +#include +#include + +/** + Counts the number of neighbor evaluations actually performed, thus checks first + if it has to evaluate.. etc. +*/ +template +class moEvalCounter : public moEval, public eoValueParam +{ +public: + typedef typename Neighbor::EOT EOT; + typedef typename EOT::Fitness Fitness; + + moEvalCounter(moEval& _eval, std::string _name = "Neighbor Eval. ") + : eoValueParam(0, _name), eval(_eval) {} + + /** + * Increase the number of neighbor evaluations and perform the evaluation + * + * @param _solution a solution + * @param _neighbor a neighbor + */ + void operator()(EOT& _solution, Neighbor& _neighbor) { + value()++; + eval(_solution, _neighbor); + } + +private: + moEval & eval; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moFullEvalByCopy.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moFullEvalByCopy.h new file mode 100644 index 000000000..701a7b951 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moFullEvalByCopy.h @@ -0,0 +1,82 @@ + /* + + 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 +#include + +/** + * Evaluation by copy + */ +template +class moFullEvalByCopy : public moEval +{ +public: + typedef typename moEval::EOT EOT; + typedef typename moEval::Fitness Fitness; + + /** + * Ctor + * @param _eval the full evaluation object + */ + moFullEvalByCopy(eoEvalFunc & _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 & eval; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moFullEvalByModif.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moFullEvalByModif.h new file mode 100644 index 000000000..80ee94d1c --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moFullEvalByModif.h @@ -0,0 +1,96 @@ +/* + + 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 +#include + +/** + * Full evaluation to use with a moBackableNeighbor + * !!!WARNING!!! Use only when your solution is composed by a fitness Value and a "genotype" + * + */ +template +class moFullEvalByModif : public moEval +{ +public: + typedef typename moEval::EOT EOT; + typedef typename moEval::Fitness Fitness; + + /** + * Ctor + * @param _eval the full evaluation object + */ + moFullEvalByModif(eoEvalFunc& _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 & eval; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moNeighborhoodEvaluation.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moNeighborhoodEvaluation.h new file mode 100644 index 000000000..92274c133 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/eval/moNeighborhoodEvaluation.h @@ -0,0 +1,56 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moNeighborhoodEvaluation_H +#define moNeighborhoodEvaluation_H + +#include + +/** + * Abstract class for the evaluation + * of all the neighborhood + * in one step + * + * It is usefull for example in a double incremental evaluation (QAP, UBQP problems) + * This class is used in combinaison with the class moEvaluatedNeighborhood + */ +template +class moNeighborhoodEvaluation : public eoUF +{ +public: + typedef typename Neighbor::EOT EOT; + typedef typename EOT::Fitness Fitness; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moAspiration.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moAspiration.h new file mode 100644 index 000000000..7a9e338e0 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moAspiration.h @@ -0,0 +1,59 @@ +/* + +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 _moAspiration_h +#define _moAspiration_h + +#include + +/** + * Abstract class for Aspiration Criteria + */ +template< class Neighbor > +class moAspiration : public eoBF +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * Virtual Init + * @param _sol the current solution + */ + virtual void init(EOT & _sol) = 0; + + /** + * Virtual update + * @param _sol the current solution + * @param _neighbor the current neighbor + */ + virtual void update(EOT & _sol, Neighbor & _neighbor) = 0; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moBestImprAspiration.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moBestImprAspiration.h new file mode 100644 index 000000000..7187ef666 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moBestImprAspiration.h @@ -0,0 +1,87 @@ +/* + +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 _moBestImprAspiration_h +#define _moBestImprAspiration_h + +#include + +/** + * Aspiration criteria accepts a solution better than the best so far + */ +template< class Neighbor > +class moBestImprAspiration : public moAspiration +{ +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 diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moCountMoveMemory.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moCountMoveMemory.h new file mode 100644 index 000000000..22cbba5fd --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moCountMoveMemory.h @@ -0,0 +1,119 @@ +/* + +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 _moCountMoveMemory_h +#define _moCountMoveMemory_h + +#include + +/** + * Count the number of move, no move and the successive stagnation since the last Move + */ +template< class Neighbor > +class moCountMoveMemory : virtual public moMemory { + +public: + typedef typename Neighbor::EOT EOT; + + /** + * Init all the counters + * @param _sol unused solution + */ + void init(EOT & _sol) { + nbMove=0; + nbNoMove=0; + counter=0; + } + + /** + * @param _sol unused solution + * @param _neighbor unused neighbor + */ + void add(EOT & _sol, Neighbor & _neighbor) { + nbMove++; + counter=0; + } + + /** + * @param _sol unused solution + * @param _neighbor unused neighbor + */ + void update(EOT & _sol, Neighbor & _neighbor) { + nbNoMove++; + counter++; + } + + /** + * ClearMemory : Reinit all the counters + */ + void clearMemory() { + nbMove=0; + nbNoMove=0; + counter=0; + } + + /** + * Getter of the number of move + * @return the counter + */ + unsigned int getNbMove() { + return nbMove; + } + + /** + * Getter of the number of no move + * @return the counter + */ + unsigned int getNbNoMove() { + return nbNoMove; + } + + /** + * Getter of the number of successive stagnation since the last Move + * @return the counter + */ + unsigned int getCounter() { + return counter; + } + + /** + * Init counter + */ + void initCounter() { + counter=0; + } + +private: + unsigned int nbMove; + unsigned int nbNoMove; + unsigned int counter; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDiversification.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDiversification.h new file mode 100644 index 000000000..5df67a3fe --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDiversification.h @@ -0,0 +1,42 @@ +/* + +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 _moDiversification_h +#define _moDiversification_h + +#include +#include + +/** + * Abstract class for diversification strategy + */ +template< class Neighbor > +class moDiversification : virtual public moMemory, public eoUF {}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDummyDiversification.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDummyDiversification.h new file mode 100644 index 000000000..72cd1f686 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDummyDiversification.h @@ -0,0 +1,53 @@ +/* + +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 _moDummyDiversification_h +#define _moDummyDiversification_h + +#include +#include + +/** + * Dummy diversification strategy + */ +template< class Neighbor > +class moDummyDiversification : public moDiversification, public moDummyMemory +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * @return always false + */ + bool operator()(EOT &) { + return false; + } +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDummyIntensification.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDummyIntensification.h new file mode 100644 index 000000000..d6fd9ef3d --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDummyIntensification.h @@ -0,0 +1,53 @@ +/* + +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 _moDummyIntensification_h +#define _moDummyIntensification_h + +#include +#include + +/** + * Dummy intensification strategy + */ +template< class Neighbor > +class moDummyIntensification : public moIntensification, public moDummyMemory +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * @return always false + */ + bool operator()(EOT &) { + return false; + } +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDummyMemory.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDummyMemory.h new file mode 100644 index 000000000..c927a30f0 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moDummyMemory.h @@ -0,0 +1,67 @@ +/* + +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 _moDummyMemory_h +#define _moDummyMemory_h + +#include + +/** + * Dummy memory to make an empty memory + */ +template< class Neighbor > +class moDummyMemory : virtual public moMemory { + +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() {} + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moIndexedVectorTabuList.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moIndexedVectorTabuList.h new file mode 100644 index 000000000..f01e17f1b --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moIndexedVectorTabuList.h @@ -0,0 +1,121 @@ +/* + +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 _moIndexedVectorTabuList_h +#define _moIndexedVectorTabuList_h + +#include +#include +#include + +/** + * Tabu List of indexed neighbors save in a vector + * each neighbor can not used during howlong iterations + */ +template +class moIndexedVectorTabuList : public moTabuList +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _maxSize maximum size of the tabu list + * @param _howlong how many iteration a move is tabu + */ + moIndexedVectorTabuList(unsigned int _maxSize, unsigned int _howlong) : maxSize(_maxSize), howlong(_howlong) { + tabuList.resize(_maxSize); + } + + /** + * init the tabuList by clearing the memory + * @param _sol the current solution + */ + virtual void init(EOT & _sol) { + clearMemory(); + } + + + /** + * add a new neighbor in the tabuList + * @param _sol unused solution + * @param _neighbor the current neighbor + */ + virtual void add(EOT & _sol, Neighbor & _neighbor) { + if (_neighbor.index() < maxSize) + tabuList[_neighbor.index()] = howlong; + } + + /** + * update the tabulist by decreasing the number of tabu iteration + * @param _sol unused solution + * @param _neighbor unused neighbor + */ + virtual void update(EOT & _sol, Neighbor & _neighbor) { + for (unsigned int i = 0; i < maxSize; i++) + if (tabuList[i] > 0) + tabuList[i]--; + } + + /** + * check if the move is tabu + * @param _sol unused solution + * @param _neighbor the current neighbor + * @return true if tabuList contains _sol + */ + virtual bool check(EOT & _sol, Neighbor & _neighbor) { + return (tabuList[_neighbor.index()] > 0); + } + + /** + * clearMemory: remove all solution of the tabuList + */ + virtual void clearMemory() { + for (unsigned int i = 0; i < maxSize; i++) + tabuList[i] = 0; + } + + void print(){ + std::cout << "Tabulist:" << std::endl; + for(int i=0; i tabuList; + //maximum size of the tabu list + unsigned int maxSize; + //how many iteration a move is tabu + unsigned int howlong; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moIntensification.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moIntensification.h new file mode 100644 index 000000000..44d6c1bc3 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moIntensification.h @@ -0,0 +1,42 @@ +/* + +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 _moIntensification_h +#define _moIntensification_h + +#include +#include + +/** + * Abstract class for intensification strategy + */ +template< class Neighbor > +class moIntensification : virtual public moMemory, public eoUF {}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moMemory.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moMemory.h new file mode 100644 index 000000000..c45f583af --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moMemory.h @@ -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 to 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 diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moMonOpDiversification.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moMonOpDiversification.h new file mode 100644 index 000000000..46fa8547b --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moMonOpDiversification.h @@ -0,0 +1,72 @@ +/* + +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 _moMonOpDiversification_h +#define _moMonOpDiversification_h + + +#include +#include +#include +#include + +/** + * Diversification strategy applies a "monOp" operator + */ +template< class Neighbor > +class moMonOpDiversification : public moDiversification, public moDummyMemory +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _monOp an eoMonOp (diversification operator) + * @param _fullEval a full evaluation function + */ + moMonOpDiversification(eoMonOp& _monOp, eoEvalFunc& _fullEval):monOp(_monOp), fullEval(_fullEval) {} + + /** + * Apply monOp on the solution + * @param _solution to diversify + * @return value of monOp + */ + bool operator()(EOT& _solution) { + bool res = monOp(_solution); + fullEval(_solution); + return res; + } + +private: + /** monOp */ + eoMonOp& monOp; + eoEvalFunc& fullEval; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moNeighborVectorTabuList.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moNeighborVectorTabuList.h new file mode 100644 index 000000000..dbf8edb0f --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moNeighborVectorTabuList.h @@ -0,0 +1,138 @@ +/* + +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 _moNeighborVectorTabuList_h +#define _moNeighborVectorTabuList_h + +#include +#include +#include + +/** + * Tabu List of neighbors stocked in a vector + */ +template +class moNeighborVectorTabuList : public moTabuList +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _maxSize maximum size of the tabu list + * @param _howlong how many iteration a move is tabu (0 -> no limits) + */ + moNeighborVectorTabuList(unsigned int _maxSize, unsigned int _howlong) : maxSize(_maxSize), howlong(_howlong), index(0) { + 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 neighbor in the tabuList + * @param _sol unused solution + * @param _neighbor the current neighbor + */ + virtual void add(EOT & _sol, Neighbor & _neighbor) { + + if (tabuList.size() < maxSize) { + std::pair tmp; + tmp.first=_neighbor; + tmp.second=howlong; + tabuList.push_back(tmp); + } + else { + tabuList[index%maxSize].first = _neighbor; + tabuList[index%maxSize].second = howlong; + index++; + } + } + + /** + * update the tabulist + * @param _sol unused solution + * @param _neighbor unused neighbor + */ + virtual void update(EOT & _sol, Neighbor & _neighbor) { + if (howlong > 0) + for (unsigned int i=0; i 0) + tabuList[i].second--; + } + + /** + * check if the move is tabu + * @param _sol unused solution + * @param _neighbor the current neighbor + * @return true if tabuList contains _sol + */ + virtual bool check(EOT & _sol, Neighbor & _neighbor) { + for (unsigned int i=0; i 0 && tabuList[i].second > 0 && tabuList[i].first.equals(_neighbor)) || (howlong==0 && tabuList[i].first.equals(_neighbor))) + return true; + } + return false; + } + + /** + * clearMemory: remove all solution of the tabuList + */ + virtual void clearMemory() { + tabuList.resize(0); + index = 0; + } + + void print(){ + std::cout << "TAbulist:" << std::endl; + for(int i=0; i > 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 diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moRndIndexedVectorTabuList.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moRndIndexedVectorTabuList.h new file mode 100644 index 000000000..82ffc0e04 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moRndIndexedVectorTabuList.h @@ -0,0 +1,81 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel + + 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 _moRndIndexedVectorTabuList_h +#define _moRndIndexedVectorTabuList_h + +#include +#include + + +/** + * Tabu List of indexed neighbors save in a vector + * each neighbor can not used during howlong + rnd(howlongRnd) iterations + * see paper: + * Zhipeng Lu, Fred Glover, Jin-Kao Hao. "A Hybrid Metaheuristic Approach to Solving the UBQP Problem". European Journal of Operational Research, 2010. + */ +template +class moRndIndexedVectorTabuList : public moIndexedVectorTabuList +{ +public: + typedef typename Neighbor::EOT EOT; + + //tabu list + using moIndexedVectorTabuList::tabuList; + //maximum size of the tabu list + using moIndexedVectorTabuList::maxSize; + //how many iteration a move is tabu + using moIndexedVectorTabuList::howlong; + + /** + * Constructor + * @param _maxSize maximum size of the tabu list + * @param _howlong how many minimal iteration a move is tabu + * @param _howlongRnd how many additional iterations a move is tabu (random between [0 , _howlongRnd [ ) + */ + moRndIndexedVectorTabuList(unsigned int _maxSize, unsigned int _howlong, unsigned int _howlongRnd) : moIndexedVectorTabuList(_maxSize, _howlong), howlongRnd(_howlongRnd) { + } + + /** + * add a new neighbor in the tabuList + * @param _sol unused solution + * @param _neighbor the current neighbor + */ + virtual void add(EOT & _sol, Neighbor & _neighbor) { + if (_neighbor.index() < maxSize) + tabuList[_neighbor.index()] = howlong + rng.uniform(howlongRnd) ; + } + + +protected: + // the random part of the forbidden time + unsigned int howlongRnd; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moSolVectorTabuList.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moSolVectorTabuList.h new file mode 100644 index 000000000..ba72ccc43 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moSolVectorTabuList.h @@ -0,0 +1,134 @@ +/* + +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 _moSolVectorTabuList_h +#define _moSolVectorTabuList_h + +#include +#include +#include + +/** + * Tabu List of solution stocked in a vector + */ +template +class moSolVectorTabuList : public moTabuList +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _maxSize maximum size of the tabu list + * @param _howlong how many iteration a solution 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 unused neighbor + */ + virtual void add(EOT & _sol, Neighbor & _neighbor) { + + if (tabuList.size() < maxSize) { + std::pair 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) { + if (howlong > 0) + for (unsigned int i=0; i 0) + 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 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 > 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 diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moTabuList.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moTabuList.h new file mode 100644 index 000000000..018996e8a --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/memory/moTabuList.h @@ -0,0 +1,53 @@ +/* + +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 _moTabuList_h +#define _moTabuList_h + +#include + +/** + * Abstract class for the Tabu List + */ +template< class Neighbor > +class moTabuList : public moMemory +{ +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 diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moBackableNeighbor.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moBackableNeighbor.h new file mode 100644 index 000000000..4a851c451 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moBackableNeighbor.h @@ -0,0 +1,56 @@ +/* + + 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 + +/** + * Neighbor with a move back function to use in a moFullEvalByModif + */ +template< class EOT, class Fitness=typename EOT::Fitness > +class moBackableNeighbor : virtual public moNeighbor +{ +public: + + /** + * the function to move back a solution + * @param _solution the solution to moveBack + */ + virtual void moveBack(EOT & _solution)=0; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moBackwardVectorVNSelection.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moBackwardVectorVNSelection.h new file mode 100644 index 000000000..b3050c439 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moBackwardVectorVNSelection.h @@ -0,0 +1,100 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moBackwardVectorVNSelection_h +#define _moBackwardVectorVNSelection_h + +#include + +/** + * This class is used for the Variable Neighborhood Search explorer inherits from moVectorVNSelection + * The search heuristics are saved in vectors + * They are given in backward order from the last ones to the first ones + * + */ +template< class EOT > +class moBackwardVectorVNSelection: public moVectorVNSelection{ + + using moVectorVNSelection::LSvector; + using moVectorVNSelection::current; + +public: + + /** + * Default constructor with first search heuristics + * + * @param _firstLS first local search + * @param _firstShake first heuristic which perturbs the solution + * @param _cycle when true, the first heuristics follows the last ones. Otherwise the search stop. + */ + moBackwardVectorVNSelection(eoMonOp& _firstLS, eoMonOp& _firstShake, bool _cycle = true) : moVectorVNSelection(_firstLS, _firstShake), cycle(_cycle){} + + /** + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moBackwardVectorVNSelection"; + } + + /** + * test if there is still some heuristics + * + * @param _solution the current solution + * @return true if there is some heuristics + */ + virtual bool cont(EOT& _solution){ + return (cycle || (current > 0)); + } + + /** + * put the current heuristics on the first ones + * + * @param _solution the current solution + */ + virtual void init(EOT& _solution){ + current = LSvector.size() - 1; + } + + /** + * put the current heuristics on the next ones + * + * @param _solution the current solution + */ + virtual void next(EOT& _solution){ + current = (current + LSvector.size() -1) % LSvector.size(); + } + +private: + // boolean to indicate the last heuristics follow the first ones + bool cycle; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moDummyNeighbor.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moDummyNeighbor.h new file mode 100644 index 000000000..a8cd01087 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moDummyNeighbor.h @@ -0,0 +1,48 @@ +/* + +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 _moDummyNeighbor_h +#define _moDummyNeighbor_h + +#include + +/** + * Dummy Neighborhood + */ +template< class EOT, class Fitness=typename EOT::Fitness > +class moDummyNeighbor : public moNeighbor< EOT, Fitness > { +public: + + /** + * NOTHING TO DO + * @param _solution the related solution + */ + virtual void move(EOT& _solution) {} +}; +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moDummyNeighborhood.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moDummyNeighborhood.h new file mode 100644 index 000000000..26c62163c --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moDummyNeighborhood.h @@ -0,0 +1,78 @@ +/* + +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 _moDummyNeighborhood_h +#define _moDummyNeighborhood_h + +#include +#include + +/** + * Dummy Neighborhood + */ +template< class Neighbor > +class moDummyNeighborhood : public moNeighborhood { +public: + typedef typename Neighbor::EOT EOT; + + /** + * NOTHING TO DO + * @param _solution unused solution + * @return always false + */ + virtual bool hasNeighbor(EOT & _solution) { + return false; + } + + /** + * NOTHING TO DO + * @param _solution unused solution + * @param _current unused neighbor + */ + virtual void init(EOT & _solution, Neighbor & _current) {} + + /** + * NOTHING TO DO + * @param _solution unused solution + * @param _current unused neighbor + */ + virtual void next(EOT & _solution, Neighbor & _current) {} + + /** + * NOTHING TO DO + * @param _solution unused solution + * @return always false + */ + virtual bool cont(EOT & _solution) { + return false; + } + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moEvaluatedNeighborhood.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moEvaluatedNeighborhood.h new file mode 100644 index 000000000..52f1f54d8 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moEvaluatedNeighborhood.h @@ -0,0 +1,128 @@ + /* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moEvaluatedNeighborhood_h +#define _moEvaluatedNeighborhood_h + +#include +#include + +/** + * A Neighborhood for the evaluation of all neighbors + * in one step + * + * It is usefull for example in a double incremental evaluation (QAP, UBQP problems) + * This class is used in combinaison with the class moNeighborhoodEvaluation + */ +template +class moEvaluatedNeighborhood: public moNeighborhood { +public: + + /** + * Define type of a solution corresponding to Neighbor + */ + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _originalNeighborhood the original neighborhood to apply + * @param _nhEval the evaluation function of the neighborhood + */ + moEvaluatedNeighborhood(moNeighborhood & _originalNeighborhood, moNeighborhoodEvaluation & _nhEval) : + moNeighborhood(), originalNeighborhood(_originalNeighborhood), nhEval(_nhEval) { + } + + /** + * @return true if the neighborhood is random (default false) + */ + virtual bool isRandom() { + return originalNeighborhood.isRandom(); + } + + /** + * Test if a neighbor exists + * @param _solution the solution to explore + * @return true if the neighborhood was not empty + */ + virtual bool hasNeighbor(EOT& _solution) { + return originalNeighborhood.hasNeighbor(_solution); + } + + /** + * Initialization of the neighborhood with the full evaluation + * + * @param _solution the solution to explore + * @param _neighbor the first neighbor + */ + virtual void init(EOT & _solution, Neighbor & _neighbor) { + // full evaluation of the neighborhood + nhEval(_solution); + // initialisation of the original neighborhood + originalNeighborhood.init(_solution, _neighbor); + } + + /** + * Give the next neighbor with the original neighborhood + * @param _solution the solution to explore + * @param _neighbor the next neighbor + */ + virtual void next(EOT & _solution, Neighbor & _neighbor) { + originalNeighborhood.next(_solution, _neighbor); + } + + /** + * give the continuation with the original neighborhood + * + * @param _solution the solution to explore + * @return true if there is again a neighbor to explore + */ + virtual bool cont(EOT & _solution) { + return originalNeighborhood.cont(_solution); + } + + /** + * Return the class Name + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moEvaluatedNeighborhood"; + } + +protected: + moNeighborhood & originalNeighborhood; + moNeighborhoodEvaluation & nhEval ; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moForwardVectorVNSelection.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moForwardVectorVNSelection.h new file mode 100644 index 000000000..d7d3546cb --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moForwardVectorVNSelection.h @@ -0,0 +1,100 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moForwardVectorVNSelection_h +#define _moForwardVectorVNSelection_h + +#include + +/** + * This class is used for the Variable Neighborhood Search explorer inherits from moVectorVNSelection + * The search heuristics are saved in vectors + * They are given in forward order from the first ones to the last ones + * + */ +template< class EOT > +class moForwardVectorVNSelection: public moVectorVNSelection{ + + using moVectorVNSelection::LSvector; + using moVectorVNSelection::current; + +public: + + /** + * Default constructor with first search heuristics + * + * @param _firstLS first local search + * @param _firstShake first heuristic which perturbs the solution + * @param _cycle when true, the first heuristics follows the last ones. Otherwise the search stop. + */ + moForwardVectorVNSelection(eoMonOp& _firstLS, eoMonOp& _firstShake, bool _cycle = true) : moVectorVNSelection(_firstLS, _firstShake), cycle(_cycle){} + + /** + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moForwardVectorVNSelection"; + } + + /** + * test if there is still some heuristics + * + * @param _solution the current solution + * @return true if there is some heuristics + */ + virtual bool cont(EOT& _solution){ + return (cycle || (current <= (LSvector.size() - 2))); + } + + /** + * put the current heuristics on the first ones + * + * @param _solution the current solution + */ + virtual void init(EOT& _solution){ + current = 0; + } + + /** + * put the current heuristics on the next ones + * + * @param _solution the current solution + */ + virtual void next(EOT& _solution){ + current = (current + 1) % LSvector.size(); + } + +private: + // boolean to indicate the first heuristics follow the last ones + bool cycle; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moIndexNeighbor.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moIndexNeighbor.h new file mode 100644 index 000000000..52c9ea1b0 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moIndexNeighbor.h @@ -0,0 +1,115 @@ +/* + + 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 + +/** + * Index Neighbor + */ +template +class moIndexNeighbor: virtual public moNeighbor { +public: + + using moNeighbor::fitness; + + /** + * Default Constructor + */ + moIndexNeighbor() : + moNeighbor (), key(0) { + } + + /** + * Copy Constructor + * @param _n the neighbor to copy + */ + moIndexNeighbor(const moIndexNeighbor& _n) : + moNeighbor (_n) { + this->key = _n.key; + } + + /** + * Assignment operator + * @param _source the source neighbor + */ + + moIndexNeighbor & operator=(const moIndexNeighbor & _source) { + moNeighbor::operator=(_source); + this->key = _source.key; + return *this; + } + + /** + * Return the class Name + * @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; + } + + /** + * @param _neighbor a neighbor + * @return if _neighbor and this one are equals + */ + virtual bool equals(moIndexNeighbor& _neighbor) { + return (key == _neighbor.index()); + } + +protected: + // key allowing to describe the neighbor + unsigned int key; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h new file mode 100644 index 000000000..83d06b267 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h @@ -0,0 +1,89 @@ +/* + + 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 + +/** + * A Indexed Neighborhood + */ +template +class moIndexNeighborhood: virtual public moNeighborhood { +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) { + } + + /** + * getter to get the value of neighborhoodSize + * @return the neighborhoodSize + */ + unsigned int getNeighborhoodSize() const { + return neighborhoodSize; + } + + /** + * Setter to fixe the neighoodSize + * @param _neighborhoodSize the value to set + */ + + void setNeighborhoodSize(unsigned int _neighborhoodSize) { + neighborhoodSize = _neighborhoodSize; + } + + /** + * Return the class Name + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moIndexNeighborhood"; + } + +protected: + // size of the neighborhood + unsigned int neighborhoodSize; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moNeighbor.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moNeighbor.h new file mode 100644 index 000000000..889dd6817 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moNeighbor.h @@ -0,0 +1,110 @@ +/* + + 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 +#include +#include + +/** + * Container of the neighbor informations + */ +template +class moNeighbor: public EO { +public: + typedef EOType EOT; + using EO::fitness; + + /** + * Default Constructor + */ + moNeighbor() : + EO () { + } + + /** + * Copy Constructor + * @param _neighbor to copy + */ + moNeighbor(const moNeighbor& _neighbor) { + if (!(_neighbor.invalid())) + fitness(_neighbor.fitness()); + else + (*this).invalidate(); + } + + /** + * Assignment operator + * @param _neighbor the neighbor to assign + * @return a neighbor equal to the other + */ + virtual moNeighbor& operator=( + const moNeighbor& _neighbor) { + if (!(_neighbor.invalid())) + fitness(_neighbor.fitness()); + else + (*this).invalidate(); + + return (*this); + } + + /** + * Move a solution + * @param _solution the related solution + */ + virtual void move(EOT & _solution) = 0; + + /** + * Test equality between two neighbors + * @param _neighbor a neighbor + * @return if _neighbor and this one are equals + */ + virtual bool equals(moNeighbor & _neighbor) { + return false; + } + + /** + * Return the class Name + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moNeighbor"; + } + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moNeighborhood.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moNeighborhood.h new file mode 100644 index 000000000..60d11c1f2 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moNeighborhood.h @@ -0,0 +1,101 @@ +/* + + 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 + +/** + * 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 true if the neighborhood is random (default false) + */ + virtual bool isRandom() { + return false; + } + + /** + * Test if a solution has (again) a Neighbor + * @param _solution the related solution + * @return true 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 true if there is again a neighbor not explored + */ + virtual bool cont(EOT & _solution) = 0 ; + + /** + * Return the class Name + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moNeighborhood"; + } +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moOrderNeighborhood.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moOrderNeighborhood.h new file mode 100644 index 000000000..7561d143b --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moOrderNeighborhood.h @@ -0,0 +1,130 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 + +/** + * An ordered Neighborhood + */ +template +class moOrderNeighborhood: public moIndexNeighborhood { +public: + + /** + * Define type of a solution corresponding to Neighbor + */ + typedef typename Neighbor::EOT EOT; + + using moIndexNeighborhood::neighborhoodSize; + + /** + * Constructor + * @param _neighborhoodSize the size of the neighborhood + */ + moOrderNeighborhood(unsigned int _neighborhoodSize) : + moIndexNeighborhood (_neighborhoodSize), currentIndex(0) { + } + + /** + * Test if a neighbor exists + * @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; + } + + /** + * Setter the position in the Neighborhood + */ + void setPosition(unsigned int _currentIndex) { + currentIndex=_currentIndex; + } + + /** + * Return the class Name + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moOrderNeighborhood"; + } + +protected: + unsigned int currentIndex; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndNeighborhood.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndNeighborhood.h new file mode 100644 index 000000000..9c7ec2d22 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndNeighborhood.h @@ -0,0 +1,51 @@ +/* + +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 + +/** + * Class used to specify a neighborhood is random + */ +template< class Neighbor > +class moRndNeighborhood : virtual public moNeighborhood { + +public: + + /** + * @return true + */ + bool isRandom() { + return true; + } +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndVectorVNSelection.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndVectorVNSelection.h new file mode 100644 index 000000000..3debb85d4 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndVectorVNSelection.h @@ -0,0 +1,118 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moRndVectorVNSelection_h +#define _moRndVectorVNSelection_h + +#include +#include + +#include + +/** + * This class is used for the Variable Neighborhood Search explorer inherits from moVectorVNSelection + * The search heuristics are saved in vectors + * They are given in random order (at each initialization the order is changed) + * + */ +template< class EOT > +class moRndVectorVNSelection: public moVectorVNSelection +{ + using moVectorVNSelection::LSvector; + using moVectorVNSelection::current; + +public: + + /** + * Default constructor with first search heuristics + * + * @param _firstLS first local search + * @param _firstShake first heuristic which perturbs the solution + * @param _cycle when true, the first heuristics follows the last ones. Otherwise the search stop. + */ + moRndVectorVNSelection(eoMonOp& _firstLS, eoMonOp& _firstShake, bool _cycle = true) : moVectorVNSelection(_firstLS, _firstShake), cycle(_cycle){} + + /** + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moRndVectorVNSelection"; + } + + /** + * test if there is still some heuristics + * + * @param _solution the current solution + * @return true if there is some heuristics + */ + virtual bool cont(EOT& _solution){ + return ( cycle || (currentOrder <= (order.size() - 2)) ); + } + + /** + * put the current heuristics on the first ones + * + * @param _solution the current solution + */ + virtual void init(EOT& _solution) { + if(order.size() == 0) + for(unsigned int i = 0; i < LSvector.size(); i++) + order.push_back(i); + + std::random_shuffle(order.begin(), order.end(), gen); + + currentOrder = 0; + current = order[currentOrder]; + } + + /** + * put the current heuristics on the next ones + * + * @param _solution the current solution + */ + virtual void next(EOT& _solution){ + currentOrder = (currentOrder + 1) % order.size(); + + current = order[currentOrder]; + } + +private: + // boolean to indicate the first heuristics follow the last ones + bool cycle; + // index in order vector + unsigned int currentOrder; + // the index of heuristics in random order + std::vector order; + // random generator + UF_random_generator gen; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndWithReplNeighborhood.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndWithReplNeighborhood.h new file mode 100644 index 000000000..16e9b0211 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndWithReplNeighborhood.h @@ -0,0 +1,109 @@ +/* + + 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 +#include +#include + +/** + * A Random With replacement Neighborhood + */ +template< class Neighbor > +class moRndWithReplNeighborhood : public moIndexNeighborhood, public moRndNeighborhood +{ +public: + + /** + * Define type of a solution corresponding to Neighbor + */ + typedef typename Neighbor::EOT EOT; + + using moIndexNeighborhood::neighborhoodSize; + + /** + * Constructor + * @param _neighborhoodSize the size of the neighborhood + */ + moRndWithReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood(_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 Name + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moRndWithReplNeighborhood"; + } + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndWithoutReplNeighborhood.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndWithoutReplNeighborhood.h new file mode 100644 index 000000000..8c66ee3f9 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moRndWithoutReplNeighborhood.h @@ -0,0 +1,138 @@ +/* + + 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 +#include +#include + +/** + * A Random without replacement Neighborhood + */ +template< class Neighbor > +class moRndWithoutReplNeighborhood : public moIndexNeighborhood, public moRndNeighborhood +{ +public: + + /** + * Define type of a solution corresponding to Neighbor + */ + typedef typename Neighbor::EOT EOT; + + + using moIndexNeighborhood::neighborhoodSize; + + /** + * Constructor + * @param _neighborhoodSize the size of the neighborhood + */ + moRndWithoutReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood(_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 Name + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moRndWithoutReplNeighborhood"; + } + +private: + unsigned int maxIndex; + std::vector indexVector; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moVariableNeighborhoodSelection.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moVariableNeighborhoodSelection.h new file mode 100644 index 000000000..99af9a98d --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moVariableNeighborhoodSelection.h @@ -0,0 +1,88 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moVariableNeighborhoodSelection_h +#define _moVariableNeighborhoodSelection_h + +#include +#include + +/** + * This class is used for the Variable Neighborhood Search explorer + * It gives the sequence of search heuristics based on the different "neighborhoods" + * The class is built such as the moNeighborhood" with init, next, cont + * and two methods to get the heuristics which shake the solution, and which give the local search + * + */ +template< class EOT > +class moVariableNeighborhoodSelection +{ +public: + + /** + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moVariableNeighborhoodSelection"; + } + + /** + * test if there is still some search heuristics to use + * @return true if there is some neighborhood to explore + */ + virtual bool cont(EOT& _solution) = 0; + + /** + * put on the first search heuristics + */ + virtual void init(EOT& _solution) = 0; + + /** + * put the next search heuristics + */ + virtual void next(EOT& _solution) = 0; + + /** + * Get the current "shake" operator based on the current neighborhood + * + * @return current shake operator + */ + virtual eoMonOp & getShake() = 0; + + /** + * Get the current local search based on the current neighborhood + * + * @return current local search + */ + virtual eoMonOp & getLocalSearch() = 0; + +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moVectorVNSelection.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moVectorVNSelection.h new file mode 100644 index 000000000..3070e0e9a --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/neighborhood/moVectorVNSelection.h @@ -0,0 +1,108 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moVectorVNSelection_h +#define _moVectorVNSelection_h + +#include +#include + +/** + * This class is used for the Variable Neighborhood Search explorer inherits from moVariableNeighborhoodSelection + * The search heuristics are saved in vectors + * The way to croos the vector is not defined here + * + */ +template< class EOT > +class moVectorVNSelection: public moVariableNeighborhoodSelection{ + +public: + + /** + * Default constructor with first search heuristics + * + * @param _firstLS first local search + * @param _firstShake first heuristic which perturbs the solution + */ + moVectorVNSelection(eoMonOp& _firstLS, eoMonOp& _firstShake){ + LSvector.push_back(&_firstLS); + shakeVector.push_back(&_firstShake); + + current = 0; + } + + /** + * Add some search heuristics + * + * @param _otherLS the added local search + * @param _otherShake the added heuristic which perturbs the solution + */ + void add(eoMonOp& _otherLS, eoMonOp& _otherShake){ + LSvector.push_back(&_otherLS); + shakeVector.push_back(&_otherShake); + } + + /** + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moVectorVNSelection"; + } + + /** + * Get the current "shake" operator based on the current neighborhood + * + * @return current shake operator + */ + virtual eoMonOp & getShake() { + return *(shakeVector[current]); + } + + /** + * Get the current local search based on the current neighborhood + * + * @return current local search + */ + virtual eoMonOp & getLocalSearch() { + return *(LSvector[current]); + } + +protected: + // vector of local searches + std::vector* > LSvector; + // vector of "shake" heiristics which perturbs the current solution + std::vector* > shakeVector; + // index of the current search heuristics which is applied + unsigned int current; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moLocalSearchInit.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moLocalSearchInit.h new file mode 100644 index 000000000..d91c5c719 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moLocalSearchInit.h @@ -0,0 +1,66 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moLocalSearchInit_h +#define _moLocalSearchInit_h + +#include +#include + +/** + * Initialization of the solution with a local search + */ +template< class Neighbor > +class moLocalSearchInit : public eoInit { +public: + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _init initialization of the solution before the local search + * @param _ls the local search to apply to the solution + */ + moLocalSearchInit(eoInit& _init, moLocalSearch& _ls) : init(_init), ls(_ls) { + } + + /** + * Apply the local search on the solution + * @param _solution to perturb + */ + void operator()(EOT& _solution) { + init(_solution); + ls(_solution); + } + +private: + eoInit& init; + moLocalSearch & ls; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moMonOpPerturb.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moMonOpPerturb.h new file mode 100644 index 000000000..c056bbf6a --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moMonOpPerturb.h @@ -0,0 +1,72 @@ +/* + +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 _moMonOpPerturb_h +#define _moMonOpPerturb_h + +#include +#include +#include +#include + +/** + * Perturbation operator using only a eoMonOp + */ +template< class Neighbor > +class moMonOpPerturb : public moPerturbation, public moDummyMemory { + +public: + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _monOp an eoMonOp (pertubation operator) + * @param _fullEval a full evaluation function + */ + moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval):monOp(_monOp), fullEval(_fullEval) {} + + /** + * Apply monOp on the solution + * @param _solution to perturb + * @return value of monOp + */ + bool operator()(EOT& _solution) { + bool res = monOp(_solution); + _solution.invalidate(); + fullEval(_solution); + return res; + } + +private: + /** monOp */ + eoMonOp& monOp; + eoEvalFunc& fullEval; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moNeighborhoodPerturb.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moNeighborhoodPerturb.h new file mode 100644 index 000000000..676f5a828 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moNeighborhoodPerturb.h @@ -0,0 +1,109 @@ +/* + +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 _moNeighborhoodPerturb_h +#define _moNeighborhoodPerturb_h + +#include +#include +#include + +/** + * Neighborhood Perturbation: explore the neighborhood to perturb the solution (the neighborhood could be different as the one used in the Local Search) + */ +template< class Neighbor, class OtherNeighbor > +class moNeighborhoodPerturb : public moPerturbation { + +public: + typedef typename Neighbor::EOT EOT; + typedef moNeighborhood OtherNH; + + /** + * Constructor + * @param _otherNeighborhood a neighborhood + * @param _eval an Evaluation Function + */ + moNeighborhoodPerturb(OtherNH& _otherNeighborhood, moEval& _eval): otherNeighborhood(_otherNeighborhood), eval(_eval) {} + + /** + * Apply move on the solution + * @param _solution the current solution + * @return true + */ + virtual bool operator()(EOT& _solution) { + if (otherNeighborhood.hasNeighbor(_solution)) { + eval(_solution, current); + current.move(_solution); + _solution.fitness(current.fitness()); + } + return true; + } + + /** + * Init the neighborhood + * @param _sol the current solution + */ + virtual void init(EOT & _sol) { + if (otherNeighborhood.hasNeighbor(_sol)) + otherNeighborhood.init(_sol, current); + } + + /** + * ReInit the neighborhood because a move was done + * @param _sol the current solution + * @param _neighbor unused neighbor (always empty) + */ + virtual void add(EOT & _sol, Neighbor & _neighbor) { + (*this).init(_sol); + } + + /** + * Explore another neighbor because no move was done + * @param _sol the current solution + * @param _neighbor unused neighbor (always empty) + */ + virtual void update(EOT & _sol, Neighbor & _neighbor) { + if (otherNeighborhood.cont(_sol)) + otherNeighborhood.next(_sol, current); + else + (*this).init(_sol); + } + + /** + * NOTHING TO DO + */ + virtual void clearMemory() {} + +private: + OtherNH& otherNeighborhood; + moEval& eval; + OtherNeighbor current; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moPerturbation.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moPerturbation.h new file mode 100644 index 000000000..46fb9b0b9 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moPerturbation.h @@ -0,0 +1,42 @@ +/* + +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 _moPertubation_h +#define _moPertubation_h + +#include +#include + +/** + * Abstract class for Perturbation operator + */ +template< class Neighbor > +class moPerturbation : public eoMonOp, virtual public moMemory {}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moRestartPerturb.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moRestartPerturb.h new file mode 100644 index 000000000..c1b4b78ba --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moRestartPerturb.h @@ -0,0 +1,77 @@ +/* + +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 _moRestartPerturb_h +#define _moRestartPerturb_h + + +#include +#include +#include +#include + +/** + * Restart Perturbation : restart when maximum number of iteration with no improvement is reached + */ +template< class Neighbor > +class moRestartPerturb : public moPerturbation, public moCountMoveMemory { + +public: + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _initializer an initializer of solution + * @param _fullEval a full evaluation function + * @param _threshold maximum number of iteration with no improvement + */ + moRestartPerturb(eoInit& _initializer, eoEvalFunc& _fullEval, unsigned int _threshold):initializer(_initializer), fullEval(_fullEval), threshold(_threshold) {} + + /** + * Apply restart when necessary + * @param _solution to restart + * @return true + */ + bool operator()(EOT& _solution) { + if ((*this).getCounter()>= threshold) { + initializer(_solution); + fullEval(_solution); + (*this).initCounter(); + } + return true; + } + +private: + eoInit& initializer; + eoEvalFunc& fullEval; + unsigned int threshold; +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moSolInit.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moSolInit.h new file mode 100644 index 000000000..8707d47fa --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/perturb/moSolInit.h @@ -0,0 +1,60 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moSolInit_h +#define _moSolInit_h + +#include + +/** + * Initialization of the solution with the external solution + */ +template< class EOT > +class moSolInit : public eoInit { +public: + + /** + * Constructor + * @param _extSol external solution of the initialization + */ + moSolInit(EOT & _extSol) : extSol(_extSol) {} + + /** + * Initialization on the external solution + * @param _solution to initialize + */ + void operator()(EOT& _solution) { + _solution = extSol; + } + +private: + EOT& extSol; +}; + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moAdaptiveWalkSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moAdaptiveWalkSampling.h new file mode 100644 index 000000000..72101dfcb --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moAdaptiveWalkSampling.h @@ -0,0 +1,110 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moAdaptiveWalkSampling_h +#define moAdaptiveWalkSampling_h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * To compute the length and final solution of an adaptive walk: + * Perform a first improvement Hill-climber based on the neighborhood (adaptive walk), + * The lengths of HC are collected and the final solution which are local optima + * The adaptive walk is repeated several times + * + */ +template +class moAdaptiveWalkSampling : public moSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood giving neighbor in random order + * @param _fullEval a full evaluation function + * @param _eval an incremental evaluation of neighbors + * @param _nbAdaptWalk Number of adaptive walks + */ + moAdaptiveWalkSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbAdaptWalk) : + moSampling(initHC, * new moRandomSearch(initHC, _fullEval, _nbAdaptWalk), copyStat), + copyStat(lengthStat), + checkpoint(trueCont), + hc(_neighborhood, _fullEval, _eval, checkpoint), + initHC(_init, hc) + { + // to count the number of step in the HC + checkpoint.add(lengthStat); + + // add the solution into statistics + add(solStat); + } + + /** + * Destructor + */ + ~moAdaptiveWalkSampling() { + // delete the pointer on the local search which has been constructed in the constructor + delete localSearch; + } + +protected: + moSolutionStat solStat; + moMinusOneCounterStat lengthStat; + moTrueContinuator trueCont; + moStatFromStat copyStat; + moCheckpoint checkpoint; + moFirstImprHC hc; + moLocalSearchInit initHC; +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moAutocorrelationSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moAutocorrelationSampling.h new file mode 100644 index 000000000..3dbeaf954 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moAutocorrelationSampling.h @@ -0,0 +1,89 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moAutocorrelationSampling_h +#define moAutocorrelationSampling_h + +#include +#include +#include +#include +#include +#include + +/** + * To compute the autocorrelation function: + * Perform a random walk based on the neighborhood, + * The fitness values of solutions are collected during the random walk + * The autocorrelation can be computed from the serie of fitness values + * + */ +template +class moAutocorrelationSampling : public moSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood giving neighbor in random order + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _nbStep Number of steps of the random walk + */ + moAutocorrelationSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbStep) : + moSampling(_init, * new moRandomWalk(_neighborhood, _fullEval, _eval, _nbStep), fitnessStat) {} + + /** + * Destructor + */ + ~moAutocorrelationSampling() { + // delete the pointer on the local search which has been constructed in the constructor + delete localSearch; + } + +protected: + moFitnessStat fitnessStat; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h new file mode 100644 index 000000000..571f546de --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moDensityOfStatesSampling.h @@ -0,0 +1,83 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moDensityOfStatesSampling_h +#define moDensityOfStatesSampling_h + +#include +#include +#include +#include +#include + +/** + * To compute the density of states: + * Sample the fitness of random solution in the search space + * The fitness values of solutions are collected during the random search + * + */ +template +class moDensityOfStatesSampling : public moSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _fullEval Fitness function, full evaluation function + * @param _nbSol Number of solutions in the sample + */ + moDensityOfStatesSampling(eoInit & _init, + eoEvalFunc& _fullEval, + unsigned int _nbSol) : + moSampling(_init, * new moRandomSearch(_init, _fullEval, _nbSol), fitnessStat) {} + + /** + * default destructor + */ + ~moDensityOfStatesSampling() { + // delete the pointer on the local search which has been constructed in the constructor + delete localSearch; + } + +protected: + moFitnessStat fitnessStat; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moFDCsampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moFDCsampling.h new file mode 100644 index 000000000..22a224759 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moFDCsampling.h @@ -0,0 +1,95 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moFDCsampling_h +#define moFDCsampling_h + +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * To compute the fitness distance correlation: + * Sample the fitness and the distance from a particular solution of random solution in the search space + * The fitness values and distances of solutions are collected during the random search + * Then the correlation between the fitness and the distance can be computed + * + */ +template +class moFDCsampling : public moSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _fullEval a full evaluation function + * @param _dist the distance function between solution + * @param _refSol the reference solution to compute the distance (think of global optimum when possible) + * @param _nbSol Number of solutions of the sample + */ + moFDCsampling(eoInit & _init, + eoEvalFunc& _fullEval, + eoDistance& _dist, + EOT& _refSol, + unsigned int _nbSol) : + moSampling(_init, * new moRandomSearch(_init, _fullEval, _nbSol), fitnessStat), + distStat(_dist, _refSol) + { + add(distStat); + } + + /** + * Destructor + */ + ~moFDCsampling() { + // delete the pointer on the local search which has been constructed in the constructor + delete localSearch; + } + +protected: + moFitnessStat fitnessStat; + moDistanceStat distStat; +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moFitnessCloudSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moFitnessCloudSampling.h new file mode 100644 index 000000000..15817555a --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moFitnessCloudSampling.h @@ -0,0 +1,100 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moFitnessCloudSampling_h +#define moFitnessCloudSampling_h + +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * To compute an estimation of the fitness cloud, + * i.e. the scatter plot of solution fitness versus neighbor fitness: + * + * This class do nothing. See others mo(...)FitnessCloudSampling classes + * with different fitness sampling methods + */ +template +class moFitnessCloudSampling : public moSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood to get a neighbor + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _nbSol Number of solutions in the sample + */ + moFitnessCloudSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbSol) : + moSampling(_init, * new moDummyLS(_fullEval), fitnessStat), + neighborhood(_neighborhood), + fullEval(_fullEval), + eval(_eval), + nbSol(_nbSol) + {} + + /** + * default destructor + */ + ~moFitnessCloudSampling() { + // delete the pointer on the local search which has been constructed in the constructor + delete localSearch; + } + +protected: + moNeighborhood & neighborhood; + eoEvalFunc& fullEval; + moEval& eval; + unsigned int nbSol; + moFitnessStat fitnessStat; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moHillClimberSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moHillClimberSampling.h new file mode 100644 index 000000000..e3e277bf7 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moHillClimberSampling.h @@ -0,0 +1,110 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moHillClimberSampling_h +#define moHillClimberSampling_h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * To compute the length and final solution of an adaptive walk: + * Perform a simple Hill-climber based on the neighborhood (gradiant walk, the whole neighborhood is visited), + * The lengths of HC are collected and the final solution which are local optima + * The adaptive walk is repeated several times + * + */ +template +class moHillClimberSampling : public moSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood giving neighbor in random order + * @param _fullEval a full evaluation function + * @param _eval an incremental evaluation of neighbors + * @param _nbAdaptWalk Number of adaptive walks + */ + moHillClimberSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbAdaptWalk) : + moSampling(initHC, * new moRandomSearch(initHC, _fullEval, _nbAdaptWalk), copyStat), + copyStat(lengthStat), + checkpoint(trueCont), + hc(_neighborhood, _fullEval, _eval, checkpoint), + initHC(_init, hc) + { + // to count the number of step in the HC + checkpoint.add(lengthStat); + + // add the solution into statistics + add(solStat); + } + + /** + * Destructor + */ + ~moHillClimberSampling() { + // delete the pointer on the local search which has been constructed in the constructor + delete localSearch; + } + +protected: + moSolutionStat solStat; + moMinusOneCounterStat lengthStat; + moTrueContinuator trueCont; + moStatFromStat copyStat; + moCheckpoint checkpoint; + moSimpleHC hc; + moLocalSearchInit initHC; +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moMHBestFitnessCloudSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moMHBestFitnessCloudSampling.h new file mode 100644 index 000000000..d68044498 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moMHBestFitnessCloudSampling.h @@ -0,0 +1,113 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moMHBestFitnessCloudSampling_h +#define moMHBestFitnessCloudSampling_h + +#include +#include +#include +#include +#include +#include +#include + +/** + * To compute an estimation of the fitness cloud, + * i.e. the scatter plot of solution fitness versus neighbor fitness: + * + * Here solution are sampled with Metropolis-Hasting method + * + * Sample the fitness of solutions from Metropolis-Hasting sampling + * and the best fitness of k random neighbor + * + * The values are collected during the Metropolis-Hasting walk + * + */ +template +class moMHBestFitnessCloudSampling : public moFitnessCloudSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + using moSampling::checkpoint; + using moSampling::monitorVec; + using moSampling::continuator; + using moFitnessCloudSampling::fitnessStat; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood to get one random neighbor (supposed to be random neighborhood) + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _nbStep Number of step of the MH sampling + */ + moMHBestFitnessCloudSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbStep) : + moFitnessCloudSampling(_init, _neighborhood, _fullEval, _eval, _nbStep), + neighborBestStat(_neighborhood, _eval) + { + // delete the dummy local search + delete localSearch; + + // Metropolis-Hasting sampling + localSearch = new moMetropolisHasting(_neighborhood, _fullEval, _eval, _nbStep); + + // delete the checkpoint with the wrong continuator + delete checkpoint; + + // set the continuator + continuator = localSearch->getContinuator(); + + // re-construction of the checkpoint + checkpoint = new moCheckpoint(*continuator); + checkpoint->add(fitnessStat); + checkpoint->add(*monitorVec[0]); + + // one random neighbor + add(neighborBestStat); + } + +protected: + moNeighborBestStat< Neighbor > neighborBestStat; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moMHRndFitnessCloudSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moMHRndFitnessCloudSampling.h new file mode 100644 index 000000000..f72d6ff42 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moMHRndFitnessCloudSampling.h @@ -0,0 +1,113 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moMHRndFitnessCloudSampling_h +#define moMHRndFitnessCloudSampling_h + +#include +#include +#include +#include +#include +#include +#include + +/** + * To compute an estimation of the fitness cloud, + * i.e. the scatter plot of solution fitness versus neighbor fitness: + * + * Here solution are sampled with Metropolis-Hasting method + * + * Sample the fitness of solutions from Metropolis-Hasting sampling + * and the fitness of one random neighbor + * + * The values are collected during the Metropolis-Hasting walk + * + */ +template +class moMHRndFitnessCloudSampling : public moFitnessCloudSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + using moSampling::checkpoint; + using moSampling::monitorVec; + using moSampling::continuator; + using moFitnessCloudSampling::fitnessStat; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood to get one random neighbor (supposed to be random neighborhood) + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _nbStep Number of step of the MH sampling + */ + moMHRndFitnessCloudSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbStep) : + moFitnessCloudSampling(_init, _neighborhood, _fullEval, _eval, _nbStep), + neighborFitnessStat(_neighborhood, _eval) + { + // delete the dummy local search + delete localSearch; + + // Metropolis-Hasting sampling + localSearch = new moMetropolisHasting(_neighborhood, _fullEval, _eval, _nbStep); + + // delete the checkpoint with the wrong continuator + delete checkpoint; + + // set the continuator + continuator = localSearch->getContinuator(); + + // re-construction of the checkpoint + checkpoint = new moCheckpoint(*continuator); + checkpoint->add(fitnessStat); + checkpoint->add(*monitorVec[0]); + + // one random neighbor + add(neighborFitnessStat); + } + +protected: + moNeighborFitnessStat< Neighbor > neighborFitnessStat; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moNeutralDegreeSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moNeutralDegreeSampling.h new file mode 100644 index 000000000..bc7386ba2 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moNeutralDegreeSampling.h @@ -0,0 +1,125 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moNeutralDegreeSampling_h +#define moNeutralDegreeSampling_h + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * To compute the neutral degree: + * Sample the fitness of random solution in the search space (1er information) + * and sample the neutral degree (2nd information), i.e. the number of neighbor solutions with the same fitness value + * The values are collected during the random search + * + */ +template +class moNeutralDegreeSampling : public moSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood to compute the neutral degree + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _nbSol Number of solutions in the sample + */ + moNeutralDegreeSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbSol) : + moSampling(_init, * new moRandomSearch(_init, _fullEval, _nbSol), fitnessStat), + neighborhoodStat(_neighborhood, _eval), + ndStat(neighborhoodStat) + { + add(neighborhoodStat, false); + add(ndStat); + } + + /** + * Constructor with comparators + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood to compute the neutral degree + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _neighborComparator a neighbor Comparator + * @param _solNeighborComparator a comparator between a solution and a neighbor + * @param _nbSol Number of solutions in the sample + */ + moNeutralDegreeSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + moNeighborComparator& _neighborComparator, + moSolNeighborComparator& _solNeighborComparator, + unsigned int _nbSol) : + moSampling(_init, * new moRandomSearch(_init, _fullEval, _nbSol), fitnessStat), + neighborhoodStat(_neighborhood, _eval, _neighborComparator, _solNeighborComparator), + ndStat(neighborhoodStat) + { + add(neighborhoodStat, false); + add(ndStat); + } + + /** + * default destructor + */ + ~moNeutralDegreeSampling() { + // delete the pointer on the local search which has been constructed in the constructor + delete localSearch; + } + +protected: + moFitnessStat fitnessStat; + moNeighborhoodStat< Neighbor > neighborhoodStat; + moNeutralDegreeNeighborStat< Neighbor > ndStat; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moNeutralWalkSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moNeutralWalkSampling.h new file mode 100644 index 000000000..258792fe0 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moNeutralWalkSampling.h @@ -0,0 +1,148 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moNeutralWalkSampling_h +#define moNeutralWalkSampling_h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * To explore the evolvability of solutions in a neutral networks: + * Perform a random neutral walk based on the neighborhood, + * The measures of evolvability of solutions are collected during the random neutral walk + * The distribution and autocorrelation can be computed from the serie of values + * + * Informations collected: + * - the current solution of the walk + * - the distance from the starting solution + * - the minimal fitness in the neighborhood + * - the average fitness + * - the standard deviation of the fitness + * - the maximal fitness + * - the size of the neighborhood + * - the number of neighbors with lower fitness + * - the number of neighbors with equal fitness (neutral degree) + * - the number of neighbors with higher fitness + */ +template +class moNeutralWalkSampling : public moSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + + /** + * Constructor + * @param _initSol the first solution of the walk + * @param _neighborhood neighborhood giving neighbor in random order + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _distance component to measure the distance from the initial solution + * @param _nbStep Number of steps of the random walk + */ + moNeutralWalkSampling(EOT & _initSol, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + eoDistance & _distance, + unsigned int _nbStep) : + moSampling(init, * new moRandomNeutralWalk(_neighborhood, _fullEval, _eval, _nbStep), solutionStat), + init(_initSol), + distStat(_distance, _initSol), + neighborhoodStat(_neighborhood, _eval), + minStat(neighborhoodStat), + averageStat(neighborhoodStat), + stdStat(neighborhoodStat), + maxStat(neighborhoodStat), + nbSupStat(neighborhoodStat), + nbInfStat(neighborhoodStat), + sizeStat(neighborhoodStat), + ndStat(neighborhoodStat) + { + add(neighborhoodStat, false); + add(distStat); + add(minStat); + add(averageStat); + add(stdStat); + add(maxStat); + add(sizeStat); + add(nbInfStat); + add(ndStat); + add(nbSupStat); + } + + /** + * default destructor + */ + ~moNeutralWalkSampling() { + // delete the pointer on the local search which has been constructed in the constructor + delete localSearch; + } + +protected: + moSolInit init; + moSolutionStat solutionStat; + moDistanceStat distStat; + moNeighborhoodStat< Neighbor > neighborhoodStat; + moMinNeighborStat< Neighbor > minStat; + moAverageFitnessNeighborStat< Neighbor > averageStat; + moStdFitnessNeighborStat< Neighbor > stdStat; + moMaxNeighborStat< Neighbor > maxStat; + moNbSupNeighborStat< Neighbor > nbSupStat; + moNbInfNeighborStat< Neighbor > nbInfStat; + moSizeNeighborStat< Neighbor > sizeStat; + moNeutralDegreeNeighborStat< Neighbor > ndStat; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moRndBestFitnessCloudSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moRndBestFitnessCloudSampling.h new file mode 100644 index 000000000..12826c512 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moRndBestFitnessCloudSampling.h @@ -0,0 +1,111 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moRndBestFitnessCloudSampling_h +#define moRndBestFitnessCloudSampling_h + +#include +#include +#include +#include +#include +#include +#include + +/** + * To compute an estimation of the fitness cloud, + * i.e. the scatter plot of solution fitness versus neighbor fitness: + * + * Sample the fitness of random solution in the search space + * and the best fitness of k random neighbor + * + * The values are collected during the random search + * + */ +template +class moRndBestFitnessCloudSampling : public moFitnessCloudSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + using moSampling::checkpoint; + using moSampling::monitorVec; + using moSampling::continuator; + using moFitnessCloudSampling::fitnessStat; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood to get one random neighbor (supposed to be random neighborhood) + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _nbSol Number of solutions in the sample + */ + moRndBestFitnessCloudSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbSol) : + moFitnessCloudSampling(_init, _neighborhood, _fullEval, _eval, _nbSol), + neighborBestStat(_neighborhood, _eval) + { + // delete the dummy local search + delete localSearch; + + // random sampling + localSearch = new moRandomSearch(_init, _fullEval, _nbSol); + + // delete the checkpoint with the wrong continuator + delete checkpoint; + + // set the continuator + continuator = localSearch->getContinuator(); + + // re-construction of the checkpoint + checkpoint = new moCheckpoint(*continuator); + checkpoint->add(fitnessStat); + checkpoint->add(*monitorVec[0]); + + // one random neighbor + add(neighborBestStat); + } + +protected: + moNeighborBestStat< Neighbor > neighborBestStat; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moRndRndFitnessCloudSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moRndRndFitnessCloudSampling.h new file mode 100644 index 000000000..ab778d69d --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moRndRndFitnessCloudSampling.h @@ -0,0 +1,111 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moRndRndFitnessCloudSampling_h +#define moRndRndFitnessCloudSampling_h + +#include +#include +#include +#include +#include +#include +#include + +/** + * To compute an estimation of the fitness cloud, + * i.e. the scatter plot of solution fitness versus neighbor fitness: + * + * Sample the fitness of random solution in the search space + * and the fitness of one random neighbor + * + * The values are collected during the random search + * + */ +template +class moRndRndFitnessCloudSampling : public moFitnessCloudSampling +{ +public: + typedef typename Neighbor::EOT EOT ; + + using moSampling::localSearch; + using moSampling::checkpoint; + using moSampling::monitorVec; + using moSampling::continuator; + using moFitnessCloudSampling::fitnessStat; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _neighborhood neighborhood to get one random neighbor (supposed to be random neighborhood) + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _nbSol Number of solutions in the sample + */ + moRndRndFitnessCloudSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbSol) : + moFitnessCloudSampling(_init, _neighborhood, _fullEval, _eval, _nbSol), + neighborFitnessStat(_neighborhood, _eval) + { + // delete the dummy local search + delete localSearch; + + // random sampling + localSearch = new moRandomSearch(_init, _fullEval, _nbSol); + + // delete the checkpoint with the wrong continuator + delete checkpoint; + + // set the continuator + continuator = localSearch->getContinuator(); + + // re-construction of the checkpoint + checkpoint = new moCheckpoint(*continuator); + checkpoint->add(fitnessStat); + checkpoint->add(*monitorVec[0]); + + // one random neighbor + add(neighborFitnessStat); + } + +protected: + moNeighborFitnessStat< Neighbor > neighborFitnessStat; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moSampling.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moSampling.h new file mode 100644 index 000000000..b118b9d48 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moSampling.h @@ -0,0 +1,239 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moSampling_h +#define moSampling_h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/** + * To sample the search space: + * A local search is used to sample the search space + * Some statistics are computed at each step of the local search + * + * Can be used to study the fitness landscape + */ +template +class moSampling : public eoF +{ +public: + typedef typename Neighbor::EOT EOT ; + + /** + * Constructor + * @param _init initialisation method of the solution + * @param _localSearch local search to sample the search space + * @param _stat statistic to compute during the search + * @param _monitoring the statistic is saved into the monitor if true + */ + template + moSampling(eoInit & _init, moLocalSearch & _localSearch, moStat & _stat, bool _monitoring = true) : init(_init), localSearch(&_localSearch), continuator(_localSearch.getContinuator()) + { + checkpoint = new moCheckpoint(*continuator); + add(_stat, _monitoring); + // precision of the output by default + precisionOutput = std::cout.precision(); + } + + /** + * default destructor + */ + ~moSampling() { + // delete all monitors + for (unsigned i = 0; i < monitorVec.size(); i++) + delete monitorVec[i]; + + // delete the checkpoint + delete checkpoint ; + } + + /** + * Add a statistic + * @param _stat another statistic to compute during the search + * @param _monitoring the statistic is saved into the monitor if true + */ + template< class ValueType > + void add(moStat & _stat, bool _monitoring = true) { + checkpoint->add(_stat); + + if (_monitoring) { + moVectorMonitor * monitor = new moVectorMonitor(_stat); + monitorVec.push_back(monitor); + checkpoint->add(*monitor); + } + } + + /** + * To sample the search and get the statistics which are stored in the moVectorMonitor vector + */ + void operator()(void) { + // clear all statistic vectors + for (unsigned i = 0; i < monitorVec.size(); i++) + monitorVec[i]->clear(); + + // change the checkpoint to compute the statistics + localSearch->setContinuator(*checkpoint); + + // the initial solution + EOT solution; + + // initialisation of the solution + init(solution); + + // compute the sampling + (*localSearch)(solution); + + // set back to initial continuator + localSearch->setContinuator(*continuator); + } + + /** + * to set the precision of the output file + * @param _precision precision of the output (number of digit) + */ + void precision(unsigned int _precision) { + precisionOutput = _precision; + } + + /** + * to export the vectors of values into one file + * @param _filename file name + * @param _delim delimiter between statistics + * @param _openFile to specify if it writes at the following of the file + */ + void fileExport(std::string _filename, std::string _delim = " ", bool _openFile=false) { + // create file + std::ofstream os; + + if(! _openFile) + os.open(_filename.c_str()); + + else + os.open(_filename.c_str(),std::ios::app); + + if (!os) { + std::string str = "moSampling: Could not open " + _filename; + throw std::runtime_error(str); + } + + // set the precision of the output + os.precision(precisionOutput); + for (unsigned int j = 0; j < monitorVec.size(); j++) + monitorVec[j]->precision(precisionOutput); + + // all vector have the same size + unsigned vecSize = monitorVec[0]->size(); + + for (unsigned int i = 0; i < vecSize; i++) { + os << monitorVec[0]->getValue(i); + + for (unsigned int j = 1; j < monitorVec.size(); j++) { + os << _delim.c_str() << monitorVec[j]->getValue(i); + } + + os << std::endl ; + } + + } + + /** + * to export one vector of values into a file + * @param _col number of vector to print into file + * @param _filename file name + * @param _openFile to specify if it writes at the following of the file + */ + void fileExport(unsigned int _col, std::string _filename, bool _openFile=false) { + if (_col >= monitorVec.size()) { + std::string str = "moSampling: Could not export into file the vector. The index does not exists (too large)"; + throw std::runtime_error(str); + } + + monitorVec[_col]->precision(precisionOutput); + monitorVec[_col]->fileExport(_filename, _openFile); + } + + + /** + * to get one vector of values + * @param _numStat number of statistics to get (in the order of creation) + * @return the vector of value (all values are converted in double) + */ + const std::vector & getValues(unsigned int _numStat) { + return monitorVec[_numStat]->getValues(); + } + + /** + * to get one vector of solutions values + * @param _numStat number of statistics to get (in the order of creation) + * @return the vector of value (all values are converted in double) + */ + const std::vector & getSolutions(unsigned int _numStat) { + return monitorVec[_numStat]->getSolutions(); + } + + /** + * @return name of the class + */ + virtual std::string className(void) const { + return "moSampling"; + } + +protected: + eoInit & init; + moLocalSearch * localSearch; + + moContinuator * continuator; + moCheckpoint * checkpoint; + + std::vector< moVectorMonitor *> monitorVec; + + // precision of the output + unsigned int precisionOutput; + +}; + + +#endif diff --git a/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moStatistics.h b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moStatistics.h new file mode 100644 index 000000000..7c74cbc16 --- /dev/null +++ b/tags/ParadisEO-GPU-1.1/paradiseo-mo/src/sampling/moStatistics.h @@ -0,0 +1,226 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 moStatistics_h +#define moStatistics_h + +#include +#include +#include + +/** + * Tools to compute some basic statistics + * + * Remember it is better to use some statistic tool like R, etc. + * But it could be usefull to have here in paradisEO + */ +class moStatistics +{ +public: + /** + * Default Constructor + */ + moStatistics() { } + + /** + * To compute min, max , average and standard deviation of a vector of double + * + * @param data vector of double + * @param min to compute + * @param max to compute + * @param avg average to compute + * @param std standard deviation to compute + */ + void basic(const std::vector & data, + double & min, double & max, double & avg, double & std) { + + if (data.size() == 0) { + min = 0.0; + max = 0.0; + avg = 0.0; + std = 0.0; + } else { + unsigned int n = data.size(); + + min = data[0]; + max = data[0]; + avg = 0.0; + std = 0.0; + + double d; + for (unsigned int i = 0; i < n; i++) { + d = data[i]; + if (d < min) + min = d; + if (max < d) + max = d; + avg += d; + std += d * d; + } + + avg /= n; + + std = (std / n) - avg * avg ; + if (std > 0) + std = sqrt(std); + } + } + + /** + * To compute the distance between solutions + * + * @param data vector of solutions + * @param distance method to compute the distance + * @param matrix matrix of distances between solutions + */ + template + void distances(const std::vector & data, eoDistance & distance, + std::vector< std::vector > & matrix) { + if (data.size() == 0) { + matrix.resize(0); + } else { + unsigned int n = data.size(); + + matrix.resize(n); + for (unsigned i = 0; i < n; i++) + matrix[i].resize(n); + + unsigned j; + for (unsigned i = 0; i < n; i++) { + matrix[i][i] = 0.0; + for (j = 0; j < i; j++) { + matrix[i][j] = distance(data[i], data[j]); + matrix[j][i] = matrix[i][j]; + } + } + } + } + + /** + * To compute the autocorrelation and partial autocorrelation + * + * @param data vector of double + * @param nbS number of correlation coefficients + * @param rho autocorrelation coefficients + * @param phi partial autocorrelation coefficients + */ + void autocorrelation(const std::vector & data, unsigned int nbS, + std::vector & rho, std::vector & phi) { + if (data.size() == 0) { + rho.resize(0); + phi.resize(0); + } else { + unsigned int n = data.size(); + + std::vector cov; + cov.resize(nbS+1); + //double cov[nbS+1]; + std::vector m; + m.resize(nbS+1); + //double m[nbS+1]; + std::vector sig; + sig.resize(nbS+1); + //double sig[nbS+1]; + + rho.resize(nbS+1); + phi.resize(nbS+1); + rho[0] = 1.0; + phi[0] = 1.0; + + unsigned s, k; + + for (s = 0; s <= nbS; s++) { + cov[s] = 0; + m[s] = 0; + sig[s] = 0; + } + + double m0, s0; + unsigned j; + + k = 0; + s = nbS; + while (s > 0) { + while (k + s < n) { + for (j = 0; j <= s; j++) { + m[j] += data[k+j]; + sig[j] += data[k+j] * data[k+j]; + cov[j] += data[k] * data[k+j]; + } + k++; + } + + m[s] /= n - s; + sig[s] = sig[s] / (n - s) - m[s] * m[s]; + if (sig[s] <= 0) + sig[s] = 0; + else + sig[s] = sqrt(sig[s]); + m0 = m[0] / (n - s); + s0 = sqrt(sig[0] / (n - s) - m0 * m0); + cov[s] = cov[s] / (n - s) - (m[0] / (n - s)) * m[s]; + rho[s] = cov[s] / (sig[s] * s0); + s--; + } + + std::vector< std::vector > phi2; + phi2.resize(nbS+1); + for(unsigned int i=0; i