Cmpe536 L8
Cmpe536 L8
Cmpe536 L8
Intelligence
Outline
• Background
o What is a Swarm Intelligence (SI)?
o Examples from nature
o Origins and Inspirations of SI
• Ant Colony Optimization
• Particle Swarm Optimization
What is a Swarm?
Food source
Nest
Pheromone Trails continued
Initial state:
E t=0 E t=1 E
no ants
30 ants 30 ants
D 15 ants
D 10 ants
D
15 ants 20 ants
d=1 d = 0.5
τ = 15 τ = 30
H C H C H C
τ = 15 τ = 30
d=1 d = 0.5
15 ants 15 ants 10 ants 20 ants
B B B
30 ants 30 ants
A A A
When an ant has finished a solution, pheromone is laid on its path, according
to quality of solution.
• Examples:
o Perform a local search
o Collection of global information
Applications Of ACO
• Vehicle routing with time window constraints
• Network routing problems
• Assembly line balancing
• Heating oil distribution
• Data mining
E.g. A 4-city TSP
Initially, random levels of pheromone are scattered on the edges
A B
C D
Pheromone
A B
C D
Pheromone
C D
Pheromone
C D
Pheromone
C D
Pheromone
C D
Pheromone
C D
Pheromone
A B
C D
Pheromone
A B
Where will he go?
C D
Pheromone
41
Ant Systems Algorithm for TSP
Initialize
No
Update pheromone level using the tour cost for each ant
No
Stopping
criteria
yes
An ant is a solution.
An ant completes its tour after selection a choice for each stand.
Pheromone levels are updated after all of the ants have completed all of
their tours.
Ant Colony Optimization
Amount of pheromone A B Desirabili ty of state transition A B
Prob A B
Amounts of pheromones Desirabili ties
Ant Colony Optimization
Where: ?
p = a coefficient related to the evaporation rate.
pheromone = 0
Ant Colony Optimization
Advantages:
Disadvantages:
• For routing problems it may make more sense, but for harvest
scheduling problems, it requires a conceptual leap of faith.
Necessary parameters
5) The constant Q.
Methodology
Parameters of ACO Algorithm
NA
Change probabilities of
pieces of each
potential tour
Has the
best solution Yes
Update pheromone levels been improved? Save best solution
No
Have we
No reached the
stopping
criteria?
Yes
Stop and report
the best solution
found during search
A simple TSP example []
[]
A B 2
[]
C 3
[]
4
D
E []
[A] [B]
2
1
A B
[C]
[D] [E]
4 D 5
E
How to build next sub-solution?
[A]
[A]
A B
1
[A] [ ij ( t )]
[ ij ]
[ ( t )] C[ ] if j allowed k
pij ( t )
k
ik ik
kallowedk
1
[A,D] [A]
0 otherwise
1
1
D
E
Iteration 2
[E,A] [C,B]
5
3
A B
[B,C]
2
C
[A,D]
[D,E]
D 4
E
Iteration 3
[D,E,A] [E,A,B]
4
5
A B
[A,D,C]
[B,C,D]
[C,B,E]
D 3
E
Iteration 4
[B,C,D,A] [D,E,A,B]
2 4
A B
[E,A,B,C]
5
C
[C,B,E,D]
[A,DCE]
3
D 1
E
Iteration 5
[C,B,E,D,A] [A,D,C,E,B]
1
3
A B
[D,E,A,B,C]
4
C
[E,A,B,C,D]
[B,C,D,A,E]
5
D
E 2
Path and Pheromone Evaluation
[A,D,C,E,B]
Q
if ( i , j ) tour
L1 =300 ik, j Lk
1 0 otherwise
[B,C,D,A,E]
L2 =450
2
[C,B,E,D,A]
total
3 A ,B
1 L =260
A ,B
3
2
A ,B 3
A ,B 4
A ,B 5
A ,B
[D,E,A,B,C]
L4 =280
4
[E,A,B,C,D]
L5 =420
5
End of First Run
67
Ant System: Pheromone
initialization
• Pheromone initialization
Τij = m / Cnn,
where:
m – number of ants
Cnn – path length of nearest-neighbor algorithm
68
Ant System: Tour construction
• Ant k is located in city i
k
• N i is the neighborhood of city i
• Probability to go to city : j N ik
ij ij
p
k
il il
ij
lN ik
69
Tour construction: comprehension
ij ij
p
k
il il
ij
lN ik
• α = 0 – greedy algorithm
• β = 0 – only pheromone is at work
quickly leads to stagnation
70
Ant System: update pheromone
trails – evaporation
Evaporation for all connections∀(i, j) ∈ L:
τij ← (1 – ρ) τij,
71
Ant System: update pheromone
trails – deposit
• Tk – path of ant k
• Ck – length of path Tk
• Ants deposit pheromone on visited arcs:
m
ij ij , i, j L
k
ij
k 1
1 / C k
, i , j T k
ijk
0, otherwise
72
Elitist Ant System
• Best-so-far ant deposits pheromone on each iteration:
m
ij ij e k
ij
best
ij
k 1
73
Rank-based Ant System
• Another improvement over AS.
• Each ant deposits an amount of pheromone that decreases
with its rank.
• In each iteration, only the best (w-1) ranked ants and the
best-so-far ant are allowed to deposit pheromone.
74
MAX-MIN Ant System
1. Only iteration-best or best-so-far ant deposits pheromone
2. Pheromone trails are limited to the interval [τmin, τmax]
new
ij old
ij e
ij
min ij max
75
Ant Colony System
• Differs from Ant System in three points:
More aggressive tour construction rule
Only best ant evaporates and deposits pheromone
Local pheromone update
76
Ant Colony System
1.Tour Construction
arg max lN k ilil , if q q0
j i
( iv ) ( iv )
Piv
( il ) (il )
lU
Local Updating
ijnew ijold (1 ) 0
(Online Updating)
Global Updating
(Offline Updating) ijnew ijold (1 ) ije
Not just for TSP of course
ACO is naturally applicable to any sequencing problem, or
indeed any problem
All you need is some way to represent solutions to the problem as
paths in a network.
E.g.
Single machine scheduling with due-dates
These jobs have to be done; their length represents the time they
will take.
A
B
C
D
E
E.g.
Single machine scheduling with due-dates
These jobs have to be done; their length represents the time they
will take.
A 3pm
B 3:30pm
C 5pm
D 4pm
E 4:30pm
E.g.
Single machine scheduling with due-dates
These jobs have to be done; their length represents the time they
will take.
E Start
C D
See here if you’re very interested in ACO:
• http://iridia.ulb.ac.be/dorigo/ACO/ACO.html