diff --git a/branches/newMo/src/memory/moAspiration.h b/branches/newMo/src/memory/moAspiration.h new file mode 100644 index 000000000..96f529326 --- /dev/null +++ b/branches/newMo/src/memory/moAspiration.h @@ -0,0 +1,17 @@ +#ifndef _moAspiration_h +#define _moAspiration_h + +/** + * Abstract class for Aspiration Criteria + */ +template< class Neighbor > +class moAspiration : public eoBF +{ +public: + typedef typename Neighbor::EOT EOT; + + virtual void init(EOT & _sol) = 0; + virtual void update(EOT & _sol, Neighbor & _neighbor) = 0; +}; + +#endif diff --git a/branches/newMo/src/memory/moBestImprAspiration.h b/branches/newMo/src/memory/moBestImprAspiration.h new file mode 100644 index 000000000..57441e066 --- /dev/null +++ b/branches/newMo/src/memory/moBestImprAspiration.h @@ -0,0 +1,48 @@ +#ifndef _moBestImprAspiration_h +#define _moBestImprAspiration_h + +#include + +/** + * Aspiration criteria accepts a solution better than the best so far + */ +template< class Neighbor > +class moBestImprAspiration : public moAspiration +{ +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