Test des Neighborhoods ajouté

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1665 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-01-21 15:29:03 +00:00
commit 88afa96663
8 changed files with 164 additions and 14 deletions

View file

@ -49,18 +49,15 @@ public:
using moNeighbor<eoBit<Fitness>, Fitness>::fitness;
// describe the neighbor
unsigned bit ;
/**
* Default Constructor
*/
moBitNeighbor() : moBackableNeighbor<eoBit<Fitness> , Fitness>() { } ;
moBitNeighbor() : moBackableNeighbor<eoBit<Fitness> , Fitness>(), bit(0) { } ;
/**
* Copy Constructor
*/
moBitNeighbor(const moBitNeighbor& _n) : moNeighbor<eoBit<Fitness> , Fitness>(_n) {
moBitNeighbor(const moBitNeighbor& _n) : moBackableNeighbor<eoBit<Fitness> , Fitness>(_n) {
this->bit = _n.bit ;
} ;
@ -68,7 +65,7 @@ public:
* Constructor
* @param _b index
*/
moBitNeighbor(unsigned int _b) : moNeighbor<eoBit<Fitness> , Fitness>() , bit(_b) { } ;
moBitNeighbor(unsigned int _b) : moBackableNeighbor<eoBit<Fitness> , Fitness>() , bit(_b) { } ;
/**
* Assignment operator
@ -135,6 +132,25 @@ public:
_os << fitness() << ' ' << bit << std::endl;
}
/**
* Getter
* @return index of the bitNeighbor
*/
unsigned int index(){
return bit;
}
/**
* Setter
* @param index of the bitNeighbor
*/
void index(unsigned int _bit){
bit=_bit;
}
private:
// describe the neighbor
unsigned int bit ;
};

View file

@ -36,6 +36,7 @@
#define _bitNeighborhood_h
#include <neighborhood/moNeighborhood.h>
#include <neighborhood/moBitNeighbor.h>
/**
* Neighborhood related to a vector of Bit
@ -50,7 +51,7 @@ public:
/**
* Default Constructor
*/
moBitNeighborhood() : moNeighborhood<Neighbor>() { }
moBitNeighborhood() : moNeighborhood<Neighbor>(), currentBit(0) { }
/**
* Test if it exist a neighbor
@ -68,7 +69,7 @@ public:
*/
virtual void init(EOT & _solution, Neighbor & _neighbor) {
currentBit = 0 ;
_neighbor.bit = currentBit ;
_neighbor.index(currentBit) ;
}
/**
@ -78,7 +79,7 @@ public:
*/
virtual void next(EOT & _solution, Neighbor & _neighbor) {
currentBit++ ;
_neighbor.bit = currentBit ;
_neighbor.index(currentBit);
}
/**
@ -88,8 +89,22 @@ public:
*/
virtual bool cont(EOT & _solution) {
return (currentBit < _solution.size()) ;
}
}
/**
* Getter
* @return the position in the Neighborhood
*/
unsigned int position(){
return currentBit;
}
/**
* Return the class id.
* @return the class name as a std::string
*/
virtual std::string className() const { return "moBitNeighborhood"; }
private:
//Position in the neighborhood
unsigned int currentBit;

View file

@ -81,7 +81,7 @@ public:
* Get the fitness of the neighbor
* @return fitness of the neighbor
*/
const Fitness& fitness() const {
const Fitness fitness() const {
return repFitness;
}
@ -124,7 +124,7 @@ public:
* @param _os A std::ostream.
*/
virtual void printOn(std::ostream& _os) const {
_os << repFitness << ' ' ;
_os << repFitness << std::endl;
}
protected: