memory fot TS added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1682 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
fa8f3a7897
commit
e6e21d345e
7 changed files with 264 additions and 0 deletions
13
branches/newMo/src/memory/moDiversification.h
Normal file
13
branches/newMo/src/memory/moDiversification.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef _moDiversification_h
|
||||
#define _moDiversification_h
|
||||
|
||||
#include <memory/moMemory.h>
|
||||
|
||||
/**
|
||||
* Abstract class for diversification strategy
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moDiversification : public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool>
|
||||
{};
|
||||
|
||||
#endif
|
||||
43
branches/newMo/src/memory/moDummyDiversification.h
Normal file
43
branches/newMo/src/memory/moDummyDiversification.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef _moDummyDiversification_h
|
||||
#define _moDummyDiversification_h
|
||||
|
||||
#include <memory/moDiversification.h>
|
||||
|
||||
/**
|
||||
* Dummy diversification strategy
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moDummyDiversification : public moDiversification<Neighbor>
|
||||
{
|
||||
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
|
||||
43
branches/newMo/src/memory/moDummyIntensification.h
Normal file
43
branches/newMo/src/memory/moDummyIntensification.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef _moDummyIntensification_h
|
||||
#define _moDummyIntensification_h
|
||||
|
||||
#include <memory/moIntensification.h>
|
||||
|
||||
/**
|
||||
* Dummy intensification strategy
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moDummyIntensification : public moIntensification<Neighbor>
|
||||
{
|
||||
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
|
||||
13
branches/newMo/src/memory/moIntensification.h
Normal file
13
branches/newMo/src/memory/moIntensification.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef _moIntensification_h
|
||||
#define _moIntensification_h
|
||||
|
||||
#include <memory/moMemory.h>
|
||||
|
||||
/**
|
||||
* Abstract class for intensification strategy
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moIntensification : public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool>
|
||||
{};
|
||||
|
||||
#endif
|
||||
40
branches/newMo/src/memory/moMemory.h
Normal file
40
branches/newMo/src/memory/moMemory.h
Normal file
|
|
@ -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
|
||||
88
branches/newMo/src/memory/moSolVectorTabuList.h
Normal file
88
branches/newMo/src/memory/moSolVectorTabuList.h
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
#ifndef _moSolVectorTabuList_h
|
||||
#define _moSolVectorTabuList_h
|
||||
|
||||
#include <memory/moTabuList.h>
|
||||
|
||||
/**
|
||||
* Tabu List of solution stocked in a vector
|
||||
*/
|
||||
template<class Neighbor >
|
||||
class moSolVectorTabuList : public moTabuList<Neighbor>
|
||||
{
|
||||
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.size(); i++){
|
||||
if (tabuList[i] == _sol)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* clearMemory: remove all solution of the tabuList
|
||||
*/
|
||||
virtual void clearMemory(){
|
||||
tabuList.resize(0);
|
||||
index = 0;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::vector<EOT> tabuList;
|
||||
unsigned int maxSize;
|
||||
unsigned long index;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
24
branches/newMo/src/memory/moTabuList.h
Normal file
24
branches/newMo/src/memory/moTabuList.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef _moTabuList_h
|
||||
#define _moTabuList_h
|
||||
|
||||
#include <memory/moMemory.h>
|
||||
|
||||
/**
|
||||
* Abstract class for the Tabu List
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moTabuList : public moMemory<Neighbor>
|
||||
{
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue