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

This commit is contained in:
jhumeau 2009-03-18 14:15:11 +00:00
commit 1d61b834d6
8 changed files with 132 additions and 51 deletions

View file

@ -39,8 +39,7 @@
#ifndef _MOEOSUBNEIGHBORHOODEXPLORER_H
#define _MOEOSUBNEIGHBORHOODEXPLORER_H
#include <eo>
#include <moeo>
#include <eoPop.h>
#include <moMove.h>
#include <moMoveInit.h>
#include <moNextMove.h>
@ -48,16 +47,25 @@
#include <moeoPopNeighborhoodExplorer.h>
/**
* TODO
* Explorer which explore a part of the neighborhood
*/
template < class Move >
class moeoSubNeighborhoodExplorer : public moeoPopNeighborhoodExplorer < Move >
{
/** Alias for the type */
typedef typename Move::EOType MOEOT;
/** Alias for the objeciveVector */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
public:
/**
* Ctor
* @param _moveInit the move initializer
* @param _nextMove allow to do or not a move
* @param _incrEval a (generally) efficient evaluation fonction
* @param _number the number of neighbor to explore
*/
moeoSubNeighborhoodExplorer(
moMoveInit < Move > & _moveInit,
moNextMove < Move > & _nextMove,
@ -65,45 +73,58 @@ public:
unsigned int _number)
: moveInit(_moveInit), nextMove(_nextMove), incrEval(_incrEval), number(_number){}
/**
* functor to explore the neighborhood
* @param _src the population to explore
* @param _select contains index of individuals from the population to explore
* @param _dest contains new generated individuals
*/
void operator()(eoPop < MOEOT > & _src, std::vector <unsigned int> _select, eoPop < MOEOT > & _dest)
{
if(number > 0){
for(unsigned int i=0; i<_select.size(); i++)
explore(_src, _select[i], _dest);
explore(_src[_select[i]], _dest);
}
}
private:
void explore(eoPop < MOEOT > & _src, unsigned int _i, eoPop < MOEOT > & _dest)
/**
* explorer of one individual
* @param _src the individual to explore
* @param _dest contains new generated individuals
*/
void explore(MOEOT & _src, eoPop < MOEOT > & _dest)
{
unsigned int tmp = number;
moveInit(move, _src[_i]);
moveInit(move, _src);
do
{
objVec = incrEval(move, _src[_i]);
_dest.push_back(_src[_i]);
objVec = incrEval(move, _src);
_dest.push_back(_src);
move(_dest.back());
_dest.back().objectiveVector(objVec);
_dest.back().flag(0);
tmp--;
}
while (nextMove(move, _src[_i]) && (tmp > 0));
if(!nextMove(move, _src[_i]))
_src[_i].flag(1);
while (nextMove(move, _src) && (tmp > 0));
if(!nextMove(move, _src))
_src.flag(1);
}
/** Move */
Move move;
/** ObjectiveVector */
ObjectiveVector objVec;
/** the move initializer */
moMoveInit < Move > & moveInit;
/** the neighborhood explorer */
/** the entity which allow to do a move */
moNextMove < Move > & nextMove;
/** the incremental evaluation */
moMoveIncrEval < Move, ObjectiveVector > & incrEval;
/** number of neighbor to explore for each solution*/
/** number of neighbor to explore for each selected individual*/
unsigned int number;
};
#endif /*_MOEOEXHAUSTIVENEIGHBORHOODEXPLORER_H_*/
#endif /*_MOEOSUBNEIGHBORHOODEXPLORER_H_*/