diff --git a/trunk/paradiseo-mo/src/explorer/moVNSexplorer.h b/trunk/paradiseo-mo/src/explorer/moVNSexplorer.h index 58c4b5a26..1eaf95159 100644 --- a/trunk/paradiseo-mo/src/explorer/moVNSexplorer.h +++ b/trunk/paradiseo-mo/src/explorer/moVNSexplorer.h @@ -1,30 +1,30 @@ /* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". + 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. + 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 + ParadisEO WebSite : http://paradiseo.gforge.inria.fr + Contact: paradiseo-help@lists.gforge.inria.fr */ #ifndef _moVNSexplorer_h @@ -37,121 +37,126 @@ Contact: paradiseo-help@lists.gforge.inria.fr #include /** - * Explorer for Variiable Neighborhood Search + * Explorer for the "Variable Neighborhood Search" metaheuristic */ template< class Neighbor> class moVNSexplorer : public moNeighborhoodExplorer< Neighbor > { public: - typedef typename Neighbor::EOT EOT; + typedef typename Neighbor::EOT EOT; - /** - * Constructor - * @param _neighborhood the neighborhood - * @param _eval the evaluation function - * @param _neighborComparator a neighbor comparator - * @param _solNeighborComparator solution vs neighbor comparator - */ - moVNSexplorer( - moVariableNeighborhoodSelection & _selection, - moAcceptanceCriterion& _acceptCrit): - moNeighborhoodExplorer(),dummyLS(dummyEval), selection(_selection), acceptCrit(_acceptCrit), ls(&dummyLS), shake(dummyLS), stop(false) - {} + /** + * Constructor + * @param _neighborhood the neighborhood + * @param _eval the evaluation function + * @param _neighborComparator a neighbor comparator + * @param _solNeighborComparator solution vs neighbor comparator + */ + moVNSexplorer(moVariableNeighborhoodSelection & _selection, + moAcceptanceCriterion& _acceptCrit): + moNeighborhoodExplorer(), selection(_selection), acceptCrit(_acceptCrit), stop(false) + {} - /** - * Destructor - */ - ~moVNSexplorer() { - } + /** + * Destructor + */ + ~moVNSexplorer() { + } - /** - * initParam: NOTHING TO DO - */ - virtual void initParam(EOT& _solution) { - selection.init(current, shake, ls); - }; + /** + * Initialization on the initial search opeartors based on the "first" neighborhood + * @param _solution the current solution + */ + virtual void initParam(EOT& _solution) { + selection.init(_solution); + } - /** - * updateParam: NOTHING TO DO - */ - virtual void updateParam(EOT & _solution) { - if ((*this).moveApplied()) { - selection.init(current, shake, ls); - } - else if (selection.cont(current, shake, ls)){ - selection.next(current, shake, ls); - } - else - stop=true; - }; + /** + * Change the search operators on the next neighborhood search. + * @param _solution the current solution + */ + virtual void updateParam(EOT & _solution) { + if ((*this).moveApplied()) { + selection.init(_solution); + } else + if (selection.cont(current)) { + selection.next(_solution); + } else + stop = true; + } - /** - * terminate: NOTHING TO DO - */ - virtual void terminate(EOT & _solution) {}; + /** + * terminate: NOTHING TO DO + */ + virtual void terminate(EOT & _solution) {}; - /** - * Explore the neighborhood of a solution - * @param _solution - */ - virtual void operator()(EOT & _solution) { - current=_solution; - std::cout << "current avec shake: "<< current << std::endl; - shake(current); - std::cout << "current apres shake: "<< current << std::endl; - (*ls)(current); - std::cout << "current apres ls: "<< ls->className() << " " << current << std::endl; - }; + /** + * Explore the neighborhood of a solution + * @param _solution the current solution + */ + virtual void operator()(EOT & _solution) { + eoMonOp & shake = selection.getShake(); + eoMonOp & ls = selection.getLocalSearch(); - /** - * continue if a move is accepted - * @param _solution the solution - * @return true if an ameliorated neighbor was be found - */ - virtual bool isContinue(EOT & _solution) { - return !stop; - }; + current = _solution; + std::cout << "current avec shake: "<< current << std::endl; + shake(current); + std::cout << "current apres shake: "<< current << std::endl; + ls(current); + std::cout << "current apres ls: "<< ls.className() << " " << current << std::endl; + } - /** - * move the solution with the best neighbor - * @param _solution the solution to move - */ - virtual void move(EOT & _solution) { - _solution=current; - }; + /** + * continue if a move is accepted + * @param _solution the solution + * @return true if an ameliorated neighbor was be found + */ + virtual bool isContinue(EOT & _solution) { + return !stop; + }; - /** - * accept test if an amelirated neighbor was be found - * @param _solution the solution - * @return true if the best neighbor ameliorate the fitness - */ - virtual bool accept(EOT & _solution) { - return acceptCrit(_solution, current); - }; + /** + * move the solution with the best neighbor + * @param _solution the solution to move + */ + virtual void move(EOT & _solution) { + _solution = current; + }; - /** - * Return the class id. - * @return the class name as a std::string - */ - virtual std::string className() const { - return "moVNSexplorer"; - } + /** + * accept test if an amelirated neighbor was be found according to acceptance criteria + * @param _solution the solution + * @return true if the best neighbor ameliorate the fitness + */ + virtual bool accept(EOT & _solution) { + return acceptCrit(_solution, current); + }; -private: - moDummyLS dummyLS; - moVariableNeighborhoodSelection& selection; - moAcceptanceCriterion& acceptCrit; - eoMonOp* ls; - eoMonOp& shake; - bool stop; - EOT current; + /** + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moVNSexplorer"; + } +private: + //moDummyLS dummyLS; + moVariableNeighborhoodSelection& selection; + moAcceptanceCriterion& acceptCrit; + //eoMonOp* ls; + //eoMonOp& shake; + bool stop; + + EOT current; + + /* class moDummyEval: public eoEvalFunc{ public: - void operator()(EOT& hop){} + void operator()(EOT& hop){} }dummyEval; - + */ }; diff --git a/trunk/paradiseo-mo/src/neighborhood/moForwardVectorVNSelection.h b/trunk/paradiseo-mo/src/neighborhood/moForwardVectorVNSelection.h index b8d2fbb61..6e11fe7d6 100644 --- a/trunk/paradiseo-mo/src/neighborhood/moForwardVectorVNSelection.h +++ b/trunk/paradiseo-mo/src/neighborhood/moForwardVectorVNSelection.h @@ -1,30 +1,30 @@ /* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". + 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. + 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 + ParadisEO WebSite : http://paradiseo.gforge.inria.fr + Contact: paradiseo-help@lists.gforge.inria.fr */ #ifndef _moForwardVectorVNSelection_h @@ -35,59 +35,55 @@ Contact: paradiseo-help@lists.gforge.inria.fr template< class EOT > class moForwardVectorVNSelection: public moVectorVNSelection{ - using moVectorVNSelection::LSvector; - using moVectorVNSelection::shakeVector; - using moVectorVNSelection::current; + using moVectorVNSelection::LSvector; + using moVectorVNSelection::shakeVector; + using moVectorVNSelection::current; public: - moForwardVectorVNSelection(eoMonOp& _firstLS, eoMonOp& _firstShake, bool _cycle):moVectorVNSelection(_firstLS, _firstShake), cycle(_cycle){} + moForwardVectorVNSelection(eoMonOp& _firstLS, eoMonOp& _firstShake, bool _cycle):moVectorVNSelection(_firstLS, _firstShake), cycle(_cycle){} - /** - * Return the class id. - * @return the class name as a std::string - */ - virtual std::string className() const { - return "moForwardVectorVNSelection"; - } + /** + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moForwardVectorVNSelection"; + } - /** - * test if there is still some neighborhood to explore - * @return true if there is some neighborhood to explore - */ - virtual bool cont(EOT& _solution, eoMonOp& _shake, eoMonOp*& _ls){ - return (cycle || (current <= (LSvector.size()-2))); - std::cout << "current LS: " << current << std::endl; - std::cout << _solution << std::endl; + /** + * test if there is still some neighborhood to explore + * @return true if there is some neighborhood to explore + */ + virtual bool cont(EOT& _solution){ + return (cycle || (current <= (LSvector.size()-2))); + std::cout << "current LS: " << current << std::endl; + std::cout << _solution << std::endl; - } + } - /** - * put the current neighborhood on the first one - */ - virtual void init(EOT& _solution, eoMonOp& _shake, eoMonOp*& _ls){ - current=0; - _ls = LSvector[current]; - _shake = *(shakeVector[current]); - std::cout << "current LS: " << _ls->className() << " " << current << std::endl; - std::cout << _solution << std::endl; + /** + * put the current neighborhood on the first one + */ + virtual void init(EOT& _solution){ + current = 0; + // std::cout << "current LS: " << _ls->className() << " " << current << std::endl; + // std::cout << _solution << std::endl; - } + } - /** - * put the current neighborhood on the next one - */ - virtual void next(EOT& _solution, eoMonOp& _shake, eoMonOp*& _ls){ - current = (current+1) % LSvector.size(); - _ls = LSvector[current]; - _shake = *(shakeVector[current]); - std::cout << "current LS: " << current << std::endl; - std::cout << _solution << std::endl; - } + /** + * put the current neighborhood on the next one + */ + virtual void next(EOT& _solution){ + current = (current + 1) % LSvector.size(); + std::cout << "current LS: " << current << std::endl; + std::cout << _solution << std::endl; + } private: - bool cycle; + bool cycle; }; diff --git a/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhoodSelection.h b/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhoodSelection.h index a3694c519..6200d2eb3 100644 --- a/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhoodSelection.h +++ b/trunk/paradiseo-mo/src/neighborhood/moVariableNeighborhoodSelection.h @@ -2,7 +2,7 @@ Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau +Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can ue, @@ -50,17 +50,31 @@ public: * test if there is still some neighborhood to explore * @return true if there is some neighborhood to explore */ - virtual bool cont(EOT& _solution, eoMonOp& _skake, eoMonOp*& _ls) = 0; + virtual bool cont(EOT& _solution) = 0; /** * put the current neighborhood on the first one */ - virtual void init(EOT& _solution, eoMonOp& _skake, eoMonOp*& _ls) = 0; + virtual void init(EOT& _solution) = 0; /** * put the current neighborhood on the next one */ - virtual void next(EOT& _solution, eoMonOp& _skake, eoMonOp*& _ls) = 0; + virtual void next(EOT& _solution) = 0; + + /** + * Get the current "shake" operator based on the current neighborhood + * + * @return current shake operator + */ + virtual const eoMon & getShake() = 0; + + /** + * Get the current local search based on the current neighborhood + * + * @return current local search + */ + virtual const eoMon & getLocalSearch() = 0; }; diff --git a/trunk/paradiseo-mo/src/neighborhood/moVectorVNSelection.h b/trunk/paradiseo-mo/src/neighborhood/moVectorVNSelection.h index 0823662f5..d886e203a 100644 --- a/trunk/paradiseo-mo/src/neighborhood/moVectorVNSelection.h +++ b/trunk/paradiseo-mo/src/neighborhood/moVectorVNSelection.h @@ -1,30 +1,30 @@ /* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". + 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. + 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 + ParadisEO WebSite : http://paradiseo.gforge.inria.fr + Contact: paradiseo-help@lists.gforge.inria.fr */ #ifndef _moVectorVNSelection_h @@ -38,45 +38,63 @@ class moVectorVNSelection: public moVariableNeighborhoodSelection{ public: - moVectorVNSelection(eoMonOp& _firstLS, eoMonOp& _firstShake){ - LSvector.push_back(&_firstLS); - shakeVector.push_back(&_firstShake); - current=0; - } + moVectorVNSelection(eoMonOp& _firstLS, eoMonOp& _firstShake){ + LSvector.push_back(&_firstLS); + shakeVector.push_back(&_firstShake); + current=0; + } + + void add(eoMonOp& _otherLS, eoMonOp& _otherShake){ + LSvector.push_back(&_otherLS); + shakeVector.push_back(&_otherShake); + } - void add(eoMonOp& _otherLS, eoMonOp& _otherShake){ - LSvector.push_back(&_otherLS); - shakeVector.push_back(&_otherShake); - } + /** + * Return the class id. + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moVectorVNSelection"; + } - /** - * Return the class id. - * @return the class name as a std::string - */ - virtual std::string className() const { - return "moVectorVNSelection"; - } + /** + * Get the current "shake" operator based on the current neighborhood + * + * @return current shake operator + */ + virtual const eoMon & getShake() { + return *(shakeVector[current]); + } - /** - * test if there is still some neighborhood to explore - * @return true if there is some neighborhood to explore - */ - virtual bool cont(EOT& _solution, eoMonOp& _shake, eoMonOp*& _ls) = 0; + /** + * Get the current local search based on the current neighborhood + * + * @return current local search + */ + virtual const eoMon & getLocalSearch() { + return *(LSvector[current]); + } - /** - * put the current neighborhood on the first one - */ - virtual void init(EOT& _solution, eoMonOp& _shake, eoMonOp*& _ls) = 0; + /** + * test if there is still some neighborhood to explore + * @return true if there is some neighborhood to explore + */ + virtual bool cont(EOT& _solution) = 0; - /** - * put the current neighborhood on the next one - */ - virtual void next(EOT& _solution, eoMonOp& _shake, eoMonOp*& _ls) = 0; + /** + * put the current neighborhood on the first one + */ + virtual void init(EOT& _solution) = 0; + + /** + * put the current neighborhood on the next one + */ + virtual void next(EOT& _solution) = 0; protected: - std::vector* > LSvector; - std::vector* > shakeVector; - unsigned int current; + std::vector* > LSvector; + std::vector* > shakeVector; + unsigned int current; };