git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1650 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
01feefce30
commit
0f370ac9e1
14 changed files with 269 additions and 185 deletions
14
branches/newMo/src/eval/moEval.h
Normal file
14
branches/newMo/src/eval/moEval.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef moEval_H
|
||||
#define moEval_H
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
template<class Neighbor>
|
||||
class moEval : public eoBF<typename Neighbor::EOType &, Neighbor&, void>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOType EOT;
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
};
|
||||
|
||||
#endif
|
||||
45
branches/newMo/src/eval/moFullEvalByCopy.h
Normal file
45
branches/newMo/src/eval/moFullEvalByCopy.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef moFullEvalByCopy_H
|
||||
#define moFullEvalByCopy_H
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
#include <moEval.h>
|
||||
|
||||
template<class Neighbor>
|
||||
class moFullEvalByCopy : public moEval<Neighbor>
|
||||
{
|
||||
public:
|
||||
using moEval<Neighbor>::EOT EOT;
|
||||
using moEval<Neighbor>::Fitness Fitness;
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
* @param _eval the full evaluation object
|
||||
*/
|
||||
moFullEvalByCopy(eoEvalFunc<EOT> & _eval) : eval(_eval) {}
|
||||
|
||||
/**
|
||||
* Full evaluation of the neighbor by copy
|
||||
* @param _sol current solution
|
||||
* @param _neighbor the neighbor to be evaluated
|
||||
*/
|
||||
void operator()(EOT & _sol, Neighbor & _neighbor)
|
||||
{
|
||||
// tmp solution
|
||||
EOT tmp(_sol);
|
||||
// move tmp solution wrt _neighbor
|
||||
_neighbor.(tmp);
|
||||
// eval copy
|
||||
tmp.invalidate();
|
||||
eval(tmp);
|
||||
// set the fitness value to the neighbor
|
||||
_neighbor.fitness(tmp.fitness());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** the full evaluation object */
|
||||
eoEvalFunc<EOT> & eval;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
56
branches/newMo/src/eval/moFullEvalByModif.h
Normal file
56
branches/newMo/src/eval/moFullEvalByModif.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef moFullEvalByModif_H
|
||||
#define moFullEvalByModif_H
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
#include <moEval.h>
|
||||
|
||||
/*
|
||||
* Full evaluation to use with a moBackableNeighbor
|
||||
*/
|
||||
template<class BackableNeighbor>
|
||||
class moFullEvalByModif : public moEval<BackableNeighbor>
|
||||
{
|
||||
public:
|
||||
using moEval<BackableNeighbor>::EOT EOT;
|
||||
using moEval<BackableNeighbor>::Fitness Fitness;
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
* @param _eval the full evaluation object
|
||||
*/
|
||||
moFullEvalByCopy(eoEvalFunc<EOT> & _eval) : eval(_eval) {}
|
||||
|
||||
/**
|
||||
* Full evaluation of the neighbor by copy
|
||||
* @param _sol current solution
|
||||
* @param _neighbor the neighbor to be evaluated
|
||||
*/
|
||||
void operator()(EOT & _sol, BackableNeighbor & _neighbor)
|
||||
{
|
||||
// tmp fitness value of the current solution
|
||||
Fitness tmpFit;
|
||||
|
||||
// save current fitness value
|
||||
tmpFit = _sol.fitness();
|
||||
|
||||
// move the current solution wrt _neighbor
|
||||
_neighbor.move(_sol);
|
||||
// eval the modified solution
|
||||
_sol.invalidate();
|
||||
eval(_sol);
|
||||
// set the fitness value to the neighbor
|
||||
_neighbor.fitness(_sol.fitness());
|
||||
// move the current solution back
|
||||
_neighbor.moveBack(_sol);
|
||||
// set the fitness back
|
||||
_sol.fitness(tmpFit);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/** the full evaluation object */
|
||||
eoEvalFunc<EOT> & eval;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
34
branches/newMo/src/eval/moIncrEvalWrapper.h
Normal file
34
branches/newMo/src/eval/moIncrEvalWrapper.h
Normal 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 increamental
|
||||
*/
|
||||
virtual void eval(MoveNeighbor& _neighbor,EOT & _solution){
|
||||
_neighbor.fitness(incrEval(*(_neighbor.getMove()), _solution));
|
||||
}
|
||||
|
||||
private:
|
||||
/** the full evaluation object */
|
||||
moIncrEval<M> & incrEval;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue