Arborescence modifiée
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1651 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
0f370ac9e1
commit
d009ffcc19
9 changed files with 14 additions and 9 deletions
64
branches/newMo/src/eval/moFullEvalBitNeighbor.h
Normal file
64
branches/newMo/src/eval/moFullEvalBitNeighbor.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#ifndef _fullEvalBitNeighbor_h
|
||||
#define _fullEvalBitNeighbor_h
|
||||
|
||||
#include <neighborhood/moBitNeighbor.h>
|
||||
#include <ga.h>
|
||||
|
||||
/*
|
||||
contener of the neighbor information
|
||||
*/
|
||||
template< class Fitness >
|
||||
class moFullEvalBitNeighbor : public moBitNeighbor<Fitness>
|
||||
{
|
||||
public:
|
||||
typedef eoBit<Fitness> EOType ;
|
||||
|
||||
using moBitNeighbor<Fitness>::bit ;
|
||||
|
||||
// empty constructor needed
|
||||
moFullEvalBitNeighbor() : moBitNeighbor<Fitness>() { } ;
|
||||
|
||||
moFullEvalBitNeighbor(unsigned b) : moBitNeighbor<Fitness>(bit) { } ;
|
||||
|
||||
/*
|
||||
make the evaluation of the current neighbor and update the information on this neighbor
|
||||
*/
|
||||
virtual void eval(EOType & solution) {
|
||||
Fitness fit = solution.fitness();
|
||||
|
||||
solution[bit] = solution[bit]?false:true ;
|
||||
|
||||
(*fullEval)(solution);
|
||||
|
||||
fitness(solution.fitness());
|
||||
|
||||
solution[bit] = solution[bit]?false:true ;
|
||||
|
||||
solution.fitness(fit);
|
||||
};
|
||||
|
||||
static void setFullEvalFunc(eoEvalFunc<EOType> & eval) {
|
||||
fullEval = & eval ;
|
||||
}
|
||||
|
||||
static eoEvalFunc<EOType> * fullEval ;
|
||||
|
||||
/** Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const { return "moFullEvalBitNeighbor"; }
|
||||
};
|
||||
|
||||
template<class Fitness>
|
||||
eoEvalFunc< eoBit<Fitness> > * moFullEvalBitNeighbor<Fitness>::fullEval = NULL ;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// coding: iso-8859-1
|
||||
// mode: C++
|
||||
// c-file-offsets: ((c . 0))
|
||||
// c-file-style: "Stroustrup"
|
||||
// fill-column: 80
|
||||
// End:
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#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