completed pso topologies+velocities
This commit is contained in:
parent
0280487348
commit
942f5214e0
6 changed files with 77 additions and 2 deletions
|
|
@ -19,6 +19,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
Contact: thomas.legrand@lifl.fr
|
Contact: thomas.legrand@lifl.fr
|
||||||
|
clive.canape@inria.fr
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -170,7 +171,13 @@ public:
|
||||||
topology.updateNeighborhood(_po,_indice);
|
topology.updateNeighborhood(_po,_indice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! eoTopology<POT> getTopology
|
||||||
|
//! @return topology
|
||||||
|
|
||||||
|
eoTopology<POT> & getTopology ()
|
||||||
|
{
|
||||||
|
return topology;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eoTopology < POT > & topology;
|
eoTopology < POT > & topology;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
Contact: thomas.legrand@lifl.fr
|
Contact: thomas.legrand@lifl.fr
|
||||||
|
clive.canape@inria.fr
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -161,6 +162,28 @@ public:
|
||||||
return (neighborhoods[theGoodNhbd].best());
|
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.
|
* Print the structure of the topology on the standrad output.
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
Contact: thomas.legrand@lifl.fr
|
Contact: thomas.legrand@lifl.fr
|
||||||
|
clive.canape@inria.fr
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -154,7 +155,14 @@ public:
|
||||||
{
|
{
|
||||||
topology.updateNeighborhood(_po,_indice);
|
topology.updateNeighborhood(_po,_indice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! eoTopology<POT> getTopology
|
||||||
|
//! @return topology
|
||||||
|
|
||||||
|
eoTopology<POT> & getTopology ()
|
||||||
|
{
|
||||||
|
return topology;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eoTopology < POT > & topology;
|
eoTopology < POT > & topology;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
Contact: thomas.legrand@lifl.fr
|
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
|
* @return POT & - The best particle in the neighborhood of the particle whose indice is _indice
|
||||||
*/
|
*/
|
||||||
POT & best (unsigned _indice) {return (neighborhood.best());}
|
POT & best (unsigned _indice) {return (neighborhood.best());}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the global best of the topology
|
||||||
|
*/
|
||||||
|
|
||||||
|
virtual POT & globalBest(const eoPop<POT>& _pop)
|
||||||
|
{
|
||||||
|
return neighborhood.best();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
Contact: thomas.legrand@lifl.fr
|
Contact: thomas.legrand@lifl.fr
|
||||||
|
clive.canape@inria.fr
|
||||||
*/
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -63,6 +64,28 @@ public:
|
||||||
* Build the neighborhoods contained in the topology.
|
* Build the neighborhoods contained in the topology.
|
||||||
*/
|
*/
|
||||||
virtual POT & best (unsigned ) = 0;
|
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.
|
* Build the neighborhoods contained in the topology.
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
#include <utils/eoRNG.h>
|
#include <utils/eoRNG.h>
|
||||||
#include <eoPop.h>
|
#include <eoPop.h>
|
||||||
|
#include <eoTopology.h>
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -38,7 +39,6 @@
|
||||||
template < class POT > class eoVelocity:public eoBF < POT &,unsigned , void >
|
template < class POT > class eoVelocity:public eoBF < POT &,unsigned , void >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the velocity computation to a whole given population.
|
* Apply the velocity computation to a whole given population.
|
||||||
* Used for synchronous PSO.
|
* Used for synchronous PSO.
|
||||||
|
|
@ -69,6 +69,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual eoTopology<POT> & getTopology () = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*EOVELOCITY_H_H */
|
#endif /*EOVELOCITY_H_H */
|
||||||
|
|
|
||||||
Reference in a new issue