diff --git a/eo/AUTHORS b/eo/AUTHORS index ca63a12d..1d6304e8 100644 --- a/eo/AUTHORS +++ b/eo/AUTHORS @@ -6,5 +6,6 @@ Gustavo Romero Lopez Maarten Keijzer Marc Schoenauer Jeroen Eggermont -Jochen Küpper +Jochen Kpper Thomas Legrand +Clive Canape diff --git a/eo/src/continuator.h b/eo/src/continuator.h deleted file mode 100644 index 97efc8ac..00000000 --- a/eo/src/continuator.h +++ /dev/null @@ -1,91 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// continuator.h -// (c) GeNeura Team, 1998 -/* - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Contact: todos@geneura.ugr.es, http://geneura.ugr.es - */ -//----------------------------------------------------------------------------- - -#ifndef _CONTINUATOR_H -#define _CONTINUATOR_H - - -#include -#include - -#include -#include - -/** - * Continue interface - */ -class continuator -{ -public: - virtual bool check()=0; -}; - - -template < class EOT> class eoContinuator : public continuator{ -public: - - eoContinuator(eoContinue & _cont, const eoPop & _pop): cont (_cont), pop(_pop){} - - virtual bool check(){ - return cont(pop); - } - -protected: - eoContinue & cont ; - const eoPop & pop; -}; - - - -template < class TYPE> class selector -{ -public: - virtual const TYPE & select()=0; -}; - - -template < class EOT> class eoSelector : public selector{ -public: - - eoSelector(eoSelectOne & _select, const eoPop & _pop): selector (_select), pop(_pop){} - - virtual const EOT & select(){ - return select(pop); - } - -protected: - eoSelectOne & selector ; - const eoPop & pop; -}; - -#endif - - - - - - - - - diff --git a/eo/src/eoPop.h b/eo/src/eoPop.h index a6ea147c..f8d75854 100644 --- a/eo/src/eoPop.h +++ b/eo/src/eoPop.h @@ -125,6 +125,16 @@ class eoPop: public std::vector, 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, public eoObject, public eoPersistent */ void sort(void) { - std::sort(begin(), end(), std::greater()); + std::sort(begin(), end(), Cmp2()); } /** creates a std::vector pointing to the individuals in descending order */ diff --git a/eo/src/eoVectorParticle.h b/eo/src/eoVectorParticle.h index b7eadc5c..ecb80a2e 100644 --- a/eo/src/eoVectorParticle.h +++ b/eo/src/eoVectorParticle.h @@ -119,6 +119,15 @@ public: { velocities.resize (_size); } + + /// to avoid conflicts between EA and PSO + bool operator<(const eoVectorParticle& _eo) const + { + if (_eo.best() > this->best()) + return true; + else + return false; + } /** * Print-on a vector-particle