add hybrid lesson and test of ILS
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1799 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
6d55b78321
commit
5f85276ea5
9 changed files with 344 additions and 20 deletions
|
|
@ -84,12 +84,11 @@ public:
|
|||
* 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):
|
||||
moILS(moLocalSearch<Neighbor>& _ls, eoEvalFunc<EOT>& _fullEval, moContinuator<moDummyNeighbor<EOT> >& _cont, moMonOpPerturb<Neighbor>& _perturb, moAcceptanceCriterion<Neighbor>& _accept):
|
||||
moLocalSearch<moDummyNeighbor<EOT> >(explorer, _cont, _fullEval),
|
||||
iterCont(0),
|
||||
defaultPerturb(dummyOp, _fullEval),
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public:
|
|||
/**
|
||||
* @param _maxIter number maximum of iterations
|
||||
*/
|
||||
moIterContinuator(unsigned int _maxIter): maxIter(_maxIter){}
|
||||
moIterContinuator(unsigned int _maxIter, bool _verbose=true): maxIter(_maxIter), verbose(_verbose){}
|
||||
|
||||
/**
|
||||
*@param _solution a solution
|
||||
|
|
@ -54,9 +54,8 @@ public:
|
|||
bool res;
|
||||
cpt++;
|
||||
res = (cpt < maxIter);
|
||||
if(!res){
|
||||
if(!res && verbose)
|
||||
std::cout << "STOP in moIterContinuator: Reached maximum number of iterations [" << cpt << "/" << maxIter << "]" << std::endl;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -79,6 +78,7 @@ public:
|
|||
private:
|
||||
unsigned int maxIter;
|
||||
unsigned int cpt;
|
||||
bool verbose;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public:
|
|||
* Ctor.
|
||||
* @param _max maximum running time
|
||||
*/
|
||||
moTimeContinuator(time_t _max): max(_max){
|
||||
moTimeContinuator(time_t _max, bool _verbose=true): max(_max), verbose(_verbose){
|
||||
start = time(NULL);
|
||||
}
|
||||
|
||||
|
|
@ -57,13 +57,12 @@ public:
|
|||
*/
|
||||
virtual bool operator() (EOT& _sol)
|
||||
{
|
||||
bool res;
|
||||
time_t elapsed = (time_t) difftime(time(NULL), start);
|
||||
if (elapsed >= max)
|
||||
{
|
||||
std::cout << "STOP in moTimeContinuator: Reached maximum time [" << elapsed << "/" << max << "]" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
res = (elapsed < max);
|
||||
if(!res && verbose)
|
||||
std::cout << "STOP in moTimeContinuator: Reached maximum time [" << elapsed << "/" << max << "]" << std::endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,6 +89,8 @@ private:
|
|||
time_t max;
|
||||
/** starting time */
|
||||
time_t start;
|
||||
/** verbose mode */
|
||||
bool verbose;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue