Particle Swarm Optimization

Demonstration of pso_js javascript code

Written by Marc Normandin


  • Basic
  • Weights
  • Stopping Condition
  • Display
  • Legend
Function the function to minimize
Topology how the particles communicate
# Neighbors particle's peers
(must be even #)
# Particles
Iterations per second
Inertial weight (Begin) particle's perseverance
Inertial weight (End) particle's perseverance
Inertial weight (Range) number of iterations to scale over
Social weight particle's peer pressure
Cognitive weight particle's independence
Stopping condition (current iteration #)
Particle radius radius of particles in pixels
Best Particle radius radius of best particle in pixels
Best Minimum radius radius of minimum in pixels
Display Dust display visited particle locations
Display lbests display each particles' local best
Display Particles display each particles' current position
LBest radius radius of lbest coordinates in pixels
Background dimension Size of background sample grid
  • red are particle current locations
  • purple are particle local best locations
  • yellow is the best overall minimum found
  • green is the particle that found the best minimum

estimated minimum:

true minimum:


A three-dimensional plot of the function being minimized


A two-dimensional contour plot of the function being minimized