mon dernier commit :) On en a chier encore jusqu'au bout !!!

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1926 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-08-27 15:59:23 +00:00
commit 7631f6e040
5 changed files with 85 additions and 49 deletions

View file

@ -34,6 +34,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <neighborhood/moVariableNeighborhoodSelection.h>
#include <eoOp.h>
#include <acceptCrit/moAcceptanceCriterion.h>
#include <algo/moDummyLS.h>
/**
* Explorer for Variiable Neighborhood Search
@ -55,7 +56,7 @@ public:
moVNSexplorer(
moVariableNeighborhoodSelection<EOT> & _selection,
moAcceptanceCriterion<Neighbor>& _acceptCrit):
moNeighborhoodExplorer<Neighbor>(), selection(_selection), shake(NULL), ls(NULL), acceptCrit(_acceptCrit), stop(false)
moNeighborhoodExplorer<Neighbor>(),dummyLS(dummyEval), selection(_selection), acceptCrit(_acceptCrit), ls(&dummyLS), shake(dummyLS), stop(false)
{}
/**
@ -68,7 +69,7 @@ public:
* initParam: NOTHING TO DO
*/
virtual void initParam(EOT& _solution) {
selection.init(_solution, *shake, *ls);
selection.init(current, shake, ls);
};
/**
@ -76,10 +77,10 @@ public:
*/
virtual void updateParam(EOT & _solution) {
if ((*this).moveApplied()) {
selection.init(_solution, *shake, *ls);
selection.init(current, shake, ls);
}
else if (selection.cont(_solution, *shake, *ls)){
selection.next(_solution, *shake, *ls);
else if (selection.cont(current, shake, ls)){
selection.next(current, shake, ls);
}
else
stop=true;
@ -96,8 +97,11 @@ public:
*/
virtual void operator()(EOT & _solution) {
current=_solution;
(*shake)(current);
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;
};
/**
@ -135,14 +139,19 @@ public:
}
private:
moDummyLS<Neighbor> dummyLS;
moVariableNeighborhoodSelection<EOT>& selection;
eoMonOp<EOT>* ls;
eoMonOp<EOT>* shake;
moAcceptanceCriterion<Neighbor>& acceptCrit;
eoMonOp<EOT>* ls;
eoMonOp<EOT>& shake;
bool stop;
EOT current;
class moDummyEval: public eoEvalFunc<EOT>{
public:
void operator()(EOT& hop){}
}dummyEval;
};

View file

@ -55,26 +55,34 @@ 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>& _shake, eoMonOp<EOT>& _ls){
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;
}
/**
* put the current neighborhood on the first one
*/
virtual void init(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>& _ls){
virtual void init(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls){
current=0;
_ls = *(LSvector[current]);
_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 next one
*/
virtual void next(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>& _ls){
virtual void next(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls){
current = (current+1) % LSvector.size();
_ls = *(LSvector[current]);
_ls = LSvector[current];
_shake = *(shakeVector[current]);
std::cout << "current LS: " << current << std::endl;
std::cout << _solution << std::endl;
}
private:

View file

@ -50,17 +50,17 @@ 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, eoMonOp<EOT>& _skake, eoMonOp<EOT>*& _ls) = 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, eoMonOp<EOT>& _skake, eoMonOp<EOT>*& _ls) = 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, eoMonOp<EOT>& _skake, eoMonOp<EOT>*& _ls) = 0;
};

View file

@ -44,7 +44,7 @@ public:
current=0;
}
void addLS(eoMonOp<EOT>& _otherLS, eoMonOp<EOT>& _otherShake){
void add(eoMonOp<EOT>& _otherLS, eoMonOp<EOT>& _otherShake){
LSvector.push_back(&_otherLS);
shakeVector.push_back(&_otherShake);
}
@ -61,17 +61,17 @@ 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>& _shake, eoMonOp<EOT>& _ls) = 0;
virtual bool cont(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls) = 0;
/**
* put the current neighborhood on the first one
*/
virtual void init(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>& _ls) = 0;
virtual void init(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls) = 0;
/**
* put the current neighborhood on the next one
*/
virtual void next(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>& _ls) = 0;
virtual void next(EOT& _solution, eoMonOp<EOT>& _shake, eoMonOp<EOT>*& _ls) = 0;
protected:
std::vector<eoMonOp<EOT>* > LSvector;