Addition of a method sort for PSO
This commit is contained in:
parent
ef8bc7b03f
commit
2273573e04
4 changed files with 22 additions and 93 deletions
|
|
@ -125,6 +125,16 @@ class eoPop: public std::vector<EOT>, public eoObject, public eoPersistent
|
|||
bool operator()(const EOT* a, const EOT* b) const
|
||||
{ return b->operator<(*a); }
|
||||
};
|
||||
/// helper struct for comparing (EA or PSO)
|
||||
struct Cmp2
|
||||
{
|
||||
bool operator()(const EOT & a,const EOT & b) const
|
||||
{
|
||||
return b.operator<(a);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
sort the population. Use this member to sort in order
|
||||
|
|
@ -132,7 +142,7 @@ class eoPop: public std::vector<EOT>, public eoObject, public eoPersistent
|
|||
*/
|
||||
void sort(void)
|
||||
{
|
||||
std::sort(begin(), end(), std::greater<EOT>());
|
||||
std::sort(begin(), end(), Cmp2());
|
||||
}
|
||||
|
||||
/** creates a std::vector<EOT*> pointing to the individuals in descending order */
|
||||
|
|
|
|||
Reference in a new issue