Class ParticleSwarmOptimization

  • All Implemented Interfaces:
    Minimizer

    public final class ParticleSwarmOptimization
    extends AbstractMinimizer
    Particle Swarm Optimization algorithm to minimize costfunctions. This works quite like GradientDescent, but for this to work we don't need to have a derivative, it is enough to provide the cost at a certain parameter position (theta). For additional information you can browse the wikipedia page: Particle swarm optimization article on Wikipedia
    Author:
    thomas.jungblut
    • Constructor Summary

      Constructors 
      Constructor Description
      ParticleSwarmOptimization​(int numParticles, double alpha, double beta, double phi, int numThreads)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      de.jungblut.math.DoubleVector minimize​(CostFunction f, de.jungblut.math.DoubleVector pInput, int maxIterations, boolean verbose)
      Minimizes the given costfunction with the starting parameter theta.
      static de.jungblut.math.DoubleVector minimizeFunction​(CostFunction f, de.jungblut.math.DoubleVector pInput, int numParticles, double alpha, double beta, double phi, int maxIterations, int numThreads, boolean verbose)
      Minimize a function using particle swarm optimization.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ParticleSwarmOptimization

        public ParticleSwarmOptimization​(int numParticles,
                                         double alpha,
                                         double beta,
                                         double phi,
                                         int numThreads)
    • Method Detail

      • minimize

        public final de.jungblut.math.DoubleVector minimize​(CostFunction f,
                                                            de.jungblut.math.DoubleVector pInput,
                                                            int maxIterations,
                                                            boolean verbose)
        Description copied from interface: Minimizer
        Minimizes the given costfunction with the starting parameter theta.
        Parameters:
        f - the costfunction to minimize.
        pInput - the starting parameters.
        maxIterations - the number of iterations to do.
        verbose - if TRUE it will print progress.
        Returns:
        the optimized theta parameters.
      • minimizeFunction

        public static de.jungblut.math.DoubleVector minimizeFunction​(CostFunction f,
                                                                     de.jungblut.math.DoubleVector pInput,
                                                                     int numParticles,
                                                                     double alpha,
                                                                     double beta,
                                                                     double phi,
                                                                     int maxIterations,
                                                                     int numThreads,
                                                                     boolean verbose)
        Minimize a function using particle swarm optimization.
        Parameters:
        f - the cost function to minimize. Note that the returned gradient will be ignored, because it is not needed in this algorithm.
        pInput - the initial starting point of the algorithm / particles. This is very important to choose, since this is considered a fast algorithm you could try out multiple starting points.
        numParticles - how many particles to use.
        alpha - personal memory weighting.
        beta - group memory weighting.
        phi - own velocity weighting (inertia).
        maxIterations - how many iterations this algorithm should perform.
        verbose - if true prints progress to STDOUT.
        Returns:
        a optimized parameter set for the costfunction.