diff --git a/trunk/paradiseo-moeo/CMakeLists.txt b/trunk/paradiseo-moeo/CMakeLists.txt index 7ae1f91c1..26e8edbfa 100644 --- a/trunk/paradiseo-moeo/CMakeLists.txt +++ b/trunk/paradiseo-moeo/CMakeLists.txt @@ -35,6 +35,11 @@ IF(NOT DEFINED config OR NOT config) give the path of the install configuration file. ") ENDIF(NOT DEFINED config OR NOT config) +EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${ParadisEO-MOEO_SOURCE_DIR}/CTestCustom.cmake + ${ParadisEO-MOEO_BINARY_DIR}/CTestCustom.cmake) + # Need the config file whose full path is given thanks to the "config" variable INCLUDE(${config}) ########################################################################################################################################## diff --git a/trunk/paradiseo-moeo/CTestCustom.cmake b/trunk/paradiseo-moeo/CTestCustom.cmake new file mode 100644 index 000000000..11f778078 --- /dev/null +++ b/trunk/paradiseo-moeo/CTestCustom.cmake @@ -0,0 +1,7 @@ +SET(CTEST_CUSTOM_COVERAGE_EXCLUDE + ${CTEST_CUSTOM_COVERAGE_EXCLUDE} +"test/" +"paradiseo-eo/" +"paradiseo-mo/" +"paradiseo-old-mo/" +) diff --git a/trunk/paradiseo-moeo/src/algo/moeoPopLS.h b/trunk/paradiseo-moeo/src/algo/moeoPopLS.h new file mode 100755 index 000000000..357a9fb61 --- /dev/null +++ b/trunk/paradiseo-moeo/src/algo/moeoPopLS.h @@ -0,0 +1,50 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* 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 MOEOPOPLS_H_ +#define MOEOPOPLS_H_ + +#include + +/** + * Abstract class for Population based multi-objective local search. + */ +template < class Neighborhhod > +class moeoPopLS : public moeoPopAlgo < typename Neighborhhod::EOT > {}; + +#endif /*MOEOPOPLS_H_*/ diff --git a/trunk/paradiseo-moeo/src/algo/moeoUnifiedDominanceBasedLS.h b/trunk/paradiseo-moeo/src/algo/moeoUnifiedDominanceBasedLS.h new file mode 100755 index 000000000..93223b42a --- /dev/null +++ b/trunk/paradiseo-moeo/src/algo/moeoUnifiedDominanceBasedLS.h @@ -0,0 +1,147 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* 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 _MOEOUNIFIEDDOMINANCEBASEDLS_H +#define _MOEOUNIFIEDDOMINANCEBASEDLS_H + +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * A class to design dominance based local searches + */ +template < class Neighborhood > +class moeoUnifiedDominanceBasedLS : public moeoPopLS < Neighborhood > +{ +public: + + /** Alias for the type */ + typedef typename Neighborhood::EOT MOEOT; + + /** + * Ctor + * @param _continuator a stop creterion + * @param _eval a evaluation function + * @param _archive a archive to store no-dominated individuals + * @param _explorer a neighborhood explorer + * @param _select a selector of unvisited individuals of a population + */ + moeoUnifiedDominanceBasedLS( + eoContinue < MOEOT > & _continuator, + eoEvalFunc < MOEOT > & _eval, + moeoArchive < MOEOT > & _archive, + moeoPopNeighborhoodExplorer < Neighborhood > & _explorer, + moeoUnvisitedSelect < MOEOT > & _select) : + continuator(_continuator), loopEval(_eval), popEval(loopEval), archive(_archive), explorer(_explorer), select(_select) {} + + /** + * Applies a few generation of evolution to the population _pop. + * @param _pop the population + */ + virtual void operator()(eoPop < MOEOT > & _pop) + { + std::vector < unsigned int> selectionVector; + eoPop < MOEOT > tmp_pop; + popEval(tmp_pop, _pop); + archive(_pop); + do{ + tmp_pop.resize(0); + //selection + selectionVector = select(archive); + //exploration + explorer(archive, selectionVector, tmp_pop); + //archivage + archive(tmp_pop); + } + while (continuator(archive) && naturalContinuator(archive)); + } + +protected: + + /** continuator */ + eoContinue < MOEOT > & continuator; + /** loopEval */ + eoPopLoopEval < MOEOT > loopEval; + /** popEval */ + eoPopEvalFunc < MOEOT > & popEval; + /** archive */ + moeoArchive < MOEOT > & archive; + /** explorer */ + moeoPopNeighborhoodExplorer < Neighborhood > & explorer; + /** selector */ + moeoUnvisitedSelect < MOEOT > & select; + + /** + * Natural Continuator (Stop when all individuals of the population are visited) + */ + class moeoContinue : public eoUF < eoPop < MOEOT > &, bool > + { + public: + + /** + * Ctor + */ + moeoContinue(){} + + /** + * functor which evaluate if the algorithm continue or not + * @param _pop the population + * @return true if the algorithm continue, else return false + */ + virtual bool operator()(eoPop < MOEOT > & _pop) + { + bool res = false; + unsigned int i=0; + while (!res && i < _pop.size()){ + res = (_pop[i].flag() != 1); + i++; + } + return res; + } + } naturalContinuator; + +}; + +#endif /*MOEOUNIFIEDDOMINANCEBASEDLS_H_*/ + diff --git a/trunk/paradiseo-moeo/src/explorer/moeoExhaustiveNeighborhoodExplorer.h b/trunk/paradiseo-moeo/src/explorer/moeoExhaustiveNeighborhoodExplorer.h new file mode 100644 index 000000000..e4e3e6e31 --- /dev/null +++ b/trunk/paradiseo-moeo/src/explorer/moeoExhaustiveNeighborhoodExplorer.h @@ -0,0 +1,124 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* 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 _MOEOEXHAUSTIVENEIGHBORHOODEXPLORER_H +#define _MOEOEXHAUSTIVENEIGHBORHOODEXPLORER_H + +#include +#include +#include +#include +#include + +/** + * Explorer which explore all the neighborhood + */ +template < class Neighborhood > +class moeoExhaustiveNeighborhoodExplorer : public moeoPopNeighborhoodExplorer < Neighborhood > +{ + /** Alias for the type */ + typedef typename Neighborhood::EOT MOEOT; + typedef typename Neighborhood::Neighbor Neighbor; + /** Alias for the objeciveVector */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + +public: + + /** + * Ctor + * @param _moveInit the move initializer + * @param _nextMove allow to do or not a move + * @param _incrEval a (generally) efficient evaluation fonction + */ + moeoExhaustiveNeighborhoodExplorer( + moNeighborhood& _neighborhood, + moEval < Neighbor > & _eval): + neighborhood(_neighborhood), eval(_eval){} + + /** + * functor to explore the neighborhood + * @param _src the population to explore + * @param _select contains index of individuals from the population to explore + * @param _dest contains new generated individuals + */ + void operator()(eoPop < MOEOT > & _src, std::vector < unsigned int> _select, eoPop < MOEOT > & _dest) + { + for(unsigned int i=0; i<_select.size(); i++) + explore(_src[_select[i]], _dest); + } + +private: + + /** + * explorer of one individual + * @param _src the individual to explore + * @param _dest contains new generated individuals + */ + void explore(MOEOT & _src , eoPop < MOEOT > & _dest) + { + if(neighborhood.hasNeighbor(_src)){ + neighborhood.init(_src, neighbor); + _dest.push_back(_src); + eval(_dest.back(),neighbor); + neighbor.move(_dest.back()); + _dest.back().objectiveVector(neighbor.fitness()); + _dest.back().flag(0); + while (neighborhood.cont(_src)){ + neighborhood.next(_src, neighbor); + _dest.push_back(_src); + eval(_dest.back(),neighbor); + neighbor.move(_dest.back()); + _dest.back().objectiveVector(neighbor.fitness()); + _dest.back().flag(0); + } + _src.flag(1); + } + } + + /** Neighbor */ + Neighbor neighbor; + /** Neighborhood */ + moNeighborhood& neighborhood; + /** ObjectiveVector */ + ObjectiveVector objVec; + /** the incremental evaluation */ + moEval < Neighbor > & eval; + +}; + +#endif /*_MOEOEXHAUSTIVENEIGHBORHOODEXPLORER_H_*/ diff --git a/trunk/paradiseo-moeo/src/explorer/moeoPopNeighborhoodExplorer.h b/trunk/paradiseo-moeo/src/explorer/moeoPopNeighborhoodExplorer.h new file mode 100755 index 000000000..41c80402c --- /dev/null +++ b/trunk/paradiseo-moeo/src/explorer/moeoPopNeighborhoodExplorer.h @@ -0,0 +1,58 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* 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 _MOEOPOPNEIGHBORHOODEXPLORER_H +#define _MOEOPOPNEIGHBORHOODEXPLORER_H + +#include + +/** + * Abstract class for multi-objective local search neighborhood exploration + */ +template < class Neighborhood > +class moeoPopNeighborhoodExplorer: public eoFunctorBase{ + +public: + /** + * abstract functor which realise exploration + */ + virtual void operator()(eoPop < typename Neighborhood::EOT > &, std::vector , eoPop < typename Neighborhood::EOT > &) = 0; + +}; + +#endif /*MOEONEIGHBORHOODEXPLORER_H_*/ diff --git a/trunk/paradiseo-moeo/src/moeo b/trunk/paradiseo-moeo/src/moeo index 14d70ddc6..f5651c1f8 100644 --- a/trunk/paradiseo-moeo/src/moeo +++ b/trunk/paradiseo-moeo/src/moeo @@ -58,7 +58,8 @@ #include #include #include - +#include +#include #include #include @@ -118,6 +119,14 @@ #include #include +#include +#include + +#include +#include +#include +#include + #include #include #include @@ -169,6 +178,9 @@ #include #include #include +#include +#include +#include #include #include @@ -191,9 +203,5 @@ #include -#include -#include - - #endif /*MOEO_*/ diff --git a/trunk/paradiseo-moeo/src/selection/moeoExhaustiveUnvisitedSelect.h b/trunk/paradiseo-moeo/src/selection/moeoExhaustiveUnvisitedSelect.h new file mode 100644 index 000000000..541a6150d --- /dev/null +++ b/trunk/paradiseo-moeo/src/selection/moeoExhaustiveUnvisitedSelect.h @@ -0,0 +1,78 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* 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 _MOEOEXHAUSTIVEUNVISITEDSELECT_H +#define _MOEOEXHAUSTIVEUNVISITEDSELECT_H + +#include +#include + +/** + * Selector which select all unvisited individuals of a population + */ +template < class MOEOT > +class moeoExhaustiveUnvisitedSelect : public moeoUnvisitedSelect < MOEOT > +{ + +public: + + /** + * Default ctor + */ + moeoExhaustiveUnvisitedSelect(){} + + /** + * functor which return index of selected individuals of a population + * @param _src the population + * @return the vector contains index of all unvisited individuals of the population + */ + std::vector operator()(eoPop < MOEOT > & _src) + { + std::vector res; + res.resize(0); + for (unsigned int i=0; i<_src.size(); i++) + { + if (_src[i].flag() == 0) + res.push_back(i); + } + return res; + } + +}; + +#endif /*_MOEOEXHAUSTIVEUNVISITEDSELECT_H_*/ diff --git a/trunk/paradiseo-moeo/src/selection/moeoNumberUnvisitedSelect.h b/trunk/paradiseo-moeo/src/selection/moeoNumberUnvisitedSelect.h new file mode 100644 index 000000000..5a0388567 --- /dev/null +++ b/trunk/paradiseo-moeo/src/selection/moeoNumberUnvisitedSelect.h @@ -0,0 +1,88 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* 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 _MOEONUMBERUNVISITEDSELECT_H +#define _MOEONUMBERUNVISITEDSELECT_H + +#include +#include + +/** + * Selector which select a part of unvisited individuals of a population + */ +template < class MOEOT > +class moeoNumberUnvisitedSelect : public moeoUnvisitedSelect < MOEOT > +{ + +public: + + /** + * Ctor + * @param _number the number of individuals to select + */ + moeoNumberUnvisitedSelect(unsigned int _number): number(_number){} + + /** + * functor which return index of selected individuals of a population + * @param _src the population + * @return the vector contains index of the part of unvisited individuals of the population + */ + std::vector operator()(eoPop < MOEOT > & _src) + { + std::vector res; + res.resize(0); + for (unsigned int i=0; i<_src.size(); i++) + { + if (_src[i].flag() == 0) + res.push_back(i); + } + if(number < res.size()){ + UF_random_generator rndGen; + std::random_shuffle(res.begin(), res.end(), rndGen); + res.resize(number); + } + return res; + } + +private: + /** number of individuals to select */ + unsigned int number; + +}; + +#endif /*_MOEONUMBERUNVISITEDSELECT_H_*/ diff --git a/trunk/paradiseo-moeo/src/selection/moeoUnvisitedSelect.h b/trunk/paradiseo-moeo/src/selection/moeoUnvisitedSelect.h new file mode 100644 index 000000000..cd0dc3759 --- /dev/null +++ b/trunk/paradiseo-moeo/src/selection/moeoUnvisitedSelect.h @@ -0,0 +1,50 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* 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 _MOEOUNVISITEDSELECT_H +#define _MOEOUNVISITEDSELECT_H + +#include + +/** + * Abstract Selector + */ +template < class MOEOT > +class moeoUnvisitedSelect: public eoUF < eoPop < MOEOT > &, std::vector< unsigned int > >{}; + +#endif /*MOEOUNVISITEDSELECT_H_*/ diff --git a/trunk/paradiseo-moeo/test/CMakeLists.txt b/trunk/paradiseo-moeo/test/CMakeLists.txt index 0355adf25..c5ccbe9ba 100644 --- a/trunk/paradiseo-moeo/test/CMakeLists.txt +++ b/trunk/paradiseo-moeo/test/CMakeLists.txt @@ -10,6 +10,7 @@ ###################################################################################### INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src) +INCLUDE_DIRECTORIES(${MO_SRC_DIR}/src) INCLUDE_DIRECTORIES(${OLDMO_SRC_DIR}/src) INCLUDE_DIRECTORIES(${ParadisEO-MOEO_SOURCE_DIR}/src) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) @@ -92,6 +93,7 @@ SET (TEST_LIST t-moeoFixedTimeOneDirectionWeightStrategy t-moeoFixedTimeBothDirectionWeightStrategy t-moeoDichoWeightStrategy + t-moeoExhaustiveNeighborhoodExplorer ) FOREACH (test ${TEST_LIST}) diff --git a/trunk/paradiseo-moeo/test/moeoTestClass.h b/trunk/paradiseo-moeo/test/moeoTestClass.h new file mode 100644 index 000000000..31eb32111 --- /dev/null +++ b/trunk/paradiseo-moeo/test/moeoTestClass.h @@ -0,0 +1,108 @@ +/* + + 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 _moeoTestClass_h +#define _moeoTestClass_h + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +class ObjectiveVectorTraits : public moeoObjectiveVectorTraits +{ +public: + static bool minimizing (int i) + { + return true; + } + static bool maximizing (int i) + { + return false; + } + static unsigned int nObjectives () + { + return 2; + } +}; + +typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector; + +typedef moeoBitVector Solution; + +class SolNeighbor : public moIndexNeighbor +{ +public: + virtual void move(Solution & _solution) { + _solution[key] = !_solution[key]; + } + +}; + +typedef moOrderNeighborhood SolNeighborhood; + +class evalSolution : public moEval< SolNeighbor > +{ +private: + unsigned size; + +public: + evalSolution(unsigned _size) : size(_size) {}; + + ~evalSolution(void) {} ; + + void operator() (Solution& _sol, SolNeighbor& _n){ + ObjectiveVector objVec=_sol.objectiveVector(); + if (_sol[_n.index()]){ + objVec[0]--; + objVec[1]++; + } + else{ + objVec[0]++; + objVec[1]--; + } + _n.fitness(objVec); + } +}; + +#endif diff --git a/trunk/paradiseo-moeo/test/t-moeoExhaustiveNeighborhoodExplorer.cpp b/trunk/paradiseo-moeo/test/t-moeoExhaustiveNeighborhoodExplorer.cpp new file mode 100644 index 000000000..a8b7e154e --- /dev/null +++ b/trunk/paradiseo-moeo/test/t-moeoExhaustiveNeighborhoodExplorer.cpp @@ -0,0 +1,81 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can ue, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr +*/ + +#include "moeoTestClass.h" +#include +#include +#include + +int main(){ + + std::cout << "[t-moeoExhaustiveNeighborhoodExplorer] => START" << std::endl; + + Solution s; + evalSolution eval(8); + ObjectiveVector o; + SolNeighbor n; + SolNeighborhood nh(8); + moeoExhaustiveNeighborhoodExplorer explorer(nh, eval); + eoPop src; + eoPop dest; + std::vector v; + v.push_back(0); + + s.push_back(true); + s.push_back(true); + s.push_back(true); + s.push_back(true); + s.push_back(true); + s.push_back(true); + s.push_back(true); + s.push_back(true); + + o[0]=8; + o[1]=0; + s.objectiveVector(o); + + n.index(3); + eval(s,n); + n.move(s); + s.objectiveVector(n.fitness()); + + std::cout << s << std::endl; + + src.push_back(s); + + explorer(src, v, dest); + + for(unsigned int i=0; i OK" << std::endl; + + return EXIT_SUCCESS; +} +