Modif sur les continuator + ILS
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1781 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
54b43683cb
commit
f580837dde
8 changed files with 114 additions and 85 deletions
|
|
@ -40,6 +40,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
#include <eval/moEval.h>
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
|
||||
/**
|
||||
* Iterated Local Search
|
||||
*/
|
||||
|
|
@ -52,7 +53,7 @@ public:
|
|||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||
|
||||
/**
|
||||
* Simple constructor for Iterated Local Search
|
||||
* Basic constructor for Iterated Local Search
|
||||
* @param _ls the local search to iterates
|
||||
* @param _fullEval the full evaluation function
|
||||
* @param _op the operator used to perturb solution
|
||||
|
|
@ -70,7 +71,7 @@ public:
|
|||
* @param _ls the local search to iterates
|
||||
* @param _fullEval the full evaluation function
|
||||
* @param _op the operator used to perturb solution
|
||||
* @param _nbIteration the time limit for search
|
||||
* @param _cont a continuator
|
||||
*/
|
||||
moILS(moLocalSearch<Neighbor>& _ls, eoEvalFunc<EOT>& _fullEval, eoMonOp<EOT>& _op, moContinuator<moDummyNeighbor<EOT> >& _cont):
|
||||
moLocalSearch<moDummyNeighbor<EOT> >(explorer, _cont, _fullEval),
|
||||
|
|
@ -79,7 +80,28 @@ public:
|
|||
explorer(_ls, defaultPerturb, defaultAccept)
|
||||
{}
|
||||
|
||||
/**
|
||||
* General constructor for Iterated Local Search
|
||||
* @param _ls the local search to iterates
|
||||
* @param _fullEval the full evaluation function
|
||||
* @param _op the operator used to perturb solution
|
||||
* @param _cont a continuator
|
||||
* @param _perturb a perturbation operator
|
||||
* @param _accept a acceptance criteria
|
||||
*/
|
||||
moILS(moLocalSearch<Neighbor>& _ls, eoEvalFunc<EOT>& _fullEval, eoMonOp<EOT>& _op, moContinuator<moDummyNeighbor<EOT> >& _cont, moMonOpPerturb<Neighbor>& _perturb, moAcceptanceCriterion<Neighbor>& _accept):
|
||||
moLocalSearch<moDummyNeighbor<EOT> >(explorer, _cont, _fullEval),
|
||||
iterCont(0),
|
||||
defaultPerturb(dummyOp, _fullEval),
|
||||
explorer(_ls, _perturb, _accept)
|
||||
{}
|
||||
|
||||
private:
|
||||
|
||||
class dummmyMonOp: public eoMonOp<EOT>{
|
||||
public:
|
||||
bool operator()(EOT&){return false;}
|
||||
}dummyOp;
|
||||
moIterContinuator<moDummyNeighbor<EOT> > iterCont;
|
||||
moMonOpPerturb<Neighbor> defaultPerturb;
|
||||
moAlwaysAcceptCrit<Neighbor> defaultAccept;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public:
|
|||
// initialization of the external continuator (for example the time, or the number of generations)
|
||||
cont->init(_solution);
|
||||
|
||||
bool b= (*cont)(_solution);
|
||||
bool b;
|
||||
|
||||
do {
|
||||
// explore the neighborhood of the solution
|
||||
|
|
|
|||
|
|
@ -96,6 +96,13 @@ public :
|
|||
* @param _sol the corresponding solution
|
||||
*/
|
||||
virtual void init(EOT& _sol) {
|
||||
for (unsigned i = 0; i < stats.size(); ++i)
|
||||
stats[i]->init(_sol);
|
||||
counter=1;
|
||||
|
||||
for (unsigned int i = 0; i < monitors.size(); ++i)
|
||||
(*monitors[i])();
|
||||
|
||||
for (unsigned i = 0; i < continuators.size(); ++i)
|
||||
continuators[i]->init(_sol);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,8 +51,13 @@ public:
|
|||
*@return true if counter < maxIter
|
||||
*/
|
||||
virtual bool operator()(EOT & _solution) {
|
||||
bool res;
|
||||
cpt++;
|
||||
return (cpt < maxIter);
|
||||
res = (cpt < maxIter);
|
||||
if(!res){
|
||||
std::cout << "STOP in moIterContinuator: Reached maximum number of iterations [" << cpt << "/" << maxIter << "]" << std::endl;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ public:
|
|||
*/
|
||||
virtual void lastCall(EOT &) {}
|
||||
|
||||
/**
|
||||
* first call of a statistical operator
|
||||
*/
|
||||
virtual void init(EOT &){}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -66,6 +66,14 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the start time
|
||||
* @param _solution a solution
|
||||
*/
|
||||
virtual void init(EOT & _solution) {
|
||||
start = time(NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue