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

@ -63,7 +63,7 @@ public:
virtual bool operator() (EOT & _solution) {
if(_solution.invalid())
fullEval(_solution);
fullEval(_solution);
// initialization of the parameter of the search (for example fill empty the tabu list)
searchExplorer.initParam(_solution);
@ -94,7 +94,6 @@ public:
continuator.lastCall(_solution);
//A CHANGER
return true;
};

View file

@ -100,6 +100,7 @@ public:
intensification.init(_solution);
diversification.init(_solution);
aspiration.init(_solution);
bestSoFar=_solution;
};
@ -114,7 +115,8 @@ public:
tabuList.add(_solution, *best);
intensification.add(_solution, *best);
diversification.add(_solution, *best);
//bestSoFar = ???;
if(_solution.fitness() > bestSoFar.fitness())
bestSoFar = _solution;
}
tabuList.update(_solution, *best);
intensification.update(_solution, *best);
@ -126,9 +128,9 @@ public:
/**
* terminate : NOTHING TO DO
*/
virtual void terminate(EOT & solution)
virtual void terminate(EOT & _solution)
{
//solution = bestSoFar;
_solution= bestSoFar;
};
@ -175,7 +177,7 @@ public:
//eval
eval(_solution, (*current));
//check if the current is better than the best and is not tabu or if it is aspirat (by the aspiration criteria of course)
if ( (!tabuList.check(_solution, *current) && neighborComparator((*best),(*current))) || aspiration(_solution, *current) ){
if ( (!tabuList.check(_solution, *current) || aspiration(_solution, (*current))) && neighborComparator((*best),(*current))){
// set best
(*best)=(*current);
}
@ -239,9 +241,13 @@ protected:
moDiversification<Neighbor> & diversification;
moAspiration<Neighbor> & aspiration;
//Current and best neighbor
Neighbor* best;
Neighbor* current;
//Best so far Solution
EOT bestSoFar;
// true if the move is accepted
bool isAccept ;

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;