git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1569 331e1502-861f-0410-8da2-ba01fb791d7f

This commit is contained in:
jhumeau 2009-03-25 10:33:12 +00:00
commit 950ec58a6e
3 changed files with 81 additions and 9 deletions

View file

@ -0,0 +1,54 @@
#ifndef _eoAmeliorationContinue_h
#define _eoAmeliorationContinue_h
#include <iostream>
#include <sstream>
#include <fstream>
#include <eoContinue.h>
template< class EOT>
class eoAmeliorationContinue: public eoContinue<EOT>
{
public:
eoAmeliorationContinue(unsigned int _maxGen) : maxGen(_maxGen), counter(0){}
// _pop must be an archive
virtual bool operator() (const eoPop<EOT> & _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

View file

@ -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;
}

View file

@ -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()<maxSize)
push_back(_moeo);
//else
//dom=!dom;
if(size()<maxSize){
push_back(_moeo);
isModified=true;
}
else
dom=!dom;
}
return !dom;
}