Archive modified
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1396 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
d6f1ad94a1
commit
c78c4c2f6b
5 changed files with 42 additions and 35 deletions
|
|
@ -42,12 +42,17 @@
|
|||
#include <comparator/moeoObjectiveVectorComparator.h>
|
||||
#include <comparator/moeoParetoObjectiveVectorComparator.h>
|
||||
|
||||
//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<size();)
|
||||
|
|
@ -194,6 +201,7 @@ protected:
|
|||
{
|
||||
push_back(_moeo);
|
||||
}
|
||||
return !dom;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -201,14 +209,16 @@ protected:
|
|||
* Updates the archive with a given population _pop
|
||||
* @param _pop the given population
|
||||
*/
|
||||
void update(const eoPop < MOEOT > & _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:
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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_*/
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue