diff --git a/contribution/branches/MOLS/src2/moeoExhaustiveNeighborhoodExplorer.h b/contribution/branches/MOLS/src2/moeoExhaustiveNeighborhoodExplorer.h index 90a35d070..4e1205dec 100644 --- a/contribution/branches/MOLS/src2/moeoExhaustiveNeighborhoodExplorer.h +++ b/contribution/branches/MOLS/src2/moeoExhaustiveNeighborhoodExplorer.h @@ -39,8 +39,7 @@ #ifndef _MOEOEXHAUSTIVENEIGHBORHOODEXPLORER_H #define _MOEOEXHAUSTIVENEIGHBORHOODEXPLORER_H -#include -#include +#include #include #include #include @@ -48,51 +47,71 @@ #include /** - * TODO + * Explorer which explore all the neighborhood */ template < class Move > class moeoExhaustiveNeighborhoodExplorer : public moeoPopNeighborhoodExplorer < Move > { + /** Alias for the type */ typedef typename Move::EOType MOEOT; + /** Alias for the objeciveVector */ typedef typename MOEOT::ObjectiveVector ObjectiveVector; public: + /** + * Ctor + * @param _moveInit the move initializer + * @param _nextMove allow to do or not a move + * @param _incrEval a (generally) efficient evaluation fonction + */ moeoExhaustiveNeighborhoodExplorer( moMoveInit < Move > & _moveInit, moNextMove < Move > & _nextMove, moMoveIncrEval < Move, ObjectiveVector > & _incrEval) : moveInit(_moveInit), nextMove(_nextMove), incrEval(_incrEval){} + /** + * functor to explore the neighborhood + * @param _src the population to explore + * @param _select contains index of individuals from the population to explore + * @param _dest contains new generated individuals + */ void operator()(eoPop < MOEOT > & _src, std::vector < unsigned int> _select, eoPop < MOEOT > & _dest) { for(unsigned int i=0; i<_select.size(); i++) - explore(_src, _select[i], _dest); + explore(_src[_select[i]], _dest); } private: - void explore(eoPop < MOEOT > & _src, unsigned int _i, eoPop < MOEOT > & _dest) + /** + * explorer of one individual + * @param _src the individual to explore + * @param _dest contains new generated individuals + */ + void explore(MOEOT & _src , eoPop < MOEOT > & _dest) { - moveInit(move, _src[_i]); + moveInit(move, _src); do { - objVec = incrEval(move, _src[_i]); - _dest.push_back(_src[_i]); + objVec = incrEval(move, _src); + _dest.push_back(_src); move(_dest.back()); _dest.back().objectiveVector(objVec); _dest.back().flag(0); } - while (nextMove(move, _src[_i])); - _src[_i].flag(1); + while (nextMove(move, _src)); + _src.flag(1); } + /** Move */ Move move; /** ObjectiveVector */ ObjectiveVector objVec; /** the move initializer */ moMoveInit < Move > & moveInit; - /** the neighborhood explorer */ + /** the entity which allow to do a move */ moNextMove < Move > & nextMove; /** the incremental evaluation */ moMoveIncrEval < Move, ObjectiveVector > & incrEval; diff --git a/contribution/branches/MOLS/src2/moeoExhaustiveUnvisitedSelect.h b/contribution/branches/MOLS/src2/moeoExhaustiveUnvisitedSelect.h index 21a864dba..a0aa7ab15 100644 --- a/contribution/branches/MOLS/src2/moeoExhaustiveUnvisitedSelect.h +++ b/contribution/branches/MOLS/src2/moeoExhaustiveUnvisitedSelect.h @@ -39,12 +39,11 @@ #ifndef _MOEOEXHAUSTIVEUNVISITEDSELECT_H #define _MOEOEXHAUSTIVEUNVISITEDSELECT_H -#include -#include +#include #include /** - * TODO + * Selector which select all unvisited individuals of a population */ template < class MOEOT > class moeoExhaustiveUnvisitedSelect : public moeoUnvisitedSelect < MOEOT > @@ -52,8 +51,16 @@ class moeoExhaustiveUnvisitedSelect : public moeoUnvisitedSelect < MOEOT > public: + /** + * Default ctor + */ moeoExhaustiveUnvisitedSelect(){} + /** + * functor which return index of selected individuals of a population + * @param _src the population + * @return the vector contains index of all unvisited individuals of the population + */ std::vector operator()(eoPop < MOEOT > & _src) { std::vector res; diff --git a/contribution/branches/MOLS/src2/moeoNumberUnvisitedSelect.h b/contribution/branches/MOLS/src2/moeoNumberUnvisitedSelect.h index be48109cb..68bc0e300 100644 --- a/contribution/branches/MOLS/src2/moeoNumberUnvisitedSelect.h +++ b/contribution/branches/MOLS/src2/moeoNumberUnvisitedSelect.h @@ -39,12 +39,11 @@ #ifndef _MOEONUMBERUNVISITEDSELECT_H #define _MOEONUMBERUNVISITEDSELECT_H -#include -#include +#include #include /** - * TODO + * Selector which select a part of unvisited individuals of a population */ template < class MOEOT > class moeoNumberUnvisitedSelect : public moeoUnvisitedSelect < MOEOT > @@ -52,8 +51,17 @@ class moeoNumberUnvisitedSelect : public moeoUnvisitedSelect < MOEOT > public: + /** + * Ctor + * @param _number the number of individuals to select + */ moeoNumberUnvisitedSelect(unsigned int _number): number(_number){} + /** + * functor which return index of selected individuals of a population + * @param _src the population + * @return the vector contains index of the part of unvisited individuals of the population + */ std::vector operator()(eoPop < MOEOT > & _src) { std::vector res; @@ -72,6 +80,7 @@ public: } private: + /** number of individuals to select */ unsigned int number; }; diff --git a/contribution/branches/MOLS/src2/moeoPopLS.h b/contribution/branches/MOLS/src2/moeoPopLS.h index 2cb90db32..a5c38e104 100755 --- a/contribution/branches/MOLS/src2/moeoPopLS.h +++ b/contribution/branches/MOLS/src2/moeoPopLS.h @@ -45,7 +45,6 @@ * Abstract class for Population based multi-objective local search. */ template < class Move > -class moeoPopLS : public moeoPopAlgo < typename Move::EOType > - {}; +class moeoPopLS : public moeoPopAlgo < typename Move::EOType > {}; #endif /*MOEOPOPLS_H_*/ diff --git a/contribution/branches/MOLS/src2/moeoPopNeighborhoodExplorer.h b/contribution/branches/MOLS/src2/moeoPopNeighborhoodExplorer.h index 10119183d..94de08ab3 100755 --- a/contribution/branches/MOLS/src2/moeoPopNeighborhoodExplorer.h +++ b/contribution/branches/MOLS/src2/moeoPopNeighborhoodExplorer.h @@ -39,16 +39,18 @@ #ifndef _MOEOPOPNEIGHBORHOODEXPLORER_H #define _MOEOPOPNEIGHBORHOODEXPLORER_H -#include -#include +#include /** - * TODO + * Abstract class for multi-objective local search neighborhood exploration */ template < class Move > class moeoPopNeighborhoodExplorer{ public: + /** + * abstract functor which realise exploration + */ virtual void operator()(eoPop < typename Move::EOType > &, std::vector , eoPop < typename Move::EOType > &) = 0; }; diff --git a/contribution/branches/MOLS/src2/moeoSubNeighborhoodExplorer.h b/contribution/branches/MOLS/src2/moeoSubNeighborhoodExplorer.h index ee1659966..52d697831 100644 --- a/contribution/branches/MOLS/src2/moeoSubNeighborhoodExplorer.h +++ b/contribution/branches/MOLS/src2/moeoSubNeighborhoodExplorer.h @@ -39,8 +39,7 @@ #ifndef _MOEOSUBNEIGHBORHOODEXPLORER_H #define _MOEOSUBNEIGHBORHOODEXPLORER_H -#include -#include +#include #include #include #include @@ -48,16 +47,25 @@ #include /** - * TODO + * Explorer which explore a part of the neighborhood */ template < class Move > class moeoSubNeighborhoodExplorer : public moeoPopNeighborhoodExplorer < Move > { + /** Alias for the type */ typedef typename Move::EOType MOEOT; + /** Alias for the objeciveVector */ typedef typename MOEOT::ObjectiveVector ObjectiveVector; public: + /** + * Ctor + * @param _moveInit the move initializer + * @param _nextMove allow to do or not a move + * @param _incrEval a (generally) efficient evaluation fonction + * @param _number the number of neighbor to explore + */ moeoSubNeighborhoodExplorer( moMoveInit < Move > & _moveInit, moNextMove < Move > & _nextMove, @@ -65,45 +73,58 @@ public: unsigned int _number) : moveInit(_moveInit), nextMove(_nextMove), incrEval(_incrEval), number(_number){} + /** + * functor to explore the neighborhood + * @param _src the population to explore + * @param _select contains index of individuals from the population to explore + * @param _dest contains new generated individuals + */ void operator()(eoPop < MOEOT > & _src, std::vector _select, eoPop < MOEOT > & _dest) { if(number > 0){ for(unsigned int i=0; i<_select.size(); i++) - explore(_src, _select[i], _dest); + explore(_src[_select[i]], _dest); } } private: - void explore(eoPop < MOEOT > & _src, unsigned int _i, eoPop < MOEOT > & _dest) + /** + * explorer of one individual + * @param _src the individual to explore + * @param _dest contains new generated individuals + */ + void explore(MOEOT & _src, eoPop < MOEOT > & _dest) { unsigned int tmp = number; - moveInit(move, _src[_i]); + moveInit(move, _src); do { - objVec = incrEval(move, _src[_i]); - _dest.push_back(_src[_i]); + objVec = incrEval(move, _src); + _dest.push_back(_src); move(_dest.back()); _dest.back().objectiveVector(objVec); _dest.back().flag(0); tmp--; } - while (nextMove(move, _src[_i]) && (tmp > 0)); - if(!nextMove(move, _src[_i])) - _src[_i].flag(1); + while (nextMove(move, _src) && (tmp > 0)); + if(!nextMove(move, _src)) + _src.flag(1); } + /** Move */ Move move; /** ObjectiveVector */ ObjectiveVector objVec; /** the move initializer */ moMoveInit < Move > & moveInit; - /** the neighborhood explorer */ + /** the entity which allow to do a move */ moNextMove < Move > & nextMove; /** the incremental evaluation */ moMoveIncrEval < Move, ObjectiveVector > & incrEval; - /** number of neighbor to explore for each solution*/ + /** number of neighbor to explore for each selected individual*/ unsigned int number; + }; -#endif /*_MOEOEXHAUSTIVENEIGHBORHOODEXPLORER_H_*/ +#endif /*_MOEOSUBNEIGHBORHOODEXPLORER_H_*/ diff --git a/contribution/branches/MOLS/src2/moeoUnifiedDominanceBasedLS.h b/contribution/branches/MOLS/src2/moeoUnifiedDominanceBasedLS.h index 3e26b2689..5b5fca235 100755 --- a/contribution/branches/MOLS/src2/moeoUnifiedDominanceBasedLS.h +++ b/contribution/branches/MOLS/src2/moeoUnifiedDominanceBasedLS.h @@ -39,20 +39,34 @@ #ifndef _MOEOUNIFIEDDOMINANCEBASEDLS_H #define _MOEOUNIFIEDDOMINANCEBASEDLS_H -#include -#include +#include +#include +#include +#include +#include #include #include #include +/** + * A class to design dominance based local searches + */ template < class Move > class moeoUnifiedDominanceBasedLS : public moeoPopLS < Move > { public: + /** Alias for the type */ typedef typename Move::EOType MOEOT; - + /** + * Ctor + * @param _continuator a stop creterion + * @param _eval a evaluation function + * @param _archive a archive to store no-dominated individuals + * @param _explorer a neighborhood explorer + * @param _select a selector of unvisited individuals of a population + */ moeoUnifiedDominanceBasedLS( eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, @@ -61,7 +75,6 @@ public: moeoUnvisitedSelect < MOEOT > & _select) : continuator(_continuator), loopEval(_eval), popEval(loopEval), archive(_archive), explorer(_explorer), select(_select) {} - /** * Applies a few generation of evolution to the population _pop. * @param _pop the population @@ -74,36 +87,48 @@ public: archive(_pop); do{ tmp_pop.resize(0); - //selection des individus non visités à explorer + //selection selectionVector = select(archive); //exploration - //explorer(archive, selectionVector, tmp_pop); explorer(archive, selectionVector, tmp_pop); - //mise à jour de la pop ou archive + //archivage archive(tmp_pop); } while (continuator(archive) && naturalContinuator(archive)); -// std::cout << "Final archive\n"; -// archive.sortedPrintOn(std::cout); -// std::cout << std::endl; } - protected: + /** continuator */ eoContinue < MOEOT > & continuator; + /** loopEval */ eoPopLoopEval < MOEOT > loopEval; + /** popEval */ eoPopEvalFunc < MOEOT > & popEval; + /** archive */ moeoArchive < MOEOT > & archive; + /** explorer */ moeoPopNeighborhoodExplorer < Move > & explorer; + /** selector */ moeoUnvisitedSelect < MOEOT > & select; -class moeoContinue : public eoUF < eoPop < MOEOT > &, bool > + /** + * Natural Continuator (Stop when all individuals of the population are visited) + */ + class moeoContinue : public eoUF < eoPop < MOEOT > &, bool > { public: + /** + * Ctor + */ moeoContinue(){} + /** + * functor which evaluate if the algorithm continue or not + * @param _pop the population + * @return true if the algorithm continue, else return false + */ virtual bool operator()(eoPop < MOEOT > & _pop) { bool res = false; diff --git a/contribution/branches/MOLS/src2/moeoUnvisitedSelect.h b/contribution/branches/MOLS/src2/moeoUnvisitedSelect.h index 2cacd4624..cd0dc3759 100644 --- a/contribution/branches/MOLS/src2/moeoUnvisitedSelect.h +++ b/contribution/branches/MOLS/src2/moeoUnvisitedSelect.h @@ -39,11 +39,10 @@ #ifndef _MOEOUNVISITEDSELECT_H #define _MOEOUNVISITEDSELECT_H -#include -#include +#include /** - * TODO + * Abstract Selector */ template < class MOEOT > class moeoUnvisitedSelect: public eoUF < eoPop < MOEOT > &, std::vector< unsigned int > >{};