Particle Swarm Optimisation
A swarm of particles flies through the search space, pulled toward the best places found.
The idea
Each particle has a position and velocity. Every step it is nudged toward its own best-ever position and toward the best position found by the swarm, with a little randomness. Information is shared, so the group converges on good regions quickly.
v ← w·v + c₁r₁(pbest − x) + c₂r₂(gbest − x)
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- particle
- velocity
- swarm best
Particles start scattered with small random velocities (orange arrows). The green dot is the best spot any particle has found.
- iteration:
- 0
- best:
- 0.614
Dark spots on the map are poor settings; bright spots are good. One of the peaks is the tallest.
Step by step
- 1Scatter particles with random positions and velocities.
- 2Score each particle; remember personal bests and the global best.
- 3Update each velocity: keep some momentum, pull toward personal and global best.
- 4Move each particle by its velocity and repeat.
Where it is used
Tuning hyper-parameters, engineering design, continuous optimisation.
Watch out for
Can converge prematurely to a local optimum if the swarm collapses too fast.