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:
parent
d7496cafff
commit
dd66b5e4bd
105 changed files with 3950 additions and 3924 deletions
|
|
@ -45,10 +45,10 @@ class moBackableNeighbor : virtual public moNeighbor<EOT, Fitness>
|
|||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* the move back function
|
||||
* @param _solution the solution to moveBack
|
||||
*/
|
||||
/**
|
||||
* the move back function
|
||||
* @param _solution the solution to moveBack
|
||||
*/
|
||||
virtual void moveBack(EOT & _solution)=0;
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public:
|
|||
* @param _solution the solution to move
|
||||
*/
|
||||
virtual void move(EOT & _solution) {
|
||||
_solution[key] = !_solution[key];
|
||||
_solution[key] = !_solution[key];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +64,7 @@ public:
|
|||
* @param _solution the solution to move back
|
||||
*/
|
||||
virtual void moveBack(EOT & _solution) {
|
||||
_solution[key] = !_solution[key];
|
||||
_solution[key] = !_solution[key];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,39 +72,39 @@ public:
|
|||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moBitNeighbor";
|
||||
return "moBitNeighbor";
|
||||
}
|
||||
|
||||
/**
|
||||
* Read object.\ \
|
||||
* Calls base class, just in case that one had something to do.
|
||||
* The read and print methods should be compatible and have the same format.
|
||||
* In principle, format is "plain": they just print a number
|
||||
* @param _is a std::istream.
|
||||
* @throw runtime_std::exception If a valid object can't be read.
|
||||
*/
|
||||
virtual void readFrom(std::istream& _is) {
|
||||
std::string fitness_str;
|
||||
int pos = _is.tellg();
|
||||
_is >> fitness_str;
|
||||
if (fitness_str == "INVALID") {
|
||||
throw std::runtime_error("invalid fitness");
|
||||
}
|
||||
else {
|
||||
Fitness repFit ;
|
||||
_is.seekg(pos); // rewind
|
||||
_is >> repFit;
|
||||
_is >> key;
|
||||
fitness(repFit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read object.\ \
|
||||
* Calls base class, just in case that one had something to do.
|
||||
* The read and print methods should be compatible and have the same format.
|
||||
* In principle, format is "plain": they just print a number
|
||||
* @param _is a std::istream.
|
||||
* @throw runtime_std::exception If a valid object can't be read.
|
||||
*/
|
||||
virtual void readFrom(std::istream& _is) {
|
||||
std::string fitness_str;
|
||||
int pos = _is.tellg();
|
||||
_is >> fitness_str;
|
||||
if (fitness_str == "INVALID"){
|
||||
throw std::runtime_error("invalid fitness");
|
||||
}
|
||||
else{
|
||||
Fitness repFit ;
|
||||
_is.seekg(pos); // rewind
|
||||
_is >> repFit;
|
||||
_is >> key;
|
||||
fitness(repFit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write object. Called printOn since it prints the object _on_ a stream.
|
||||
* @param _os A std::ostream.
|
||||
*/
|
||||
virtual void printOn(std::ostream& _os) const {
|
||||
_os << fitness() << ' ' << key << std::endl;
|
||||
_os << fitness() << ' ' << key << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -50,22 +50,22 @@ public:
|
|||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moIndexNeighbor() : moNeighbor<EOT, Fitness>(), key(0){}
|
||||
moIndexNeighbor() : moNeighbor<EOT, Fitness>(), key(0) {}
|
||||
|
||||
/**
|
||||
* Copy Constructor
|
||||
*/
|
||||
moIndexNeighbor(const moIndexNeighbor& _n) : moNeighbor<EOT, Fitness>(_n) {
|
||||
this->key = _n.key ;
|
||||
this->key = _n.key ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
*/
|
||||
virtual moIndexNeighbor<EOT, Fitness> & operator=(const moIndexNeighbor<EOT, Fitness> & _source) {
|
||||
moNeighbor<EOT, Fitness>::operator=(_source);
|
||||
this->key = _source.key ;
|
||||
return *this ;
|
||||
moNeighbor<EOT, Fitness>::operator=(_source);
|
||||
this->key = _source.key ;
|
||||
return *this ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -73,23 +73,23 @@ public:
|
|||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moIndexNeighbor";
|
||||
return "moIndexNeighbor";
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter
|
||||
* @return index of the IndexNeighbor
|
||||
*/
|
||||
unsigned int index(){
|
||||
return key;
|
||||
unsigned int index() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter
|
||||
* @param _key index of the IndexNeighbor
|
||||
*/
|
||||
void index(unsigned int _key){
|
||||
key=_key;
|
||||
void index(unsigned int _key) {
|
||||
key=_key;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -44,23 +44,23 @@ template< class Neighbor >
|
|||
class moIndexNeighborhood : virtual public moNeighborhood<Neighbor>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moIndexNeighborhood(unsigned int _neighborhoodSize):neighborhoodSize(_neighborhoodSize){}
|
||||
moIndexNeighborhood(unsigned int _neighborhoodSize):neighborhoodSize(_neighborhoodSize) {}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moIndexNeighborhood";
|
||||
return "moIndexNeighborhood";
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -47,30 +47,30 @@ template< class EOType , class Fitness >
|
|||
class moNeighbor : public eoObject, public eoPersistent
|
||||
{
|
||||
public:
|
||||
typedef EOType EOT;
|
||||
typedef EOType EOT;
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moNeighbor(){}
|
||||
moNeighbor() {}
|
||||
|
||||
/**
|
||||
* Copy Constructor
|
||||
* @param _neighbor to copy
|
||||
*/
|
||||
moNeighbor(const moNeighbor<EOT, Fitness>& _neighbor) {
|
||||
repFitness = _neighbor.fitness();
|
||||
repFitness = _neighbor.fitness();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
* @param _neighbor the neighbor to assign
|
||||
* @return a neighbor equal to the other
|
||||
*/
|
||||
virtual moNeighbor<EOT, Fitness>& operator=(const moNeighbor<EOT, Fitness>& _neighbor) {
|
||||
repFitness = _neighbor.fitness();
|
||||
return (*this);
|
||||
repFitness = _neighbor.fitness();
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move a solution
|
||||
* @param _solution the related solution
|
||||
|
|
@ -82,32 +82,34 @@ public:
|
|||
* @return fitness of the neighbor
|
||||
*/
|
||||
const Fitness fitness() const {
|
||||
return repFitness;
|
||||
return repFitness;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get fitness as reference, useful when fitness is set in a multi-stage way, e.g., MOFitness gets performance information, is subsequently ranked
|
||||
* @return fitness as reference of the neighbor
|
||||
*/
|
||||
Fitness& fitnessReference() {
|
||||
return repFitness;
|
||||
return repFitness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fitness. At the same time, validates it.
|
||||
* @param _fitness new fitness value.
|
||||
*/
|
||||
void fitness(const Fitness& _fitness){
|
||||
repFitness = _fitness;
|
||||
}
|
||||
|
||||
void fitness(const Fitness& _fitness) {
|
||||
repFitness = _fitness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const { return "moNeighbor"; }
|
||||
|
||||
virtual std::string className() const {
|
||||
return "moNeighbor";
|
||||
}
|
||||
|
||||
/**
|
||||
* Read object.
|
||||
* Calls base class, just in case that one had something to do.
|
||||
|
|
@ -116,7 +118,7 @@ public:
|
|||
* @param _is a std::istream.
|
||||
*/
|
||||
virtual void readFrom(std::istream& _is) {
|
||||
_is >> repFitness;
|
||||
_is >> repFitness;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -124,9 +126,9 @@ public:
|
|||
* @param _os A std::ostream.
|
||||
*/
|
||||
virtual void printOn(std::ostream& _os) const {
|
||||
_os << repFitness << std::endl;
|
||||
_os << repFitness << std::endl;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
// minimal information on the neighbor : fitness
|
||||
Fitness repFitness ;
|
||||
|
|
|
|||
|
|
@ -44,21 +44,21 @@ template< class Neighbor >
|
|||
class moNeighborhood : public eoObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moNeighborhood(){}
|
||||
moNeighborhood() {}
|
||||
|
||||
/**
|
||||
* @return if the neighborhood is random
|
||||
*/
|
||||
virtual bool isRandom(){
|
||||
return false;
|
||||
virtual bool isRandom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -94,7 +94,7 @@ public:
|
|||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moNeighborhood";
|
||||
return "moNeighborhood";
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -45,21 +45,21 @@ class moOrderNeighborhood : public moIndexNeighborhood<N>
|
|||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef N Neighbor;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moOrderNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), currentIndex(0){}
|
||||
moOrderNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), currentIndex(0) {}
|
||||
|
||||
/**
|
||||
* Test if it exist a neighbor
|
||||
|
|
@ -67,7 +67,7 @@ public:
|
|||
* @return true if the neighborhood was not empty
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT& _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -76,8 +76,8 @@ public:
|
|||
* @param _neighbor the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _neighbor) {
|
||||
currentIndex = 0 ;
|
||||
_neighbor.index(currentIndex) ;
|
||||
currentIndex = 0 ;
|
||||
_neighbor.index(currentIndex) ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -86,8 +86,8 @@ public:
|
|||
* @param _neighbor the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _neighbor) {
|
||||
currentIndex++ ;
|
||||
_neighbor.index(currentIndex);
|
||||
currentIndex++ ;
|
||||
_neighbor.index(currentIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -98,15 +98,15 @@ public:
|
|||
* @return true if there is again a neighbor to explore
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return (currentIndex < neighborhoodSize - 1) ;
|
||||
return (currentIndex < neighborhoodSize - 1) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter
|
||||
* @return the position in the Neighborhood
|
||||
*/
|
||||
unsigned int position(){
|
||||
return currentIndex;
|
||||
unsigned int position() {
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,7 +114,7 @@ public:
|
|||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moOrderNeighborhood";
|
||||
return "moOrderNeighborhood";
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
template< class Neighbor >
|
||||
class moRndNeighborhood : virtual public moNeighborhood<Neighbor>{
|
||||
class moRndNeighborhood : virtual public moNeighborhood<Neighbor> {
|
||||
|
||||
public:
|
||||
|
||||
bool isRandom(){
|
||||
return true;
|
||||
}
|
||||
bool isRandom() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -47,20 +47,20 @@ class moRndWithReplNeighborhood : public moIndexNeighborhood<N>, public moRndNei
|
|||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef N Neighbor;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moRndWithReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize){}
|
||||
moRndWithReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize) {}
|
||||
|
||||
/**
|
||||
* Test if it exist a neighbor
|
||||
|
|
@ -68,7 +68,7 @@ public:
|
|||
* @return true if the neighborhood was not empty
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT& _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -77,7 +77,7 @@ public:
|
|||
* @param _neighbor the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _neighbor) {
|
||||
_neighbor.index(rng.random(neighborhoodSize));
|
||||
_neighbor.index(rng.random(neighborhoodSize));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -86,7 +86,7 @@ public:
|
|||
* @param _neighbor the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _neighbor) {
|
||||
_neighbor.index(rng.random(neighborhoodSize));
|
||||
_neighbor.index(rng.random(neighborhoodSize));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -95,7 +95,7 @@ public:
|
|||
* @return true if there is again a neighbor to explore
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -103,7 +103,7 @@ public:
|
|||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moRndWithReplNeighborhood";
|
||||
return "moRndWithReplNeighborhood";
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,22 +47,22 @@ class moRndWithoutReplNeighborhood : public moIndexNeighborhood<N>, public moRnd
|
|||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef N Neighbor;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moRndWithoutReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), maxIndex(0){
|
||||
for(unsigned int i=0; i < neighborhoodSize; i++)
|
||||
indexVector.push_back(i);
|
||||
moRndWithoutReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), maxIndex(0) {
|
||||
for (unsigned int i=0; i < neighborhoodSize; i++)
|
||||
indexVector.push_back(i);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -71,7 +71,7 @@ public:
|
|||
* @return true if the neighborhood was not empty
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT& _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -80,14 +80,14 @@ public:
|
|||
* @param _neighbor the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _neighbor) {
|
||||
unsigned int i, tmp;
|
||||
maxIndex = neighborhoodSize ;
|
||||
i = rng.random(maxIndex);
|
||||
_neighbor.index(indexVector[i]);
|
||||
tmp=indexVector[i];
|
||||
indexVector[i]=indexVector[maxIndex-1];
|
||||
indexVector[maxIndex-1]=tmp;
|
||||
maxIndex--;
|
||||
unsigned int i, tmp;
|
||||
maxIndex = neighborhoodSize ;
|
||||
i = rng.random(maxIndex);
|
||||
_neighbor.index(indexVector[i]);
|
||||
tmp=indexVector[i];
|
||||
indexVector[i]=indexVector[maxIndex-1];
|
||||
indexVector[maxIndex-1]=tmp;
|
||||
maxIndex--;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,31 +96,31 @@ public:
|
|||
* @param _neighbor the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _neighbor) {
|
||||
unsigned int i, tmp;
|
||||
i = rng.random(maxIndex);
|
||||
_neighbor.index(indexVector[i]);
|
||||
tmp=indexVector[i];
|
||||
indexVector[i]=indexVector[maxIndex-1];
|
||||
indexVector[maxIndex-1]=tmp;
|
||||
maxIndex--;
|
||||
unsigned int i, tmp;
|
||||
i = rng.random(maxIndex);
|
||||
_neighbor.index(indexVector[i]);
|
||||
tmp=indexVector[i];
|
||||
indexVector[i]=indexVector[maxIndex-1];
|
||||
indexVector[maxIndex-1]=tmp;
|
||||
maxIndex--;
|
||||
}
|
||||
|
||||
/**
|
||||
* test if all neighbors are explore or not,if false, there is no neighbor left to explore
|
||||
* maxIndex is number of neighbors
|
||||
* maxIndex is number of neighbors
|
||||
* @param _solution the solution to explore
|
||||
* @return true if there is again a neighbor to explore
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return (maxIndex > 0) ;
|
||||
return (maxIndex > 0) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter
|
||||
* @return the position in the Neighborhood
|
||||
*/
|
||||
unsigned int position(){
|
||||
return indexVector[maxIndex];
|
||||
unsigned int position() {
|
||||
return indexVector[maxIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -128,7 +128,7 @@ public:
|
|||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moRndWithoutReplNeighborhood";
|
||||
return "moRndWithoutReplNeighborhood";
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue