Essai du nouveau "modele"

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1655 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-01-20 09:43:06 +00:00
commit c3085595bf
13 changed files with 85 additions and 98 deletions

View file

@ -5,7 +5,7 @@
* Neighbor with a move back function to use in a moFullEvalByModif
*/
template< class EOT , class Fitness >
class moBackableNeighbor : moNeighbor<EOT, Fitness>
class moBackableNeighbor : public moNeighbor<EOT, Fitness>
{
public:
@ -13,7 +13,7 @@ public:
* the move back function
* @param _solution the solution to moveBack
*/
virtual moveBack(EOT & _solution) = 0;
virtual void moveBack(EOT & _solution){}
};

View file

@ -2,24 +2,25 @@
#define _bitNeighbor_h
#include <ga/eoBit.h>
#include <neighborhood/moNeighbor.h>
#include <neighborhood/moBackableNeighbor.h>
/*
contener of the neighbor information
*/
template< class Fitness >
class moBitNeighbor : public moNeighbor< eoBit<Fitness> , Fitness>
class moBitNeighbor : public moBackableNeighbor<eoBit<Fitness>, Fitness>
{
public:
typedef eoBit<Fitness> EOType ;
using moNeighbor< eoBit<Fitness> , Fitness>::fitness;
using moNeighbor<eoBit<Fitness>, Fitness>::fitness;
// describe the neighbor
unsigned bit ;
// empty constructor needed
moBitNeighbor() : moNeighbor<eoBit<Fitness> , Fitness>() { } ;
moBitNeighbor() : moBackableNeighbor<eoBit<Fitness> , Fitness>() { } ;
// copy constructor
moBitNeighbor(const moBitNeighbor & n) : moNeighbor<eoBit<Fitness> , Fitness>(n) {
@ -43,7 +44,11 @@ public:
move the solution
*/
virtual void move(EOType & solution) {
solution[bit] = solution[bit]?false:true ;
solution[bit] = !solution[bit];
}
virtual void moveBack(EOType & solution) {
solution[bit] = !solution[bit];
}
// by default: if the fitness of the current solution is stricly higher than the other neighbor

View file

@ -22,18 +22,18 @@ public:
initialisation of the neighborhood
*/
virtual void init(EOT & solution, Neighbor & _neighbor) {
currentBit = 0 ;
currentBit = 0 ;
_neighbor.bit = currentBit ;
_neighbor.bit = currentBit ;
}
/*
Give the next neighbor
*/
virtual void next(EOT & solution, Neighbor & neighbor) {
currentBit++ ;
currentBit++ ;
neighbor.bit = currentBit ;
neighbor.bit = currentBit ;
}
/*
@ -50,11 +50,3 @@ private:
#endif
// Local Variables:
// coding: iso-8859-1
// mode: C++
// c-file-offsets: ((c . 0))
// c-file-style: "Stroustrup"
// fill-column: 80
// End:

View file

@ -61,7 +61,7 @@ public:
* Copy Constructor
* @param _neighbor to copy
*/
moNeighbor(const moNeighbor<EOType, Fitness>& _neighbor) {
moNeighbor(const moNeighbor<EOT, Fitness>& _neighbor) {
repFitness = _neighbor.fitness();
}
@ -131,7 +131,7 @@ public:
_os << repFitness << ' ' ;
}
private:
protected:
// minimal information on the neighbor : fitness
Fitness repFitness ;