diff --git a/branches/newMo/src/memory/moDiversification.h b/branches/newMo/src/memory/moDiversification.h new file mode 100644 index 000000000..0a697300a --- /dev/null +++ b/branches/newMo/src/memory/moDiversification.h @@ -0,0 +1,13 @@ +#ifndef _moDiversification_h +#define _moDiversification_h + +#include + +/** + * Abstract class for diversification strategy + */ +template< class Neighbor > +class moDiversification : public moMemory, public eoUF +{}; + +#endif diff --git a/branches/newMo/src/memory/moDummyDiversification.h b/branches/newMo/src/memory/moDummyDiversification.h new file mode 100644 index 000000000..9f0e14376 --- /dev/null +++ b/branches/newMo/src/memory/moDummyDiversification.h @@ -0,0 +1,43 @@ +#ifndef _moDummyDiversification_h +#define _moDummyDiversification_h + +#include + +/** + * Dummy diversification strategy + */ +template< class Neighbor > +class moDummyDiversification : public moDiversification +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * Init : NOTHIING TO DO + */ + void init(EOT & _sol) {} + + /** + * Add : NOTHIING TO DO + */ + void add(EOT & _sol, Neighbor & _neighbor) {} + + /** + * Update : NOTHIING TO DO + */ + void update(EOT & _sol, Neighbor & _neighbor) {} + + /** + * ClearMemory : NOTHIING TO DO + */ + void clearMemory() {} + + /** + * @return always false + */ + bool operator()(EOT &){ + return false; + } +}; + +#endif diff --git a/branches/newMo/src/memory/moDummyIntensification.h b/branches/newMo/src/memory/moDummyIntensification.h new file mode 100644 index 000000000..7cc124871 --- /dev/null +++ b/branches/newMo/src/memory/moDummyIntensification.h @@ -0,0 +1,43 @@ +#ifndef _moDummyIntensification_h +#define _moDummyIntensification_h + +#include + +/** + * Dummy intensification strategy + */ +template< class Neighbor > +class moDummyIntensification : public moIntensification +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * Init : NOTHIING TO DO + */ + void init(EOT & _sol) {} + + /** + * Add : NOTHIING TO DO + */ + void add(EOT & _sol, Neighbor & _neighbor) {} + + /** + * Update : NOTHIING TO DO + */ + void update(EOT & _sol, Neighbor & _neighbor) {} + + /** + * ClearMemory : NOTHIING TO DO + */ + void clearMemory() {} + + /** + * @return always false + */ + bool operator()(EOT &){ + return false; + } +}; + +#endif diff --git a/branches/newMo/src/memory/moIntensification.h b/branches/newMo/src/memory/moIntensification.h new file mode 100644 index 000000000..2d85ee6ed --- /dev/null +++ b/branches/newMo/src/memory/moIntensification.h @@ -0,0 +1,13 @@ +#ifndef _moIntensification_h +#define _moIntensification_h + +#include + +/** + * Abstract class for intensification strategy + */ +template< class Neighbor > +class moIntensification : public moMemory, public eoUF +{}; + +#endif diff --git a/branches/newMo/src/memory/moMemory.h b/branches/newMo/src/memory/moMemory.h new file mode 100644 index 000000000..a1284a094 --- /dev/null +++ b/branches/newMo/src/memory/moMemory.h @@ -0,0 +1,40 @@ +#ifndef _moMemory_h +#define _moMemory_h + +/** + * Abstract class for different memory + */ +template< class Neighbor > +class moMemory //: public eoObject +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * Init the memory + * @param _sol the current solution + */ + virtual void init(EOT & _sol) = 0; + + /** + * Add data in the memory + * @param _sol the current solution + * @param _neighbor the current neighbor + */ + virtual void add(EOT & _sol, Neighbor & _neighbor) = 0; + + /** + * update the memory + * @param _sol the current solution + * @param _neighbor the current neighbor + */ + virtual void update(EOT & _sol, Neighbor & _neighbor) = 0; + + /** + * clear the memory + */ + virtual void clearMemory() = 0; + +}; + +#endif diff --git a/branches/newMo/src/memory/moSolVectorTabuList.h b/branches/newMo/src/memory/moSolVectorTabuList.h new file mode 100644 index 000000000..8f4c0cc65 --- /dev/null +++ b/branches/newMo/src/memory/moSolVectorTabuList.h @@ -0,0 +1,88 @@ +#ifndef _moSolVectorTabuList_h +#define _moSolVectorTabuList_h + +#include + +/** + * Tabu List of solution stocked in a vector + */ +template +class moSolVectorTabuList : public moTabuList +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _maxSize maximum size of the tabu list + */ + moSolVectorTabuList(unsigned int _maxSize) : maxSize(_maxSize){ + tabuList.reserve(_maxSize); + tabuList.resize(0); + } + + /** + * init the tabuList by clearing the memory + * @param _sol the current solution + */ + void init(EOT & _sol){ + clearMemory(); + } + + + /** + * add a new solution in the tabuList + * @param _sol the current solution + * @param _neighbor the current neighbor (unused) + */ + void add(EOT & _sol, Neighbor & _neighbor) + { + if(tabuList.size() < maxSize) + tabuList.push_back(_sol); + else{ + tabuList[index%maxSize] = _sol; + index++; + } + } + + /** + * update the tabulist + * @param _sol the current solution + * @param _neighbor the current neighbor (unused) + */ + void update(EOT & _sol, Neighbor & _neighbor){ + // ??? + } + + /** + * check if the solution is tabu + * @param _sol the current solution + * @param _neighbor the current neighbor (unused) + * @return true if tabuList contains _sol + */ + bool check(EOT & _sol, Neighbor & _neighbor){ + for(unsigned int i=0; i tabuList; + unsigned int maxSize; + unsigned long index; + +}; + +#endif diff --git a/branches/newMo/src/memory/moTabuList.h b/branches/newMo/src/memory/moTabuList.h new file mode 100644 index 000000000..96131286e --- /dev/null +++ b/branches/newMo/src/memory/moTabuList.h @@ -0,0 +1,24 @@ +#ifndef _moTabuList_h +#define _moTabuList_h + +#include + +/** + * Abstract class for the Tabu List + */ +template< class Neighbor > +class moTabuList : public moMemory +{ +public: + typedef typename Neighbor::EOT EOT; + + /** + * Check if a neighbor is tabu or not + * @param _sol the current solution + * @param _neighbor the neighbor + * @return true if the neighbor is tabu + */ + virtual bool check(EOT & _sol, Neighbor & _neighbor) = 0; +}; + +#endif