diff --git a/eo/src/eoConstrictedVelocity.h b/eo/src/eoConstrictedVelocity.h index baac496b..ba3eb4f6 100644 --- a/eo/src/eoConstrictedVelocity.h +++ b/eo/src/eoConstrictedVelocity.h @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: thomas.legrand@lifl.fr + clive.canape@inria.fr */ //----------------------------------------------------------------------------- @@ -170,7 +171,13 @@ public: topology.updateNeighborhood(_po,_indice); } + //! eoTopology getTopology + //! @return topology + eoTopology & getTopology () + { + return topology; + } protected: eoTopology < POT > & topology; diff --git a/eo/src/eoLinearTopology.h b/eo/src/eoLinearTopology.h index 164d2bf4..f6daed53 100644 --- a/eo/src/eoLinearTopology.h +++ b/eo/src/eoLinearTopology.h @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: thomas.legrand@lifl.fr + clive.canape@inria.fr */ //----------------------------------------------------------------------------- @@ -161,6 +162,28 @@ public: return (neighborhoods[theGoodNhbd].best()); } + /* + * Return the global best of the topology + */ + + virtual POT & globalBest(const eoPop& _pop) + { + unsigned howManyNeighborhood=_pop.size()/ neighborhoodSize; + POT globalBest,tmp; + unsigned indGlobalBest=0; + globalBest=neighborhoods[0].best(); + for(unsigned i=1;i getTopology + //! @return topology + eoTopology & getTopology () + { + return topology; + } protected: eoTopology < POT > & topology; diff --git a/eo/src/eoStarTopology.h b/eo/src/eoStarTopology.h index 55fe81b0..5f935cc3 100644 --- a/eo/src/eoStarTopology.h +++ b/eo/src/eoStarTopology.h @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: thomas.legrand@lifl.fr + clive.canape@inria.fr */ //----------------------------------------------------------------------------- @@ -106,6 +107,15 @@ public: * @return POT & - The best particle in the neighborhood of the particle whose indice is _indice */ POT & best (unsigned _indice) {return (neighborhood.best());} + + /* + * Return the global best of the topology + */ + + virtual POT & globalBest(const eoPop& _pop) + { + return neighborhood.best(); + } /** diff --git a/eo/src/eoTopology.h b/eo/src/eoTopology.h index 6a47721e..d62e6a2a 100644 --- a/eo/src/eoTopology.h +++ b/eo/src/eoTopology.h @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: thomas.legrand@lifl.fr + clive.canape@inria.fr */ //----------------------------------------------------------------------------- @@ -63,6 +64,28 @@ public: * Build the neighborhoods contained in the topology. */ virtual POT & best (unsigned ) = 0; + + /* + * Return the global best + */ + + virtual POT & globalBest(const eoPop& _pop) + { + POT globalBest,tmp; + unsigned indGlobalBest=0; + globalBest=best(0); + for(unsigned i=1;i<_pop.size();i++) + { + tmp=best(i); + if(globalBest.best() < tmp.best()) + { + globalBest=tmp; + indGlobalBest=i; + } + + } + return best(indGlobalBest); + } /** * Build the neighborhoods contained in the topology. diff --git a/eo/src/eoVelocity.h b/eo/src/eoVelocity.h index 7b656dea..3e01efdb 100644 --- a/eo/src/eoVelocity.h +++ b/eo/src/eoVelocity.h @@ -29,6 +29,7 @@ #include #include #include +#include //----------------------------------------------------------------------------- /** @@ -38,7 +39,6 @@ template < class POT > class eoVelocity:public eoBF < POT &,unsigned , void > { public: - /** * Apply the velocity computation to a whole given population. * Used for synchronous PSO. @@ -69,6 +69,10 @@ public: } } + + + virtual eoTopology & getTopology () = 0; + }; #endif /*EOVELOCITY_H_H */