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 @@
|
|||
/*
|
||||
/*
|
||||
* <moTS.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
|
|
@ -52,118 +52,118 @@
|
|||
Generic algorithm that describes a tabu search.
|
||||
*/
|
||||
template < class M > class moTS:public moAlgo < typename M::EOType >
|
||||
{
|
||||
{
|
||||
|
||||
//!Alias for the type
|
||||
typedef
|
||||
//!Alias for the type
|
||||
typedef
|
||||
typename
|
||||
M::EOType
|
||||
EOT;
|
||||
|
||||
//!Alias for the fitness
|
||||
typedef
|
||||
//!Alias for the fitness
|
||||
typedef
|
||||
typename
|
||||
EOT::Fitness
|
||||
Fitness;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//!Constructor of a moTS specifying all the boxes
|
||||
/*!
|
||||
In this constructor, a moTSMoveLoopExpl is instanciated.
|
||||
//!Constructor of a moTS specifying all the boxes
|
||||
/*!
|
||||
In this constructor, a moTSMoveLoopExpl is instanciated.
|
||||
|
||||
\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
|
||||
\param __cont stop criterion
|
||||
\param __full_eval full evaluation function
|
||||
*/
|
||||
moTS (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (*new moTSMoveLoopExpl < M >
|
||||
(__move_init, __next_move, __incr_eval, __tabu_list,
|
||||
__aspir_crit)), cont (__cont), full_eval (__full_eval)
|
||||
{}
|
||||
|
||||
//! Constructor with less parameters
|
||||
/*!
|
||||
The explorer is given in the parameters.
|
||||
|
||||
\param __move_expl the explorer (generally different that a moTSMoveLoopExpl)
|
||||
\param __cont stop criterion
|
||||
\param __full_eval full evaluation function
|
||||
*/
|
||||
moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
|
||||
cont (__cont),
|
||||
full_eval (__full_eval)
|
||||
\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
|
||||
\param __cont stop criterion
|
||||
\param __full_eval full evaluation function
|
||||
*/
|
||||
moTS (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (*new moTSMoveLoopExpl < M >
|
||||
(__move_init, __next_move, __incr_eval, __tabu_list,
|
||||
__aspir_crit)), cont (__cont), full_eval (__full_eval)
|
||||
{}
|
||||
|
||||
//! Function which launchs the Tabu Search
|
||||
/*!
|
||||
Algorithm of the tabu search.
|
||||
As a moSA or a moHC, it can be used for HYBRIDATION in an evolutionary algorithm.
|
||||
For security a lock (pthread_mutex_t) is closed during the algorithm.
|
||||
//! Constructor with less parameters
|
||||
/*!
|
||||
The explorer is given in the parameters.
|
||||
|
||||
\param __sol a solution to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
bool operator ()(EOT & __sol)
|
||||
{
|
||||
if (__sol.invalid ())
|
||||
{
|
||||
full_eval (__sol);
|
||||
}
|
||||
\param __move_expl the explorer (generally different that a moTSMoveLoopExpl)
|
||||
\param __cont stop criterion
|
||||
\param __full_eval full evaluation function
|
||||
*/
|
||||
moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
|
||||
cont (__cont),
|
||||
full_eval (__full_eval)
|
||||
{}
|
||||
|
||||
M move;
|
||||
//! Function which launchs the Tabu Search
|
||||
/*!
|
||||
Algorithm of the tabu search.
|
||||
As a moSA or a moHC, it can be used for HYBRIDATION in an evolutionary algorithm.
|
||||
For security a lock (pthread_mutex_t) is closed during the algorithm.
|
||||
|
||||
EOT best_sol = __sol, new_sol;
|
||||
\param __sol a solution to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
bool operator ()(EOT & __sol)
|
||||
{
|
||||
if (__sol.invalid ())
|
||||
{
|
||||
full_eval (__sol);
|
||||
}
|
||||
|
||||
cont.init ();
|
||||
M move;
|
||||
|
||||
do
|
||||
{
|
||||
EOT best_sol = __sol, new_sol;
|
||||
|
||||
new_sol = __sol;
|
||||
cont.init ();
|
||||
|
||||
try
|
||||
{
|
||||
do
|
||||
{
|
||||
|
||||
move_expl (__sol, new_sol);
|
||||
new_sol = __sol;
|
||||
|
||||
}
|
||||
catch (EmptySelection & __ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
move_expl (__sol, new_sol);
|
||||
|
||||
/* Updating the best solution
|
||||
found until now ? */
|
||||
if (new_sol.fitness () > __sol.fitness ())
|
||||
{
|
||||
best_sol = new_sol;
|
||||
}
|
||||
}
|
||||
catch (EmptySelection & __ex)
|
||||
{
|
||||
|
||||
__sol = new_sol;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
while (cont (__sol));
|
||||
/* Updating the best solution
|
||||
found until now ? */
|
||||
if (new_sol.fitness () > __sol.fitness ())
|
||||
{
|
||||
best_sol = new_sol;
|
||||
}
|
||||
|
||||
__sol = best_sol;
|
||||
|
||||
return true;
|
||||
}
|
||||
__sol = new_sol;
|
||||
|
||||
private:
|
||||
}
|
||||
while (cont (__sol));
|
||||
|
||||
//! Neighborhood explorer
|
||||
moMoveExpl < M > &move_expl;
|
||||
__sol = best_sol;
|
||||
|
||||
//! Stop criterion
|
||||
moSolContinue < EOT > &cont;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Full evaluation function
|
||||
eoEvalFunc < EOT > &full_eval;
|
||||
};
|
||||
private:
|
||||
|
||||
//! Neighborhood explorer
|
||||
moMoveExpl < M > &move_expl;
|
||||
|
||||
//! Stop criterion
|
||||
moSolContinue < EOT > &cont;
|
||||
|
||||
//! Full evaluation function
|
||||
eoEvalFunc < EOT > &full_eval;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue