Class Particle


  • public class Particle
    extends Object
    Class representing a particle in the swarm.
    Author:
    Andrea Antonello (www.hydrologis.com)
    • Constructor Detail

      • Particle

        public Particle​(double[][] ranges)
        Create a new Particle with a given number of parameters dimension.
        Parameters:
        ranges - the parameters spaces ranges.
    • Method Detail

      • getInitialLocations

        public double[] getInitialLocations()
        Returns:
        the initial swarm location.
      • update

        public double[] update​(double w,
                               double c1,
                               double rand1,
                               double c2,
                               double rand2,
                               double[] globalBest)
        Particle swarming formula to update positions.
        Parameters:
        w - inertia weight (controls the impact of the past velocity of the particle over the current one).
        c1 - constant weighting the influence of local best solutions.
        rand1 - random factor introduced in search process.
        c2 - constant weighting the influence of global best solutions.
        rand2 - random factor introduced in search process.
        globalBest - leader particle (global best) in all dimensions.
        Returns:
        the updated locations or null, if they are outside the ranges.
      • getParticleBestFunction

        public double getParticleBestFunction()
        Calculated local best function value for the particle.
        Returns:
        the local best function value for the particle.
      • setParticleBestFunction

        public void setParticleBestFunction​(double particleBestFunction)
        Setter for the local best function value of the particle.
        Parameters:
        particleBestFunction - the new local best function value to set for the particle.
      • setParticleLocalBeststoCurrent

        public void setParticleLocalBeststoCurrent()
        Setter to set the current positions to be the local best positions.