add new dummy neighbor : XCHangeNeighborDummy
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2304 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
1ab2731502
commit
6c5a1b4e81
1 changed files with 179 additions and 129 deletions
|
|
@ -53,13 +53,17 @@
|
|||
#include <utils/eoUpdater.h>
|
||||
|
||||
#include <eoInit.h>
|
||||
#include <neighborhood/moXChangeNeighbor.h>
|
||||
|
||||
typedef eoBit<eoMinimizingFitness> bitVector;
|
||||
typedef moBitNeighbor<eoMinimizingFitness> bitNeighbor;
|
||||
|
||||
class moDummyRndNeighborhood: public moOrderNeighborhood<bitNeighbor>, public moRndNeighborhood<bitNeighbor> {
|
||||
class moDummyRndNeighborhood: public moOrderNeighborhood<bitNeighbor> ,
|
||||
public moRndNeighborhood<bitNeighbor> {
|
||||
public:
|
||||
moDummyRndNeighborhood(unsigned int a): moOrderNeighborhood<bitNeighbor>(a) {}
|
||||
moDummyRndNeighborhood(unsigned int a) :
|
||||
moOrderNeighborhood<bitNeighbor> (a) {
|
||||
}
|
||||
};
|
||||
|
||||
typedef moDummyRndNeighborhood bitNeighborhood;
|
||||
|
|
@ -68,20 +72,51 @@ typedef EO<int> Solution;
|
|||
|
||||
class moDummyNeighborTest: public moNeighbor<Solution> {
|
||||
public:
|
||||
virtual void move(Solution & _solution) {}
|
||||
virtual void move(Solution & _solution) {
|
||||
}
|
||||
};
|
||||
|
||||
class moDummyBackableNeighbor: public moBackableNeighbor<Solution> {
|
||||
public:
|
||||
virtual void move(Solution & _solution) {}
|
||||
virtual void moveBack(Solution & _solution) {}
|
||||
virtual void move(Solution & _solution) {
|
||||
}
|
||||
virtual void moveBack(Solution & _solution) {
|
||||
}
|
||||
};
|
||||
|
||||
template < class EOT>
|
||||
class XChangeNeighborDummy: public moXChangeNeighbor<EOT> {
|
||||
public:
|
||||
|
||||
XChangeNeighborDummy() :
|
||||
moXChangeNeighbor<EOT> () {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _xChange the number of x-change to do
|
||||
*/
|
||||
|
||||
XChangeNeighborDummy(unsigned int _xChange) :
|
||||
moXChangeNeighbor<EOT> (_xChange) {
|
||||
}
|
||||
/**
|
||||
* Move a solution
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
void move(EOT & _solution) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class moDummyNeighborhoodTest: public moNeighborhood<moDummyNeighborTest> {
|
||||
public:
|
||||
typedef moDummyNeighborTest Neighbor;
|
||||
|
||||
moDummyNeighborhoodTest():i(0),j(0) {}
|
||||
moDummyNeighborhoodTest() :
|
||||
i(0), j(0) {
|
||||
}
|
||||
|
||||
virtual bool hasNeighbor(EOT & _solution) {
|
||||
bool res;
|
||||
|
|
@ -92,8 +127,10 @@ public:
|
|||
i++;
|
||||
return res;
|
||||
}
|
||||
virtual void init(EOT & _solution, Neighbor & _current) {}
|
||||
virtual void next(EOT & _solution, Neighbor & _current) {}
|
||||
virtual void init(EOT & _solution, Neighbor & _current) {
|
||||
}
|
||||
virtual void next(EOT & _solution, Neighbor & _current) {
|
||||
}
|
||||
virtual bool cont(EOT & _solution) {
|
||||
j++;
|
||||
return (j % 10 != 0);
|
||||
|
|
@ -113,15 +150,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class evalOneMax : public moEval< bitNeighbor >
|
||||
{
|
||||
class evalOneMax: public moEval<bitNeighbor> {
|
||||
private:
|
||||
unsigned size;
|
||||
|
||||
public:
|
||||
evalOneMax(unsigned _size) : size(_size) {};
|
||||
evalOneMax(unsigned _size) :
|
||||
size(_size) {
|
||||
}
|
||||
;
|
||||
|
||||
~evalOneMax(void) {} ;
|
||||
~evalOneMax(void) {
|
||||
}
|
||||
;
|
||||
|
||||
void operator()(bitVector& _sol, bitNeighbor& _n) {
|
||||
unsigned int fit = _sol.fitness();
|
||||
|
|
@ -133,15 +174,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class dummyEvalOneMax : public moEval< bitNeighbor >
|
||||
{
|
||||
class dummyEvalOneMax: public moEval<bitNeighbor> {
|
||||
private:
|
||||
unsigned size;
|
||||
|
||||
public:
|
||||
dummyEvalOneMax(unsigned _size) : size(_size) {};
|
||||
dummyEvalOneMax(unsigned _size) :
|
||||
size(_size) {
|
||||
}
|
||||
;
|
||||
|
||||
~dummyEvalOneMax(void) {} ;
|
||||
~dummyEvalOneMax(void) {
|
||||
}
|
||||
;
|
||||
|
||||
void operator()(bitVector& _sol, bitNeighbor& _n) {
|
||||
unsigned int fit = _sol.fitness();
|
||||
|
|
@ -149,11 +194,12 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class monitor1 : public eoMonitor
|
||||
{
|
||||
class monitor1: public eoMonitor {
|
||||
public:
|
||||
|
||||
monitor1(unsigned int& _a): a(_a) {}
|
||||
monitor1(unsigned int& _a) :
|
||||
a(_a) {
|
||||
}
|
||||
|
||||
eoMonitor& operator()() {
|
||||
a++;
|
||||
|
|
@ -168,11 +214,12 @@ private:
|
|||
unsigned int& a;
|
||||
};
|
||||
|
||||
class monitor2 : public eoMonitor
|
||||
{
|
||||
class monitor2: public eoMonitor {
|
||||
public:
|
||||
|
||||
monitor2(unsigned int& _a): a(_a) {}
|
||||
monitor2(unsigned int& _a) :
|
||||
a(_a) {
|
||||
}
|
||||
|
||||
eoMonitor& operator()() {
|
||||
a++;
|
||||
|
|
@ -187,10 +234,11 @@ private:
|
|||
unsigned int& a;
|
||||
};
|
||||
|
||||
class updater1: public eoUpdater
|
||||
{
|
||||
class updater1: public eoUpdater {
|
||||
public:
|
||||
updater1(unsigned int& _a): a(_a) {}
|
||||
updater1(unsigned int& _a) :
|
||||
a(_a) {
|
||||
}
|
||||
|
||||
void operator()() {
|
||||
a++;
|
||||
|
|
@ -213,7 +261,9 @@ public:
|
|||
class dummyInit2: public eoInit<bitVector> {
|
||||
|
||||
public:
|
||||
dummyInit2(unsigned int _size):size(_size){}
|
||||
dummyInit2(unsigned int _size) :
|
||||
size(_size) {
|
||||
}
|
||||
|
||||
void operator()(bitVector& sol) {
|
||||
sol.resize(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue