Professional Documents
Culture Documents
Intelligence Algorithms
Topic 5 – Swarm Intelligence
Faculty of Computer & Mathematical Sciences
Universiti Teknologi MARA
A. Introduction: Swarms
A. Introduction: Objectives
• To understand the key principles of swarm intelligence;
• To understand the laying/following mechanisms;
• To understand Particle Swarm Optimization (PSO) and Ant
Colony Optimization (ACO).
A. Introduction: Swarm Intelligence
A. Introduction: Swarm Intelligence
A. Introduction: What is Swarm Intelligence?
• An individual ant is not very bright, almost blind
• But ants in a colony, operating in a team do remarkable
things
• At the basis of increased intelligence is shared information
discovered individually and communicated to the swarm
• These seamless coordination of all individual activities does
not to seem to require any leader / supervisor
A. Introduction: What is Swarm Intelligence?
• Swarm Intelligence (SI) is an artificial intelligence technique
based around the study of collective behavior in
decentralized, self-organized systems.
• A typical swarm intelligence system consists of a population
of simple agents which can communicate (either directly or
indirectly) locally with each other by acting on their local
environment.
A. Introduction: What is Swarm Intelligence?
(cont)
• Though the agents in a swarm follow very simple rules, the
interactions between such agents can lead to the emergence
of very complicated global behavior, far beyond the
capability of individual agents
• SI was introduced by Gerardo Beni and Jing Wang in 1989
• Main objectives of SI: minimize power consumption and
minimize path
A. Introduction: What is Swarm Intelligence?
(cont)
• Swarm Intelligence examples in nature:
• Ant colonies
• Bee beehives
• Fish schooling
• Bird flocking
• Bacterial growth
• Microbial intelligence
• There are biological advantages of swarm intelligence. E.g: birds flying
in formation use up to a fifth less energy than those flying solo
A. Introduction: What is Swarm Intelligence?
(cont)
B. Swarm Intelligence – From Natural to
Artificial Systems
• Swarm Intelligence are modeled for the purposes of:
• Understanding microscopic (local) to macroscopic
(global) transformations
• Getting ideas for artificial systems with similar
properties
B. Swarm Intelligence – From Natural to
Artificial Systems (cont)
• There are two main development areas of Swarm
Intelligence:
• Particle Swarm Optimization (PSO)
• Ant Colony Optimization (ACO)
Particle Swarm Optimization
C. Particle Swarm Optimization: Introduction
• PSO is inspired mostly by the social behavior of bird flocking and fish
schooling
• Key question: How does a large number of birds produce a seamless,
graceful flocking dance, while often, but suddenly changing direction,
scattering and regrouping?
D. Particle Swarm Optimization: Behaviors
• In 1986, Craig Reynolds described this process in 3 simple behaviors:
12
10
0 2 4 6 8 10 12 14 16
insert: Cooperation Example
E. Particle Swarm Optimization: Concept
(cont)
• In each timestep (t), a particle has to move to a new position. It
modifies its position according to:
• its current position
• its current velocity
• the distance between its current position and pBest
• the distance between its current position and gBest
• Having worked out a new velocity, its position is simply its old
position plus the new velocity.
• Goal of the movement: get swarm moving to a promising area that
signifies global optimum
E. Particle Swarm Optimization: Concept
(cont)
• Influences on particle flying:
F. Particle Swarm Optimization: Algorithm
Particle velocity (equation a):
• v = v + c1 * rand * (pBest – p) + c2 * rand * (gBest – p)
Particle update rule (equation b):
• p=p+v
where:
• p: particle’s position • pBest: best position of the
• v: path velocity particle
• c1: weight in the direction of • gBest: best position of the
personal best swarm
• c2: weight in the direction of • rand: random variable
global best between 0 - 1
F. Particle Swarm Optimization: Algorithm –
Pseudocode
For each particle
Initialize particle
END
Do
For each particle
Calculate fitness value
If the fitness value is better than its personal best
set current value as the new pBest
End
Choose the particle with the best fitness value of all as gBest
For each particle
Calculate particle velocity according equation (a)
Update particle position according equation (b)
End
While maximum iterations or minimum error criteria is not attained
F. Particle Swarm Optimization: Algorithm –
Parameters
• Parameters are the coefficients in the formula which indicates how to
update the velocity of a given particle.
• Swarm size and neighbourhood size are parameters but less
important.
• You can perfectly use a swarm size of 20 and a neighbourhood of 3 for a large
range of problems with good results.
• Particles' velocities on each dimension are clamped to a maximum
velocity Vmax – this parameter is specified by user
• If the sum causes velocity to exceed Vmax, then the velocity value is Vmax
F. Particle Swarm Optimization: Algorithm –
Parameters (cont)
• Parameters to be considered:
• Number of particles (10 – 50 are usually sufficient)
• C1: importance of personal best
• C2: importance of neighbourhood best
• Usually C1+C2 = 4. No good reason other than empiricism
• Vmax – too low, too slow; too high, too unstable
G. Particle Swarm Optimization: Visualization
G. Particle Swarm Optimization: Visualization
Ant Colony Optimization
H. Ant Colony Optimization: Introduction
• Ant Colony Optimization (ACO) is inspired from how ants forage for
food
• Individual ants lay pheromone trails while travelling from the nest, to
the nest or possibly in both directions.
• The pheromone trail gradually evaporates over time.
• But pheromone trail strength accumulate with multiple ants using
path.
Food source
Nest
I. Ant Colony Optimization: Concept
• Ants lay down pheromone trails when it is moving
• An isolated ant moves at random, but when it finds a pheromone
trail, the ant has a high probability of following the trail
• An ant foraging for food deposits pheromone over its route, when it
finds a food source, it returns to the nest reinforcing its trail
Nest Food
I. Ant Colony Optimization: Concept (cont)
• When other ants discover this trail, it follows the path therefore
laying more pheromones on it
• This process works as a positive feedback loop – the higher the
pheromone intensity of the trail, higher chance other ants start travel
on it
J. Ant Colony Optimization: Pheromone Trails
E E E
T= T=
0 1
30 ants
30 ants
D D D
10 20
15 15
d=1.0 d=0.5 ants ants
ants ants
H C C H C
H
d=1.0 d=0.5
B 10 B 20
15 B 15
ants ants
ants ants
30
30
A A ants A ants
J. Ant Colony Optimization: Pheromone Trails
(cont)
K. Ant Colony Optimization: Stigmergy
• Stigmergy is indirect communication via interaction with the
environment
• The highly sophisticated way ants collectively perform complex tasks
is due to stigmergy
• They communicate using pheromones
• They lay trails of pheromones that can be followed by other ants
L. Ant Colony Optimization: Algorithm Basic
Ideas
• Ants are agents that move along between nodes in a graph
• They choose where to go based on pheromone strength (and maybe
other factors)
• An ants path represents a specific candidate solution
• When an ant has finished a solution, pheromone is laid on its path
according to quality of solution – (problem specific, example distance
in TSP)
L. Ant Colony Optimization: Algorithm Basic
Ideas (cont)
• Pheromones on edges path also decrease by certain percentage for
every cycle, this is evaporation property that is also observed in
nature
• This procedure is repeatedly applied until a termination criterion is
satisfied.
M. Ant Colony Optimization: TSP4 Example
Initially, random levels of pheromone are scattered on the edges
A B
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
A B
An ant is placed at a random node
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
A B
The ant decides where to go from that node,
based on probabilities
calculated from:
- pheromone strengths,
- next-hop distances.
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
A B
The ant is now at C, and has a `tour
memory’ = {B, C} – so he cannot
visit B or C again.
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
A B
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
A B
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
AB is added to complete the round A B
trip.
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
• Examples of three ants solutions on first run
• After all ants have finished creating their solutions, pheromones are updated
based on quality of solution
• At the same time, pheromones everywhere are also decreased to model decay
M. Ant Colony Optimization: TSP4 Example
(cont)
A B
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
A B
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
A B
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
A B
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
M. Ant Colony Optimization: TSP4 Example
(cont)
A B
We start again, with another
ant in a random position.
D
Pheromone C
AB: 10, AC: 10, AD, 30, BC, 40, BD, 15, CD 20
Ant
The ACO algorithm for the TSP
[a simplified version with all essential details]
No
Update pheromone level using the tour cost for each ant
No
Stopping
criteria
yes