passage du code dans astyle

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1713 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-03-24 10:25:33 +00:00
commit dd66b5e4bd
105 changed files with 3950 additions and 3924 deletions

View file

@ -10,10 +10,10 @@ template< class Neighbor >
class moAspiration : public eoBF<typename Neighbor::EOT &, Neighbor &, bool>
{
public:
typedef typename Neighbor::EOT EOT;
typedef typename Neighbor::EOT EOT;
virtual void init(EOT & _sol) = 0;
virtual void update(EOT & _sol, Neighbor & _neighbor) = 0;
virtual void init(EOT & _sol) = 0;
virtual void update(EOT & _sol, Neighbor & _neighbor) = 0;
};
#endif

View file

@ -11,47 +11,47 @@ class moBestImprAspiration : public moAspiration<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
typedef typename Neighbor::EOT EOT;
/**
* init the best solution
* @param _sol the best solution found
*/
void init(EOT & _sol){
bestFoundSoFar = _sol;
}
/**
* 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;
}
/**
* 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 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 _neighbor fitness is better than the "bestFoundSoFar"
*/
bool operator()(EOT & _sol, Neighbor & _neighbor){
return (bestFoundSoFar.fitness() < _neighbor.fitness());
}
/**
* 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 _neighbor fitness is better than the "bestFoundSoFar"
*/
bool operator()(EOT & _sol, Neighbor & _neighbor) {
return (bestFoundSoFar.fitness() < _neighbor.fitness());
}
/**
* Getter
* @return a reference on the best found so far solution
*/
EOT& getBest(){
return bestFoundSoFar;
}
/**
* Getter
* @return a reference on the best found so far solution
*/
EOT& getBest() {
return bestFoundSoFar;
}
private:
EOT bestFoundSoFar;
EOT bestFoundSoFar;
};
#endif

View file

@ -9,6 +9,6 @@
*/
template< class Neighbor >
class moDiversification : public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool>
{};
{};
#endif

View file

@ -10,34 +10,34 @@ template< class Neighbor >
class moDummyDiversification : public moDiversification<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
typedef typename Neighbor::EOT EOT;
/**
* Init : NOTHIING TO DO
*/
void init(EOT & _sol) {}
/**
* Init : NOTHIING TO DO
*/
void init(EOT & _sol) {}
/**
* Add : NOTHIING TO DO
*/
void add(EOT & _sol, Neighbor & _neighbor) {}
/**
* Add : NOTHIING TO DO
*/
void add(EOT & _sol, Neighbor & _neighbor) {}
/**
* Update : NOTHIING TO DO
*/
void update(EOT & _sol, Neighbor & _neighbor) {}
/**
* Update : NOTHIING TO DO
*/
void update(EOT & _sol, Neighbor & _neighbor) {}
/**
* ClearMemory : NOTHIING TO DO
*/
void clearMemory() {}
/**
* ClearMemory : NOTHIING TO DO
*/
void clearMemory() {}
/**
* @return always false
*/
bool operator()(EOT &){
return false;
}
/**
* @return always false
*/
bool operator()(EOT &) {
return false;
}
};
#endif

View file

@ -10,34 +10,34 @@ template< class Neighbor >
class moDummyIntensification : public moIntensification<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
typedef typename Neighbor::EOT EOT;
/**
* Init : NOTHIING TO DO
*/
void init(EOT & _sol) {}
/**
* Init : NOTHIING TO DO
*/
void init(EOT & _sol) {}
/**
* Add : NOTHIING TO DO
*/
void add(EOT & _sol, Neighbor & _neighbor) {}
/**
* Add : NOTHIING TO DO
*/
void add(EOT & _sol, Neighbor & _neighbor) {}
/**
* Update : NOTHIING TO DO
*/
void update(EOT & _sol, Neighbor & _neighbor) {}
/**
* Update : NOTHIING TO DO
*/
void update(EOT & _sol, Neighbor & _neighbor) {}
/**
* ClearMemory : NOTHIING TO DO
*/
void clearMemory() {}
/**
* ClearMemory : NOTHIING TO DO
*/
void clearMemory() {}
/**
* @return always false
*/
bool operator()(EOT &){
return false;
}
/**
* @return always false
*/
bool operator()(EOT &) {
return false;
}
};
#endif

View file

@ -9,6 +9,6 @@
*/
template< class Neighbor >
class moIntensification : public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool>
{};
{};
#endif

View file

@ -8,32 +8,32 @@ template< class Neighbor >
class moMemory //: public eoObject
{
public:
typedef typename Neighbor::EOT EOT;
typedef typename Neighbor::EOT EOT;
/**
* Init the memory
* @param _sol the current solution
*/
virtual void init(EOT & _sol) = 0;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* clear the memory
*/
virtual void clearMemory() = 0;
};

View file

@ -12,91 +12,91 @@ template<class Neighbor >
class moSolVectorTabuList : public moTabuList<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
typedef typename Neighbor::EOT EOT;
/**
* Constructor
* @param _maxSize maximum size of the tabu list
* @param _howlong how many iteration a move is tabu
*/
moSolVectorTabuList(unsigned int _maxSize, unsigned int _howlong) : maxSize(_maxSize), howlong(_howlong){
tabuList.reserve(_maxSize);
tabuList.resize(0);
}
/**
* Constructor
* @param _maxSize maximum size of the tabu list
* @param _howlong how many iteration a move is tabu
*/
moSolVectorTabuList(unsigned int _maxSize, unsigned int _howlong) : maxSize(_maxSize), howlong(_howlong) {
tabuList.reserve(_maxSize);
tabuList.resize(0);
}
/**
* init the tabuList by clearing the memory
* @param _sol the current solution
*/
virtual void init(EOT & _sol){
clearMemory();
}
/**
* init the tabuList by clearing the memory
* @param _sol the current solution
*/
virtual void init(EOT & _sol) {
clearMemory();
}
/**
* add a new solution in the tabuList
* @param _sol the current solution
* @param _neighbor the current neighbor (unused)
*/
virtual void add(EOT & _sol, Neighbor & _neighbor){
/**
* add a new solution in the tabuList
* @param _sol the current solution
* @param _neighbor the current neighbor (unused)
*/
virtual void add(EOT & _sol, Neighbor & _neighbor) {
if(tabuList.size() < maxSize){
std::pair<EOT, unsigned int> tmp;
tmp.first=_sol;
tmp.second=howlong;
tabuList.push_back(tmp);
}
else{
tabuList[index%maxSize].first = _sol;
tabuList[index%maxSize].second = howlong;
index++;
}
}
if (tabuList.size() < maxSize) {
std::pair<EOT, unsigned int> tmp;
tmp.first=_sol;
tmp.second=howlong;
tabuList.push_back(tmp);
}
else {
tabuList[index%maxSize].first = _sol;
tabuList[index%maxSize].second = howlong;
index++;
}
}
/**
* update the tabulist: NOTHING TO DO
* @param _sol the current solution
* @param _neighbor the current neighbor (unused)
*/
virtual void update(EOT & _sol, Neighbor & _neighbor){
for(unsigned int i=0; i<tabuList.size(); i++)
tabuList[i].second--;
}
/**
* update the tabulist: NOTHING TO DO
* @param _sol the current solution
* @param _neighbor the current neighbor (unused)
*/
virtual void update(EOT & _sol, Neighbor & _neighbor) {
for (unsigned int i=0; i<tabuList.size(); i++)
tabuList[i].second--;
}
/**
* check if the solution is tabu
* @param _sol the current solution
* @param _neighbor the current neighbor (unused)
* @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 ((howlong > 0 && tabuList[i].second > 0 && tabuList[i].first == tmp) || (howlong==0 && tabuList[i].first==tmp))
return true;
}
return false;
}
/**
* check if the solution is tabu
* @param _sol the current solution
* @param _neighbor the current neighbor (unused)
* @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 ((howlong > 0 && tabuList[i].second > 0 && tabuList[i].first == tmp) || (howlong==0 && tabuList[i].first==tmp))
return true;
}
return false;
}
/**
* clearMemory: remove all solution of the tabuList
*/
virtual void clearMemory(){
tabuList.resize(0);
index = 0;
}
/**
* clearMemory: remove all solution of the tabuList
*/
virtual void clearMemory() {
tabuList.resize(0);
index = 0;
}
private:
//tabu list
std::vector< std::pair<EOT, unsigned int> > tabuList;
//maximum size of the tabu list
unsigned int maxSize;
//how many iteration a move is tabu
unsigned int howlong;
//index on the tabulist
unsigned long index;
//tabu list
std::vector< std::pair<EOT, unsigned int> > tabuList;
//maximum size of the tabu list
unsigned int maxSize;
//how many iteration a move is tabu
unsigned int howlong;
//index on the tabulist
unsigned long index;
};

View file

@ -10,15 +10,15 @@ template< class Neighbor >
class moTabuList : public moMemory<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
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;
/**
* 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