diff --git a/trunk/paradiseo-moeo/src/algo/moeoPLS1.h b/trunk/paradiseo-moeo/src/algo/moeoPLS1.h new file mode 100644 index 000000000..b11c920a2 --- /dev/null +++ b/trunk/paradiseo-moeo/src/algo/moeoPLS1.h @@ -0,0 +1,84 @@ +/* +* +* 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 _MOEOPLS1_H +#define _MOEOPLS1_H + +#include +#include +#include + +/** + * PLS1 algorithm + * + * Paquete L, Chiarandini M, St ̈ tzle T (2004) Pareto local optimum sets in the biobjective + * traveling salesman problem: An experimental study. In: Metaheuristics for Multiobjective + * Optimisation, Lecture Notes in Economics and Mathematical Systems, vol 535, Springer- + * Verlag, Berlin, Germany, chap 7, pp 177–199 + */ +template < class Neighbor > +class moeoPLS1 : public moeoUnifiedDominanceBasedLS < Neighbor > +{ +public: + + /** Alias for the type */ + typedef typename Neighbor::EOT MOEOT; + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + /** + * Ctor + * @param _continuator a stop creterion + * @param _eval a evaluation function + * @param _archive a archive to store no-dominated individuals + */ + moeoPLS1( + eoContinue < MOEOT > & _continuator, + eoEvalFunc < MOEOT > & _eval, + moeoArchive < MOEOT > & _archive, + moNeighborhood& _neighborhood, + moEval < Neighbor > & _incrEval): + moeoUnifiedDominanceBasedLS( + _continuator, + _eval, + _archive, + *(new moeoExhaustiveNeighborhoodExplorer(_neighborhood, _incrEval)), + *(new moeoNumberUnvisitedSelect(1)) + ){} + +}; + +#endif /*MOEOPLS1_H_*/ diff --git a/trunk/paradiseo-moeo/src/algo/moeoPLS2.h b/trunk/paradiseo-moeo/src/algo/moeoPLS2.h new file mode 100644 index 000000000..dc6dc5a96 --- /dev/null +++ b/trunk/paradiseo-moeo/src/algo/moeoPLS2.h @@ -0,0 +1,96 @@ +/* +* +* 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 _MOEOPLS2_H +#define _MOEOPLS2_H + +#include +#include +#include + +/** + * PLS2 algorithm + * + * Talbi EG, Rahoual M, Mabed MH, Dhaenens C (2001) A hybrid evolutionary approach for + * multicriteria optimization problems : Application to the fow shop. In: First International + * Conference on Evolutionary Multi-criterion Optimization (EMO 2001), Springer-Verlag, + * Zurich, Switzerland, Lecture Notes in Computer Science, vol 1993, pp 416–428 + * + * Basseur M, Seynhaeve F, Talbi E (2003) Adaptive mechanisms for multiobjective evolution- + * ary algorithms. In: Congress on Engineering in System Application (CESA 2003), Lille, + * France, pp 72–86 + * + * Angel E, Bampis E, Gourv ́ s L (2004) A dynasearch neighbohood for the bicriteria travel- + * ing salesman problem. In: Metaheuristics for Multiobjective Optimisation, Lecture Notes + * in Economics and Mathematical Systems, vol 535, Springer-Verlag, Berlin, Germany, + * chap 6, pp 153–176 + */ +template < class Neighbor > +class moeoPLS2 : public moeoUnifiedDominanceBasedLS < Neighbor > +{ +public: + + /** Alias for the type */ + typedef typename Neighbor::EOT MOEOT; + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + /** + * Ctor + * @param _continuator a stop creterion + * @param _eval a evaluation function + * @param _archive a archive to store no-dominated individuals + * @param _moveInit the move initializer + * @param _nextMove allow to do or not a move + * @param _incrEval a (generally) efficient evaluation fonction + */ + moeoPLS2( + eoContinue < MOEOT > & _continuator, + eoEvalFunc < MOEOT > & _eval, + moeoArchive < MOEOT > & _archive, + moNeighborhood& _neighborhood, + moEval < Neighbor > & _incrEval): + moeoUnifiedDominanceBasedLS( + _continuator, + _eval, + _archive, + *(new moeoExhaustiveNeighborhoodExplorer(_neighborhood, _incrEval)), + *(new moeoExhaustiveUnvisitedSelect()) + ){} + +}; + +#endif /*MOEOPLS2_H_*/ diff --git a/trunk/paradiseo-moeo/src/algo/moeoUnifiedDominanceBasedLS.h b/trunk/paradiseo-moeo/src/algo/moeoUnifiedDominanceBasedLS.h index 93223b42a..21ea6bdad 100755 --- a/trunk/paradiseo-moeo/src/algo/moeoUnifiedDominanceBasedLS.h +++ b/trunk/paradiseo-moeo/src/algo/moeoUnifiedDominanceBasedLS.h @@ -51,13 +51,13 @@ /** * A class to design dominance based local searches */ -template < class Neighborhood > -class moeoUnifiedDominanceBasedLS : public moeoPopLS < Neighborhood > +template < class Neighbor > +class moeoUnifiedDominanceBasedLS : public moeoPopLS < Neighbor > { public: /** Alias for the type */ - typedef typename Neighborhood::EOT MOEOT; + typedef typename Neighbor::EOT MOEOT; /** * Ctor @@ -71,7 +71,7 @@ public: eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, moeoArchive < MOEOT > & _archive, - moeoPopNeighborhoodExplorer < Neighborhood > & _explorer, + moeoPopNeighborhoodExplorer < Neighbor > & _explorer, moeoUnvisitedSelect < MOEOT > & _select) : continuator(_continuator), loopEval(_eval), popEval(loopEval), archive(_archive), explorer(_explorer), select(_select) {} @@ -108,7 +108,7 @@ protected: /** archive */ moeoArchive < MOEOT > & archive; /** explorer */ - moeoPopNeighborhoodExplorer < Neighborhood > & explorer; + moeoPopNeighborhoodExplorer < Neighbor > & explorer; /** selector */ moeoUnvisitedSelect < MOEOT > & select; diff --git a/trunk/paradiseo-moeo/src/explorer/moeoExhaustiveNeighborhoodExplorer.h b/trunk/paradiseo-moeo/src/explorer/moeoExhaustiveNeighborhoodExplorer.h index 968c396c4..ef4bc0948 100644 --- a/trunk/paradiseo-moeo/src/explorer/moeoExhaustiveNeighborhoodExplorer.h +++ b/trunk/paradiseo-moeo/src/explorer/moeoExhaustiveNeighborhoodExplorer.h @@ -48,12 +48,11 @@ /** * Explorer which explore all the neighborhood */ -template < class Neighborhood > -class moeoExhaustiveNeighborhoodExplorer : public moeoPopNeighborhoodExplorer < Neighborhood > +template < class Neighbor> +class moeoExhaustiveNeighborhoodExplorer : public moeoPopNeighborhoodExplorer { /** Alias for the type */ - typedef typename Neighborhood::EOT MOEOT; - typedef typename Neighborhood::Neighbor Neighbor; + typedef typename Neighbor::EOT MOEOT; /** Alias for the objeciveVector */ typedef typename MOEOT::ObjectiveVector ObjectiveVector; @@ -90,13 +89,21 @@ private: */ void explore(MOEOT & _src , eoPop < MOEOT > & _dest) { + //if the neighborhood is not empty if(neighborhood.hasNeighbor(_src)){ + //init the neighborhood neighborhood.init(_src, neighbor); + //copy the solution (_src) at the end of the destination (_dest) _dest.push_back(_src); + //eval the neighbor eval(_dest.back(),neighbor); + //move the copy neighbor.move(_dest.back()); + //affect objective vector to the copy _dest.back().objectiveVector(neighbor.fitness()); + //fix its flag to 0 (unvisited solution) _dest.back().flag(0); + //repeat all instructions for each neighbor in the neighborhood while (neighborhood.cont(_src)){ neighborhood.next(_src, neighbor); _dest.push_back(_src); @@ -105,6 +112,7 @@ private: _dest.back().objectiveVector(neighbor.fitness()); _dest.back().flag(0); } + //fix the source flag to 1 (visited solution) _src.flag(1); } } @@ -113,8 +121,6 @@ private: Neighbor neighbor; /** Neighborhood */ moNeighborhood& neighborhood; - /** ObjectiveVector */ - ObjectiveVector objVec; /** the incremental evaluation */ moEval < Neighbor > & eval; diff --git a/trunk/paradiseo-moeo/src/explorer/moeoFirstImprovingNeighborhoodExplorer.h b/trunk/paradiseo-moeo/src/explorer/moeoFirstImprovingNeighborhoodExplorer.h new file mode 100644 index 000000000..14d69fba6 --- /dev/null +++ b/trunk/paradiseo-moeo/src/explorer/moeoFirstImprovingNeighborhoodExplorer.h @@ -0,0 +1,118 @@ +/* +* +* 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 _MOEOFIRSTIMPROVINGNEIGHBORHOODEXPLORER_H +#define _MOEOFIRSTIMPROVINGNEIGHBORHOODEXPLORER_H + +#include + +/** + * Explorer which explore a part of the neighborhood + */ +template < class Neighbor > +class moeoFirstImprovingNeighborhoodExplorer : public moeoSubNeighborhoodExplorer < Neighbor > +{ + /** Alias for the type */ + typedef typename Neighbor::EOT MOEOT; + /** Alias for the objeciveVector */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + using moeoSubNeighborhoodExplorer::neighborhood; + using moeoSubNeighborhoodExplorer::neighbor; + +public: + + /** + * Ctor + * @param _moveInit the move initializer + * @param _nextMove allow to do or not a move + * @param _incrEval a (generally) efficient evaluation fonction + */ + moeoFirstImprovingNeighborhoodExplorer( + moNeighborhood& _neighborhood, + moEval < Neighbor > & _eval): + moeoSubNeighborhoodExplorer< Neighbor >(_neighborhood, 0), eval(_eval){} + +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 the neighborhood is not empty + if(neighborhood.hasNeighbor(_src)){ + //init the neighborhood + neighborhood.init(_src, neighbor); + //eval the neighbor + cycle(_src, _dest); + //repeat all instructions for each neighbor in the neighborhood until a best neighbor is found + while (!comparator(_src.objectiveVector(), neighbor.fitness()) && neighborhood.cont(_src)){ + neighborhood.next(_src, neighbor); + cycle(_src, _dest); + } + //if all neighbors are been visited, fix the source flag to 1 (visited solution) + if(!neighborhood.cont(_src)) + _src.flag(1); + } + } + + void cycle(MOEOT & _src, eoPop < MOEOT > & _dest){ + eval(_src, neighbor); + if(!comparator(neighbor.fitness(), _src.objectiveVector())){ + //copy the solution (_src) at the end of the destination (_dest) + _dest.push_back(_src); + //move the copy + neighbor.move(_dest.back()); + //affect objective vector to the copy + _dest.back().objectiveVector(neighbor.fitness()); + //fix its flag to 0 (unvisited solution) + _dest.back().flag(0); + } + } + + /** Objective Vector Pareto Comparator */ + moeoParetoObjectiveVectorComparator comparator; + /** Incremental evaluation of a neighbor */ + moEval < Neighbor > & eval; + +}; + +#endif /*_MOEOFIRSTIMPROVINGNEIGHBORHOODEXPLORER_H_*/ diff --git a/trunk/paradiseo-moeo/src/explorer/moeoNoDesimprovingNeighborhoodExplorer.h b/trunk/paradiseo-moeo/src/explorer/moeoNoDesimprovingNeighborhoodExplorer.h new file mode 100644 index 000000000..0cad28004 --- /dev/null +++ b/trunk/paradiseo-moeo/src/explorer/moeoNoDesimprovingNeighborhoodExplorer.h @@ -0,0 +1,111 @@ +/* +* +* 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 _MOEONODESIMPROVINGNEIGHBORHOODEXPLORER_H +#define _MOEONODESIMPROVINGNEIGHBORHOODEXPLORER_H + +#include + +/** + * Explorer which explore a part of the neighborhood + */ +template < class Neighbor > +class moeoNoDesimprovingNeighborhoodExplorer : public moeoSubNeighborhoodExplorer < Neighbor > +{ + /** Alias for the type */ + typedef typename Neighbor::EOT MOEOT; + /** Alias for the objeciveVector */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + using moeoSubNeighborhoodExplorer::neighborhood; + using moeoSubNeighborhoodExplorer::neighbor; + +public: + + /** + * Ctor + * @param _neighborhood a neighborhood + */ + moeoNoDesimprovingNeighborhoodExplorer( + moNeighborhood& _neighborhood, + moEval < Neighbor > & _eval) + : moeoSubNeighborhoodExplorer< Neighbor >(_neighborhood, 0), eval(_eval){} + +private: + + /** + * explorer of one individual + * @param _src the individual to explore + * @param _dest contains new generated individuals + */ + void explore(MOEOT & _src, eoPop < MOEOT > & _dest) + { + bool tmp=true; + if(neighborhood.hasNeighbor(_src)){ + neighborhood.init(_src, neighbor); + eval(_src,neighbor); + if(!comparator(neighbor.fitness(), _src.objectiveVector())){ + _dest.push_back(_src); + neighbor.move(_dest.back()); + _dest.back().objectiveVector(neighbor.fitness()); + _dest.back().flag(0); + tmp=false; + } + while (neighborhood.cont(_src) && tmp){ + neighborhood.next(_src, neighbor); + eval(_src,neighbor); + if(!comparator(neighbor.fitness(), _src.objectiveVector())){ + _dest.push_back(_src); + neighbor.move(_dest.back()); + _dest.back().objectiveVector(neighbor.fitness()); + _dest.back().flag(0); + tmp=false; + } + } + if(!neighborhood.cont(_src)) + _src.flag(1); + } + } + + /** Objective Vector Pareto Comparator */ + moeoParetoObjectiveVectorComparator comparator; + /** Incremental evaluation of a neighbor */ + moEval < Neighbor > & eval; +}; + +#endif /*_MOEONODESIMPROVINGNEIGHBORHOODEXPLORER_H_*/ diff --git a/trunk/paradiseo-moeo/src/explorer/moeoPopNeighborhoodExplorer.h b/trunk/paradiseo-moeo/src/explorer/moeoPopNeighborhoodExplorer.h index 41c80402c..eff855939 100755 --- a/trunk/paradiseo-moeo/src/explorer/moeoPopNeighborhoodExplorer.h +++ b/trunk/paradiseo-moeo/src/explorer/moeoPopNeighborhoodExplorer.h @@ -44,14 +44,16 @@ /** * Abstract class for multi-objective local search neighborhood exploration */ -template < class Neighborhood > +template < class Neighbor > class moeoPopNeighborhoodExplorer: public eoFunctorBase{ public: + + typedef typename Neighbor::EOT MOEOT; /** * abstract functor which realise exploration */ - virtual void operator()(eoPop < typename Neighborhood::EOT > &, std::vector , eoPop < typename Neighborhood::EOT > &) = 0; + virtual void operator()(eoPop &, std::vector , eoPop &) = 0; }; diff --git a/trunk/paradiseo-moeo/src/explorer/moeoSimpleSubNeighborhoodExplorer.h b/trunk/paradiseo-moeo/src/explorer/moeoSimpleSubNeighborhoodExplorer.h new file mode 100644 index 000000000..54f0ba80d --- /dev/null +++ b/trunk/paradiseo-moeo/src/explorer/moeoSimpleSubNeighborhoodExplorer.h @@ -0,0 +1,120 @@ +/* +* +* 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 _MOEOSIMPLESUBNEIGHBORHOODEXPLORER_H +#define _MOEOSIMPLESUBNEIGHBORHOODEXPLORER_H + +#include + +/** + * Explorer which explore a part of the neighborhood + */ +template < class Neighbor > +class moeoSimpleSubNeighborhoodExplorer : public moeoSubNeighborhoodExplorer < Neighbor > +{ + /** Alias for the type */ + typedef typename Neighbor::EOT MOEOT; + /** Alias for the objeciveVector */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + using moeoSubNeighborhoodExplorer::neighborhood; + using moeoSubNeighborhoodExplorer::neighbor; + using moeoSubNeighborhoodExplorer::number; + +public: + + /** + * Ctor + * @param _moveInit the move initializer + * @param _nextMove allow to do or not a move + * @param _incrEval a (generally) efficient evaluation fonction + * @param _number the number of neighbor to explore + */ + moeoSimpleSubNeighborhoodExplorer( + moNeighborhood& _neighborhood, + unsigned int _number, + moEval < Neighbor > & _eval) + : moeoSubNeighborhoodExplorer(_neighborhood, _number), eval(_eval){} + +private: + + /** + * explorer of one individual + * @param _src the individual to explore + * @param _dest contains new generated individuals + */ + void explore(MOEOT & _src, eoPop < MOEOT > & _dest) + { + unsigned int tmp=number; + //if the neighborhood is not empty + if(neighborhood.hasNeighbor(_src) && tmp>0){ + //init the neighborhood + neighborhood.init(_src, neighbor); + //eval the neighbor + cycle(_src, _dest); + tmp--; + //repeat all instructions for each neighbor in the neighborhood until a best neighbor is found + while (neighborhood.cont(_src) && tmp>0){ + neighborhood.next(_src, neighbor); + cycle(_src, _dest); + tmp--; + } + //if all neighbors are been visited, fix the source flag to 1 (visited solution) + if(!neighborhood.cont(_src)) + _src.flag(1); + } + } + + void cycle(MOEOT & _src, eoPop < MOEOT > & _dest){ + eval(_src, neighbor); + //copy the solution (_src) at the end of the destination (_dest) + _dest.push_back(_src); + //move the copy + neighbor.move(_dest.back()); + //affect objective vector to the copy + _dest.back().objectiveVector(neighbor.fitness()); + //fix its flag to 0 (unvisited solution) + _dest.back().flag(0); + } + + /** Incremental evaluation of a neighbor */ + moEval < Neighbor > & eval; + +}; + +#endif /*_MOEOSIMPLESUBNEIGHBORHOODEXPLORER_H_*/ diff --git a/trunk/paradiseo-moeo/src/explorer/moeoSubNeighborhoodExplorer.h b/trunk/paradiseo-moeo/src/explorer/moeoSubNeighborhoodExplorer.h new file mode 100644 index 000000000..168afefc2 --- /dev/null +++ b/trunk/paradiseo-moeo/src/explorer/moeoSubNeighborhoodExplorer.h @@ -0,0 +1,101 @@ +/* +* +* 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 _MOEOSUBNEIGHBORHOODEXPLORER_H +#define _MOEOSUBNEIGHBORHOODEXPLORER_H + +#include +#include +#include +#include + +/** + * Explorer which explore a part of the neighborhood + */ +template < class Neighbor > +class moeoSubNeighborhoodExplorer : public moeoPopNeighborhoodExplorer < Neighbor > +{ + /** Alias for the type */ + typedef typename Neighbor::EOT MOEOT; + /** Alias for the objeciveVector */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + +public: + + /** + * Ctor + * @param _neighborhood a neighborhood + * @param _number the number of neighbor to explore + */ + moeoSubNeighborhoodExplorer( + moNeighborhood& _neighborhood, + unsigned int _number) + : neighborhood(_neighborhood), number(_number){} + + /** + * 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 _select, eoPop < MOEOT > & _dest) + { + for(unsigned int i=0; i<_select.size(); i++) + explore(_src[_select[i]], _dest); + } + +protected: + + /** + * explorer of one individual + * @param _src the individual to explore + * @param _dest contains new generated individuals + */ + virtual void explore(MOEOT & _src, eoPop < MOEOT > & _dest) = 0; + + /** Neighbor */ + Neighbor neighbor; + /** Neighborhood */ + moNeighborhood & neighborhood; + + /** number of neighbor to explore for each selected individual*/ + unsigned int number; + +}; + +#endif /*_MOEOSUBNEIGHBORHOODEXPLORER_H_*/ diff --git a/trunk/paradiseo-moeo/src/hybridization/moeoDMLSGenUpdater.h b/trunk/paradiseo-moeo/src/hybridization/moeoDMLSGenUpdater.h new file mode 100644 index 000000000..c318f76ca --- /dev/null +++ b/trunk/paradiseo-moeo/src/hybridization/moeoDMLSGenUpdater.h @@ -0,0 +1,150 @@ +/* +* +* 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 _MOEODMLSGENUPDATER_H +#define _MOEODMLSGENUPDATER_H + +#include +#include +#include +#include +#include +#include +#include + +/** updater allowing hybridization with a dmls at checkpointing*/ +template < class Neighbor > +class moeoDMLSGenUpdater : public eoUpdater +{ + + typedef typename Neighbor::EOT MOEOT; + + public : + /** Ctor with a dmls. + * @param _dmls the dmls use for the hybridization (!!! Special care is needed when choosing the continuator of the dmls !!!) + * @param _dmlsArchive an archive (used to instantiate the dmls) + * @param _globalArchive the same archive used in the other algorithm + * @param _continuator is a Generational Continuator which allow to run dmls on the global archive each X generation(s) + * @param _verbose verbose mode + */ + moeoDMLSGenUpdater(moeoUnifiedDominanceBasedLS & _dmls, + moeoArchive < MOEOT > & _dmlsArchive, + moeoArchive < MOEOT > & _globalArchive, + eoGenContinue < MOEOT > & _continuator, + bool _verbose = true): + defaultContinuator(0), dmlsArchive(_dmlsArchive), dmls(_dmls), globalArchive(_globalArchive), continuator(_continuator), verbose(_verbose){} + + /** Ctor with a dmls. + * @param _eval a evaluation function (used to instantiate the dmls) + * @param _explorer a neighborhood explorer (used to instantiate the dmls) + * @param _select a selector of unvisited individuals of a population (used to instantiate the dmls) + * @param _globalArchive the same archive used in the other algorithm + * @param _continuator is a Generational Continuator which allow to run dmls on the global archive each X generation(s) + * @param _step (default=1) is the number of Generation of dmls (used to instantiate the defaultContinuator for the dmls) + * @param _verbose verbose mode + */ + moeoDMLSGenUpdater(eoEvalFunc < MOEOT > & _eval, + moeoPopNeighborhoodExplorer < Neighbor > & _explorer, + moeoUnvisitedSelect < MOEOT > & _select, + moeoArchive < MOEOT > & _globalArchive, + eoGenContinue < MOEOT > & _continuator, + unsigned int _step=1, + bool _verbose = true): + defaultContinuator(_step), dmlsArchive(defaultArchive), dmls(defaultContinuator, _eval, defaultArchive, _explorer, _select), globalArchive(_globalArchive), continuator(_continuator), verbose(_verbose){} + + /** Ctor with a dmls. + * @param _eval a evaluation function (used to instantiate the dmls) + * @param _dmlsArchive an archive (used to instantiate the dmls) + * @param _explorer a neighborhood explorer (used to instantiate the dmls) + * @param _select a selector of unvisited individuals of a population (used to instantiate the dmls) + * @param _globalArchive the same archive used in the other algorithm + * @param _continuator is a Generational Continuator which allow to run dmls on the global archive each X generation(s) + * @param _step (default=1) is the number of Generation of dmls (used to instantiate the defaultContinuator for the dmls) + * @param _verbose verbose mode + */ + moeoDMLSGenUpdater(eoEvalFunc < MOEOT > & _eval, + moeoArchive < MOEOT > & _dmlsArchive, + moeoPopNeighborhoodExplorer < Neighbor > & _explorer, + moeoUnvisitedSelect < MOEOT > & _select, + moeoArchive < MOEOT > & _globalArchive, + eoGenContinue < MOEOT > & _continuator, + unsigned int _step=1, + bool _verbose = true): + defaultContinuator(_step), dmlsArchive(_dmlsArchive), dmls(defaultContinuator, _eval, _dmlsArchive, _explorer, _select), globalArchive(_globalArchive), continuator(_continuator), verbose(_verbose){} + + /** functor which allow to run the dmls*/ + virtual void operator()() + { + if(!continuator(globalArchive)){ + if(verbose) + std::cout << std::endl << "moeoDMLSGenUpdater: dmls start" << std::endl; + dmls(globalArchive); + globalArchive(dmlsArchive); + if(verbose) + std::cout << "moeoDMLSGenUpdater: dmls stop" << std::endl; + defaultContinuator.totalGenerations(defaultContinuator.totalGenerations()); + if(verbose) + std::cout << "the other algorithm restart for " << continuator.totalGenerations() << " generation(s)" << std::endl << std::endl; + continuator.totalGenerations(continuator.totalGenerations()); + } + } + + /** + * @return the class name + */ + virtual std::string className(void) const { return "moeoDMLSGenUpdater"; } + +private: + /** defaultContinuator used for the dmls */ + eoGenContinue < MOEOT > defaultContinuator; + /** dmls archive */ + moeoArchive < MOEOT > & dmlsArchive; + /** default archive used for the dmls */ + moeoUnboundedArchive < MOEOT > defaultArchive; + /** the dmls */ + moeoUnifiedDominanceBasedLS dmls; + /** the global archive */ + moeoArchive < MOEOT > & globalArchive; + /** continuator used to run the dmls each X generation(s) */ + eoGenContinue < MOEOT > & continuator; + /** verbose mode */ + bool verbose; +}; + + +#endif /*_MOEODMLSGENUPDATER_H_*/ diff --git a/trunk/paradiseo-moeo/src/hybridization/moeoDMLSMonOp.h b/trunk/paradiseo-moeo/src/hybridization/moeoDMLSMonOp.h new file mode 100644 index 000000000..a9c52d4c8 --- /dev/null +++ b/trunk/paradiseo-moeo/src/hybridization/moeoDMLSMonOp.h @@ -0,0 +1,134 @@ +/* +* +* 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 _MOEODMLSMONOP_H +#define _MOEODMLSMONOP_H + +#include +#include +#include +#include +#include +#include +#include +#include + +/** eoMonOp allowing hybridization with a dmls at mutation */ +template < class Neighbor > +class moeoDMLSMonOp : public eoMonOp < typename Neighbor::EOT > +{ + + typedef typename Neighbor::EOT MOEOT; + + public : + /** Ctor with a dmls. + * @param _dmls the dmls use for the hybridization (!!! Special care is needed when choosing the continuator of the dmls !!!) + * @param _dmlsArchive an archive (used to instantiate the dmls) + * @param _verbose verbose mode + */ + moeoDMLSMonOp(moeoUnifiedDominanceBasedLS & _dmls, + moeoArchive < MOEOT > & _dmlsArchive, + bool _verbose = true): + defaultContinuator(0), dmlsArchive(_dmlsArchive), dmls(_dmls), verbose(_verbose) {} + + /** Ctor with a dmls. + * @param _eval a evaluation function (used to instantiate the dmls) + * @param _explorer a neighborhood explorer (used to instantiate the dmls) + * @param _select a selector of unvisited individuals of a population (used to instantiate the dmls) + * @param _step (default=1) is the number of Generation of dmls (used to instantiate the defaultContinuator for the dmls) + * @param _verbose verbose mode + */ + moeoDMLSMonOp(eoEvalFunc < MOEOT > & _eval, + moeoPopNeighborhoodExplorer < Neighbor > & _explorer, + moeoUnvisitedSelect < MOEOT > & _select, + unsigned int _step=1, + bool _verbose = true): + defaultContinuator(_step), dmlsArchive(defaultArchive), dmls(defaultContinuator, _eval, defaultArchive, _explorer, _select), verbose(_verbose){} + + /** Ctor with a dmls. + * @param _eval a evaluation function (used to instantiate the dmls) + * @param _dmlsArchive an archive (used to instantiate the dmls) + * @param _explorer a neighborhood explorer (used to instantiate the dmls) + * @param _select a selector of unvisited individuals of a population (used to instantiate the dmls) + * @param _step (default=1) is the number of Generation of dmls (used to instantiate the defaultContinuator for the dmls) + * @param _verbose verbose mode + */ + moeoDMLSMonOp(eoEvalFunc < MOEOT > & _eval, + moeoArchive < MOEOT > & _dmlsArchive, + moeoPopNeighborhoodExplorer < Neighbor > & _explorer, + moeoUnvisitedSelect < MOEOT > & _select, + unsigned int _step=1, + bool _verbose = true): + defaultContinuator(_step), dmlsArchive(_dmlsArchive), dmls(defaultContinuator, _eval, _dmlsArchive, _explorer, _select), verbose(_verbose){} + + /** functor which allow to run the dmls on a MOEOT and return one of the resulting archive*/ + bool operator()( MOEOT & _moeo) + { + if(verbose) + std::cout << std::endl << "moeoDMLSMonOp: dmls start" << std::endl; + unsigned int tmp; + eoPop < MOEOT> pop; + pop.push_back(_moeo); + dmls(pop); + tmp = rng.random(dmlsArchive.size()); + _moeo = dmlsArchive[tmp]; + defaultContinuator.totalGenerations(defaultContinuator.totalGenerations()); + if(verbose) + std::cout << "moeoDMLSMonOp: dmls stop" << std::endl << std::endl; + return false; + } + + /** + * @return the class name + */ + virtual std::string className(void) const { return "moeoDMLSMonOp"; } + +private: + /** defaultContinuator used for the dmls */ + eoGenContinue < MOEOT > defaultContinuator; + /** dmls archive */ + moeoArchive < MOEOT > & dmlsArchive; + /** default archive used for the dmls */ + moeoUnboundedArchive < MOEOT > defaultArchive; + /** the dmls */ + moeoUnifiedDominanceBasedLS dmls; + /** verbose mode */ + bool verbose; +}; + +#endif /*_MOEODMLSMONOP_H_*/ diff --git a/trunk/paradiseo-moeo/src/moeo b/trunk/paradiseo-moeo/src/moeo index f5651c1f8..22e52eb7b 100644 --- a/trunk/paradiseo-moeo/src/moeo +++ b/trunk/paradiseo-moeo/src/moeo @@ -60,6 +60,8 @@ #include #include #include +#include +#include #include #include @@ -119,13 +121,15 @@ #include #include -#include -#include #include #include #include #include +#include +#include +#include +#include #include #include @@ -151,6 +155,8 @@ #include #include +#include +#include #include #include diff --git a/trunk/paradiseo-moeo/test/CMakeLists.txt b/trunk/paradiseo-moeo/test/CMakeLists.txt index c5ccbe9ba..0c826eced 100644 --- a/trunk/paradiseo-moeo/test/CMakeLists.txt +++ b/trunk/paradiseo-moeo/test/CMakeLists.txt @@ -72,7 +72,7 @@ SET (TEST_LIST t-moeoDetArchiveSelect t-moeoASEEA #t-moeoEpsilonHyperboxArchive - t-moeoQuadTreeIndex + #t-moeoQuadTreeIndex t-moeoQuickUnboundedArchiveIndex t-moeoAggregationFitnessAssignment t-moeoConstraintFitnessAssignment @@ -94,6 +94,15 @@ SET (TEST_LIST t-moeoFixedTimeBothDirectionWeightStrategy t-moeoDichoWeightStrategy t-moeoExhaustiveNeighborhoodExplorer + t-moeoFirstImprovingNeighborhoodExplorer + t-moeoSimpleSubNeighborhoodExplorer + t-moeoNoDesimprovingNeighborhoodExplorer + t-moeoPLS1 + t-moeoPLS2 + t-moeoExhaustiveUnvisitedSelect + t-moeoNumberUnvisitedSelect + t-moeoDMLSMonOp + t-moeoDMLSGenUpdater ) FOREACH (test ${TEST_LIST}) diff --git a/trunk/paradiseo-moeo/test/moeoTestClass.h b/trunk/paradiseo-moeo/test/moeoTestClass.h index 31eb32111..dd9d188be 100644 --- a/trunk/paradiseo-moeo/test/moeoTestClass.h +++ b/trunk/paradiseo-moeo/test/moeoTestClass.h @@ -47,7 +47,7 @@ #include #include #include -#include +#include class ObjectiveVectorTraits : public moeoObjectiveVectorTraits { @@ -85,24 +85,74 @@ class evalSolution : public moEval< SolNeighbor > { private: unsigned size; + int flag; public: - evalSolution(unsigned _size) : size(_size) {}; + evalSolution(unsigned _size, int _flag=1) : size(_size), flag(_flag) {}; ~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); + if(flag>0){ + if (_sol[_n.index()]){ + objVec[0]--; + objVec[1]++; + } + else{ + objVec[0]++; + objVec[1]--; + } + _n.fitness(objVec); + } + else if(flag==0){ + if (_sol[_n.index()]){ + objVec[0]--; + objVec[1]--; + } + else{ + objVec[0]++; + objVec[1]--; + } + _n.fitness(objVec); + } + else{ + if (_sol[_n.index()]){ + objVec[0]++; + objVec[1]++; + } + else{ + objVec[0]++; + objVec[1]--; + } + _n.fitness(objVec); + } } + }; +class fullEvalSolution : public eoEvalFunc< Solution > +{ +private: + unsigned size; + +public: + fullEvalSolution(unsigned _size) : size(_size){}; + + ~fullEvalSolution(void) {} ; + + void operator() (Solution& _sol){ + ObjectiveVector o; + for(unsigned int i=0; i +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 +#include +#include +#include +#include + +#include +#include +#include + +int main(){ + + std::cout << "[t-moeoDMLSGenUpdater] => START" << std::endl; + + //init all components + moeoUnboundedArchive arch(false); + moeoUnboundedArchive globalArch(false); + eoTimeContinue cont(1); + fullEvalSolution fullEval(8); + Solution s; + evalSolution eval(8); + ObjectiveVector o; + SolNeighbor n; + SolNeighborhood nh(8); + moeoPLS1 pls1(cont, fullEval, arch, nh, eval); + moeoExhaustiveUnvisitedSelect select; + moeoExhaustiveNeighborhoodExplorer explorer(nh, eval); + eoGenContinue genCont(2); + + //Create a solution + 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); + + //Set its objective Vector + o[0]=8; + o[1]=0; + s.objectiveVector(o); + + globalArch(s); + assert(globalArch.size()==1); + + //test constructor 1 with a dmls, its archive, a global archive and a generational continuator + moeoDMLSGenUpdater test1(pls1, arch, globalArch, genCont); + + //test constructor 2 with a full evaluation function, an explorer, a selector, a global archive and a generational continuator + moeoDMLSGenUpdater test2(fullEval, explorer, select, globalArch, genCont); + + //test constructor 3 with a full evaluation function, an explorer, a selector, a global archive and a generational continuator + moeoDMLSGenUpdater test3(fullEval, arch, explorer, select, globalArch, genCont); + + std::cout << "initial solution:" << std::endl; + std::cout << s << std::endl; + + test1(); + assert(globalArch.size()==1); + test1(); + assert(globalArch.size()==9); + + std::cout << "global arch:" << std::endl; + for(unsigned int i=0; i OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-moeo/test/t-moeoDMLSMonOp.cpp b/trunk/paradiseo-moeo/test/t-moeoDMLSMonOp.cpp new file mode 100644 index 000000000..105c5662c --- /dev/null +++ b/trunk/paradiseo-moeo/test/t-moeoDMLSMonOp.cpp @@ -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 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 +#include +#include + +#include "moeoTestClass.h" +#include +#include +#include +#include +#include +#include + +int main(){ + + std::cout << "[t-moeoDMLSMonOp] => START" << std::endl; + + //init all components + moeoUnboundedArchive arch(false); + eoTimeContinue cont(1); + fullEvalSolution fullEval(8); + Solution s; + evalSolution eval(8); + ObjectiveVector o; + SolNeighbor n; + SolNeighborhood nh(8); + moeoPLS1 pls1(cont, fullEval, arch, nh, eval); + moeoExhaustiveUnvisitedSelect select; + moeoExhaustiveNeighborhoodExplorer explorer(nh, eval); + + //Create a solution + 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); + + //Set its objective Vector + o[0]=8; + o[1]=0; + s.objectiveVector(o); + + //test constructor 1 with a dmls and its archive + moeoDMLSMonOp test1(pls1, arch); + + //test constructor 2 with an incremental evaluation function, a selector and an explorer + moeoDMLSMonOp test2(fullEval, explorer, select, 2, true); + + //test constructor 3 with an incremental evaluation function, a selector and an explorer and the dmls archive + moeoDMLSMonOp test3(fullEval, arch, explorer, select, 2, true); + + std::cout << "initial solution:" << std::endl; + std::cout << s << std::endl; + + test1(s); + + std::cout << "mutate solution:" << std::endl; + std::cout << s << std::endl; + + std::cout << "[t-moeoDMLSMonOp] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-moeo/test/t-moeoExhaustiveNeighborhoodExplorer.cpp b/trunk/paradiseo-moeo/test/t-moeoExhaustiveNeighborhoodExplorer.cpp index a8b7e154e..3d06060c8 100644 --- a/trunk/paradiseo-moeo/test/t-moeoExhaustiveNeighborhoodExplorer.cpp +++ b/trunk/paradiseo-moeo/test/t-moeoExhaustiveNeighborhoodExplorer.cpp @@ -2,7 +2,7 @@ Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau +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, @@ -36,17 +36,23 @@ int main(){ std::cout << "[t-moeoExhaustiveNeighborhoodExplorer] => START" << std::endl; + //init all components Solution s; evalSolution eval(8); ObjectiveVector o; SolNeighbor n; SolNeighborhood nh(8); - moeoExhaustiveNeighborhoodExplorer explorer(nh, eval); + moeoExhaustiveNeighborhoodExplorer explorer(nh, eval); + + //create source and destination population eoPop src; eoPop dest; + + //create a vector for selection std::vector v; v.push_back(0); + //create a solution s.push_back(true); s.push_back(true); s.push_back(true); @@ -56,21 +62,49 @@ int main(){ s.push_back(true); s.push_back(true); + //set its objective vector o[0]=8; o[1]=0; s.objectiveVector(o); + // aplly a move on th solution n.index(3); eval(s,n); n.move(s); s.objectiveVector(n.fitness()); + //print initial sol + std::cout << "solution:" << std::endl; std::cout << s << std::endl; + //copy the solution in the source population src.push_back(s); + //test the explorer explorer(src, v, dest); + //verify the destination population + assert(dest.size()==8); + + assert(dest[0].objectiveVector()[0]==6); + assert(dest[1].objectiveVector()[0]==6); + assert(dest[2].objectiveVector()[0]==6); + assert(dest[3].objectiveVector()[0]==8); + assert(dest[4].objectiveVector()[0]==6); + assert(dest[5].objectiveVector()[0]==6); + assert(dest[6].objectiveVector()[0]==6); + assert(dest[7].objectiveVector()[0]==6); + + assert(dest[0].objectiveVector()[1]==2); + assert(dest[1].objectiveVector()[1]==2); + assert(dest[2].objectiveVector()[1]==2); + assert(dest[3].objectiveVector()[1]==0); + assert(dest[4].objectiveVector()[1]==2); + assert(dest[5].objectiveVector()[1]==2); + assert(dest[6].objectiveVector()[1]==2); + assert(dest[7].objectiveVector()[1]==2); + + std::cout << "destination:" << std::endl; for(unsigned int i=0; i +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 +#include +#include + +#include +#include + +int main(){ + + std::cout << "[t-moeoExhaustiveUnvisitedSelect] => START" << std::endl; + + // objective vectors + eoPop < Solution > pop; + pop.resize(5); + pop[0].flag(1); + pop[1].flag(0); + pop[2].flag(0); + pop[3].flag(1); + pop[4].flag(0); + + moeoExhaustiveUnvisitedSelect < Solution > select; + + std::vector res; + + res=select(pop); + assert(res.size()==3); + assert(res[0]==1); + assert(res[1]==2); + assert(res[2]==4); + + std::cout << "[t-moeoExhaustiveUnvisitedSelect] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-moeo/test/t-moeoFirstImprovingNeighborhoodExplorer.cpp b/trunk/paradiseo-moeo/test/t-moeoFirstImprovingNeighborhoodExplorer.cpp new file mode 100644 index 000000000..2cc031fd1 --- /dev/null +++ b/trunk/paradiseo-moeo/test/t-moeoFirstImprovingNeighborhoodExplorer.cpp @@ -0,0 +1,132 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +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 +#include + +int main(){ + + std::cout << "[t-moeoFirstImprovingNeighborhoodExplorer] => START" << std::endl; + + //init all components + Solution s; + evalSolution eval(8); + evalSolution eval2(8, 0); + ObjectiveVector o; + SolNeighbor n; + SolNeighborhood nh(8); + moeoFirstImprovingNeighborhoodExplorer explorer(nh, eval); + moeoFirstImprovingNeighborhoodExplorer explorer2(nh, eval2); + + //create source and destination population + eoPop src; + eoPop dest; + + //create a vector for selection + std::vector v; + v.push_back(0); + + //create a solution + 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); + + //set its objective vector + o[0]=8; + o[1]=0; + s.objectiveVector(o); + + // aplly a move on th solution + n.index(3); + eval(s,n); + n.move(s); + s.objectiveVector(n.fitness()); + + //print initial sol + std::cout << "solution:" << std::endl; + std::cout << s << std::endl; + + //copy the solution in the source population + src.push_back(s); + + //test the explorer + explorer(src, v, dest); + + assert(dest.size()==8); + assert(dest[0].objectiveVector()[0]==6); + assert(dest[1].objectiveVector()[0]==6); + assert(dest[2].objectiveVector()[0]==6); + assert(dest[3].objectiveVector()[0]==8); + assert(dest[4].objectiveVector()[0]==6); + assert(dest[5].objectiveVector()[0]==6); + assert(dest[6].objectiveVector()[0]==6); + assert(dest[7].objectiveVector()[0]==6); + + assert(dest[0].objectiveVector()[1]==2); + assert(dest[1].objectiveVector()[1]==2); + assert(dest[2].objectiveVector()[1]==2); + assert(dest[3].objectiveVector()[1]==0); + assert(dest[4].objectiveVector()[1]==2); + assert(dest[5].objectiveVector()[1]==2); + assert(dest[6].objectiveVector()[1]==2); + assert(dest[7].objectiveVector()[1]==2); + + std::cout << "destination:" << std::endl; + for(unsigned int i=0; i src)" << std::endl; + for(unsigned int i=0; i OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-moeo/test/t-moeoNoDesimprovingNeighborhoodExplorer.cpp b/trunk/paradiseo-moeo/test/t-moeoNoDesimprovingNeighborhoodExplorer.cpp new file mode 100644 index 000000000..90d53d7e1 --- /dev/null +++ b/trunk/paradiseo-moeo/test/t-moeoNoDesimprovingNeighborhoodExplorer.cpp @@ -0,0 +1,101 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +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 +#include +#include + +#include "moeoTestClass.h" +#include + +int main(){ + + std::cout << "[t-moeoNoDesimprovingNeighborhoodExplorer] => START" << std::endl; + + //init all components + Solution s; + evalSolution eval(8, -1); + ObjectiveVector o; + SolNeighbor n; + SolNeighborhood nh(8); + moeoNoDesimprovingNeighborhoodExplorer explorer(nh, eval); + + //create source and destination population + eoPop src; + eoPop dest; + + //create a vector for selection + std::vector v; + v.push_back(0); + + //create a solution + 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); + + //set its objective vector + o[0]=8; + o[1]=0; + s.objectiveVector(o); + + // aplly a move on th solution + n.index(3); + eval(s,n); + n.move(s); + s.objectiveVector(n.fitness()); + + //print initial sol + std::cout << "solution:" << std::endl; + std::cout << s << std::endl; + + //copy the solution in the source population + src.push_back(s); + + //test explorer, the evaluation function is adapt to test this explorer + explorer(src, v, dest); + + //verify destination population + assert(dest.size()==1); + assert(dest[0].objectiveVector()[0]==10); + assert(dest[0].objectiveVector()[1]==0); + + std::cout << "destination:" << std::endl; + for(unsigned int i=0; i OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-moeo/test/t-moeoNumberUnvisitedSelect.cpp b/trunk/paradiseo-moeo/test/t-moeoNumberUnvisitedSelect.cpp new file mode 100644 index 000000000..64e5d2f92 --- /dev/null +++ b/trunk/paradiseo-moeo/test/t-moeoNumberUnvisitedSelect.cpp @@ -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 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 +#include +#include + +#include +#include + +int main(){ + + std::cout << "[t-moeoNumberUnvisitedSelect] => START" << std::endl; + + // objective vectors + eoPop < Solution > pop; + pop.resize(5); + pop[0].flag(1); + pop[1].flag(0); + pop[2].flag(0); + pop[3].flag(1); + pop[4].flag(0); + + moeoNumberUnvisitedSelect < Solution > select(2); + + std::vector res; + + //test general + res=select(pop); + assert(res.size()==2); + assert(res[0]==1 || res[0]==2 || res[0]==4); + assert(res[1]==1 || res[1]==2 || res[1]==4); + assert(res[0] != res[1]); + + //test au bornes + moeoNumberUnvisitedSelect < Solution > select2(6); + res.resize(0); + res=select2(pop); + assert(res.size()==3); + assert(res[0]==1 || res[0]==2 || res[0]==4); + assert(res[1]==1 || res[1]==2 || res[1]==4); + assert(res[2]==1 || res[2]==2 || res[2]==4); + assert(res[0] != res[1]); + assert(res[0] != res[2]); + assert(res[1] != res[2]); + + moeoNumberUnvisitedSelect < Solution > select3(0); + res.resize(0); + res=select3(pop); + assert(res.size()==0); + + + std::cout << "[t-moeoNumberUnvisitedSelect] => OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-moeo/test/t-moeoPLS1.cpp b/trunk/paradiseo-moeo/test/t-moeoPLS1.cpp new file mode 100644 index 000000000..9f525a4f9 --- /dev/null +++ b/trunk/paradiseo-moeo/test/t-moeoPLS1.cpp @@ -0,0 +1,118 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +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 +#include +#include + +#include "moeoTestClass.h" +#include +#include +#include + +int main(){ + + std::cout << "[t-moeoPLS1] => START" << std::endl; + + //init all components + moeoUnboundedArchive arch(false); + eoTimeContinue cont(1); + fullEvalSolution fullEval(8); + Solution s; + evalSolution eval(8); + ObjectiveVector o; + SolNeighbor n; + SolNeighborhood nh(8); + moeoPLS1 test(cont, fullEval, arch, nh, eval); + + //create source population + eoPop src; + + //Create a solution + 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); + + //Set its objective Vector + o[0]=8; + o[1]=0; + s.objectiveVector(o); + + //apply a move on the solution and compute new objective vector + n.index(3); + eval(s,n); + n.move(s); + s.objectiveVector(n.fitness()); + + //copy the solution in the source population + src.push_back(s); + + //test PLS1 + test(src); + + //verify all objective vector was found. + assert(arch.size()==9); + assert(arch[0].objectiveVector()[0]==7); + assert(arch[1].objectiveVector()[0]==6); + assert(arch[2].objectiveVector()[0]==8); + assert(arch[3].objectiveVector()[0]==5); + assert(arch[4].objectiveVector()[0]==4); + assert(arch[5].objectiveVector()[0]==3); + assert(arch[6].objectiveVector()[0]==2); + assert(arch[7].objectiveVector()[0]==1); + assert(arch[8].objectiveVector()[0]==0); + + assert(arch[0].objectiveVector()[1]==1); + assert(arch[1].objectiveVector()[1]==2); + assert(arch[2].objectiveVector()[1]==0); + assert(arch[3].objectiveVector()[1]==3); + assert(arch[4].objectiveVector()[1]==4); + assert(arch[5].objectiveVector()[1]==5); + assert(arch[6].objectiveVector()[1]==6); + assert(arch[7].objectiveVector()[1]==7); + assert(arch[8].objectiveVector()[1]==8); + + //Print + std::cout << "source:" << std::endl; + std::cout << src << std::endl; + + std::cout << "archive:" << std::endl; + for(unsigned int i=0; i OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-moeo/test/t-moeoPLS2.cpp b/trunk/paradiseo-moeo/test/t-moeoPLS2.cpp new file mode 100644 index 000000000..3f4cc076e --- /dev/null +++ b/trunk/paradiseo-moeo/test/t-moeoPLS2.cpp @@ -0,0 +1,119 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +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 +#include +#include + +#include "moeoTestClass.h" +#include +#include +#include + +int main(){ + + std::cout << "[t-moeoPLS2] => START" << std::endl; + + //init all components + moeoUnboundedArchive arch(false); + eoTimeContinue cont(1); + fullEvalSolution fullEval(8); + Solution s; + evalSolution eval(8); + ObjectiveVector o; + SolNeighbor n; + SolNeighborhood nh(8); + moeoPLS2 test(cont, fullEval, arch, nh, eval); + + //create source population + eoPop src; + + //Create a solution + 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); + + //Set its objective Vector + o[0]=8; + o[1]=0; + s.objectiveVector(o); + + //apply a move on the solution and compute new objective vector + n.index(3); + eval(s,n); + n.move(s); + s.objectiveVector(n.fitness()); + + //copy the solution in the source population + src.push_back(s); + + //test PLS2 + test(src); + + //verify all objective vector was found. + assert(arch.size()==9); + assert(arch[0].objectiveVector()[0]==7); + assert(arch[1].objectiveVector()[0]==6); + assert(arch[2].objectiveVector()[0]==8); + assert(arch[3].objectiveVector()[0]==5); + assert(arch[4].objectiveVector()[0]==4); + assert(arch[5].objectiveVector()[0]==3); + assert(arch[6].objectiveVector()[0]==2); + assert(arch[7].objectiveVector()[0]==1); + assert(arch[8].objectiveVector()[0]==0); + + assert(arch[0].objectiveVector()[1]==1); + assert(arch[1].objectiveVector()[1]==2); + assert(arch[2].objectiveVector()[1]==0); + assert(arch[3].objectiveVector()[1]==3); + assert(arch[4].objectiveVector()[1]==4); + assert(arch[5].objectiveVector()[1]==5); + assert(arch[6].objectiveVector()[1]==6); + assert(arch[7].objectiveVector()[1]==7); + assert(arch[8].objectiveVector()[1]==8); + + //Print + std::cout << "source:" << std::endl; + std::cout << src << std::endl; + + std::cout << "archive:" << std::endl; + for(unsigned int i=0; i OK" << std::endl; + + return EXIT_SUCCESS; +} + diff --git a/trunk/paradiseo-moeo/test/t-moeoSimpleSubNeighborhoodExplorer.cpp b/trunk/paradiseo-moeo/test/t-moeoSimpleSubNeighborhoodExplorer.cpp new file mode 100644 index 000000000..ab4e12fe3 --- /dev/null +++ b/trunk/paradiseo-moeo/test/t-moeoSimpleSubNeighborhoodExplorer.cpp @@ -0,0 +1,109 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +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 +#include +#include + +#include "moeoTestClass.h" +#include + +int main(){ + + std::cout << "[t-moeoSimpleSubNeighborhoodExplorer] => START" << std::endl; + + //init all components + Solution s; + evalSolution eval(8); + ObjectiveVector o; + SolNeighbor n; + SolNeighborhood nh(8); + moeoSimpleSubNeighborhoodExplorer explorer(nh, 4, eval); + + //create source and destination population + eoPop src; + eoPop dest; + + //create a vector for selection + std::vector v; + v.push_back(0); + + //create a solution + 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); + + //set its objective vector + o[0]=8; + o[1]=0; + s.objectiveVector(o); + + // aplly a move on th solution + n.index(3); + eval(s,n); + n.move(s); + s.objectiveVector(n.fitness()); + + //print initial sol + std::cout << "solution:" << std::endl; + std::cout << s << std::endl; + + //copy the solution in the source population + src.push_back(s); + + //test the explorer (only 4 neighbors are visited) + explorer(src, v, dest); + + //verify the destination population + assert(dest.size()==4); + + assert(dest[0].objectiveVector()[0]==6); + assert(dest[1].objectiveVector()[0]==6); + assert(dest[2].objectiveVector()[0]==6); + assert(dest[3].objectiveVector()[0]==8); + + assert(dest[0].objectiveVector()[1]==2); + assert(dest[1].objectiveVector()[1]==2); + assert(dest[2].objectiveVector()[1]==2); + assert(dest[3].objectiveVector()[1]==0); + + std::cout << "destination:" << std::endl; + for(unsigned int i=0; i OK" << std::endl; + + return EXIT_SUCCESS; +} +