Particle Swarm Optimization (PSO) Explorer © 2026 Theodore P. Pavlic · MIT License

PSO updates each particle's velocity as a weighted sum of three influences: its own momentum (inertia), attraction toward its personal best position (cognitive), and attraction toward the swarm's global best (social) — as introduced by Kennedy & Eberhart (1995), with the inertia weight refinement by Shi & Eberhart (1998). The animation cycles through the velocity decomposition for a single particle with fixed parameters; the right panel gives the update equations and a pseudocode sketch of the full algorithm. For a fully interactive simulation with adjustable parameters and live fitness landscapes, see Tab ② PSO Simulation.

Initializing…
Current position x Personal best p Global best g Current velocity v
➡ New Velocity
vi(t+1) = ωvi + φprp(pi−xi) + φgrg(g−xi) + η
Clamped to |v| ≤ vmax. Position updated: xi(t+1) = xi(t) + vi(t+1). The η term is optional.
Velocity Update
① Inertia
ω · vi(t)
Carries previous velocity forward. High ω → exploration; low ω → exploitation.
② Cognitive (Personal Best)
φp · rp · (pi − xi(t))
Pulls toward the particle's own historical best. Stochastic weight rp ∼ U(0,1) each step.
⊕ Velocity Noise — non-standard
η ∼ 𝒩(0, σ2I)
Additive Gaussian noise applied each step, independent of pbest and gbest. Not part of Kennedy & Eberhart's (1995) canonical PSO — inspired by the Vicsek (1995) flocking model and enables independent hill climbing by individuals.
Algorithm Sketch
initialize N particles randomly xi ∼ U(lb, ub); vi ∼ U(−vmax, vmax) pi ← xi; g ← argmaxi f(xi) repeat for each particle i: rp, rg ∼ U(0,1) ηi ∼ 𝒩(0,σ²I) // non-standard viωvi + φprp(pi−xi) + φgrg(g−xi) + ηi // non-standard vi ← clip(vi, −vmax, vmax) xi ← xi + vi if f(xi) > f(pi): pi ← xi if f(xi) > f(g): g ← xi until // mean|v| < ε or iter ≥ max
Convergence guarantee
Clerc & Kennedy (2002) analyzed convergence by writing the update as v(t+1) = χ [v(t) + φp rp(p−x) + φg rg(g−x)], where χ is the constriction factor. Convergence can be guaranteed under the conditions χ = 2 / |2−φ−√(φ2−4φ)| where φ ≜ φp + φg and φp + φg > 4 (which ensures χ is real and less than 1). The canonical choice φp = φg = 2.05 gives φ = 4.1 and χ ≈ 0.729 in this constriction-factor form. Distributing χ into the bracket recovers the inertia-weight form used here, with ω = χ ≈ 0.729 and effective coefficients χφp = χφg ≈ 1.494. The displayed φp, φg sliders on Tab ② control these distributed effective coefficients (which sum to > 4χ).