Particle Swarm Optimization (PSO): How Particles Update Positions and Velocities (with a Flocking Analogy)

Particle Swarm Optimization (PSO): How Particles Update Positions and Velocities (with a Flocking Analogy)

Verified Sources
Nov 4, 2026

Particle Swarm Optimization keyword(PSO) keyworduses a swarm of particles to search for an optimum in a space of decision variables. Each particle “moves” through the search space by updating its keywordvelocity and keywordposition. The motion is guided by two memories: the particle’s own best position found so far (its keywordpbest) and the best position found by the entire swarm (its keywordgbest). In common form, PSO balances three effects: (i) inertia (continue moving as before), (ii) attraction to pbest (learn from self), and (iii) attraction to gbest (learn from the group).2

A simple birds-flocking analogy:

  • Imagine each particle is a bird flying over terrain.
  • The bird’s current keywordvelocity is how fast and in which direction it’s currently flying.
  • The bird also “remembers” the best spot it has ever found (pbest).
  • Birds can observe the best spot the flock has found so far (gbest).
  • At each moment, the bird keeps some of its prior motion (inertia), then adjusts direction toward its own best and the flock’s best—while some randomness helps exploration and prevents the flock from getting stuck too early.2

Mermaid mental model:

Footnotes

  1. Particle swarm optimization (PSO) overview and update equations — https://en.wikipedia.org/wiki/Particle_swarm_optimization - Defines velocity/position updates, inertia weight, and pbest/gbest concepts. ↩ ↩2

  2. Standard PSO algorithm description and parameter roles — https://www.geeksforgeeks.org/particle-swarm-optimization/ - Explains PSO steps and interprets inertia/cognitive/social terms in the iteration process. ↩ ↩2

Particle Swarm Optimization (PSO) - How it Works

Core PSO update rules: positions and velocities

Let particle ii at iteration tt have:

  • position vector xi(t)x_i(t) (candidate solution),
  • velocity vector vi(t)v_i(t) (movement),
  • personal best position pbestipbest_i,
  • global best position gbestgbest.

A widely used PSO update uses these equations (vector form):2

  1. Velocity update
vi(t+1)=w vi(t)+c1 r1 (pbesti−xi(t))+c2 r2 (gbest−xi(t))v_i(t+1)=w\,v_i(t)+c_1\,r_1\,(pbest_i-x_i(t))+c_2\,r_2\,(gbest-x_i(t))
  1. Position update
xi(t+1)=xi(t)+vi(t+1)x_i(t+1)=x_i(t)+v_i(t+1)

Where:

  • ww is the inertia weight controlling how much the particle retains its current velocity.2
  • c1c_1 and c2c_2 are acceleration coefficients controlling how strongly a particle is pulled toward pbestipbest_i and gbestgbest respectively.2
  • r1r_1 and r2r_2 are random numbers in [0,1][0,1], typically sampled independently at each iteration (and usually per dimension), adding stochastic exploration.2

Key interpretation (ties to birds flocking)

  • Inertia term w vi(t)w\,v_i(t): “Keep some of your previous flying direction and speed.”2
  • Cognitive term c1 r1 (pbesti−xi(t))c_1\,r_1\,(pbest_i-x_i(t)): “Turn toward where you personally did best.”2
  • Social term c2 r2 (gbest−xi(t))c_2\,r_2\,(gbest-x_i(t)): “Also adjust toward where the flock did best.”2

Footnotes

  1. Particle swarm optimization (PSO) overview and update equations — https://en.wikipedia.org/wiki/Particle_swarm_optimization - Defines velocity/position updates, inertia weight, and pbest/gbest concepts. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7

  2. Standard PSO algorithm description and parameter roles — https://www.geeksforgeeks.org/particle-swarm-optimization/ - Explains PSO steps and interprets inertia/cognitive/social terms in the iteration process. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7

One PSO iteration (particle update loop)

  1. 1
    Step 1

    Pick NN particles with random positions xi(0)x_i(0) and velocities vi(0)v_i(0). Evaluate each particle’s fitness at its starting position.

  2. 2
    Step 2

    For each particle, set pbesti=xi(0)pbest_i=x_i(0). Track gbestgbest as the best pbestipbest_i across the swarm.

  3. 3
    Step 3

    Compute vi(t+1)=w vi(t)+c1 r1 (pbesti−xi(t))+c2 r2 (gbest−xi(t))v_i(t+1)=w\,v_i(t)+c_1\,r_1\,(pbest_i-x_i(t))+c_2\,r_2\,(gbest-x_i(t)) using new random r1,r2r_1,r_2 each iteration.

  4. 4
    Step 4

    Move the particle: xi(t+1)=xi(t)+vi(t+1)x_i(t+1)=x_i(t)+v_i(t+1).

  5. 5
    Step 5

    Compute the objective/fitness value at xi(t+1)x_i(t+1).

  6. 6
    Step 6

    If the new position improves the particle, update pbesti=xi(t+1)pbest_i=x_i(t+1). Then update gbestgbest to the best pbestipbest_i over all particles.

  7. 7
    Step 7

    Stop after a fixed number of iterations, or when improvement becomes small, or when a target fitness is reached.

How each PSO term influences motion (conceptual contributions)

These are qualitative weights: higher magnitude typically causes stronger pull in that direction.

Pro Tip: Why the random numbers matter

The r1r_1 and r2r_2 terms make the cognitive and social pulls vary every iteration, which helps the swarm explore different regions instead of collapsing into a single trajectory too early.2

Footnotes

  1. Particle swarm optimization (PSO) overview and update equations — https://en.wikipedia.org/wiki/Particle_swarm_optimization - Defines velocity/position updates, inertia weight, and pbest/gbest concepts. ↩

  2. Standard PSO algorithm description and parameter roles — https://www.geeksforgeeks.org/particle-swarm-optimization/ - Explains PSO steps and interprets inertia/cognitive/social terms in the iteration process. ↩

Common implementation pitfall: update ordering

Be consistent about whether you use vi(t+1)v_i(t+1) immediately for xi(t+1)x_i(t+1). The standard form shown here updates velocity first, then position using the new velocity: xi(t+1)=xi(t)+vi(t+1)x_i(t+1)=x_i(t)+v_i(t+1). Mixing vi(t)v_i(t) vs vi(t+1)v_i(t+1) can change behavior substantially.2

Footnotes

  1. Particle swarm optimization (PSO) overview and update equations — https://en.wikipedia.org/wiki/Particle_swarm_optimization - Defines velocity/position updates, inertia weight, and pbest/gbest concepts. ↩

  2. Standard PSO algorithm description and parameter roles — https://www.geeksforgeeks.org/particle-swarm-optimization/ - Explains PSO steps and interprets inertia/cognitive/social terms in the iteration process. ↩

A tiny numeric walk-through (1D) to make the updates tangible

Assume a 1D objective, so everything is scalars. At iteration tt for particle ii:

  • current position: xi(t)=2x_i(t)=2
  • current velocity: vi(t)=0.5v_i(t)=0.5
  • personal best: pbesti=5pbest_i=5
  • global best: gbest=4gbest=4
  • parameters: w=0.7w=0.7, c1=1.5c_1=1.5, c2=1.5c_2=1.5
  • random draws: r1=0.3r_1=0.3, r2=0.8r_2=0.8

Velocity update

vi(t+1)=0.7(0.5)+1.5(0.3)(5−2)+1.5(0.8)(4−2)v_i(t+1)=0.7(0.5)+1.5(0.3)(5-2)+1.5(0.8)(4-2) vi(t+1)=0.35+1.5(0.3)(3)+1.5(0.8)(2)v_i(t+1)=0.35+1.5(0.3)(3)+1.5(0.8)(2) vi(t+1)=0.35+1.35+2.4=4.10v_i(t+1)=0.35+1.35+2.4=4.10

Position update

xi(t+1)=xi(t)+vi(t+1)=2+4.10=6.10x_i(t+1)=x_i(t)+v_i(t+1)=2+4.10=6.10

Interpretation in flocking terms: the particle had inertia (kept moving in its prior direction), but strong social pull toward gbestgbest (because gbest−xi(t)gbest-x_i(t) is large and r2r_2 was large) made it turn more aggressively than the cognitive term.2

Footnotes

  1. Particle swarm optimization (PSO) overview and update equations — https://en.wikipedia.org/wiki/Particle_swarm_optimization - Defines velocity/position updates, inertia weight, and pbest/gbest concepts. ↩

  2. Standard PSO algorithm description and parameter roles — https://www.geeksforgeeks.org/particle-swarm-optimization/ - Explains PSO steps and interprets inertia/cognitive/social terms in the iteration process. ↩

Common PSO concepts (mapped to the flocking analogy)

PSO search cycle (repeated iterations)

Initialize

t = 0

Random positions xi(0)x_i(0), velocities vi(0)v_i(0); set pbestipbest_i and gbestgbest."

Move

t → t+1 (repeat)

Update vi(t+1)v_i(t+1) using inertia + cognitive + social; then set xi(t+1)=xi(t)+vi(t+1)x_i(t+1)=x_i(t)+v_i(t+1)."

Remember

After moving

Evaluate fitness; update pbestipbest_i and then gbestgbest."

Termination

Stop

Stop at max iterations or when improvements fall below a threshold."

PSO Quick Recall

1 / 4
Question · Term

What are the two quantities each PSO particle maintains?

Click to reveal
Answer · Definition

A position xix_i (candidate solution) and a velocity viv_i (how it moves).

Knowledge Check

Question 1 of 3
Q1Single choice

In the standard PSO update, which term pulls a particle toward its own best position?