These notes are directly copied from the PSO model included in NetLogo, created by Uri Wilensky.
Particle swarm optimization (PSO) is a search/optimization technique in the field of machine learning. Although PSO is usually employed on search spaces with many dimensions, this model demonstrates its use in a two dimensional space, for purposes of easier visualization.
Formally speaking, there is some unknown function
One approach (random search) would be to keep randomly choosing values
for
This model is closely based on the algorithm described by Kennedy and Eberhart’s original paper (see reference below). However, this model is meant to demonstrate the principle, rather than be an exact replica. Some alterations were necessary to account for using a toroidal (wrapping) world, and to enhance the visualization of the swarm motion. Also, the function being optimized is discrete (based on a grid of values), rather than continuous.
Each particle has a position
- Each particle is attracted toward the best location that it has personally found (personal best) previously in its history.
- Each particle is attracted toward the best location that any particle has ever found (global best) in the search space.
The strength with which the particles are pulled in each of these
directions is dependent on the parameters
ATTRACTION-TO-PERSONAL-BEST
and ATTRACTION-TO-GLOBAL-BEST
. As
particles move farther away from these “best” locations, the force of
attraction grows stronger. There is also a random factor about how
much the particle is pulled toward each of these locations.
In this model, the particle swarm is trying to optimize a function
that is determined by the values in the discrete grid of cells shown
in the view. The landscape is created by randomly assigning values to
each grid cell, then performing diffusion to smooth out the values,
resulting in numerous local minima (valleys) and maxima (hills). This
function was chosen merely for illustrative purposes. As a more
plausible example of a real application of PSO, the variables
The model runs until some particle in the swarm has found the “true” optimum value (which is 1.00).