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
|
|
@ -1,64 +0,0 @@
|
|||
#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,69 +0,0 @@
|
|||
#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
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
#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
|
||||
Loading…
Reference in a new issue