Aspiration Criteria Added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1680 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
e34d9a745b
commit
4f98176c49
2 changed files with 65 additions and 0 deletions
17
branches/newMo/src/memory/moAspiration.h
Normal file
17
branches/newMo/src/memory/moAspiration.h
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef _moAspiration_h
|
||||||
|
#define _moAspiration_h
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class for Aspiration Criteria
|
||||||
|
*/
|
||||||
|
template< class Neighbor >
|
||||||
|
class moAspiration : public eoBF<typename Neighbor::EOT &, Neighbor &, bool>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
|
virtual void init(EOT & _sol) = 0;
|
||||||
|
virtual void update(EOT & _sol, Neighbor & _neighbor) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
48
branches/newMo/src/memory/moBestImprAspiration.h
Normal file
48
branches/newMo/src/memory/moBestImprAspiration.h
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#ifndef _moBestImprAspiration_h
|
||||||
|
#define _moBestImprAspiration_h
|
||||||
|
|
||||||
|
#include <memory/moAspiration.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aspiration criteria accepts a solution better than the best so far
|
||||||
|
*/
|
||||||
|
template< class Neighbor >
|
||||||
|
class moBestImprAspiration : public moAspiration<Neighbor>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* init the best solution
|
||||||
|
* @param _sol the best solution found
|
||||||
|
*/
|
||||||
|
void init(EOT & _sol){
|
||||||
|
bestFoundSoFar = _sol;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update the "bestFoundSoFar" if a best solution is found
|
||||||
|
* @param _sol a solution
|
||||||
|
* @param _neighbor a neighbor
|
||||||
|
*/
|
||||||
|
void update(EOT & _sol, Neighbor & _neighbor){
|
||||||
|
if (bestFoundSoFar.fitness() < _sol.fitness())
|
||||||
|
bestFoundSoFar = _sol;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test if a solution is better than the "bestFoundSoFar"
|
||||||
|
* @param _sol a solution
|
||||||
|
* @param _neighbor a neighbor
|
||||||
|
* @return true if _sol is better than the "bestFoundSoFar"
|
||||||
|
*/
|
||||||
|
bool operator()(EOT & _sol, Neighbor & _neighbor){
|
||||||
|
return (bestFoundSoFar.fitness() < _sol.fitness());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
EOT bestFoundSoFar;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue