completed pso topologies+velocities

This commit is contained in:
tlegrand 2007-11-12 15:45:27 +00:00
commit 942f5214e0
6 changed files with 77 additions and 2 deletions

View file

@ -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<POT> getTopology
//! @return topology
eoTopology<POT> & getTopology ()
{
return topology;
}
protected:
eoTopology < POT > & topology;

View file

@ -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<POT>& _pop)
{
unsigned howManyNeighborhood=_pop.size()/ neighborhoodSize;
POT globalBest,tmp;
unsigned indGlobalBest=0;
globalBest=neighborhoods[0].best();
for(unsigned i=1;i<howManyNeighborhood;i++)
{
tmp=neighborhoods[i].best();
if(globalBest.best() < tmp.best())
{
globalBest=tmp;
indGlobalBest=i;
}
}
return neighborhoods[indGlobalBest].best();
}
/**
* Print the structure of the topology on the standrad output.

View file

@ -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
*/
//-----------------------------------------------------------------------------
@ -154,7 +155,14 @@ public:
{
topology.updateNeighborhood(_po,_indice);
}
//! eoTopology<POT> getTopology
//! @return topology
eoTopology<POT> & getTopology ()
{
return topology;
}
protected:
eoTopology < POT > & topology;

View file

@ -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<POT>& _pop)
{
return neighborhood.best();
}
/**

View file

@ -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<POT>& _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.

View file

@ -29,6 +29,7 @@
#include <eoFunctor.h>
#include <utils/eoRNG.h>
#include <eoPop.h>
#include <eoTopology.h>
//-----------------------------------------------------------------------------
/**
@ -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<POT> & getTopology () = 0;
};
#endif /*EOVELOCITY_H_H */