diff --git a/trunk/paradiseo-mo/src/neighborhood/moBackwardVariableNeighborhood.h b/trunk/paradiseo-mo/src/neighborhood/moBackwardVariableNeighborhood.h deleted file mode 100644 index 397246ea4..000000000 --- a/trunk/paradiseo-mo/src/neighborhood/moBackwardVariableNeighborhood.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 - -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -#ifndef _moBackwardVariableNeighborhood_h -#define _moBackwardVariableNeighborhood_h - -#include - -/** - * A variable Neighborhood Search (VNS) in the Backward manner - */ -template< class EOT > -class moBackwardVariableNeighborhood : public moVariableNeighborhood -{ -public: - typedef moNeighbor Neighbor; - - using moVariableNeighborhood::currentNH; - using moVariableNeighborhood::neighborhoodVector; - - /** - * Construction of at least one neighborhood - * @param _firstNH first neighborhood in the vector - */ - moBackwardVariableNeighborhood(moNeighborhood& _firstNH) : moVariableNeighborhood(_firstNH) { } - - /** - * Return the class id. - * @return the class name as a std::string - */ - virtual std::string className() const { - return "moBackwardVariableNeighborhood"; - } - - /** - * test if there is still some neighborhood to explore - * @return true if there is some neighborhood to explore - */ - virtual bool contNeighborhood() { - return (currentNH > 0); - } - - /** - * put the current neighborhood on the last one - */ - virtual void initNeighborhood() { - currentNH = neighborhoodVector.size() - 1; - } - - /** - * put the current neighborhood on the next one - */ - virtual void nextNeighborhood() { - currentNH--; - } - -}; -#endif diff --git a/trunk/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h b/trunk/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h index e4452c3f2..281c8751e 100644 --- a/trunk/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h +++ b/trunk/paradiseo-mo/src/neighborhood/moIndexNeighborhood.h @@ -55,6 +55,10 @@ public: */ moIndexNeighborhood(unsigned int _neighborhoodSize):neighborhoodSize(_neighborhoodSize) {} + unsigned int size(){ + return neighborhoodSize; + } + protected: // size of the neighborhood unsigned int neighborhoodSize; diff --git a/trunk/paradiseo-mo/src/neighborhood/moRndVariableNeighborhood.h b/trunk/paradiseo-mo/src/neighborhood/moRndVariableNeighborhood.h deleted file mode 100644 index 8b7421a1e..000000000 --- a/trunk/paradiseo-mo/src/neighborhood/moRndVariableNeighborhood.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 - -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -#ifndef _moRndVariableNeighborhood_h -#define _moRndVariableNeighborhood_h - -#include -#include - -/** - * A variable Neighborhood Search (VNS) in the random manner - */ -template< class EOT, class Fitness > -class moRndVariableNeighborhood : public moVariableNeighborhood -{ -public: - typedef moNeighbor Neighbor; - - using moVariableNeighborhood::currentNH; - using moVariableNeighborhood::neighborhoodVector; - - /** - * Construction of at least one neighborhood - * @param _firstNH first neighborhood in the vector - */ - moRndVariableNeighborhood(moNeighborhood& _firstNH) : moVariableNeighborhood(_firstNH) { - indexVector.push_back(0); - } - - /** - * to add a neighborhood in the vector - * @param _nh the neighborhood to add at the end of the vector of neighborhood - */ - virtual void add(moNeighborhood& _nh) { - neighborhoodVector.push_back(_nh); - indexVector.push_back(indexVector.size()); - } - - - /** - * Return the class id. - * @return the class name as a std::string - */ - virtual std::string className() const { - return "moRndVariableNeighborhood"; - } - - /** - * test if there is still some neighborhood to explore - * @return true if there is some neighborhood to explore - */ - virtual bool contNeighborhood() { - return (index < neighborhoodVector.size() - 1); - } - - /** - * put the current neighborhood on the first one - */ - virtual void initNeighborhood() { - std::random_shuffle(indexVector.begin(), indexVector.end()); - index = 0; - currentNH = indexVector[index]; - } - - /** - * put the current neighborhood on the next one - */ - virtual void nextNeighborhood() { - index++; - currentNH = indexVector[index]; - } - -private: - unsigned int index; - std::vector indexVector; -}; - -#endif diff --git a/trunk/paradiseo-mo/src/neighborhood/moRndWithoutReplNeighborhood.h b/trunk/paradiseo-mo/src/neighborhood/moRndWithoutReplNeighborhood.h index 8c66ee3f9..1ec9feeff 100644 --- a/trunk/paradiseo-mo/src/neighborhood/moRndWithoutReplNeighborhood.h +++ b/trunk/paradiseo-mo/src/neighborhood/moRndWithoutReplNeighborhood.h @@ -87,6 +87,7 @@ public: indexVector[i]=indexVector[maxIndex-1]; indexVector[maxIndex-1]=tmp; maxIndex--; + std::cout << _neighbor.className() << ", key: " << _neighbor.index() << std::endl; } /** @@ -102,6 +103,8 @@ public: indexVector[i]=indexVector[maxIndex-1]; indexVector[maxIndex-1]=tmp; maxIndex--; + + std::cout << _neighbor.className() << ", key: " << _neighbor.index() << std::endl; } /** diff --git a/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhood.h b/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhood.h deleted file mode 100644 index ac07af8b0..000000000 --- a/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhood.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 - -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -#ifndef _moVariableNeighborhood_h -#define _moVariableNeighborhood_h - -#include -#include -#include -#include - -/** - * A vector of neighborhood for the Variable Neighborhood Search (VNS) - */ -template< class EOT > -class moVariableNeighborhood : public moNeighborhood > -{ -public: - - typedef moNeighbor Neighbor; - /** - * Construction of at least one neighborhood - * @param _firstNH first neighborhood in the vector - */ - moVariableNeighborhood(moNeighborhood& _firstNH) { - neighborhoodVector.push_back(&_firstNH); - // the current neighborhood - currentNH = 0; - } - - /** - * @return if the current neighborhood is random - */ - virtual bool isRandom() { - return neighborhoodVector[currentNH]->isRandom(); - } - - /** - * Test if a solution has a Neighbor in the current neighborhood - * @param _solution the related solution - * @return if _solution has a Neighbor in the current neighborhood - */ - virtual bool hasNeighbor(EOT & _solution) { - return neighborhoodVector[currentNH]->hasNeighbor(_solution); - } - - /** - * Initialization of the current neighborhood - * @param _solution the solution to explore - * @param _current the first neighbor in the current neighborhood - */ - virtual void init(EOT & _solution, Neighbor & _current) { - neighborhoodVector[currentNH]->init(_solution, _current); - } - - /** - * Give the next neighbor in the current neighborhood - * @param _solution the solution to explore - * @param _current the next neighbor in the current neighborhood - */ - virtual void next(EOT & _solution, Neighbor & _current) { - neighborhoodVector[currentNH]->next(_solution, _current); - } - - /** - * Test if there is again a neighbor in the current neighborhood - * @param _solution the solution to explore - * @return if there is still a neighbor not explored in the current neighborhood - */ - virtual bool cont(EOT & _solution) { - return neighborhoodVector[currentNH]->cont(_solution); - } - - /** - * Return the class id. - * @return the class name as a std::string - */ - virtual std::string className() const { - return "moVariableNeighborhood"; - } - - /** - * to add a neighborhood in the vector - * @param _nh the neighborhood to add at the end of the vector of neighborhood - */ - virtual void add(moNeighborhood& _nh) { - neighborhoodVector.push_back(&_nh); - } - - /** - * test if there is still some neighborhood to explore - * @return true if there is some neighborhood to explore - */ - virtual bool contNeighborhood() = 0; - - /** - * put the current neighborhood on the first one - */ - virtual void initNeighborhood() = 0; - - /** - * put the current neighborhood on the next one - */ - virtual void nextNeighborhood() = 0; - -protected: - // the vector of neighborhoods - std::vector* > neighborhoodVector; - // the index of the current neighborhood - unsigned int currentNH; - -}; -#endif diff --git a/trunk/paradiseo-mo/src/neighborhood/moForwardVariableNeighborhood.h b/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhoodSelection.h similarity index 64% rename from trunk/paradiseo-mo/src/neighborhood/moForwardVariableNeighborhood.h rename to trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhoodSelection.h index 449999208..ec2954e21 100644 --- a/trunk/paradiseo-mo/src/neighborhood/moForwardVariableNeighborhood.h +++ b/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhoodSelection.h @@ -1,5 +1,5 @@ /* - + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau @@ -27,59 +27,40 @@ ParadisEO WebSite : http://paradiseo.gforge.inria.fr Contact: paradiseo-help@lists.gforge.inria.fr */ -#ifndef _moForwardVariableNeighborhood_h -#define _moForwardVariableNeighborhood_h +#ifndef _moVariableNeighborhoodSelection_h +#define _moVariableNeighborhoodSelection_h -#include +#include +#include -/** - * A variable Neighborhood Search (VNS) in the forward manner - */ template< class EOT > -class moForwardVariableNeighborhood : public moVariableNeighborhood +class moVariableNeighborhoodSelection { public: - typedef moNeighbor Neighbor; - - using moVariableNeighborhood::currentNH; - using moVariableNeighborhood::neighborhoodVector; - - /** - * Construction of at least one neighborhood - * @param _firstNH first neighborhood in the vector - */ - moForwardVariableNeighborhood(moNeighborhood& _firstNH) : moVariableNeighborhood(_firstNH) { } - /** * Return the class id. * @return the class name as a std::string */ virtual std::string className() const { - return "moForwardVariableNeighborhood"; + return "moVariableNeighborhoodSelection"; } /** * test if there is still some neighborhood to explore * @return true if there is some neighborhood to explore */ - virtual bool contNeighborhood() { - return (currentNH < neighborhoodVector.size() - 1); - } + virtual bool cont(EOT& _solution, eoMonOp& _skake, eoMonOp& _ls) = 0; /** * put the current neighborhood on the first one */ - virtual void initNeighborhood() { - currentNH = 0; - } + virtual void init(EOT& _solution, eoMonOp& _skake, eoMonOp& _ls) = 0; /** * put the current neighborhood on the next one */ - virtual void nextNeighborhood() { - currentNH++; - } + virtual void next(EOT& _solution, eoMonOp& _skake, eoMonOp& _ls) = 0; };