Swarm Intelligence & PSO
Source: Unit 5 §9
What a swarm is
A swarm is a loosely structured collection of interacting agents that exhibits collective behaviour. Agents belong to a group, contribute to it and benefit from it, and can recognise, communicate with and interact with one another.
Swarm intelligence is an AI technique based on decentralised, self-organised systems: robust, reliable, simple, with no central control, and copied from nature. The standard examples are a bee swarm, an ant colony, a bird flock, road traffic, human crowds and the immune system.
A single ant acts almost randomly, often to its own destruction, yet the colony feeds and protects the whole population (E. O. Wilson, 1950s). That gap between agent and group is emergent intelligence, and it is the entire premise of swarm methods.
Particle swarm optimisation
PSO (Kennedy and Eberhart, 1995) is a population-based stochastic optimisation technique. Individuals, called particles, fly through the problem space, learning from their own experience and from their neighbours, and gradually move into better regions. It is inspired by flocks of birds, schools of fish and bee swarms.
- Each particle is searching for the optimum, and it moves, so it has a velocity.
- Each particle remembers its own best position so far, its
pbest. That memory is the thing a GA chromosome does not have. - Particles cooperate: a particle knows the fitness of its neighbourhood and uses the position of the best neighbour to adjust its velocity.
The equations
For particle , dimension , iteration :
| Symbol | Meaning |
|---|---|
xᵢ | particle position, a D-dimensional vector |
vᵢ | particle velocity |
pᵢ (pbest) | the particle's best previous position, i.e. its memory |
p_g (gbest) | the best position found anywhere in the swarm |
c₁, c₂ | cognitive and social parameters, positive constants |
rand₁, rand₂ | random numbers drawn uniformly from [0, 1] |
- Velocity clamping - if set , and if set . Without it a particle can leave the search space in one step.
- Inertia weight multiplies the previous velocity. Start it large for global exploration and decrease it over time for refinement.
- Constriction factor guarantees convergence.
must exceed 4 or the square root goes imaginary and the formula is meaningless. This is a constraint on your choice of and , not a suggestion.
The algorithm, global version
- Initialise the particles with random positions and velocities in D dimensions.
- Evaluate the fitness of each particle.
- Update
pbest: if the current fitness beats the particle's own best, replace it. - Update
gbest: if the current fitness beats the swarm's best, replace it. - Update velocity and position with the two equations, applying inertia.
- If the stopping criterion is not met, good enough fitness or maximum iterations, go back to step 2. Otherwise stop.
A worked example
Minimise with a swarm of 3 particles, , , and take to keep the arithmetic clean.
Both particles moved towards , the true optimum, pulled there by
gbest. Repeat until convergence.
The slide deck's PSO example was image-only, so the 1-D walkthrough above was reconstructed to show the same mechanics. The equations and the parameter meanings are the examinable part.