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:
canape 2007-11-16 11:25:54 +00:00
commit 7161febf9c
80 changed files with 2014 additions and 2038 deletions

View file

@ -1,4 +1,4 @@
/*
/*
* <moTSMoveLoopExpl.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -53,105 +53,105 @@
It is used by a moTS.
*/
template < class M > class moTSMoveLoopExpl:public moMoveLoopExpl < M >
{
//!Alias for the type
typedef typename M::EOType EOT;
//!Alias for the fitness
typedef typename M::EOType::Fitness Fitness;
public:
//!Constructor
/*!
\param __move_init move initialisation
\param __next_move neighborhood explorer
\param __incr_eval efficient evaluation
\param __tabu_list tabu list
\param __aspir_crit aspiration criterion
*/
moTSMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit):
move_init (__move_init),
next_move (__next_move),
incr_eval (__incr_eval),
tabu_list (__tabu_list), aspir_crit (__aspir_crit)
{
tabu_list.init ();
aspir_crit.init ();
}
//!Alias for the type
typedef typename M::EOType EOT;
//!Procedure which lauches the exploration
/*!
The exploration continues while the chosen move is not in the tabu list
or the aspiration criterion is true. If these 2 conditions are not true, the
exploration stops if the move selector update function returns false.
//!Alias for the fitness
typedef typename M::EOType::Fitness Fitness;
\param __old_sol the initial solution
\param __new_sol the new solution
*/
void operator () (const EOT & __old_sol, EOT & __new_sol)
{
public:
M move;
//!Constructor
/*!
\param __move_init move initialisation
\param __next_move neighborhood explorer
\param __incr_eval efficient evaluation
\param __tabu_list tabu list
\param __aspir_crit aspiration criterion
*/
moTSMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit):
move_init (__move_init),
next_move (__next_move),
incr_eval (__incr_eval),
tabu_list (__tabu_list), aspir_crit (__aspir_crit)
{
tabu_list.init ();
aspir_crit.init ();
}
//!Procedure which lauches the exploration
/*!
The exploration continues while the chosen move is not in the tabu list
or the aspiration criterion is true. If these 2 conditions are not true, the
exploration stops if the move selector update function returns false.
\param __old_sol the initial solution
\param __new_sol the new solution
*/
void operator () (const EOT & __old_sol, EOT & __new_sol)
{
M move;
move_init (move, __old_sol); /* Restarting the exploration of
of the neighborhood ! */
move_init (move, __old_sol); /* Restarting the exploration of
of the neighborhood ! */
move_select.init (__old_sol.fitness ());
move_select.init (__old_sol.fitness ());
do
{
do
{
Fitness fit = incr_eval (move, __old_sol);
Fitness fit = incr_eval (move, __old_sol);
if (!tabu_list (move, __old_sol) || aspir_crit (move, fit))
{
if (!move_select.update (move, fit))
break;
}
if (!tabu_list (move, __old_sol) || aspir_crit (move, fit))
{
if (!move_select.update (move, fit))
break;
}
}
while (next_move (move, __old_sol));
}
while (next_move (move, __old_sol));
M best_move;
M best_move;
Fitness best_move_fit;
Fitness best_move_fit;
move_select (best_move, best_move_fit);
move_select (best_move, best_move_fit);
__new_sol.fitness (best_move_fit);
best_move (__new_sol);
__new_sol.fitness (best_move_fit);
best_move (__new_sol);
/* Removing moves that are
no more tabu */
tabu_list.update ();
/* Removing moves that are
no more tabu */
tabu_list.update ();
// Updating the tabu list
tabu_list.add (best_move, __new_sol);
}
// Updating the tabu list
tabu_list.add (best_move, __new_sol);
}
private:
private:
//!Move initialisation
moMoveInit < M > &move_init;
//!Move initialisation
moMoveInit < M > &move_init;
//!Neighborhood explorer
moNextMove < M > &next_move;
//!Neighborhood explorer
moNextMove < M > &next_move;
//!Efficient evaluation
moMoveIncrEval < M > &incr_eval;
//!Efficient evaluation
moMoveIncrEval < M > &incr_eval;
//!Move selector
moBestImprSelect < M > move_select;
//!Move selector
moBestImprSelect < M > move_select;
//!Tabu list
moTabuList < M > &tabu_list;
//!Tabu list
moTabuList < M > &tabu_list;
//!Aspiration criterion
moAspirCrit < M > &aspir_crit;
};
//!Aspiration criterion
moAspirCrit < M > &aspir_crit;
};
#endif