![JAR search and dependency download from the Maven repository](/logo.png)
net.sourceforge.cilib.pso.iterationstrategies.SynchronousIterationStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cilib-library Show documentation
Show all versions of cilib-library Show documentation
A library of composable components enabling simpler Computational Intelligence
/** __ __
* _____ _/ /_/ /_ Computational Intelligence Library (CIlib)
* / ___/ / / / __ \ (c) CIRG @ UP
* / /__/ / / / /_/ / http://cilib.net
* \___/_/_/_/_.___/
*/
package net.sourceforge.cilib.pso.iterationstrategies;
import net.sourceforge.cilib.algorithm.population.AbstractIterationStrategy;
import net.sourceforge.cilib.entity.Topology;
import net.sourceforge.cilib.pso.PSO;
import net.sourceforge.cilib.pso.particle.Particle;
/**
* Implementation of the synchronous iteration strategy for PSO.
*/
public class SynchronousIterationStrategy extends AbstractIterationStrategy {
private static final long serialVersionUID = 6617737228912852220L;
/**
* {@inheritDoc}
*/
@Override
public SynchronousIterationStrategy getClone() {
return this;
}
/**
* This is an Synchronous strategy:
*
* - For all particles:
* - Update the particle velocity
* - Update the particle position
* - For all particles:
* - Calculate the particle fitness
* - For all particles in the current particle's neighbourhood:
* - Update the neighbourhood best
*
*
* @see net.sourceforge.cilib.PSO.IterationStrategy#performIteration(net.sourceforge.cilib.PSO.PSO)
* @param pso The {@link PSO} to have an iteration applied.
*/
@Override
public void performIteration(PSO pso) {
Topology topology = pso.getTopology();
for (Particle current : topology) {
current.updateVelocity();
current.updatePosition(); // TODO: replace with visitor (will simplify particle interface)
boundaryConstraint.enforce(current);
}
for (Particle current : topology) {
current.calculateFitness();
for (Particle other : topology.neighbourhood(current)) {
if (current.getSocialFitness().compareTo(other.getNeighbourhoodBest().getSocialFitness()) > 0) {
other.setNeighbourhoodBest(current);
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy