Soft Computing

Chapter 7
Swarm and Bio-Inspired Intelligence

Post Graduate Program in AI and ML
Soft Computing   •   Post Graduate

Swarm and Bio-Inspired Intelligence

Introduction

Swarm and bio-inspired intelligence study computational methods motivated by biological evolution, collective animal behaviour, natural adaptation, and self-organization. These methods are especially valuable when an optimization problem is nonlinear, multimodal, discontinuous, noisy, dynamic, or too large for exhaustive search. Rather than constructing a complete mathematical model of the search space, they use populations of candidate solutions and iterative adaptation.

The central idea is collective intelligence: relatively simple agents can produce effective global behaviour through local interactions, feedback, randomness, and information sharing. Examples include birds adjusting flight direction, ants reinforcing successful trails, immune systems recognizing patterns, and evolutionary populations adapting through variation and selection.

This chapter focuses on particle swarm optimization (PSO), ant colony optimization (ACO), and selected related algorithms. It emphasizes algorithmic mechanics, exploration–exploitation balance, parameter control, suitability for complex optimization, implementation, and critical evaluation.

Learning Objectives

By the end of this chapter, a learner should be able to:

  1. Explain emergence, self-organization, stigmergy, adaptation, and collective intelligence.
  2. Formulate and implement the main steps of PSO and ACO.
  3. Interpret exploration and exploitation in population-based optimization.
  4. Select and control important algorithm parameters.
  5. Compare swarm algorithms with respect to representation, convergence, robustness, and computational cost.
  6. Apply swarm methods to a realistic optimization problem and evaluate the result critically.
  7. Identify limitations, reproducibility requirements, and responsible-use considerations.

1. Foundations of Swarm Intelligence

1.1 Collective behaviour and emergence

A swarm is a population of agents that interact locally, often without centralized control. Each agent follows relatively simple rules, but the population may display sophisticated global behaviour. This global behaviour is called emergence. A flock, for example, can maintain cohesion and avoid collisions even though each bird reacts primarily to nearby birds.

Important principles include:

  • Local interaction: Agents use information from neighbours or the environment.
  • Distributed control: No single agent necessarily directs the entire population.
  • Positive feedback: Successful behaviour is reinforced.
  • Negative feedback: Over-concentration or excessive reinforcement is limited.
  • Randomness and variation: New regions of the search space remain reachable.
  • Self-organization: Order arises without an explicit central plan.

In optimization, an agent represents a candidate solution. Its quality is measured by an objective or fitness function. Information is exchanged so that promising regions receive more attention while randomness prevents immediate convergence to a potentially poor local optimum.

1.2 Optimization formulation

A general constrained minimization problem can be written as:

minimize f(x)
subject to gj(x) ≤ 0, j = 1, …, m
hk(x) = 0, k = 1, …, p
xiL ≤ xi ≤ xiU, i = 1, …, d

Here, x = (x1, …, xd) is a d-dimensional decision vector, f(x) is the objective function, gj and hk are inequality and equality constraints, and xiL, xiU are variable bounds. The formulation assumes that candidate solutions can be evaluated, at least approximately, by the objective function.

A maximization problem can be converted to minimization by using fmin(x) = −fmax(x), provided that the transformation is appropriate for the evaluation scale. Constraints may be handled by repair operators, feasibility-preserving representations, penalty functions, or multi-objective treatment of violation.

1.3 Exploration and exploitation

Exploration searches widely across the domain and reduces the probability of missing promising regions. Exploitation intensifies the search around good solutions. Too much exploration produces slow, unfocused progress; too much exploitation causes premature convergence.

A useful conceptual model is:

Search effectiveness = exploration × exploitation

This is not a numerical law but a design principle: both components are necessary. Algorithm parameters, neighbourhood structures, mutation, restart strategies, and adaptive schedules influence the balance.

2. Particle Swarm Optimization

2.1 Biological inspiration and representation

PSO was introduced by Kennedy and Eberhart as a computational abstraction of social movement in flocks and schools. A swarm contains particles. Each particle has a position representing a candidate solution and a velocity representing the direction and magnitude of movement.

For particle i at iteration t:

  • xi(t) is its position;
  • vi(t) is its velocity;
  • pi is its personal-best position;
  • g is the best position found by the relevant neighbourhood or entire swarm;
  • f(x) is the objective value.

For minimization, a personal best is updated when a new position has a lower objective value.

2.2 Canonical PSO equations

The standard velocity and position updates are:

vi(t+1) = w vi(t) + c1 r1(t) ⊙ [pi(t) − xi(t)] + c2 r2(t) ⊙ [g(t) − xi(t)]
xi(t+1) = xi(t) + vi(t+1)

The symbol ⊙ denotes component-wise multiplication. The random vectors r1, r2 have independently sampled components, usually from the uniform interval [0, 1]. The inertia weight w controls persistence of motion; c1 is the cognitive coefficient; and c2 is the social coefficient. All three are dimensionless. Position and velocity must use compatible units, and velocity limits may be imposed for bounded variables.

The three velocity components have distinct roles:

  1. wvi preserves movement direction and supports exploration.
  2. The cognitive term attracts a particle toward its own experience.
  3. The social term attracts it toward successful collective experience.

A common linear inertia schedule is:

w(t) = wmax − [wmax − wmin] t/T

where T is the maximum number of iterations and 0 ≤ t ≤ T. This schedule is a heuristic, not a universal guarantee of convergence.

An alternative constriction formulation is:

vi(t+1) = χ [vi(t) + c1 r1 ⊙ (pi − xi) + c2 r2 ⊙ (g − xi)]

where χ is a constriction factor. Specific convergence results depend on the chosen topology, stochastic assumptions, parameter values, and problem conditions; therefore, parameter settings should not be treated as universally optimal.

2.3 PSO procedure

A practical continuous PSO procedure is:

  1. Choose swarm size, iteration budget, coefficients, bounds, and stopping criteria.
  2. Initialize positions within the feasible domain and initialize velocities.
  3. Evaluate every particle.
  4. Set each personal best and the neighbourhood/global best.
  5. Sample random vectors and update velocities.
  6. Update positions.
  7. Apply boundary handling and constraint treatment.
  8. Re-evaluate particles and update best records.
  9. Stop when the iteration budget, target quality, or stagnation criterion is reached.

Boundary handling may use clamping, reflection, random reinitialization, or projection. Clamping is simple but can create particles that remain at boundaries. Reflection may preserve motion but must be implemented carefully. Constraint repair should preserve meaningful problem structure rather than silently distorting solutions.

2.4 Topologies and variants

In a global-best topology, every particle is attracted to the best solution known to the swarm. It often converges quickly but may lose diversity. In a local-best or ring topology, a particle communicates with a smaller neighbourhood. This usually slows information propagation but can improve exploration and resistance to premature convergence.

Other variants include:

  • Binary PSO for binary decision variables, where velocity is interpreted as a probability or transformed through a sigmoid function.
  • Discrete and permutation PSO for scheduling and routing, requiring specialized movement operators.
  • Multi-objective PSO, which maintains an archive of non-dominated solutions.
  • Adaptive PSO, which changes coefficients using diversity, progress, or feedback.
  • Cooperative coevolution, which optimizes subsets of variables separately for very high-dimensional problems.

A continuous PSO should not be applied directly to a permutation problem by merely rounding coordinates. Such rounding may produce duplicate or invalid items. Discrete representations need valid operators.

3. Ant Colony Optimization

3.1 Biological inspiration

Real ants can discover short routes between a nest and a food source. Ants deposit pheromone on paths, and pheromone evaporates over time. Shorter or more frequently used paths tend to accumulate stronger pheromone, increasing their probability of being selected. This process is an example of stigmergy: agents communicate indirectly by modifying the environment.

ACO is particularly natural for graph-based combinatorial problems such as the travelling salesperson problem (TSP), vehicle routing, assignment, scheduling, and network design.

3.2 Probabilistic construction rule

Suppose ant k is at node i and may move to node j. Let τij be pheromone intensity and ηij be heuristic desirability. For TSP, a common choice is ηij = 1/dij, where dij is the distance between nodes i and j. The probability of choosing j is:

Pijk = [τij^α ηij^β] / [∑l ∈ Nik τil^α ηil^β], j ∈ Nik

Here, Nik is the feasible neighbourhood for ant k, and α, β ≥ 0 control the influence of pheromone and heuristic information. The denominator sums over feasible candidate nodes, so probabilities sum to one. If a move is infeasible, it is excluded from the neighbourhood.

3.3 Pheromone update

After ants construct solutions, pheromone evaporates and is reinforced:

τij(t+1) = (1 − ρ)τij(t) + Δτij(t)

where ρ is the evaporation rate, normally satisfying 0 < ρ ≤ 1, and Δτij is deposited pheromone. A common elitist deposit is:

Δτij(t) = ∑k Δτijk(t), Δτijk(t) = Q/Lk if (i,j) is used by ant k; 0 otherwise

Here, Q is a positive scaling constant and Lk is the objective value, such as tour length, for ant k. For a minimization problem, shorter tours deposit more pheromone. Units of τ are determined by the chosen scaling and are algorithmic rather than physical.

Evaporation prevents unlimited accumulation and supports forgetting. If evaporation is too weak, early random choices may dominate. If it is too strong, useful information disappears before being exploited.

3.4 ACO procedure

A standard iteration consists of:

  1. Initialize pheromone values and heuristic information.
  2. For each ant, construct a feasible solution probabilistically.
  3. Evaluate each solution.
  4. Evaporate pheromone.
  5. Deposit pheromone according to selected ants or the best-so-far solution.
  6. Optionally apply pheromone bounds, local search, or candidate lists.
  7. Record the best solution and repeat.

Candidate lists reduce computation by restricting choices to promising neighbours. Local search, such as 2-opt for TSP, can substantially improve constructed tours. However, intensive local search changes the method into a hybrid metaheuristic and increases computational cost.

4. Selected Bio-Inspired Algorithms

4.1 Genetic algorithms

Genetic algorithms maintain a population of encoded solutions and apply selection, crossover, and mutation. A chromosome may be a binary string, real vector, or permutation. Selection increases the representation of fit solutions; crossover combines parental material; mutation introduces variation.

Unlike PSO, a genetic algorithm does not require a velocity or explicit social-best memory. Its performance depends strongly on representation and operators. For permutations, order-preserving crossover and swap or inversion mutation are more appropriate than ordinary bitwise operators.

4.2 Differential evolution

Differential evolution is designed primarily for continuous optimization. A typical mutation step is:

vi = xa + F(xb − xc)

where a, b, and c are distinct population indices, F is a scale factor, and the indices differ from i. A crossover combines vi with xi to produce a trial vector, which replaces the target when its objective is no worse. The difference vector supplies adaptive directional variation based on population geometry.

4.3 Artificial bee colony and other methods

Artificial bee colony algorithms model employed bees, onlooker bees, and scouts. Employed and onlooker bees exploit promising food sources, while scouts explore new locations. Scout behaviour is particularly useful for restoring diversity.

Other methods include firefly algorithms, bat algorithms, cuckoo search, grey wolf optimization, and harmony search. Their metaphors differ, but many share common mechanisms: population sampling, attraction or selection, stochastic variation, memory of good solutions, and termination under limited evaluations. The metaphor alone does not establish superiority. Representation, operators, parameter settings, benchmarking quality, and computational budget are more important.

5. Parameter Control and Performance Evaluation

5.1 Parameter categories

Parameters can be classified as:

CategoryExamplesMain effect
PopulationSwarm or colony sizeDiversity and evaluation cost
Movement/reinforcementPSO coefficients; ACO α, β, ρSearch direction and memory
VariationMutation, noise, restart rateExploration
ConstraintPenalty or repair settingsFeasibility pressure
TerminationIterations, evaluations, stagnationComputational budget

Parameter tuning selects values before execution. Parameter control changes values during execution. Control may be deterministic, adaptive, or self-adaptive.

Examples include decreasing PSO inertia, increasing mutation after stagnation, adapting ACO evaporation based on diversity, and restarting a population when no improvement occurs for a specified number of evaluations. Adaptive methods should be evaluated against fixed-parameter baselines because adaptation itself introduces complexity and additional assumptions.

5.2 Evaluation methodology

A single run is not adequate for a stochastic optimizer. A sound comparison should specify:

  • objective functions and constraint definitions;
  • representation and initialization method;
  • population size and evaluation budget;
  • random seeds or seed policy;
  • stopping rule;
  • hardware and implementation conditions;
  • best, mean, median, standard deviation, and worst results;
  • computational time or number of objective evaluations.

For stochastic results, confidence intervals or non-parametric tests may be useful. When comparing many algorithms across many functions, multiple-comparison effects must be considered. Reporting only the best run is highly misleading.

Important performance measures include final objective value, anytime performance, feasibility rate, convergence speed, robustness, and scalability. For expensive objectives, the number of evaluations is often more informative than raw iteration count.

5.3 Constraint handling

Three common strategies are:

  1. Penalty functions: Add a violation cost to the objective, for example F(x) = f(x) + λV(x), where V(x) ≥ 0 measures violation and λ is a penalty weight. The penalty must be scaled consistently with the objective.
  2. Repair: Transform an infeasible solution into a feasible one. Repair should be domain-aware.
  3. Feasibility rules: Prefer feasible solutions over infeasible ones; among feasible solutions choose the better objective, and among infeasible solutions choose the smaller violation.

Penalty methods may fail when λ is too small, allowing unacceptable violations, or too large, causing the search to ignore useful objective structure. Dynamic penalties can help but require validation.

6. Worked Example: One PSO Update

Consider one-dimensional minimization of f(x) = x². A particle has:

  • current position x = 4;
  • current velocity v = 1;
  • personal best p = 2;
  • neighbourhood best g = 1;
  • inertia w = 0.5;
  • c1 = 1.5, c2 = 1.0;
  • random values r1 = 0.4, r2 = 0.7.

Using the canonical update:

v(t+1) = 0.5(1) + 1.5(0.4)(2 − 4) + 1.0(0.7)(1 − 4)
v(t+1) = 0.5 − 1.2 − 2.1 = −2.8

Therefore:

x(t+1) = 4 + (−2.8) = 1.2

The new objective is f(1.2) = 1.44, whereas the previous personal-best objective was f(2) = 4. Thus, the personal best becomes 1.2. This example illustrates attraction toward both remembered good positions and the effect of random coefficients. It does not establish convergence; many subsequent particles and iterations are required.

7. Applied Case: Delivery-Routing Optimization

Background

This illustrative case concerns a regional distributor delivering medical supplies from one depot to 60 clinics. Vehicles have capacity limits, each clinic must be visited once, and some clinics have delivery time windows. Travel times vary with traffic.

Problem

The company seeks to minimize total operational cost while satisfying capacity and time-window constraints. The problem is a capacitated vehicle-routing problem with time windows, a difficult combinatorial optimization problem. Exact methods may become expensive as the number of locations and constraints grows.

Analysis

ACO is a natural first choice because solutions are constructed on a graph and pheromone can represent desirable travel arcs. A solution is a set of vehicle routes. The heuristic value of an arc may combine inverse travel time, urgency, and remaining vehicle capacity. Infeasible moves are removed from each ant’s candidate list.

However, pure ACO may produce inefficient routes if local construction decisions are not corrected. A hybrid approach therefore uses ACO for global route construction and 2-opt or relocate operators for local improvement. A feasibility-first rule rejects routes that violate capacity or time windows; if all candidates are infeasible, a repair procedure inserts waiting, changes vehicle assignment, or applies a penalized move.

Approach and solution

The implementation uses repeated independent runs, identical evaluation budgets, and a fixed seed policy for comparison. Baselines include a greedy nearest-neighbour method and a mixed-integer solver on smaller instances. ACO parameters are tuned on training instances and then tested on unseen daily demand patterns. Performance is measured by total cost, late-delivery count, feasibility rate, and runtime.

Because traffic changes during the day, the system periodically re-optimizes only the uncompleted portion of the routes. Previously committed decisions are treated as fixed constraints. This rolling-horizon design is more suitable than assuming a static problem throughout the day.

Outcome and learning points

The important outcome is not merely the lowest cost in one simulation. A dependable deployment should demonstrate feasible routes, stable performance across demand and traffic scenarios, transparent constraint handling, and a fallback plan when the optimizer exceeds its time limit. The case shows that:

  • representation must reflect operational rules;
  • hybrid local search can improve solution quality;
  • dynamic conditions require repeated or online optimization;
  • business constraints must be encoded explicitly;
  • evaluation must include reliability and feasibility, not only objective value.

