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>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
<moVNSexplorer.h>
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 <algo/moDummyLS.h>
/**
* 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<EOT> & _selection,
moAcceptanceCriterion<Neighbor>& _acceptCrit):
moNeighborhoodExplorer<Neighbor>(),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<EOT> & _selection,
moAcceptanceCriterion<Neighbor>& _acceptCrit):
moNeighborhoodExplorer<Neighbor>(), 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<EOT> & shake = selection.getShake();
eoMonOp<EOT> & 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<Neighbor> dummyLS;
moVariableNeighborhoodSelection<EOT>& selection;
moAcceptanceCriterion<Neighbor>& acceptCrit;
eoMonOp<EOT>* ls;
eoMonOp<EOT>& 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<Neighbor> dummyLS;
moVariableNeighborhoodSelection<EOT>& selection;
moAcceptanceCriterion<Neighbor>& acceptCrit;
//eoMonOp<EOT>* ls;
//eoMonOp<EOT>& shake;
bool stop;
EOT current;
/*
class moDummyEval: public eoEvalFunc<EOT>{
public:
void operator()(EOT& hop){}
void operator()(EOT& hop){}
}dummyEval;
*/
};

View file

@ -1,30 +1,30 @@
/*
<moForwardVectorVNSelection.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
<moForwardVectorVNSelection.h>
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<EOT>{
using moVectorVNSelection<EOT>::LSvector;
using moVectorVNSelection<EOT>::shakeVector;
using moVectorVNSelection<EOT>::current;
using moVectorVNSelection<EOT>::LSvector;
using moVectorVNSelection<EOT>::shakeVector;
using moVectorVNSelection<EOT>::current;
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 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<EOT>& _shake, eoMonOp<EOT>*& _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<EOT>& _shake, eoMonOp<EOT>*& _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<EOT>& _shake, eoMonOp<EOT>*& _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;
};

View file

@ -2,7 +2,7 @@
<moVariableNeighborhoodSelection.h>
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<EOT>& _skake, eoMonOp<EOT>*& _ls) = 0;
virtual bool cont(EOT& _solution) = 0;
/**
* 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
*/
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>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
<moVectorVNSelection.h>
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<EOT>{
public:
moVectorVNSelection(eoMonOp<EOT>& _firstLS, eoMonOp<EOT>& _firstShake){
LSvector.push_back(&_firstLS);
shakeVector.push_back(&_firstShake);
current=0;
}
moVectorVNSelection(eoMonOp<EOT>& _firstLS, eoMonOp<EOT>& _firstShake){
LSvector.push_back(&_firstLS);
shakeVector.push_back(&_firstShake);
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);
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<EOT> & 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<EOT>& _shake, eoMonOp<EOT>*& _ls) = 0;
/**
* Get the current local search based on the current neighborhood
*
* @return current local search
*/
virtual const eoMon<EOT> & getLocalSearch() {
return *(LSvector[current]);
}
/**
* put the current neighborhood on the first one
*/
virtual void init(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _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<EOT>& _shake, eoMonOp<EOT>*& _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<eoMonOp<EOT>* > LSvector;
std::vector<eoMonOp<EOT>* > shakeVector;
unsigned int current;
std::vector<eoMonOp<EOT>* > LSvector;
std::vector<eoMonOp<EOT>* > shakeVector;
unsigned int current;
};