Modification de vsn, encore à compiler...

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1927 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
verel 2010-08-28 09:17:43 +00:00
commit 1cf50233ee
4 changed files with 305 additions and 272 deletions

View file

@ -1,30 +1,30 @@
/* /*
<moVNSexplorer.h> <moVNSexplorer.h>
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 This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue, abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info". "http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software, 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 that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or 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 data to be ensured and, more generally, to use and operate it in the
same conditions as regards security. same conditions as regards security.
The fact that you are presently reading this means that you have had The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms. knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr Contact: paradiseo-help@lists.gforge.inria.fr
*/ */
#ifndef _moVNSexplorer_h #ifndef _moVNSexplorer_h
@ -37,121 +37,126 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <algo/moDummyLS.h> #include <algo/moDummyLS.h>
/** /**
* Explorer for Variiable Neighborhood Search * Explorer for the "Variable Neighborhood Search" metaheuristic
*/ */
template< class Neighbor> template< class Neighbor>
class moVNSexplorer : public moNeighborhoodExplorer< Neighbor > class moVNSexplorer : public moNeighborhoodExplorer< Neighbor >
{ {
public: public:
typedef typename Neighbor::EOT EOT; typedef typename Neighbor::EOT EOT;
/** /**
* Constructor * Constructor
* @param _neighborhood the neighborhood * @param _neighborhood the neighborhood
* @param _eval the evaluation function * @param _eval the evaluation function
* @param _neighborComparator a neighbor comparator * @param _neighborComparator a neighbor comparator
* @param _solNeighborComparator solution vs neighbor comparator * @param _solNeighborComparator solution vs neighbor comparator
*/ */
moVNSexplorer( moVNSexplorer(moVariableNeighborhoodSelection<EOT> & _selection,
moVariableNeighborhoodSelection<EOT> & _selection, moAcceptanceCriterion<Neighbor>& _acceptCrit):
moAcceptanceCriterion<Neighbor>& _acceptCrit): moNeighborhoodExplorer<Neighbor>(), selection(_selection), acceptCrit(_acceptCrit), stop(false)
moNeighborhoodExplorer<Neighbor>(),dummyLS(dummyEval), selection(_selection), acceptCrit(_acceptCrit), ls(&dummyLS), shake(dummyLS), stop(false) {}
{}
/** /**
* Destructor * Destructor
*/ */
~moVNSexplorer() { ~moVNSexplorer() {
} }
/** /**
* initParam: NOTHING TO DO * Initialization on the initial search opeartors based on the "first" neighborhood
*/ * @param _solution the current solution
virtual void initParam(EOT& _solution) { */
selection.init(current, shake, ls); virtual void initParam(EOT& _solution) {
}; selection.init(_solution);
}
/** /**
* updateParam: NOTHING TO DO * Change the search operators on the next neighborhood search.
*/ * @param _solution the current solution
virtual void updateParam(EOT & _solution) { */
if ((*this).moveApplied()) { virtual void updateParam(EOT & _solution) {
selection.init(current, shake, ls); if ((*this).moveApplied()) {
} selection.init(_solution);
else if (selection.cont(current, shake, ls)){ } else
selection.next(current, shake, ls); if (selection.cont(current)) {
} selection.next(_solution);
else } else
stop=true; stop = true;
}; }
/** /**
* terminate: NOTHING TO DO * terminate: NOTHING TO DO
*/ */
virtual void terminate(EOT & _solution) {}; virtual void terminate(EOT & _solution) {};
/** /**
* Explore the neighborhood of a solution * Explore the neighborhood of a solution
* @param _solution * @param _solution the current solution
*/ */
virtual void operator()(EOT & _solution) { virtual void operator()(EOT & _solution) {
current=_solution; eoMonOp<EOT> & shake = selection.getShake();
std::cout << "current avec shake: "<< current << std::endl; eoMonOp<EOT> & ls = selection.getLocalSearch();
shake(current);
std::cout << "current apres shake: "<< current << std::endl;
(*ls)(current);
std::cout << "current apres ls: "<< ls->className() << " " << current << std::endl;
};
/** current = _solution;
* continue if a move is accepted std::cout << "current avec shake: "<< current << std::endl;
* @param _solution the solution shake(current);
* @return true if an ameliorated neighbor was be found std::cout << "current apres shake: "<< current << std::endl;
*/ ls(current);
virtual bool isContinue(EOT & _solution) { std::cout << "current apres ls: "<< ls.className() << " " << current << std::endl;
return !stop; }
};
/** /**
* move the solution with the best neighbor * continue if a move is accepted
* @param _solution the solution to move * @param _solution the solution
*/ * @return true if an ameliorated neighbor was be found
virtual void move(EOT & _solution) { */
_solution=current; virtual bool isContinue(EOT & _solution) {
}; return !stop;
};
/** /**
* accept test if an amelirated neighbor was be found * move the solution with the best neighbor
* @param _solution the solution * @param _solution the solution to move
* @return true if the best neighbor ameliorate the fitness */
*/ virtual void move(EOT & _solution) {
virtual bool accept(EOT & _solution) { _solution = current;
return acceptCrit(_solution, current); };
};
/** /**
* Return the class id. * accept test if an amelirated neighbor was be found according to acceptance criteria
* @return the class name as a std::string * @param _solution the solution
*/ * @return true if the best neighbor ameliorate the fitness
virtual std::string className() const { */
return "moVNSexplorer"; virtual bool accept(EOT & _solution) {
} return acceptCrit(_solution, current);
};
private: /**
moDummyLS<Neighbor> dummyLS; * Return the class id.
moVariableNeighborhoodSelection<EOT>& selection; * @return the class name as a std::string
moAcceptanceCriterion<Neighbor>& acceptCrit; */
eoMonOp<EOT>* ls; virtual std::string className() const {
eoMonOp<EOT>& shake; return "moVNSexplorer";
bool stop; }
EOT current;
private:
//moDummyLS<Neighbor> dummyLS;
moVariableNeighborhoodSelection<EOT>& selection;
moAcceptanceCriterion<Neighbor>& acceptCrit;
//eoMonOp<EOT>* ls;
//eoMonOp<EOT>& shake;
bool stop;
EOT current;
/*
class moDummyEval: public eoEvalFunc<EOT>{ class moDummyEval: public eoEvalFunc<EOT>{
public: public:
void operator()(EOT& hop){} void operator()(EOT& hop){}
}dummyEval; }dummyEval;
*/
}; };

View file

@ -1,30 +1,30 @@
/* /*
<moForwardVectorVNSelection.h> <moForwardVectorVNSelection.h>
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 This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue, abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info". "http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software, 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 that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or 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 data to be ensured and, more generally, to use and operate it in the
same conditions as regards security. same conditions as regards security.
The fact that you are presently reading this means that you have had The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms. knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr Contact: paradiseo-help@lists.gforge.inria.fr
*/ */
#ifndef _moForwardVectorVNSelection_h #ifndef _moForwardVectorVNSelection_h
@ -35,59 +35,55 @@ Contact: paradiseo-help@lists.gforge.inria.fr
template< class EOT > template< class EOT >
class moForwardVectorVNSelection: public moVectorVNSelection<EOT>{ class moForwardVectorVNSelection: public moVectorVNSelection<EOT>{
using moVectorVNSelection<EOT>::LSvector; using moVectorVNSelection<EOT>::LSvector;
using moVectorVNSelection<EOT>::shakeVector; using moVectorVNSelection<EOT>::shakeVector;
using moVectorVNSelection<EOT>::current; using moVectorVNSelection<EOT>::current;
public: public:
moForwardVectorVNSelection(eoMonOp<EOT>& _firstLS, eoMonOp<EOT>& _firstShake, bool _cycle):moVectorVNSelection<EOT>(_firstLS, _firstShake), cycle(_cycle){} moForwardVectorVNSelection(eoMonOp<EOT>& _firstLS, eoMonOp<EOT>& _firstShake, bool _cycle):moVectorVNSelection<EOT>(_firstLS, _firstShake), cycle(_cycle){}
/** /**
* Return the class id. * Return the class id.
* @return the class name as a std::string * @return the class name as a std::string
*/ */
virtual std::string className() const { virtual std::string className() const {
return "moForwardVectorVNSelection"; return "moForwardVectorVNSelection";
} }
/** /**
* test if there is still some neighborhood to explore * test if there is still some neighborhood to explore
* @return true if there is some neighborhood to explore * @return true if there is some neighborhood to explore
*/ */
virtual bool cont(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls){ virtual bool cont(EOT& _solution){
return (cycle || (current <= (LSvector.size()-2))); return (cycle || (current <= (LSvector.size()-2)));
std::cout << "current LS: " << current << std::endl; std::cout << "current LS: " << current << std::endl;
std::cout << _solution << std::endl; std::cout << _solution << std::endl;
} }
/** /**
* put the current neighborhood on the first one * put the current neighborhood on the first one
*/ */
virtual void init(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls){ virtual void init(EOT& _solution){
current=0; current = 0;
_ls = LSvector[current]; // std::cout << "current LS: " << _ls->className() << " " << current << std::endl;
_shake = *(shakeVector[current]); // std::cout << _solution << std::endl;
std::cout << "current LS: " << _ls->className() << " " << current << std::endl;
std::cout << _solution << std::endl;
} }
/** /**
* put the current neighborhood on the next one * put the current neighborhood on the next one
*/ */
virtual void next(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls){ virtual void next(EOT& _solution){
current = (current+1) % LSvector.size(); current = (current + 1) % LSvector.size();
_ls = LSvector[current]; std::cout << "current LS: " << current << std::endl;
_shake = *(shakeVector[current]); std::cout << _solution << std::endl;
std::cout << "current LS: " << current << std::endl; }
std::cout << _solution << std::endl;
}
private: private:
bool cycle; bool cycle;
}; };

View file

@ -2,7 +2,7 @@
<moVariableNeighborhoodSelection.h> <moVariableNeighborhoodSelection.h>
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 This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue, 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 * test if there is still some neighborhood to explore
* @return true if there is some neighborhood to explore * @return true if there is some neighborhood to explore
*/ */
virtual bool cont(EOT& _solution, eoMonOp<EOT>& _skake, eoMonOp<EOT>*& _ls) = 0; virtual bool cont(EOT& _solution) = 0;
/** /**
* put the current neighborhood on the first one * put the current neighborhood on the first one
*/ */
virtual void init(EOT& _solution, eoMonOp<EOT>& _skake, eoMonOp<EOT>*& _ls) = 0; virtual void init(EOT& _solution) = 0;
/** /**
* put the current neighborhood on the next one * put the current neighborhood on the next one
*/ */
virtual void next(EOT& _solution, eoMonOp<EOT>& _skake, eoMonOp<EOT>*& _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<EOT> & getShake() = 0;
/**
* Get the current local search based on the current neighborhood
*
* @return current local search
*/
virtual const eoMon<EOT> & getLocalSearch() = 0;
}; };

View file

@ -1,30 +1,30 @@
/* /*
<moVectorVNSelection.h> <moVectorVNSelection.h>
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 This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue, abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info". "http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software, 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 that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or 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 data to be ensured and, more generally, to use and operate it in the
same conditions as regards security. same conditions as regards security.
The fact that you are presently reading this means that you have had The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms. knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr Contact: paradiseo-help@lists.gforge.inria.fr
*/ */
#ifndef _moVectorVNSelection_h #ifndef _moVectorVNSelection_h
@ -38,45 +38,63 @@ class moVectorVNSelection: public moVariableNeighborhoodSelection<EOT>{
public: public:
moVectorVNSelection(eoMonOp<EOT>& _firstLS, eoMonOp<EOT>& _firstShake){ moVectorVNSelection(eoMonOp<EOT>& _firstLS, eoMonOp<EOT>& _firstShake){
LSvector.push_back(&_firstLS); LSvector.push_back(&_firstLS);
shakeVector.push_back(&_firstShake); shakeVector.push_back(&_firstShake);
current=0; current=0;
} }
void add(eoMonOp<EOT>& _otherLS, eoMonOp<EOT>& _otherShake){
LSvector.push_back(&_otherLS);
shakeVector.push_back(&_otherShake);
}
void add(eoMonOp<EOT>& _otherLS, eoMonOp<EOT>& _otherShake){ /**
LSvector.push_back(&_otherLS); * Return the class id.
shakeVector.push_back(&_otherShake); * @return the class name as a std::string
} */
virtual std::string className() const {
return "moVectorVNSelection";
}
/** /**
* Return the class id. * Get the current "shake" operator based on the current neighborhood
* @return the class name as a std::string *
*/ * @return current shake operator
virtual std::string className() const { */
return "moVectorVNSelection"; virtual const eoMon<EOT> & getShake() {
} return *(shakeVector[current]);
}
/** /**
* test if there is still some neighborhood to explore * Get the current local search based on the current neighborhood
* @return true if there is some neighborhood to explore *
*/ * @return current local search
virtual bool cont(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls) = 0; */
virtual const eoMon<EOT> & getLocalSearch() {
return *(LSvector[current]);
}
/** /**
* put the current neighborhood on the first one * test if there is still some neighborhood to explore
*/ * @return true if there is some neighborhood to explore
virtual void init(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls) = 0; */
virtual bool cont(EOT& _solution) = 0;
/** /**
* put the current neighborhood on the next one * put the current neighborhood on the first one
*/ */
virtual void next(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls) = 0; virtual void init(EOT& _solution) = 0;
/**
* put the current neighborhood on the next one
*/
virtual void next(EOT& _solution) = 0;
protected: protected:
std::vector<eoMonOp<EOT>* > LSvector; std::vector<eoMonOp<EOT>* > LSvector;
std::vector<eoMonOp<EOT>* > shakeVector; std::vector<eoMonOp<EOT>* > shakeVector;
unsigned int current; unsigned int current;
}; };