8. Suitability, Limitations, and Governance

Swarm algorithms are suitable when objective evaluations are available but gradients are unavailable, unreliable, discontinuous, or expensive to derive. They are also useful for mixed and combinatorial spaces when appropriate representations are designed. They are less attractive when a reliable convex formulation or efficient gradient method already exists, or when each objective evaluation is extremely expensive and no surrogate or model-based strategy is available.

Common limitations include premature convergence, sensitivity to parameter settings, high evaluation cost, weak theoretical guarantees for complex variants, and difficulty explaining why a particular solution was selected. No-free-lunch reasoning reminds us that no optimizer is best for every problem class. Performance claims should therefore be tied to problem structure and evaluation protocol.

In AI and ML, swarm methods can tune hyperparameters, select features, design neural architectures, optimize rule systems, and schedule computational resources. Care is required: optimization of validation performance can overfit the validation set, and automated feature selection may amplify measurement bias. In high-stakes applications, feasibility, fairness, privacy, auditability, and human oversight must be considered. A swarm optimizer should not be used to bypass regulatory constraints or produce decisions that cannot be reviewed.

Reproducibility requires publishing representations, preprocessing, parameter schedules, stopping criteria, constraint handling, code or pseudocode, and randomization policy. When objective functions involve people or sensitive data, governance should also address data protection, accountability, and the consequences of optimizing an incomplete proxy objective.

9. Contemporary Directions and Best Practices

Current research increasingly combines swarm methods with surrogate models, parallel evaluation, machine learning, multi-objective optimization, and online adaptation. Surrogates estimate expensive objective values, but errors can mislead the swarm; occasional true evaluations and uncertainty-aware selection are therefore important. Multi-objective methods maintain a set of non-dominated trade-offs rather than a single optimum.

Recommended practice is to:

  1. Define the decision variables, objectives, constraints, and evaluation budget precisely.
  2. Select a representation that guarantees or facilitates valid solutions.
  3. Establish simple and strong baseline methods.
  4. Use multiple independent runs and report distributions, not only best values.
  5. Tune parameters without contaminating the final test set.
  6. Monitor diversity, feasibility, improvement, and computational cost.
  7. Use adaptive control or restarts when stagnation is detected.
  8. Validate on realistic, noisy, and changing scenarios.
  9. Prefer hybrid methods when domain-specific local improvement is available.
  10. Document assumptions and retain human responsibility for consequential decisions.

Chapter Summary

Swarm and bio-inspired intelligence formulate optimization as adaptive population search. PSO models social movement through position, velocity, personal memory, and neighbourhood information. ACO models indirect communication through pheromone reinforcement and evaporation and is particularly effective for graph-based combinatorial problems. Genetic algorithms, differential evolution, artificial bee colony, and related methods provide alternative variation and selection mechanisms.

The central design challenge is balancing exploration and exploitation. In PSO, inertia, cognitive attraction, social attraction, topology, boundaries, and restarts shape this balance. In ACO, pheromone influence, heuristic influence, evaporation, candidate lists, and deposit rules play corresponding roles. Representation and constraint handling are as important as the algorithmic metaphor.

Reliable application requires multiple-run evaluation, fair budgets, meaningful baselines, transparent parameter control, and attention to feasibility and robustness. Swarm methods are powerful general-purpose tools, but they do not guarantee global optimality and should not be selected merely because their biological metaphor is attractive. Responsible deployment also requires governance of data, objectives, fairness, interpretability, and human oversight.

Key Terms

Swarm intelligence: Collective problem-solving behaviour produced by interacting agents.

Agent: An individual computational entity representing or modifying a candidate solution.

Emergence: Global behaviour arising from local interactions.

Self-organization: Formation of organized patterns without centralized control.

Stigmergy: Indirect communication through changes made to a shared environment.

Exploration: Search of relatively unvisited regions.

Exploitation: Intensive search around promising solutions.

Particle swarm optimization: Population-based method using positions, velocities, and social learning.

Particle: Candidate solution in PSO.

Personal best: Best position previously found by a particle.

Global or neighbourhood best: Best solution known globally or within a communication neighbourhood.

