diff --git a/trunk/paradiseo-old-mo/src/moIncrEvalWrapper.h b/trunk/paradiseo-old-mo/src/moIncrEvalWrapper.h new file mode 100644 index 000000000..5d4b2b86b --- /dev/null +++ b/trunk/paradiseo-old-mo/src/moIncrEvalWrapper.h @@ -0,0 +1,34 @@ +#ifndef moIncrEvalWrapper_H +#define moIncrEvalWrapper_H + +#include +#include + +/* + * (Old fashioned) Incremental evaluation to use with a moMoveNeighbor + * WARNING: Don't use this class unless you are an moMove user. + */ +template +class moIncrEvalWrapper : public moEval +{ +public: + using moEval::EOT EOT; + using moEval::Fitness Fitness; + + moIncrEvalWrapper(moIncrEval& _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 & incrEval; + +}; + +#endif diff --git a/trunk/paradiseo-old-mo/src/moMoveNeighbor.h b/trunk/paradiseo-old-mo/src/moMoveNeighbor.h new file mode 100644 index 000000000..7550be693 --- /dev/null +++ b/trunk/paradiseo-old-mo/src/moMoveNeighbor.h @@ -0,0 +1,71 @@ +#ifndef _moMoveNeighbor_h +#define _moMoveNeighbor_h + +#include + +#include +#include +#include + + +/* + contener of the neighbor informations +*/ +template< class M , class Fitness > +class moMoveNeighbor : public moNeighbor +{ +public: + + typedef typename M::EOType EOT; + + // empty constructor + moMoveNeighbor() { + move=new M(); + }; + + ~moMoveNeighbor() { + delete move; + }; + + // copy constructeur + moMoveNeighbor(const moMoveNeighbor & _n) { + moNeighbor::operator=(_n); + (*move) = *(_n.getMove()); + } + + // assignment operator + virtual moMoveNeighbor & operator=(const moMoveNeighbor & _n) { + moNeighbor ::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 diff --git a/trunk/paradiseo-old-mo/src/moMoveNeighborhood.h b/trunk/paradiseo-old-mo/src/moMoveNeighborhood.h new file mode 100644 index 000000000..aede5fc44 --- /dev/null +++ b/trunk/paradiseo-old-mo/src/moMoveNeighborhood.h @@ -0,0 +1,61 @@ +#ifndef _moMoveNeighborhood_h +#define _moMoveNeighborhood_h + +#include +#include + +#include +#include + +template< class M, class Fitness > +class moMoveNeighborhood : public moNeighborhood > +{ +public: + + typedef moMoveNeighbor Neighbor; + typedef typename M::EOType EOT; + + moMoveNeighborhood(moMoveInit& i, moNextMove& 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& _init; + moNextMove& _next; + bool isContinue; + +}; + + +#endif