Correction des continuators, Ajout dans lesson 1

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1765 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
verel 2010-04-29 14:37:23 +00:00
commit d613e38c20
9 changed files with 968 additions and 25 deletions

View file

@ -36,6 +36,9 @@ Contact: paradiseo-help@lists.gforge.inria.fr
/**
* Continue until a maximum fixed number of neighbor evaluation is reached
*
* Becareful 1: The number of full evaluations considered is within the local search (not before it)
* Becareful 2: Can not be used if the evaluation function is used in parallel
*/
template< class Neighbor >
class moNeighborEvalContinuator : public moContinuator<Neighbor>
@ -48,15 +51,15 @@ public:
* @param _eval neighbor evaluation function to count
* @param _maxNeighborEval number maximum of iterations
*/
moNeighborEvalContinuator(moEvalCounter<Neighbor> & _eval, unsigned int _maxNeighborEval): maxNeighborEval(_maxNeighborEval){}
moNeighborEvalContinuator(moEvalCounter<Neighbor> & _eval, unsigned int _maxNeighborEval): eval(_eval), maxNeighborEval(_maxNeighborEval){}
/**
* Test if continue
*@param _solution a solution
*@return true if number of evaluations < maxNeighborEval
* @param _solution a solution
* @return true if number of evaluations < maxNeighborEval
*/
virtual bool operator()(EOT & _solution) {
return (eval.value() < maxNeighborEval);
return (eval.value() - nbEval_start < maxNeighborEval);
}
/**
@ -64,12 +67,21 @@ public:
* @param _solution a solution
*/
virtual void init(EOT & _solution) {
eval.value() = 0;
nbEval_start = eval.value();
}
/**
* the current number of evaluation from the begining
* @return the number of evaluation
*/
unsigned int value() {
return eval.value() - nbEval_start ;
}
private:
moEvalCounter<Neighbor> & eval;
unsigned int maxNeighborEval;
unsigned int nbEval_start ;
};
#endif