Inertia weight: PSO parameter controlling persistence of velocity.

Ant colony optimization: Probabilistic graph-search method using pheromone trails.

Pheromone: Artificial memory associated with solution components or graph edges.

Evaporation: Reduction of pheromone over time.

Heuristic information: Problem-specific desirability used to guide construction.

Metaheuristic: General search strategy designed to find good solutions under limited computation.

Constraint handling: Methods for maintaining or penalizing feasibility.

Parameter control: Adjustment of algorithm settings during execution.

Premature convergence: Loss of diversity before a high-quality solution is found.

Review Questions

Short Answer Questions

  1. What is meant by emergence in swarm intelligence?
  2. Distinguish exploration from exploitation.
  3. What are the cognitive and social components of the PSO velocity update?
  4. Why is pheromone evaporation required in ACO?
  5. Give two reasons why representation is important in bio-inspired optimization.

Long Answer Questions

  1. Explain canonical PSO, including its equations, variables, parameter roles, and boundary handling.
  2. Describe the construction and pheromone-update processes in ACO and explain their suitability for routing problems.
  3. Compare PSO, ACO, genetic algorithms, and differential evolution in terms of representation and search mechanism.
  4. Discuss parameter tuning, adaptive parameter control, and the exploration–exploitation trade-off.
  5. Explain how stochastic optimization experiments should be designed and reported for reproducibility.

Analytical / Application Questions

  1. Design a PSO representation and constraint-handling strategy for selecting a fixed number of features for a classifier. Justify the representation and evaluation metrics.
  2. Formulate an ACO approach for a vehicle-routing problem with capacity and time windows. Specify the heuristic, feasible neighbourhood, pheromone deposit rule, and repair strategy.
  3. An optimizer obtains an excellent result in one run but poor results in several others. Analyze possible causes and propose an experimental and algorithmic response.

Multiple Choice Questions with Answers

Question 1

In canonical PSO, which term preserves part of a particle’s previous movement?

A. The inertia term

B. The heuristic term

C. The pheromone deposit

D. The penalty term

Correct Answer: A. The inertia term

Question 2

In the ACO transition rule, what does ηᵢⱼ usually represent?

A. The number of ants

B. Heuristic desirability of moving from i to j

C. The evaporation rate

D. The iteration limit

Correct Answer: B. Heuristic desirability of moving from i to j

Question 3

For a minimization problem, which ant tour receives a larger deposit under Δτ = Q/L?

A. The longest feasible tour

B. A randomly selected tour

C. The shortest feasible tour

D. The tour with the most edges only

Correct Answer: C. The shortest feasible tour

Question 4

What is the main risk of excessive exploitation in a population-based optimizer?

A. Premature convergence

B. Guaranteed global optimality

C. Infinite population growth

D. Removal of all constraints

Correct Answer: A. Premature convergence

Question 5

In PSO, the personal best stores:

A. The best position found by the entire population

B. The current velocity of a particle

C. The best position previously found by that particle

D. The average position of all particles

Correct Answer: C. The best position previously found by that particle

Question 6

Why is a permutation-specific representation needed for routing problems?

A. Continuous coordinates always guarantee valid tours

B. Naive rounding can create duplicates or invalid routes

C. Pheromone cannot be used on graphs

D. Routing has no objective function

Correct Answer: B. Naive rounding can create duplicates or invalid routes

Question 7

If f(x) = x² and x = −3, what is the objective value?

A. −9

B. −6

C. 6

D. 9

Correct Answer: D. 9

Question 8

What is the principal function of pheromone evaporation?

A. To prevent unlimited accumulation and support forgetting

B. To guarantee the first path is selected

C. To eliminate heuristic information

D. To increase vehicle capacity

Correct Answer: A. To prevent unlimited accumulation and support forgetting

Question 9

Which practice is most appropriate when evaluating a stochastic optimizer?

A. Report only the best single run

B. Use multiple independent runs and report distributions

C. Change the objective after each run

D. Ignore computational budget

Correct Answer: B. Use multiple independent runs and report distributions

Question 10

In the worked PSO example, the new position after the update is:

A. −2.8

B. 1.2

C. 2.8

D. 6.8

Correct Answer: B. 1.2

Soft Computing
Chapter 7 of 15