Add the SMP module
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2714 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
409a1b21b8
commit
0890c67d31
43 changed files with 4030 additions and 41 deletions
35
trunk/smp/src/MWAlgo/eoEasyPSO.cpp
Normal file
35
trunk/smp/src/MWAlgo/eoEasyPSO.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
template<template <class> class EOAlgo, class EOT>
|
||||
void paradiseo::smp::MWModel<EOAlgo,EOT>::operator()(eoPop<EOT>& _pop, const eoEasyPSO_tag&)
|
||||
{
|
||||
try
|
||||
{
|
||||
// initializes the topology, velocity, best particle(s)
|
||||
this->init();
|
||||
do
|
||||
{
|
||||
// loop over all the particles for the current iteration
|
||||
for (unsigned idx = 0; idx < _pop.size (); idx++)
|
||||
{
|
||||
// perform velocity evaluation
|
||||
this->velocity (_pop[idx],idx);
|
||||
|
||||
// apply the flight
|
||||
this->flight (_pop[idx]);
|
||||
}
|
||||
|
||||
// evaluate the position
|
||||
scheduler(EOAlgo<EOT>::eval, _pop);
|
||||
|
||||
for (unsigned idx = 0; idx < _pop.size (); idx++)
|
||||
// update the topology (particle and local/global best(s))
|
||||
this->velocity.updateNeighborhood(_pop[idx],idx);
|
||||
|
||||
} while (this->continuator (_pop));
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
std::string s = e.what ();
|
||||
s.append (" in eoEasyPSO");
|
||||
throw std::runtime_error (s);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue