diff --git a/trunk/paradiseo-moeo/src/archive/moeoArchive.h b/trunk/paradiseo-moeo/src/archive/moeoArchive.h index d5e23da1c..edc1492c0 100644 --- a/trunk/paradiseo-moeo/src/archive/moeoArchive.h +++ b/trunk/paradiseo-moeo/src/archive/moeoArchive.h @@ -42,12 +42,17 @@ #include #include +//template < class MOEOT > +//class ufMOEOT : public eoUF < const MOEOT &, bool> {}; +//template < class MOEOT > +//class ufPop : eoUF < const eoPop < MOEOT > &, bool> {}; + /** * Abstract class for representing an archive ; * an archive is a secondary population that stores non-dominated solutions. */ template < class MOEOT > -class moeoArchive : public eoPop < MOEOT > +class moeoArchive : public eoPop < MOEOT >, public eoUF < const MOEOT &, bool>, public eoUF < const eoPop < MOEOT > &, bool> { public: @@ -112,22 +117,24 @@ public: } return false; } - - + + /** * Updates the archive with a given individual _moeo * @param _moeo the given individual + * @return if the _moeo is added to the archive */ - virtual void operator()(const MOEOT & _moeo) = 0; + virtual bool operator()(const MOEOT & _moeo) = 0; /** * Updates the archive with a given population _pop * @param _pop the given population + * @return if at least one _pop[i] is added to the archive */ - virtual void operator()(const eoPop < MOEOT > & _pop) = 0; + virtual bool operator()(const eoPop < MOEOT > & _pop) = 0; /** @@ -152,13 +159,13 @@ public: } return true; } - + protected: /** * Updates the archive with a given individual _moeo * @param _moeo the given individual */ - void update(const MOEOT & _moeo) + bool update(const MOEOT & _moeo) { // first step: removing the dominated solutions from the archive for (unsigned int j=0; j & _pop) + bool update(const eoPop < MOEOT > & _pop) { + bool res = false; for (unsigned int i=0; i<_pop.size(); i++) { - (*this).update(_pop[i]); + res = (*this).update(_pop[i]) || res; } + return res; } - + private: diff --git a/trunk/paradiseo-moeo/src/archive/moeoBoundedArchive.h b/trunk/paradiseo-moeo/src/archive/moeoBoundedArchive.h index 45e1e92d2..f442464c0 100644 --- a/trunk/paradiseo-moeo/src/archive/moeoBoundedArchive.h +++ b/trunk/paradiseo-moeo/src/archive/moeoBoundedArchive.h @@ -99,10 +99,12 @@ public: /** * Updates the archive with a given individual _moeo * @param _moeo the given individual + * @return true if _moeo is non-dominated (and not if it is added to the archive) */ - void operator()(const MOEOT & _moeo) + bool operator()(const MOEOT & _moeo) { - update(_moeo); + bool res; + res = update(_moeo); if(size() > maxSize){ fitness(*this); @@ -110,16 +112,19 @@ public: std::sort(begin(), end(), indiComparator); resize(maxSize); } + return res; } /** * Updates the archive with a given population _pop * @param _pop the given population + * @return true if a _pop[i] is non-dominated (and not if it is added to the archive) */ - void operator()(const eoPop < MOEOT > & _pop) + bool operator()(const eoPop < MOEOT > & _pop) { - update(_pop); + bool res; + res = update(_pop); if(size() > maxSize){ fitness(*this); @@ -127,6 +132,7 @@ public: std::sort(begin(), end(), indiComparator); resize(maxSize); } + return res; } private: diff --git a/trunk/paradiseo-moeo/src/archive/moeoFixedSizeArchive.h b/trunk/paradiseo-moeo/src/archive/moeoFixedSizeArchive.h index e87c4385f..cef1493ae 100644 --- a/trunk/paradiseo-moeo/src/archive/moeoFixedSizeArchive.h +++ b/trunk/paradiseo-moeo/src/archive/moeoFixedSizeArchive.h @@ -73,20 +73,6 @@ public: */ moeoFixedSizeArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator) : moeoArchive < MOEOT >( _comparator) {} - - /** - * Updates the archive with a given individual _moeo - * @param _moeo the given individual - */ - virtual void operator()(const MOEOT & _moeo)=0; - - - /** - * Updates the archive with a given population _pop - * @param _pop the given population - */ - virtual void operator()(const eoPop < MOEOT > & _pop)=0; - }; #endif /*MOEOFIXEDSIZEARCHIVE_H_*/ diff --git a/trunk/paradiseo-moeo/src/archive/moeoSPEA2Archive.h b/trunk/paradiseo-moeo/src/archive/moeoSPEA2Archive.h index af3678e1f..a39304be2 100644 --- a/trunk/paradiseo-moeo/src/archive/moeoSPEA2Archive.h +++ b/trunk/paradiseo-moeo/src/archive/moeoSPEA2Archive.h @@ -126,20 +126,23 @@ public: /** * Updates the archive with a given individual _moeo * @param _moeo the given individual + * @return true (TODO) */ - void operator()(const MOEOT & _moeo) + bool operator()(const MOEOT & _moeo) { eoPop < MOEOT > pop_tmp; pop_tmp.push_back(_moeo); operator()(pop_tmp); + return true; } /** * Updates the archive with a given population _pop * @param _pop the given population + * @return true (TODO) */ - void operator()(const eoPop < MOEOT > & _pop) + bool operator()(const eoPop < MOEOT > & _pop) { unsigned int i; unsigned int foo=0; @@ -275,7 +278,7 @@ public: } } } - + return true; }//endoperator() diff --git a/trunk/paradiseo-moeo/src/archive/moeoUnboundedArchive.h b/trunk/paradiseo-moeo/src/archive/moeoUnboundedArchive.h index bae417896..6fc9998f2 100644 --- a/trunk/paradiseo-moeo/src/archive/moeoUnboundedArchive.h +++ b/trunk/paradiseo-moeo/src/archive/moeoUnboundedArchive.h @@ -75,20 +75,22 @@ public: /** * Updates the archive with a given individual _moeo * @param _moeo the given individual + * @return true if _moeo is added to the archive */ - void operator()(const MOEOT & _moeo) + bool operator()(const MOEOT & _moeo) { - update(_moeo); + return update(_moeo); } /** * Updates the archive with a given population _pop * @param _pop the given population + * @return true if a _pop[i] is added to the archive */ - void operator()(const eoPop < MOEOT > & _pop) + bool operator()(const eoPop < MOEOT > & _pop) { - update(_pop); + return update(_pop); } };