Particle Swarm Optimization
A swarm of candidate solutions moves through the search space, each pulled toward its own best and the swarm's best position.
Swarm intelligence
Particle swarm optimization (PSO) models a population of particles flying through the search space. Each particle has a position (a candidate solution) and a velocity. It remembers its own best position found so far and knows the best position found by the swarm, and it accelerates toward a blend of both. Collective behavior converges the swarm on good regions.
The velocity update
v_{i} = w*v_i + c1*r1*(pbest_i - x_i) + c2*r2*(gbest - x_i), then x_i = x_i + v_i. Here w is inertia weight, c1 the cognitive coefficient (pull toward the particle's own best), c2 the social coefficient (pull toward the global best), and r1, r2 are random numbers in [0,1] that add stochasticity.
Balancing the terms
- Inertia w controls exploration; large w keeps particles moving, small w encourages convergence.
- Cognitive term c1 promotes individual exploration of remembered good spots.
- Social term c2 promotes convergence toward the swarm's best.
- Decreasing w over the run shifts from exploration to exploitation.
Neighborhood topologies
Using the global best (gbest) makes the swarm converge fast but risks premature convergence. Local topologies, where each particle sees only a neighborhood's best (lbest), slow convergence but explore more thoroughly and resist getting trapped. Ring and von Neumann topologies are common choices.
Characteristics
PSO is simple, needs no gradients, has few parameters, and parallelizes naturally. It works well on continuous multimodal problems but can stagnate if the swarm loses diversity. It shares the strengths and limitations of other population-based metaheuristics: robust but evaluation-hungry, with no convergence guarantee.
for _ in range(iters):
for p in swarm:
p.v = w*p.v + c1*rand()*(p.best-p.x) + c2*rand()*(gbest-p.x)
p.x = p.x + p.v
update_bests(p)
Particle swarm optimization tunes continuous design parameters against black-box objectives with minimal setup and easy parallelism.