From a2c9db1140a0a25ba293c9c381ba9d75706d4b3e Mon Sep 17 00:00:00 2001 From: jhumeau Date: Wed, 8 Apr 2009 09:57:02 +0000 Subject: [PATCH] git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1578 331e1502-861f-0410-8da2-ba01fb791d7f --- .../branches/MOLS/src2/moeoDMLSGenUpdater.h | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 contribution/branches/MOLS/src2/moeoDMLSGenUpdater.h diff --git a/contribution/branches/MOLS/src2/moeoDMLSGenUpdater.h b/contribution/branches/MOLS/src2/moeoDMLSGenUpdater.h new file mode 100644 index 000000000..420e35cfe --- /dev/null +++ b/contribution/branches/MOLS/src2/moeoDMLSGenUpdater.h @@ -0,0 +1,98 @@ +#include +#include +#include +#include +#include +#include +#include + +/** updater allowing hybridization with a dmls at checkpointing*/ +template < class Move > +class moeoDMLSGenUpdater : public eoUpdater +{ + + typedef typename Move::EOType MOEOT; + + public : + /** Ctor with a dmls. + * @param _dmls the dmls use for the hybridization (!!! Special care is needed when choosing the continuator of the dmls !!!) + * @param _globalArchive the same archive used in the other algorithm + * @param _continuator is a Generational Continuator which allow to run dmls on the global archive each X generation(s) + */ + moeoDMLSGenUpdater(moeoUnifiedDominanceBasedLS & _dmls, + moeoArchive < MOEOT > & _globalArchive, + eoGenContinue < MOEOT > & _continuator, + bool _verbose = true): + defaultContinuator(0), dmls(_dmls), globalArchive(_globalArchive), continuator(_continuator), verbose(_verbose){} + + /** Ctor with a dmls. + * @param _eval a evaluation function (used to instantiate the dmls) + * @param _eplorer a neighborhood explorer (used to instantiate the dmls) + * @param _select a selector of unvisited individuals of a population (used to instantiate the dmls) + * @param _globalArchive the same archive used in the other algorithm + * @param _continuator is a Generational Continuator which allow to run dmls on the global archive each X generation(s) + * @param _step (default=1) is the number of Generation of dmls (used to instantiate the defaultContinuator for the dmls) + */ + moeoDMLSGenUpdater(eoEvalFunc < MOEOT > & _eval, + moeoPopNeighborhoodExplorer < Move > & _explorer, + moeoUnvisitedSelect < MOEOT > & _select, + moeoArchive < MOEOT > & _globalArchive, + eoGenContinue < MOEOT > & _continuator, + unsigned int _step=1, + bool _verbose = true): + defaultContinuator(_step), dmls(defaultContinuator, _eval, defaultArchive, _explorer, _select), globalArchive(_globalArchive), continuator(_continuator), verbose(_verbose){} + + /** Ctor with a dmls. + * @param _eval a evaluation function (used to instantiate the dmls) + * @param _dmlsArchive an archive (used to instantiate the dmls) + * @param _eplorer a neighborhood explorer (used to instantiate the dmls) + * @param _select a selector of unvisited individuals of a population (used to instantiate the dmls) + * @param _globalArchive the same archive used in the other algorithm + * @param _continuator is a Generational Continuator which allow to run dmls on the global archive each X generation(s) + * @param _step (default=1) is the number of Generation of dmls (used to instantiate the defaultContinuator for the dmls) + */ + moeoDMLSGenUpdater(eoEvalFunc < MOEOT > & _eval, + moeoArchive < MOEOT > & _dmlsArchive, + moeoPopNeighborhoodExplorer < Move > & _explorer, + moeoUnvisitedSelect < MOEOT > & _select, + moeoArchive < MOEOT > & _globalArchive, + eoGenContinue < MOEOT > & _continuator, + unsigned int _step=1, + bool _verbose = true): + defaultContinuator(_step), dmls(defaultContinuator, _eval, _dmlsArchive, _explorer, _select), globalArchive(_globalArchive), continuator(_continuator), verbose(_verbose){} + + /** functor which allow to run the dmls*/ + virtual void operator()() + { + if(!continuator(globalArchive)){ + if(verbose) + std::cout << std::endl << "dmls started" << std::endl; + dmls(globalArchive); + if(verbose) + std::cout << "dmls stop" << std::endl; + defaultContinuator.totalGenerations(defaultContinuator.totalGenerations()); + if(verbose) + std::cout << "the other algorithm restart for " << continuator.totalGenerations() << " generation(s)" << std::endl << std::endl; + continuator.totalGenerations(continuator.totalGenerations()); + } + } + + /** + * @return the class name + */ + virtual std::string className(void) const { return "moeoDMLSGenUpdater"; } + +private: + /** defaultContinuator used for the dmls */ + eoGenContinue < MOEOT > defaultContinuator; + /** default archive used for the dmls */ + moeoUnboundedArchive < MOEOT > defaultArchive; + /** the dmls */ + moeoUnifiedDominanceBasedLS dmls; + /** the global archive */ + moeoArchive < MOEOT > & globalArchive; + /** continuator used to run the dmls each X generation(s) */ + eoGenContinue < MOEOT > & continuator; + /** verbose mode */ + bool verbose; +};