liveBook · Manning

Velocity

As explained in Grokking AI Algorithms, Second Edition

A velocity is a particle's vector describing the direction and magnitude of its movement through the search space.

In particle swarm optimization, velocity is a particle’s vector describing the direction and magnitude of its movement through the search space. It determines how far and which way the particle moves during an update. section 7.4 section 7.8

Velocity combines three influences:

  • Inertia preserves some of the particle’s current motion; high inertia encourages exploration, while low inertia supports exploitation near good solutions. section 7.8
  • The cognitive component pulls the particle toward its own best-known position. section 7.8
  • The social component pulls the particle toward the swarm’s best-known position. section 7.8

The algorithm adds these influences to calculate a new velocity, then adds that velocity to the current position. Repeating this process lets particles explore different regions while converging toward promising solutions. section 7.8

A particle takes its next step

A particle at position (-1, 9) receives velocity 1.52. Its new position becomes (0.52, 10.52), illustrating how velocity translates a calculated movement into a position update. A firefly analogy captures the initialization intuition: small random starting velocities make particles scatter immediately instead of waiting for a leader. section 7.6 section 7.8

Figure 7.23 Particle-velocity calculation walk-through
07_23

Use the particle-velocity calculation walk-through to trace how the component influences combine into a new velocity. section 7.8

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Explains velocity through inertia, cognitive, and social components, then traces its use in position updates and Python code.
Examples
Uses random starting kicks, particle tables, fireflies, plotted movement, and a worked transition from velocity 1.52 to position (0.52, 10.52).
What you can do after
Apply via Python by calculating component influences, combining them into velocity, and updating each particle’s position.
How it connects
Connects velocity with particles, position, fitness function, inertia, cognitive component, social component, and search space.

Also explained in

Compare how 4 books explain velocity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.