tests added

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1704 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-03-23 10:17:39 +00:00
commit 8129dff882
9 changed files with 316 additions and 42 deletions

View file

@ -1,6 +1,8 @@
#ifndef _moAspiration_h
#define _moAspiration_h
#include <eoFunctor.h>
/**
* Abstract class for Aspiration Criteria
*/

View file

@ -32,13 +32,22 @@ public:
}
/**
* test if a solution is better than the "bestFoundSoFar"
* Test the tabu feature of the neighbor:
* test if the neighbor's fitness is better than the "bestFoundSoFar" fitness
* @param _sol a solution
* @param _neighbor a neighbor
* @return true if _sol is better than the "bestFoundSoFar"
* @return true if _neighbor fitness is better than the "bestFoundSoFar"
*/
bool operator()(EOT & _sol, Neighbor & _neighbor){
return (bestFoundSoFar.fitness() < _sol.fitness());
return (bestFoundSoFar.fitness() < _neighbor.fitness());
}
/**
* Getter
* @return a reference on the best found so far solution
*/
EOT& getBest(){
return bestFoundSoFar;
}
private:

View file

@ -3,6 +3,7 @@
#include <memory/moTabuList.h>
#include <vector>
#include <iostream>
/**
* Tabu List of solution stocked in a vector
@ -36,15 +37,14 @@ public:
* @param _sol the current solution
* @param _neighbor the current neighbor (unused)
*/
virtual void add(EOT & _sol, Neighbor & _neighbor)
{
virtual void add(EOT & _sol, Neighbor & _neighbor){
if(tabuList.size() < maxSize)
tabuList.push_back(_sol);
else{
tabuList[index%maxSize] = _sol;
index++;
}
}
}
/**
* update the tabulist: NOTHING TO DO
@ -60,8 +60,10 @@ public:
* @return true if tabuList contains _sol
*/
virtual bool check(EOT & _sol, Neighbor & _neighbor){
EOT tmp=_sol;
_neighbor.move(tmp);
for(unsigned int i=0; i<tabuList.size(); i++){
if (tabuList[i] == _sol)
if (tabuList[i] == tmp)
return true;
}
return false;