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
|
|
@ -44,8 +44,6 @@
|
|||
moHC, moTS and moSA are 3 examples of algorithm of the paradiseo-mo library.
|
||||
*/
|
||||
template < class EOT > class moAlgo:public eoMonOp < EOT >
|
||||
{
|
||||
|
||||
};
|
||||
{};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@
|
|||
template < class M > class moAspirCrit:public eoBF < const M &, const typename
|
||||
M::EOType::Fitness &,
|
||||
bool >
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
//! Procedure which initialises all that needs a aspiration criterion.
|
||||
/*!
|
||||
It can be possible that this procedure do nothing...
|
||||
|
|
@ -57,6 +57,6 @@ public:
|
|||
virtual void
|
||||
init () = 0;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@
|
|||
which enables the best improvement is selected.
|
||||
*/
|
||||
template < class M > class moBestImprSelect:public moMoveSelect < M >
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
|
@ -102,7 +102,7 @@ public:
|
|||
throw EmptySelection ();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! Allowing to know if at least one move has been generated.
|
||||
bool first_time;
|
||||
|
|
@ -113,6 +113,6 @@ private:
|
|||
//! The best fitness.
|
||||
Fitness best_fit;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@
|
|||
*/
|
||||
template<class EOT>
|
||||
class moComparator: public eoBF<const EOT&, const EOT&, bool>
|
||||
{
|
||||
};
|
||||
{};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,8 +45,6 @@
|
|||
See moExponentialCoolingSchedule or moLinearCoolingSchedule for example.
|
||||
*/
|
||||
class moCoolingSchedule:public eoUF < double &, bool >
|
||||
{
|
||||
|
||||
};
|
||||
{};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@
|
|||
the temperature is greater than a given threshold.
|
||||
*/
|
||||
class moExponentialCoolingSchedule: public moCoolingSchedule
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
//! Simple constructor
|
||||
/*!
|
||||
\param __threshold the threshold.
|
||||
|
|
@ -68,13 +68,13 @@ public:
|
|||
return (__temp *= ratio) > threshold;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! The temperature threhold.
|
||||
double threshold;
|
||||
|
||||
//! The decreasing factor of the temperature.
|
||||
double ratio;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@
|
|||
current solution.
|
||||
*/
|
||||
template < class M > class moFirstImprSelect:public moMoveSelect < M >
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
|
@ -110,7 +110,7 @@ public:
|
|||
throw EmptySelection ();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! Allow to know if at least one move has improved the solution.
|
||||
bool valid;
|
||||
|
|
@ -124,6 +124,6 @@ private:
|
|||
//! Best stored fitness.
|
||||
Fitness best_fit;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
*/
|
||||
template<class EOT>
|
||||
class moFitComparator: public moComparator<EOT>
|
||||
{
|
||||
{
|
||||
public:
|
||||
|
||||
//! Function which makes the comparison and gives the result.
|
||||
|
|
@ -56,6 +56,6 @@ class moFitComparator: public moComparator<EOT>
|
|||
{
|
||||
return _solution1.fitness()>_solution2.fitness();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@
|
|||
The stop criterion corresponds to a fitness threshold gained.
|
||||
*/
|
||||
template < class EOT > class moFitSolContinue:public moSolContinue < EOT >
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
|
@ -67,7 +67,7 @@ public:
|
|||
*/
|
||||
bool operator () (const EOT & __sol)
|
||||
{
|
||||
if(__sol.invalid())
|
||||
if (__sol.invalid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -82,10 +82,10 @@ public:
|
|||
void init ()
|
||||
{}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! Fitness target.
|
||||
Fitness fitness;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -44,18 +44,16 @@
|
|||
The stop criterion corresponds to a maximum number of iteration.
|
||||
*/
|
||||
template < class EOT > class moGenSolContinue:public moSolContinue < EOT >
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//! Simple constructor.
|
||||
/*!
|
||||
\param __maxNumGen the maximum number of generation.
|
||||
*/
|
||||
moGenSolContinue (unsigned int __maxNumGen):maxNumGen (__maxNumGen), numGen (0)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
//! Function that activates the stop criterion.
|
||||
/*!
|
||||
|
|
@ -82,13 +80,13 @@ public:
|
|||
numGen = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! Iteration maximum number.
|
||||
unsigned int maxNumGen;
|
||||
|
||||
//! Iteration current number.
|
||||
unsigned int numGen;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
Class which describes the algorithm for a hill climbing.
|
||||
*/
|
||||
template < class M > class moHC:public moAlgo < typename M::EOType >
|
||||
{
|
||||
{
|
||||
|
||||
//! Alias for the type.
|
||||
typedef
|
||||
|
|
@ -62,7 +62,7 @@ template < class M > class moHC:public moAlgo < typename M::EOType >
|
|||
EOT::Fitness
|
||||
Fitness;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//! Full constructor.
|
||||
/*!
|
||||
|
|
@ -74,12 +74,10 @@ public:
|
|||
\param __move_select a move selector.
|
||||
\param __full_eval a full evaluation function.
|
||||
*/
|
||||
moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select, eoEvalFunc < EOT > &__full_eval):move_expl (*new moHCMoveLoopExpl < M >
|
||||
moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select, eoEvalFunc < EOT > &__full_eval):move_expl (*new moHCMoveLoopExpl < M >
|
||||
(__move_init, __next_move, __incr_eval, __move_select)),
|
||||
full_eval (__full_eval)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
//! Light constructor.
|
||||
/*!
|
||||
|
|
@ -88,12 +86,10 @@ moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEv
|
|||
\param __move_expl a complete explorer.
|
||||
\param __full_eval a full evaluation function.
|
||||
*/
|
||||
moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
|
||||
moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
|
||||
full_eval
|
||||
(__full_eval)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
//! Function which launches the HC
|
||||
/*!
|
||||
|
|
@ -145,13 +141,13 @@ moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl
|
|||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! Complete exploration of the neighborhood.
|
||||
moMoveExpl < M > &move_expl;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > &full_eval;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
//! Iterative explorer used by a moHC.
|
||||
template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M >
|
||||
{
|
||||
{
|
||||
|
||||
//! Alias for the type.
|
||||
typedef typename M::EOType EOT;
|
||||
|
|
@ -54,7 +54,7 @@ template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M >
|
|||
//! Alias for the fitness.
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
/*!
|
||||
|
|
@ -65,14 +65,12 @@ public:
|
|||
\param __incr_eval (generally) efficient evaluation function.
|
||||
\param __move_select the move selector.
|
||||
*/
|
||||
moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select):
|
||||
moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select):
|
||||
|
||||
move_init (__move_init),
|
||||
next_move (__next_move),
|
||||
incr_eval (__incr_eval), move_select (__move_select)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
//! Procedure which launches the explorer.
|
||||
/*!
|
||||
|
|
@ -114,7 +112,7 @@ moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move,
|
|||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! Move initialiser.
|
||||
moMoveInit < M > &move_init;
|
||||
|
|
@ -128,6 +126,6 @@ private:
|
|||
//! Move selector.
|
||||
moMoveSelect < M > &move_select;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
Class which describes the algorithm for a iterated local search.
|
||||
*/
|
||||
template < class M > class moILS:public moAlgo < typename M::EOType >
|
||||
{
|
||||
{
|
||||
|
||||
//! Alias for the type.
|
||||
typedef typename M::EOType EOT;
|
||||
|
|
@ -56,7 +56,7 @@ template < class M > class moILS:public moAlgo < typename M::EOType >
|
|||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//! Generic constructor
|
||||
/*!
|
||||
|
|
@ -152,7 +152,7 @@ public:
|
|||
|
||||
algo(__sol);
|
||||
|
||||
if(acceptance_criterion(__sol, __sol_saved))
|
||||
if (acceptance_criterion(__sol, __sol_saved))
|
||||
{
|
||||
__sol_saved=__sol;
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ public:
|
|||
|
||||
algo(__sol);
|
||||
|
||||
if(acceptance_criterion(__sol, __sol_saved))
|
||||
if (acceptance_criterion(__sol, __sol_saved))
|
||||
{
|
||||
__sol_saved=__sol;
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! The solution based heuristic.
|
||||
moAlgo<EOT> &algo;
|
||||
|
|
@ -198,6 +198,6 @@ private:
|
|||
|
||||
//! The full evaluation function
|
||||
eoEvalFunc<EOT> &full_eval;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@
|
|||
is the best ever considered.
|
||||
*/
|
||||
template < class M > class moImprBestFitAspirCrit:public moAspirCrit < M >
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename M::EOType::Fitness Fitness;
|
||||
|
|
@ -97,13 +97,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! Best fitness found until now
|
||||
Fitness best_fit;
|
||||
|
||||
//! Indicates that a fitness has been already saved or not
|
||||
bool first_time;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@
|
|||
This class is a move (moMove) generator with a bound for the maximum number of iterations.
|
||||
*/
|
||||
template < class M > class moItRandNextMove:public moNextMove < M >
|
||||
{
|
||||
{
|
||||
|
||||
//! Alias for the type.
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//! The constructor.
|
||||
/*!
|
||||
|
|
@ -62,9 +62,7 @@ public:
|
|||
moItRandNextMove (moRandMove < M > &__rand_move,
|
||||
unsigned int __max_iter):rand_move (__rand_move),
|
||||
max_iter (__max_iter), num_iter (0)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
//! Generation of a new move
|
||||
/*!
|
||||
|
|
@ -93,7 +91,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! A move generator (generally randomly).
|
||||
moRandMove < M > &rand_move;
|
||||
|
|
@ -104,6 +102,6 @@ private:
|
|||
//! Iteration current number.
|
||||
unsigned int num_iter;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@
|
|||
*/
|
||||
template < class M > class moLSCheckPoint:public eoBF < const M &, const typename
|
||||
M::EOType &, void >
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
//! Function which launches the checkpointing
|
||||
/*!
|
||||
Each saved function is used on the current move and the current solution.
|
||||
|
|
@ -77,7 +77,7 @@ public:
|
|||
func.push_back (&__f);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! vector of function
|
||||
std::vector < eoBF < const
|
||||
|
|
@ -86,6 +86,6 @@ private:
|
|||
M::EOType &, void >*>
|
||||
func;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@
|
|||
the temperature is greater than a threshold.
|
||||
*/
|
||||
class moLinearCoolingSchedule: public moCoolingSchedule
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
//! Simple constructor
|
||||
/*!
|
||||
\param __threshold the threshold.
|
||||
|
|
@ -68,13 +68,13 @@ public:
|
|||
return (__temp -= quantity) > threshold;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
//! The temperature threhold.
|
||||
double threshold;
|
||||
|
||||
//! The quantity that allows the temperature to decrease.
|
||||
double quantity;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@
|
|||
It describes how a solution can be modified to another one.
|
||||
*/
|
||||
template < class EOT > class moMove:public eoUF < EOT &, void >
|
||||
{
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
//! Alias for the type
|
||||
typedef EOT EOType;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue