git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1825 331e1502-861f-0410-8da2-ba01fb791d7f

This commit is contained in:
jhumeau 2010-05-26 15:29:42 +00:00
commit 633e961b80
3 changed files with 166 additions and 0 deletions

View file

@ -0,0 +1,34 @@
#ifndef moIncrEvalWrapper_H
#define moIncrEvalWrapper_H
#include <eoEvalFunc.h>
#include <moEval.h>
/*
* (Old fashioned) Incremental evaluation to use with a moMoveNeighbor
* WARNING: Don't use this class unless you are an moMove user.
*/
template<class MoveNeighbor, class M>
class moIncrEvalWrapper : public moEval<MoveNeighbor>
{
public:
using moEval<BackableNeighbor>::EOT EOT;
using moEval<BackableNeighbor>::Fitness Fitness;
moIncrEvalWrapper(moIncrEval<M>& _incr):incr(_incr) {}
/*
* make the evaluation of the current neighbor and update the information on this neighbor
* the evaluation could be incremental
*/
virtual void eval(MoveNeighbor& _neighbor,EOT & _solution) {
_neighbor.fitness(incrEval(*(_neighbor.getMove()), _solution));
}
private:
/** the full evaluation object */
moIncrEval<M> & incrEval;
};
#endif

View file

@ -0,0 +1,71 @@
#ifndef _moMoveNeighbor_h
#define _moMoveNeighbor_h
#include <eo>
#include <neighborhood/moNeighbor.h>
#include <move/moMoveIncrEval.h>
#include <move/moMove.h>
/*
contener of the neighbor informations
*/
template< class M , class Fitness >
class moMoveNeighbor : public moNeighbor <typename M::EOType, Fitness>
{
public:
typedef typename M::EOType EOT;
// empty constructor
moMoveNeighbor() {
move=new M();
};
~moMoveNeighbor() {
delete move;
};
// copy constructeur
moMoveNeighbor(const moMoveNeighbor<M, Fitness> & _n) {
moNeighbor<EOT, Fitness>::operator=(_n);
(*move) = *(_n.getMove());
}
// assignment operator
virtual moMoveNeighbor<M, Fitness> & operator=(const moMoveNeighbor<M, Fitness> & _n) {
moNeighbor <EOT, Fitness>::operator=(_n);
(*move) = *(_n.getMove());
return *this ;
}
/*
* move the solution
*/
virtual void move(EOT & _solution) {
(*move)(_solution);
}
/** Return the class id.
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moMoveNeighbor";
}
void setMove(M* _move) {
move=_move;
}
M* getMove() {
return move;
}
private:
M* move;
};
#endif

View file

@ -0,0 +1,61 @@
#ifndef _moMoveNeighborhood_h
#define _moMoveNeighborhood_h
#include <neighborhood/moMoveNeighbor.h>
#include <neighborhood/moNeighborhood.h>
#include <move/moMoveInit.h>
#include <move/moNextMove.h>
template< class M, class Fitness >
class moMoveNeighborhood : public moNeighborhood <moMoveNeighbor<M, Fitness> >
{
public:
typedef moMoveNeighbor<M, Fitness> Neighbor;
typedef typename M::EOType EOT;
moMoveNeighborhood(moMoveInit<M>& i, moNextMove<M>& n):_init(i), _next(n), isContinue(true) {}
virtual bool hasNeighbor(EOT & solution) {
return true;
}
/*
initialisation of the neighborhood
*/
virtual void init(EOT & solution, Neighbor & current) {
_init(*(current._move), solution);
isContinue=true;
}
/*
Give the next neighbor
*/
virtual void next(EOT & solution, Neighbor & current) {
isContinue=_next(*(current._move), solution);
}
/*
if false, there is no neighbor left to explore
*/
virtual bool cont(EOT & solution) {
return isContinue;
}
/** Return the class id.
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moMoveNeighborhood";
}
private:
moMoveInit<M>& _init;
moNextMove<M>& _next;
bool isContinue;
};
#endif