liveBook · Manning

Particle swarm optimization

As explained in Grokking AI Algorithms, Second Edition

Particle swarm optimization is a swarm-intelligence optimization technique in which particles adjust candidate solutions using collective and individual search information.

Particle swarm optimization (PSO) searches for a good solution by moving a group of candidate solutions, called particles, through a search space. The idea comes from swarms such as bird flocks: individuals move, but their collective behavior helps the group find a direction. PSO is especially useful when there are too many possible combinations to check one by one. section 7.1 section 7.2

Finding a drone material mix

Suppose a drone’s performance depends on its amounts of aluminum and plastic. Those amounts give each candidate a position in a two-dimensional search space; the resulting performance is its fitness score, not a third dimension to search. Because the amounts can vary by tiny decimal increments, testing every mix is impractical. PSO instead explores selected positions and seeks a high-scoring mix—like hikers searching for a mountain peak. section 7.3

A PSO run follows a repeating cycle:

  • Choose the number of particles and give each a random starting position. section 7.5
  • Calculate how good each position is using the problem’s fitness measure. section 7.5
  • Move the particles using swarm behavior, then evaluate their new positions. Repeat until the stopping condition is met. section 7.5
  • Return the best position the swarm found. section 7.5
Figure 7.13 The life cycle of a PSO algorithm
07_13

The life-cycle diagram shows where evaluation and movement repeat before the swarm returns a solution. section 7.5

PSO can search large, high-dimensional spaces without exhaustively testing every value. Applications include configuring electrodes for deep-brain stimulation and tuning neural-network weights. As a rule of thumb, swarm algorithms suit continuous numeric choices, while genetic algorithms are often better suited to discrete choices. section 7.10 section 6.1

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Walks through initialization, fitness evaluation, repeated particle movement, stopping, and returning the best position; treats movement details as a further step.
Examples
Uses a drone’s aluminum–plastic mix and a mountain-peak analogy, then identifies electrode configuration and neural-network weights as applications.
What it assumes
Introduces search-space dimensions and fitness through concrete examples; defers the mechanics of artificial neural networks.
What you can do after
Build it from scratch: initialize particles, evaluate fitness, repeat position updates, and return the best solution found.
How it connects
Connects swarm intelligence, continuous optimization, fitness scores, genetic algorithms, and neural-network weight tuning.

Also explained in

Compare how 3 books explain particle swarm optimization →

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.