From 950ec58a6e1f2701dd932470cb32bcf6d3bd458c Mon Sep 17 00:00:00 2001 From: jhumeau Date: Wed, 25 Mar 2009 10:33:12 +0000 Subject: [PATCH] git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1569 331e1502-861f-0410-8da2-ba01fb791d7f --- .../MOLS/src2/eoAmeliorationContinue.h | 54 +++++++++++++++++++ .../branches/MOLS/src2/moeoNewArchive.h | 14 +++-- .../MOLS/src2/moeoNewBoundedArchive.h | 22 +++++--- 3 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 contribution/branches/MOLS/src2/eoAmeliorationContinue.h diff --git a/contribution/branches/MOLS/src2/eoAmeliorationContinue.h b/contribution/branches/MOLS/src2/eoAmeliorationContinue.h new file mode 100644 index 000000000..cafe316bb --- /dev/null +++ b/contribution/branches/MOLS/src2/eoAmeliorationContinue.h @@ -0,0 +1,54 @@ +#ifndef _eoAmeliorationContinue_h +#define _eoAmeliorationContinue_h + +#include +#include +#include +#include + +template< class EOT> +class eoAmeliorationContinue: public eoContinue +{ +public: + + eoAmeliorationContinue(unsigned int _maxGen) : maxGen(_maxGen), counter(0){} + + + // _pop must be an archive + virtual bool operator() (const eoPop & _pop) + { + if(_pop.modified()) + counter=0; + else + counter++; + return (counter < maxGen); + } + + + virtual std::string className(void) const + { + return "eoAmeliorationContinue"; + } + + + void readFrom (std :: istream & __is) + { + + __is >> start; + } + + + void printOn (std :: ostream & __os) const + { + + __os << start << ' ' << std :: endl; + } + +private: + + unsigned int maxGeneration; + unsigned int counter; + +}; + +#endif diff --git a/contribution/branches/MOLS/src2/moeoNewArchive.h b/contribution/branches/MOLS/src2/moeoNewArchive.h index 2f23331eb..ee5008784 100755 --- a/contribution/branches/MOLS/src2/moeoNewArchive.h +++ b/contribution/branches/MOLS/src2/moeoNewArchive.h @@ -63,7 +63,7 @@ public: * Default ctor. * The moeoObjectiveVectorComparator used to compare solutions is based on Pareto dominance */ - moeoNewArchive() : moeoArchive < MOEOT >(), comparator(paretoComparator) + moeoNewArchive() : moeoArchive < MOEOT >(), comparator(paretoComparator), isModified(false) {} @@ -71,7 +71,7 @@ public: * Ctor * @param _comparator the moeoObjectiveVectorComparator used to compare solutions */ - moeoNewArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator) : eoPop < MOEOT >(), comparator(_comparator) + moeoNewArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator) : eoPop < MOEOT >(), comparator(_comparator), isModified(false) {} @@ -160,6 +160,12 @@ public: return true; } + bool modified(){ + bool tmp = isModified; + isModified = false; + return tmp; + } + private: @@ -167,7 +173,8 @@ private: moeoObjectiveVectorComparator < ObjectiveVector > & comparator; /** A moeoObjectiveVectorComparator based on Pareto dominance (used as default) */ moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; - + /** bool*/ + bool isModified; /** * Updates the archive with a given individual _moeo *** NEW *** @@ -217,6 +224,7 @@ private: if (!dom) { push_back(_moeo); + isModified=true; } return !dom; } diff --git a/contribution/branches/MOLS/src2/moeoNewBoundedArchive.h b/contribution/branches/MOLS/src2/moeoNewBoundedArchive.h index 505440453..0f58561ce 100644 --- a/contribution/branches/MOLS/src2/moeoNewBoundedArchive.h +++ b/contribution/branches/MOLS/src2/moeoNewBoundedArchive.h @@ -63,7 +63,7 @@ public: * Default ctor. * The moeoObjectiveVectorComparator used to compare solutions is based on Pareto dominance */ - moeoNewBoundedArchive(unsigned int _maxSize=100) : moeoArchive < MOEOT >(), comparator(paretoComparator), maxSize(_maxSize) + moeoNewBoundedArchive(unsigned int _maxSize=100) : moeoArchive < MOEOT >(), comparator(paretoComparator), maxSize(_maxSize), isModified(false) {} @@ -71,7 +71,7 @@ public: * Ctor * @param _comparator the moeoObjectiveVectorComparator used to compare solutions */ - moeoNewBoundedArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100) : eoPop < MOEOT >(), comparator(_comparator), maxSize(_maxSize) + moeoNewBoundedArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, unsigned int _maxSize=100) : eoPop < MOEOT >(), comparator(_comparator), maxSize(_maxSize), isModified(false) {} @@ -160,6 +160,12 @@ public: return true; } + bool modified(){ + bool tmp = isModified; + isModified = false; + return tmp; + } + private: @@ -169,6 +175,8 @@ private: moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; /** Max size of archive*/ unsigned int maxSize; + /** bool */ + bool isModified; /** * Updates the archive with a given individual _moeo *** NEW *** @@ -217,10 +225,12 @@ private: } if (!dom) { - //if(size()