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

@ -44,8 +44,6 @@
moHC, moTS and moSA are 3 examples of algorithm of the paradiseo-mo library. moHC, moTS and moSA are 3 examples of algorithm of the paradiseo-mo library.
*/ */
template < class EOT > class moAlgo:public eoMonOp < EOT > template < class EOT > class moAlgo:public eoMonOp < EOT >
{ {};
};
#endif #endif

View file

@ -47,9 +47,9 @@
template < class M > class moAspirCrit:public eoBF < const M &, const typename template < class M > class moAspirCrit:public eoBF < const M &, const typename
M::EOType::Fitness &, M::EOType::Fitness &,
bool > bool >
{ {
public: public:
//! Procedure which initialises all that needs a aspiration criterion. //! Procedure which initialises all that needs a aspiration criterion.
/*! /*!
It can be possible that this procedure do nothing... It can be possible that this procedure do nothing...
@ -57,6 +57,6 @@ public:
virtual void virtual void
init () = 0; init () = 0;
}; };
#endif #endif

View file

@ -45,9 +45,9 @@
which enables the best improvement is selected. which enables the best improvement is selected.
*/ */
template < class M > class moBestImprSelect:public moMoveSelect < M > template < class M > class moBestImprSelect:public moMoveSelect < M >
{ {
public: public:
//! Alias for the fitness. //! Alias for the fitness.
typedef typename M::EOType::Fitness Fitness; typedef typename M::EOType::Fitness Fitness;
@ -102,7 +102,7 @@ public:
throw EmptySelection (); throw EmptySelection ();
} }
private: private:
//! Allowing to know if at least one move has been generated. //! Allowing to know if at least one move has been generated.
bool first_time; bool first_time;
@ -113,6 +113,6 @@ private:
//! The best fitness. //! The best fitness.
Fitness best_fit; Fitness best_fit;
}; };
#endif #endif

View file

@ -44,7 +44,6 @@
*/ */
template<class EOT> template<class EOT>
class moComparator: public eoBF<const EOT&, const EOT&, bool> class moComparator: public eoBF<const EOT&, const EOT&, bool>
{ {};
};
#endif #endif

View file

@ -45,8 +45,6 @@
See moExponentialCoolingSchedule or moLinearCoolingSchedule for example. See moExponentialCoolingSchedule or moLinearCoolingSchedule for example.
*/ */
class moCoolingSchedule:public eoUF < double &, bool > class moCoolingSchedule:public eoUF < double &, bool >
{ {};
};
#endif #endif

View file

@ -45,9 +45,9 @@
the temperature is greater than a given threshold. the temperature is greater than a given threshold.
*/ */
class moExponentialCoolingSchedule: public moCoolingSchedule class moExponentialCoolingSchedule: public moCoolingSchedule
{ {
public: public:
//! Simple constructor //! Simple constructor
/*! /*!
\param __threshold the threshold. \param __threshold the threshold.
@ -68,13 +68,13 @@ public:
return (__temp *= ratio) > threshold; return (__temp *= ratio) > threshold;
} }
private: private:
//! The temperature threhold. //! The temperature threhold.
double threshold; double threshold;
//! The decreasing factor of the temperature. //! The decreasing factor of the temperature.
double ratio; double ratio;
}; };
#endif #endif

View file

@ -46,9 +46,9 @@
current solution. current solution.
*/ */
template < class M > class moFirstImprSelect:public moMoveSelect < M > template < class M > class moFirstImprSelect:public moMoveSelect < M >
{ {
public: public:
//! Alias for the fitness. //! Alias for the fitness.
typedef typename M::EOType::Fitness Fitness; typedef typename M::EOType::Fitness Fitness;
@ -110,7 +110,7 @@ public:
throw EmptySelection (); throw EmptySelection ();
} }
private: private:
//! Allow to know if at least one move has improved the solution. //! Allow to know if at least one move has improved the solution.
bool valid; bool valid;
@ -124,6 +124,6 @@ private:
//! Best stored fitness. //! Best stored fitness.
Fitness best_fit; Fitness best_fit;
}; };
#endif #endif

