// the one-minute version
Particle Swarm Optimization, introduced by Kennedy and Eberhart in 1995, is swarm intelligence inspired by bird flocking and fish schooling. Instead of evolving a population through crossover and mutation, PSO moves a cloud of candidate solutions through the search space. Each particle remembers its own best position, listens to the best position found by its neighborhood or the whole swarm, and updates its velocity using inertia, personal experience, and social information. The result is a simple but surprisingly strong optimiser for continuous spaces, feature selection, neural network training, and many engineering problems.
Chapter 6 is the point where the ACI story shifts from Darwin-style evolution to collective motion. Chapter 5 gave us evolutionary computation: populations, selection pressure, recombination, mutation, and survival of fitter individuals. Chapter 7 will give us ants, pheromone, and constructive graph search. Particle Swarm Optimization sits beautifully between them. It is population-based like evolutionary algorithms, but the population does not reproduce. It is swarm-based like ACO, but it does not leave pheromone trails. Its memory lives inside particles and inside the communication topology of the swarm.
01 Why PSO belongs after evolutionary computation
PSO is easiest to understand if you first notice what it is not. It is not a genetic algorithm with a bird costume. There is no crossover operator taking two parent strings and splicing them into children. There is no mutation operator flipping bits or perturbing genes just to maintain diversity. There is usually no explicit survival contest where weak individuals are removed and strong individuals reproduce. A PSO particle stays itself. It moves.
That tiny change of verb matters. In a GA, the central question is: how do we create better offspring from existing solutions? In PSO, the central question is: how should each existing solution move next, given what it has personally learned and what the group has learned? So the algorithm feels less like breeding and more like coordinated navigation.
Kennedy and Eberhart originally developed PSO while thinking about social behaviour, especially the way flocks and schools appear to move with coordinated intelligence even though no single bird or fish is solving an optimisation equation. Individuals respond to their own state and to information from nearby individuals. The group pattern emerges from simple rules. That is the swarm-intelligence idea in one sentence.
02 The bird flocking metaphor, without over-romanticising it
The biological image is useful: imagine birds scattered over a landscape looking for food. Each bird can sense how good its current location is. Each bird remembers the best place it personally visited. It can also observe some successful neighbour or the best bird in the flock. A sensible bird will not teleport directly to the best known point, because the landscape might contain better food nearby and because sudden movement can overshoot. Instead, it drifts with momentum, bends toward its own memory, and bends toward social information.
That is already PSO. The landscape is the objective function. A bird is a particle. Food quality is fitness. A good remembered location is a best-so-far solution. Velocity is the current direction and speed of search. Randomness makes the pull imperfect, preventing the swarm from becoming a perfectly rigid machine.
The metaphor has limits. Real birds care about collision avoidance, aerodynamics, predators, and three-dimensional movement. PSO abstracts almost all of that away. What survives is the computationally useful part: multiple agents, simple local memory, social sharing, and adaptive movement. Engelbrecht's treatment emphasizes this distinction. We borrow inspiration from natural swarms, but the algorithm is a mathematical search process.
03 Swarm intelligence versus evolutionary computation
Swarm intelligence and evolutionary computation both use populations, randomness, and iterative improvement, so students often lump them together. The clean distinction is the mechanism of adaptation. Evolutionary computation adapts through selection and variation. Better individuals tend to influence the next generation more strongly, and variation operators create new individuals. Swarm intelligence adapts through interaction among agents and the environment. Agents usually persist, communicate directly or indirectly, and adjust behaviour based on collective information.
In PSO, every particle is a candidate solution. The particle does not die when it performs badly. It is simply pulled by memory and by social experience. This makes PSO psychologically easier to follow than many EAs. You can track one particle across time and see exactly why it moved.
| Question | Evolutionary computation | Particle Swarm Optimization |
|---|---|---|
| Main metaphor | Natural evolution | Flocking / schooling / social learning |
| Population member | Individual chromosome | Particle with position and velocity |
| Primary adaptation | Selection, crossover, mutation | Movement guided by pbest and gbest/lbest |
| Memory | Mostly implicit in population composition | Explicit personal and social bests |
| Natural fit | Discrete, combinatorial, mixed encodings | Continuous numerical optimisation |
04 Anatomy of a particle
A particle is a tiny record containing enough state to fly through the search space. For particle number 1, 2, ..., or generally particle i, we usually track at least four things.
- Position \(x_i(t)\): the current candidate solution at iteration \(t\). If the problem has \(d\) variables, then \(x_i\) is a vector in \(d\)-dimensional space.
- Velocity \(v_i(t)\): the particle's current movement vector. It says how much the position will change and in what direction.
- Personal best \(p_i\): also called pbest. This is the best position particle \(i\) has personally visited so far.
- Social best \(g\): often called gbest when it is the best position found by the whole swarm. In local-topology PSO it may instead be the best position found in particle \(i\)'s neighborhood.
So a particle is not just a point. It is a point with memory and momentum. That is why PSO can be more efficient than naive random search. A purely random point forgets everything after evaluation. A PSO particle carries its own search history and can be influenced by the discoveries of others.
If the objective is minimisation, “best” means lowest function value. If the objective is maximisation, “best” means highest. In most textbook examples, including the clean numerical examples below, we minimise a function such as \(f(x)=x^2\).
05 The full PSO update equation
The standard PSO update has two lines. First update velocity:
Then update position:
Every symbol in that first line deserves a plain-English translation.
- \(x_i(t)\) is particle \(i\)'s current position at time \(t\).
- \(v_i(t)\) is particle \(i\)'s current velocity before the update.
- \(v_i(t+1)\) is the new velocity that will be applied to the position.
- \(p_i\) is the particle's personal-best position, the best place it personally found.
- \(g\) is the social-best position available to the particle, usually the global best in the whole swarm.
- \(w\) is the inertia weight. It controls how much old velocity carries forward.
- \(c_1\) is the cognitive acceleration coefficient. It controls how strongly the particle trusts its own memory.
- \(c_2\) is the social acceleration coefficient. It controls how strongly the particle trusts the swarm.
- \(r_1\) and \(r_2\) are random numbers sampled from \([0,1]\), often independently for each dimension and each particle.
The equation is usually vector-valued. In two dimensions, for example, \(x_i=(x_{i1},x_{i2})\) and the same update is applied component by component. The random terms may differ per component, so the particle is not pulled in a perfectly straight deterministic line.
06 The three forces: inertia, cognitive pull, social pull
The velocity equation is much less scary when split into three forces. The first term, \(w\,v_i(t)\), is momentum. It says, “keep going somewhat in the direction you were already going.” A large inertia weight encourages wide exploration because particles keep flying across the search space. A small inertia weight damps movement, helping particles settle down.
The second term, \(c_1 r_1 (p_i-x_i(t))\), is the cognitive component. It says, “return toward the best place I personally discovered.” This protects individual experience. Even if the swarm is excited about some global location, a particle can still remember that it found something useful elsewhere.
The third term, \(c_2 r_2 (g-x_i(t))\), is the social component. It says, “move toward the best place the group knows about.” This is cooperation. Without it, each particle would be a private local searcher. With it, good discoveries spread through the swarm.
Fig 1 — the PSO velocity update as three vector pulls: inertia from old motion, cognitive pull toward pbest, and social pull toward gbest or lbest.
The random numbers \(r_1\) and \(r_2\) are not noise for the sake of noise. They randomise how strongly each pull acts at each update. Sometimes a particle follows its own memory more. Sometimes it follows the swarm more. This variation keeps paths from being too synchronized.
07 Global-best and local-best topologies
The symbol \(g\) hides an important design choice. In the simplest version, \(g\) is the best position found by the entire swarm. This is called the global-best model, or gbest PSO. Its communication topology is a star: every particle can be influenced by the same best-known solution.
gbest tends to converge quickly because good information spreads instantly. If any particle finds a strong region, the whole swarm feels the pull. The downside is premature convergence. If the early best point is only locally good, the entire swarm may collapse around it before exploring enough alternatives.
Local-best PSO, or lbest PSO, restricts social information to a neighborhood. A particle may communicate only with two neighbours in a ring, or with four neighbours in a von Neumann grid. In that case \(g\) should be read as “best in my neighborhood,” not necessarily best in the whole swarm.
Fig 2 — gbest connects everyone to the same best particle; ring lbest spreads information gradually through neighbourhoods.
The exploration-exploitation tradeoff is the whole story. gbest is exploitative. It uses the best known information aggressively. lbest is more exploratory. Several parts of the swarm can investigate different basins before the whole group agrees. For rugged multimodal functions, lbest topologies often avoid early collapse better than pure gbest.
08 Inertia weight, constriction, and velocity clamping
The original PSO formulation did not always use the same inertia-weight notation that later became standard, but modern teaching often presents \(w\) as the main speed-control knob. If \(w\) is high, old velocity survives strongly, so particles roam. If \(w\) is low, motion is damped, so particles settle.
A popular strategy is a linearly decreasing inertia weight. Start with something like \(w=0.9\) to encourage exploration, then reduce toward \(w=0.4\) to encourage exploitation near the end. The schedule can be written as:
Here \(T\) is the maximum number of iterations. This formula includes the exact idea: early motion is energetic, late motion is cautious.
Clerc and Kennedy's constriction-factor analysis gives another way to control swarm stability. Instead of only relying on inertia, we multiply the whole velocity update by a constriction factor \(\chi\):
A famous setting is \(c_1=c_2\approx2.05\), giving \(\phi\approx4.10\) and \(\chi\approx0.729\). This combination became popular because it gives a useful balance between convergence pressure and controlled movement.
Velocity clamping is a simpler safety device. It imposes a maximum allowed speed \(V_{max}\). Component-wise, after computing velocity, we clip it:
09 Parameter tuning guidance that actually helps
PSO has fewer knobs than many evolutionary algorithms, but the knobs interact. A common beginner setting is \(c_1=c_2=2\) with an inertia weight around 0.7. A common constriction-style setting is \(c_1=c_2\approx2.05\) with \(\chi\approx0.729\). A common inertia schedule is \(w\) decreasing from 0.9 to 0.4. These are not laws. They are sensible starting points.
The meaning of the parameters is more important than memorising numbers. Increasing \(c_1\) makes particles more individualistic. They orbit back toward their own discoveries and may preserve diversity longer. Increasing \(c_2\) makes particles more social. They rush toward the best shared discovery and may converge faster. Increasing \(w\) makes movement more ballistic. Decreasing \(w\) makes movement more careful.
High \(w\)
More momentum, wider exploration, higher chance of overshooting.
High \(c_1\)
More self-trust. Particles revisit personal discoveries and maintain variety.
High \(c_2\)
More social pressure. Faster convergence, more premature-collapse risk.
Small swarm
Cheap iterations, but limited coverage of the search space.
For simple smooth functions, gbest with moderate social pressure can work beautifully. For rugged functions with many local optima, use more particles, consider lbest topology, keep inertia higher for longer, or restart stagnant particles. The tuning question is always the same: are we exploring enough before we exploit?
10 A fully worked one-dimensional numerical iteration
Let us minimise \(f(x)=x^2\). The optimum is obviously \(x=0\), but that is exactly why it is a good teaching example: we can focus on the PSO bookkeeping rather than on a mysterious objective.
Use three particles at iteration \(t=0\):
| Particle | Position \(x_i(0)\) | Velocity \(v_i(0)\) | Fitness \(f(x)\) | Initial pbest \(p_i\) |
|---|---|---|---|---|
| 1 | 4.0 | -0.5 | 16.0 | 4.0 |
| 2 | -2.0 | 0.3 | 4.0 | -2.0 |
| 3 | 1.5 | -0.2 | 2.25 | 1.5 |
Because we are minimising, particle 3 has the best initial fitness, so the global best is \(g=1.5\). Choose \(w=0.7\), \(c_1=1.5\), and \(c_2=1.5\). Now update particle 1 using random values \(r_1=0.4\) and \(r_2=0.8\).
For particle 1, the personal-best term is zero because \(p_1=x_1(0)=4.0\). The social vector is \(g-x_1(0)=1.5-4.0=-2.5\). Therefore:
The new position is:
Now evaluate the new position: \(f(0.65)=0.4225\). That is better than particle 1's old personal best \(f(4)=16\), so update \(p_1=0.65\). It is also better than the previous global best \(f(1.5)=2.25\), so update \(g=0.65\).
11 A two-dimensional mini-step for vector intuition
In real optimisation, positions are often vectors. Suppose a particle is at \(x_i(t)=(3,4)\) with velocity \(v_i(t)=(-1,0.5)\). Its personal best is \(p_i=(2,1)\), and the swarm best is \(g=(0,0)\). Use \(w=0.5\), \(c_1=2\), \(c_2=2\), \(r_1=0.25\), and \(r_2=0.75\). For simplicity, use the same random values in both dimensions.
The terms are:
- Inertia: \(0.5(-1,0.5)=(-0.5,0.25)\)
- Cognitive: \(2(0.25)((2,1)-(3,4))=0.5(-1,-3)=(-0.5,-1.5)\)
- Social: \(2(0.75)((0,0)-(3,4))=1.5(-3,-4)=(-4.5,-6)\)
Add them:
So the next position is:
This example shows why velocity control matters. The particle was pulled strongly toward the origin and overshot it. That might be useful exploration, or it might be unstable behaviour if it repeats endlessly. In a real run, \(V_{max}\), constriction, or a smaller social coefficient would moderate the jump.
12 The algorithm in exam-friendly pseudocode
The complete PSO loop is short enough to memorise, but do not memorise it as a magic incantation. Read it as a repeated cycle of evaluation, memory update, social update, and movement.
- Initialise a swarm of particles with random positions and velocities.
- Evaluate each particle using the objective function.
- Set each particle's pbest to its initial position.
- Find the best pbest in the relevant topology and call it gbest or lbest.
- For each iteration, update velocities using inertia, cognitive, and social terms.
- Move particles by adding velocity to position.
- Apply bounds or repair if a particle leaves the legal search region.
- Evaluate new positions and update pbest values.
- Update neighborhood/global best values.
- Stop after a maximum iteration count, a target fitness, or a long period with no improvement.
If written compactly, the state update is almost a two-line engine wrapped in bookkeeping. That is one reason PSO became popular: it is simple to implement, easy to parallelise, and surprisingly competitive for many continuous problems.
13 Boundary handling and scaling
Most real problems have bounds. A neural-network weight may be allowed between two values, a design variable may have a physical range, or a feature-selection vector may need binary decisions. If a particle flies outside the valid space, the implementation must decide what to do.
Common strategies include clamping position to the nearest boundary, reflecting velocity like a ball bouncing from a wall, resampling invalid coordinates, or penalising invalid solutions through the fitness function. None is universally best. Clamping is simple, but it can cause particles to pile up on boundaries. Reflection preserves motion but can create oscillation. Resampling restores legality but may inject too much randomness.
Scaling also matters. If one variable ranges from 0 to 1 and another ranges from 0 to 1,000, the same velocity settings do not mean the same thing in both dimensions. Good implementations normalise variables or choose velocity limits per dimension. In notation, you might transform a raw variable \(x\) to a scaled variable \(\tilde{x}\) before optimisation, then map it back for evaluation.
14 PSO versus GA versus ACO
Because this chapter sits between EC and ACO, the comparison is worth making explicit. All three are population-based CI methods, but they store and use information differently.
| Feature | PSO | GA | ACO |
|---|---|---|---|
| Main inspiration | Flocks and schools | Biological evolution | Ant foraging and pheromone |
| Candidate solution | Particle position | Chromosome / individual | Constructed path or solution |
| Search motion | Velocity update in continuous space | Generate offspring by operators | Probabilistic construction step by step |
| Information sharing | pbest plus gbest/lbest | Selection pressure through reproduction | Pheromone matrix \(\tau\) and heuristic visibility |
| Typical strengths | Continuous numerical optimisation, tuning, model parameters | Flexible encodings, combinatorial and mixed problems | Graph, route, scheduling, TSP-style construction |
| Common risk | Premature convergence / swarm stagnation | Loss of diversity or disruptive crossover | Pheromone stagnation and greedy lock-in |
| Mathematical flavour | Difference vectors, velocities, sometimes \(\nabla f\)-free search | Selection and stochastic variation | Transition probabilities with \(\alpha\), \(\beta\), and evaporation \(\rho\) |
The phrase \(\nabla f\)-free matters. PSO does not need gradients. It only needs objective-function evaluations. That makes it useful when the function is noisy, discontinuous, non-differentiable, or too awkward for gradient methods. But if smooth gradients are cheap and reliable, gradient-based optimisation may be faster.
15 Variants: binary PSO, MOPSO, adaptive PSO, and hybrids
The original PSO is naturally continuous: positions and velocities are real-valued vectors. But many problems are discrete. Binary PSO adapts the idea by interpreting velocity as a probability-like tendency for a bit to be 1. A common mapping uses a sigmoid function:
Then a bit may be set according to whether a random number is less than \(S(v)\). The position no longer changes by simple addition in the same physical sense, but the velocity still stores a tendency shaped by personal and social experience. Binary PSO is especially common in feature selection, where each bit says whether a feature is included.
Multi-objective PSO, usually called MOPSO, handles problems with more than one objective. Instead of one best solution, the algorithm tries to approximate a Pareto front: a set of tradeoff solutions where improving one objective would worsen another. MOPSO often keeps an external archive of non-dominated solutions and chooses social leaders from that archive to maintain diversity along the front.
Adaptive PSO changes parameters during the run. For example, it may adjust \(w\), \(c_1\), or \(c_2\) according to swarm diversity. Hybrid PSO combines PSO with local search, differential evolution, simulated annealing, or gradient fine-tuning. A common practical pattern is: let PSO find a promising region globally, then let a local optimiser polish the final answer.
16 Applications: where PSO shows up in practice
PSO became popular partly because it is easy to code and partly because the metaphor maps neatly onto parameter search. If you can represent a solution as a vector and compute a score, PSO is a candidate.
In neural-network training, a particle can represent all weights and biases. For a small network, a position vector \(\theta\) may contain every parameter. The objective is loss on training data, perhaps \(L(\theta)\). PSO then searches for a low-loss parameter vector without backpropagation. For large modern networks, pure PSO is usually too expensive compared with gradient methods, but for small networks, neuroevolution, controller tuning, or non-differentiable components, it can be useful.
In feature selection, a binary PSO particle represents selected and unselected features. The objective may combine validation accuracy with a penalty for using too many features. In engineering design, a particle may represent dimensions of an antenna, controller gains, structural parameters, or process settings. In clustering, particles may encode centroids. In hyperparameter tuning, each particle is one possible configuration.
17 Convergence, premature convergence, and stagnation
PSO often converges in the practical sense that particles cluster and improvement slows. But practical convergence is not the same as proof of global optimality. Like GA and ACO, PSO is a stochastic metaheuristic. It trades guarantees for flexibility and speed on difficult landscapes.
Premature convergence happens when particles become too similar too early. In gbest PSO, this usually means the social best grabbed everyone before the swarm sampled enough of the search space. Velocity may shrink, pbest values may become nearly identical, and the swarm may hover around a local optimum. Stagnation is the annoying state where the algorithm keeps running but no meaningful improvement occurs.
Common cures include using lbest topology, increasing swarm size, restarting some particles, adding turbulence or mutation-like perturbations, adjusting inertia, reducing social pressure, or hybridising with local search. Another useful diagnostic is swarm diversity: if the average distance between particles collapses while fitness is still poor, the swarm is probably stuck.
common catches & gotchas
- Confusing pbest and gbest — pbest belongs to one particle; gbest belongs to the whole swarm or neighborhood.
- Forgetting velocity — position alone is not the particle state. Velocity is the movement memory.
- Using huge velocity limits — particles may fly across good regions without exploiting them.
- Using tiny velocity limits — the swarm may crawl and fail to escape local basins.
- Assuming gbest is always better than lbest — gbest is faster, but lbest can preserve exploration.
- Not normalising variables — dimensions with large numerical ranges can dominate motion.
- Stopping only by iteration count — also watch improvement plateau and diversity collapse.
18 How to read Engelbrecht's PSO chapter for exams
For AIMLCZG557, do not treat PSO as a bag of formulas. The likely exam understanding is conceptual plus numerical. You should be able to define the particle state, write the velocity and position update equations, explain the roles of \(w\), \(c_1\), \(c_2\), \(r_1\), and \(r_2\), distinguish gbest from lbest, and compute at least one update step by hand.
When a numerical question appears, make a small table. Put columns for current position, current velocity, pbest, gbest or lbest, random values, new velocity, new position, new fitness, and whether pbest changes. Most mistakes disappear when the bookkeeping is visible.
Also remember the story arc. Chapter 5 says population search can improve through variation and selection. Chapter 6 says population search can improve through social learning and motion. Chapter 7 says population search can improve through stigmergic memory in the environment. These are three different answers to the same CI question: how can simple agents collectively search a huge space?
19 Stability intuition without drowning in theory
PSO has a rich stability literature because the velocity update can behave like a stochastic dynamical system. You do not need to derive the full theory for a first course, but the intuition is valuable. If inertia and acceleration are too strong, particles can oscillate or diverge. If damping is too strong, they can freeze before reaching useful areas. Stable PSO is about controlled oscillation that gradually concentrates around promising positions.
The constriction factor was introduced exactly because researchers wanted movement that did not explode. The inequality \(\phi>4\), where \(\phi=c_1+c_2\), and the formula for \(\chi\) are part of that story. The popular \(\chi\approx0.729\), \(c_1=c_2\approx2.05\) setting is not random folklore; it comes from analysing how particles move under attraction to best points.
Still, real landscapes are messy. Noise, constraints, boundary repairs, and high dimensionality can dominate elegant theory. So use stability theory as a guide, then validate empirically. Run multiple seeds. Compare against baselines. Plot convergence curves. Inspect whether different runs find similar solutions or wildly different ones.
20 Why PSO feels intelligent
PSO feels intelligent because the swarm turns local experiences into coordinated search. No particle knows the whole objective landscape. No central planner computes a complete map. Yet the group becomes better over time because useful information is preserved and shared.
There is also a nice humility in PSO. A particle trusts itself, but not completely. It trusts the swarm, but not completely. It keeps momentum, but not completely. The algorithm works because these partial influences compete. Too much self-trust and particles ignore useful discoveries. Too much social trust and everyone crowds into one basin. Too much momentum and the swarm flies past answers. Too little momentum and it stops learning.
That balance is the core lesson. Computational intelligence rarely comes from one perfect rule. It comes from interacting pressures: exploration and exploitation, memory and randomness, independence and cooperation. PSO is one of the cleanest algorithms for seeing that balance directly in equations.
Who introduced PSO?
Particle Swarm Optimization was introduced by James Kennedy and Russell Eberhart in 1995, inspired by social behaviour such as bird flocking and fish schooling.
What is the difference between pbest and gbest?
pbest is the best position personally visited by one particle. gbest is the best position found by the whole swarm. In local-best PSO, the social best is the best found within a neighborhood instead of the whole swarm.
Does PSO use crossover or mutation?
Standard PSO does not use crossover or mutation. Particles persist and move according to velocity updates shaped by inertia, personal memory, and social memory.
Why do we need random numbers \(r_1\) and \(r_2\)?
They randomise the strength of the cognitive and social pulls. This prevents particles from moving in perfectly deterministic synchrony and helps preserve exploration.
Is PSO only for continuous optimisation?
The original form is most natural for continuous vectors, but variants such as binary PSO and MOPSO adapt the idea to discrete and multi-objective problems.
- PSO is swarm intelligence inspired by flocking and schooling, introduced by Kennedy and Eberhart in 1995.
- A particle stores position \(x_i\), velocity \(v_i\), personal best \(p_i\), and social best information.
- The velocity update combines inertia, cognitive pull, and social pull.
- gbest topologies converge quickly; lbest topologies preserve diversity longer.
- Inertia schedules, constriction factors, and velocity clamping are stability tools.
- PSO is strong for continuous optimisation, feature selection variants, neural-network tuning, and engineering design.
core formulas
symbol guide
practical memory hooks