New style for MO
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@787 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
47298125ec
commit
7161febf9c
80 changed files with 2014 additions and 2038 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* <moFirstImprSelect.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
|
|
@ -46,84 +46,84 @@
|
|||
current solution.
|
||||
*/
|
||||
template < class M > class moFirstImprSelect:public moMoveSelect < M >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
||||
//! Procedure which initialise the exploration.
|
||||
/*!
|
||||
It save the current fitness as the initial value for the fitness.
|
||||
*/
|
||||
virtual void init (const Fitness & __fit)
|
||||
{
|
||||
|
||||
valid = false;
|
||||
init_fit = __fit;
|
||||
}
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
||||
//! Procedure which initialise the exploration.
|
||||
/*!
|
||||
It save the current fitness as the initial value for the fitness.
|
||||
*/
|
||||
virtual void init (const Fitness & __fit)
|
||||
{
|
||||
|
||||
valid = false;
|
||||
init_fit = __fit;
|
||||
}
|
||||
|
||||
|
||||
//!Function that indicates if the current move has not improved the fitness.
|
||||
/*!
|
||||
If the given fitness enables an improvment,
|
||||
the move (moMove) should be applied to the current solution.
|
||||
//!Function that indicates if the current move has not improved the fitness.
|
||||
/*!
|
||||
If the given fitness enables an improvment,
|
||||
the move (moMove) should be applied to the current solution.
|
||||
|
||||
\param __move a move.
|
||||
\param __fit a fitness linked to the move.
|
||||
\return TRUE if the move does not improve the fitness.
|
||||
*/
|
||||
bool update (const M & __move, const typename M::EOType::Fitness & __fit)
|
||||
{
|
||||
\param __move a move.
|
||||
\param __fit a fitness linked to the move.
|
||||
\return TRUE if the move does not improve the fitness.
|
||||
*/
|
||||
bool update (const M & __move, const typename M::EOType::Fitness & __fit)
|
||||
{
|
||||
|
||||
if (__fit > init_fit)
|
||||
{
|
||||
if (__fit > init_fit)
|
||||
{
|
||||
|
||||
best_fit = __fit;
|
||||
best_move = __move;
|
||||
valid = true;
|
||||
best_fit = __fit;
|
||||
best_move = __move;
|
||||
valid = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//! Procedure which saved the best move and fitness.
|
||||
/*!
|
||||
\param __move the current move (result of the procedure).
|
||||
\param __fit the current fitness (result of the procedure).
|
||||
\throws EmptySelection if no move has improved the fitness.
|
||||
*/
|
||||
void operator () (M & __move, Fitness & __fit) throw (EmptySelection)
|
||||
{
|
||||
//! Procedure which saved the best move and fitness.
|
||||
/*!
|
||||
\param __move the current move (result of the procedure).
|
||||
\param __fit the current fitness (result of the procedure).
|
||||
\throws EmptySelection if no move has improved the fitness.
|
||||
*/
|
||||
void operator () (M & __move, Fitness & __fit) throw (EmptySelection)
|
||||
{
|
||||
|
||||
if (valid)
|
||||
{
|
||||
__move = best_move;
|
||||
__fit = best_fit;
|
||||
}
|
||||
else
|
||||
throw EmptySelection ();
|
||||
}
|
||||
if (valid)
|
||||
{
|
||||
__move = best_move;
|
||||
__fit = best_fit;
|
||||
}
|
||||
else
|
||||
throw EmptySelection ();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! Allow to know if at least one move has improved the solution.
|
||||
bool valid;
|
||||
//! Allow to know if at least one move has improved the solution.
|
||||
bool valid;
|
||||
|
||||
//! Best stored movement.
|
||||
M best_move;
|
||||
//! Best stored movement.
|
||||
M best_move;
|
||||
|
||||
//! Initial fitness.
|
||||
Fitness init_fit;
|
||||
//! Initial fitness.
|
||||
Fitness init_fit;
|
||||
|
||||
//! Best stored fitness.
|
||||
Fitness best_fit;
|
||||
//! Best stored fitness.
|
||||
Fitness best_fit;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue