added best position updating + printOn

This commit is contained in:
tlegrand 2007-10-08 15:22:25 +00:00
commit c864f2deb5
4 changed files with 24 additions and 29 deletions

View file

@ -128,17 +128,18 @@ public:
return i;
}
/**
/**
* Update the neighborhood: update the particle's best fitness and the best particle
* of the corresponding neighborhood.
*/
void updateNeighborhood(POT & _po,unsigned _indice)
{
{
// update the best fitness of the particle
if (_po.fitness() > _po.best())
{
_po.best(_po.fitness());
_po.best(_po.fitness());
for(unsigned i=0;i<_po.size();i++)
_po.bestPositions[i]=_po[i];
}
// update the best in its neighborhood
@ -149,7 +150,6 @@ public:
}
}
/**
* Return the best informative of a particle. Could be itself.
* @param _indice - The indice of a particle in the population