View file

@ -43,7 +43,7 @@
*/ */
template<class EOT> template<class EOT>
class moFitComparator: public moComparator<EOT> class moFitComparator: public moComparator<EOT>
{ {
public: public:
//! Function which makes the comparison and gives the result. //! Function which makes the comparison and gives the result.
@ -56,6 +56,6 @@ class moFitComparator: public moComparator<EOT>
{ {
return _solution1.fitness()>_solution2.fitness(); return _solution1.fitness()>_solution2.fitness();
} }
}; };
#endif #endif

View file

@ -44,9 +44,9 @@
The stop criterion corresponds to a fitness threshold gained. The stop criterion corresponds to a fitness threshold gained.
*/ */
template < class EOT > class moFitSolContinue:public moSolContinue < EOT > template < class EOT > class moFitSolContinue:public moSolContinue < EOT >
{ {
public: public:
//! Alias for the fitness. //! Alias for the fitness.
typedef typename EOT::Fitness Fitness; typedef typename EOT::Fitness Fitness;
@ -67,7 +67,7 @@ public:
*/ */
bool operator () (const EOT & __sol) bool operator () (const EOT & __sol)
{ {
if(__sol.invalid()) if (__sol.invalid())
{ {
return true; return true;
} }
@ -82,10 +82,10 @@ public:
void init () void init ()
{} {}
private: private:
//! Fitness target. //! Fitness target.
Fitness fitness; Fitness fitness;
}; };
#endif #endif

View file

@ -44,18 +44,16 @@
The stop criterion corresponds to a maximum number of iteration. The stop criterion corresponds to a maximum number of iteration.
*/ */
template < class EOT > class moGenSolContinue:public moSolContinue < EOT > template < class EOT > class moGenSolContinue:public moSolContinue < EOT >
{ {
public: public:
//! Simple constructor. //! Simple constructor.
/*! /*!
\param __maxNumGen the maximum number of generation. \param __maxNumGen the maximum number of generation.
*/ */
moGenSolContinue (unsigned int __maxNumGen):maxNumGen (__maxNumGen), numGen (0) moGenSolContinue (unsigned int __maxNumGen):maxNumGen (__maxNumGen), numGen (0)
{ {}
}
//! Function that activates the stop criterion. //! Function that activates the stop criterion.
/*! /*!
@ -82,13 +80,13 @@ public:
numGen = 0; numGen = 0;
} }
private: private:
//! Iteration maximum number. //! Iteration maximum number.
unsigned int maxNumGen; unsigned int maxNumGen;
//! Iteration current number. //! Iteration current number.
unsigned int numGen; unsigned int numGen;
}; };
#endif #endif

View file

@ -48,7 +48,7 @@
Class which describes the algorithm for a hill climbing. Class which describes the algorithm for a hill climbing.
*/ */
template < class M > class moHC:public moAlgo < typename M::EOType > template < class M > class moHC:public moAlgo < typename M::EOType >
{ {
//! Alias for the type. //! Alias for the type.
typedef typedef
@ -62,7 +62,7 @@ template < class M > class moHC:public moAlgo < typename M::EOType >
EOT::Fitness EOT::Fitness
Fitness; Fitness;
public: public:
//! Full constructor. //! Full constructor.
/*! /*!
@ -74,12 +74,10 @@ public:
\param __move_select a move selector. \param __move_select a move selector.
\param __full_eval a full evaluation function. \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)), (__move_init, __next_move, __incr_eval, __move_select)),
full_eval (__full_eval) full_eval (__full_eval)
{ {}
}
//! Light constructor. //! Light constructor.
/*! /*!
@ -88,12 +86,10 @@ moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEv
\param __move_expl a complete explorer. \param __move_expl a complete explorer.
\param __full_eval a full evaluation function. \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
(__full_eval) (__full_eval)
{ {}
}
//! Function which launches the HC //! Function which launches the HC
/*! /*!
@ -145,13 +141,13 @@ moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl
return true; return true;
} }
private: private:
//! Complete exploration of the neighborhood. //! Complete exploration of the neighborhood.
moMoveExpl < M > &move_expl; moMoveExpl < M > &move_expl;
//! A full evaluation function. //! A full evaluation function.
eoEvalFunc < EOT > &full_eval; eoEvalFunc < EOT > &full_eval;
}; };
#endif #endif

View file

@ -46,7 +46,7 @@
//! Iterative explorer used by a moHC. //! Iterative explorer used by a moHC.
template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M > template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M >
{ {
//! Alias for the type. //! Alias for the type.
typedef typename M::EOType EOT; typedef typename M::EOType EOT;
@ -54,7 +54,7 @@ template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M >
//! Alias for the fitness. //! Alias for the fitness.
typedef typename M::EOType::Fitness Fitness; typedef typename M::EOType::Fitness Fitness;
public: public:
//! Constructor. //! Constructor.
/*! /*!
@ -65,14 +65,12 @@ public:
\param __incr_eval (generally) efficient evaluation function. \param __incr_eval (generally) efficient evaluation function.
\param __move_select the move selector. \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), move_init (__move_init),
next_move (__next_move), next_move (__next_move),
incr_eval (__incr_eval), move_select (__move_select) incr_eval (__incr_eval), move_select (__move_select)
{ {}
}
//! Procedure which launches the explorer. //! Procedure which launches the explorer.
/*! /*!
@ -114,7 +112,7 @@ moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move,
} }
} }
private: private:
//! Move initialiser. //! Move initialiser.
moMoveInit < M > &move_init; moMoveInit < M > &move_init;
@ -128,6 +126,6 @@ private:
//! Move selector. //! Move selector.
moMoveSelect < M > &move_select; moMoveSelect < M > &move_select;
}; };
#endif #endif

View file

@ -48,7 +48,7 @@
Class which describes the algorithm for a iterated local search. Class which describes the algorithm for a iterated local search.
*/ */
template < class M > class moILS:public moAlgo < typename M::EOType > template < class M > class moILS:public moAlgo < typename M::EOType >
{ {
//! Alias for the type. //! Alias for the type.
typedef typename M::EOType EOT; typedef typename M::EOType EOT;
@ -56,7 +56,7 @@ template < class M > class moILS:public moAlgo < typename M::EOType >
//! Alias for the fitness. //! Alias for the fitness.
typedef typename EOT::Fitness Fitness; typedef typename EOT::Fitness Fitness;
public: public:
//! Generic constructor //! Generic constructor
/*! /*!
@ -152,7 +152,7 @@ public:
algo(__sol); algo(__sol);
if(acceptance_criterion(__sol, __sol_saved)) if (acceptance_criterion(__sol, __sol_saved))
{ {
__sol_saved=__sol; __sol_saved=__sol;
@ -169,7 +169,7 @@ public:
algo(__sol); algo(__sol);
if(acceptance_criterion(__sol, __sol_saved)) if (acceptance_criterion(__sol, __sol_saved))
{ {
__sol_saved=__sol; __sol_saved=__sol;
} }
@ -182,7 +182,7 @@ public:
return true; return true;
} }
private: private:
//! The solution based heuristic. //! The solution based heuristic.
moAlgo<EOT> &algo; moAlgo<EOT> &algo;
@ -198,6 +198,6 @@ private:
//! The full evaluation function //! The full evaluation function
eoEvalFunc<EOT> &full_eval; eoEvalFunc<EOT> &full_eval;
}; };
#endif #endif

View file

@ -45,9 +45,9 @@
is the best ever considered. is the best ever considered.
*/ */
template < class M > class moImprBestFitAspirCrit:public moAspirCrit < M > template < class M > class moImprBestFitAspirCrit:public moAspirCrit < M >
{ {
public: public:
//! Alias for the fitness //! Alias for the fitness
typedef typename M::EOType::Fitness Fitness; typedef typename M::EOType::Fitness Fitness;
@ -97,13 +97,13 @@ public:
} }
} }
private: private:
//! Best fitness found until now //! Best fitness found until now
Fitness best_fit; Fitness best_fit;
//! Indicates that a fitness has been already saved or not //! Indicates that a fitness has been already saved or not
bool first_time; bool first_time;
}; };
#endif #endif

View file

@ -45,12 +45,12 @@
This class is a move (moMove) generator with a bound for the maximum number of iterations. This class is a move (moMove) generator with a bound for the maximum number of iterations.
*/ */
template < class M > class moItRandNextMove:public moNextMove < M > template < class M > class moItRandNextMove:public moNextMove < M >
{ {
//! Alias for the type. //! Alias for the type.
typedef typename M::EOType EOT; typedef typename M::EOType EOT;
public: public:
//! The constructor. //! The constructor.
/*! /*!
@ -62,9 +62,7 @@ public:
moItRandNextMove (moRandMove < M > &__rand_move, moItRandNextMove (moRandMove < M > &__rand_move,
unsigned int __max_iter):rand_move (__rand_move), unsigned int __max_iter):rand_move (__rand_move),
max_iter (__max_iter), num_iter (0) max_iter (__max_iter), num_iter (0)
{ {}
}
//! Generation of a new move //! Generation of a new move
/*! /*!
@ -93,7 +91,7 @@ public:
} }
} }
private: private:
//! A move generator (generally randomly). //! A move generator (generally randomly).
moRandMove < M > &rand_move; moRandMove < M > &rand_move;
@ -104,6 +102,6 @@ private:
//! Iteration current number. //! Iteration current number.
unsigned int num_iter; unsigned int num_iter;
}; };
#endif #endif

View file

@ -45,9 +45,9 @@
*/ */
template < class M > class moLSCheckPoint:public eoBF < const M &, const typename template < class M > class moLSCheckPoint:public eoBF < const M &, const typename
M::EOType &, void > M::EOType &, void >
{ {
public: public:
//! Function which launches the checkpointing //! Function which launches the checkpointing
/*! /*!
Each saved function is used on the current move and the current solution. Each saved function is used on the current move and the current solution.
@ -77,7 +77,7 @@ public:
func.push_back (&__f); func.push_back (&__f);
} }
private: private:
//! vector of function //! vector of function
std::vector < eoBF < const std::vector < eoBF < const
@ -86,6 +86,6 @@ private:
M::EOType &, void >*> M::EOType &, void >*>
func; func;
}; };
#endif #endif

View file

@ -45,9 +45,9 @@
the temperature is greater than a threshold. the temperature is greater than a threshold.
*/ */
class moLinearCoolingSchedule: public moCoolingSchedule class moLinearCoolingSchedule: public moCoolingSchedule
{ {
public: public:
//! Simple constructor //! Simple constructor
/*! /*!
\param __threshold the threshold. \param __threshold the threshold.
@ -68,13 +68,13 @@ public:
return (__temp -= quantity) > threshold; return (__temp -= quantity) > threshold;
} }
private: private:
//! The temperature threhold. //! The temperature threhold.
double threshold; double threshold;
//! The quantity that allows the temperature to decrease. //! The quantity that allows the temperature to decrease.
double quantity; double quantity;
}; };
#endif #endif

View file

@ -46,12 +46,12 @@
It describes how a solution can be modified to another one. It describes how a solution can be modified to another one.
*/ */
template < class EOT > class moMove:public eoUF < EOT &, void > template < class EOT > class moMove:public eoUF < EOT &, void >
{ {
public: public:
//! Alias for the type //! Alias for the type
typedef EOT EOType; typedef EOT EOType;
}; };
#endif #endif

Some files were not shown because too many files have changed in this diff Show more