Particle Swarm Optimization
Particle Swarm Optimization
Prakash Kotecha
Debasis Maharana & Remya Kommadath
Department of Chemical Engineering
Indian Institute of Technology Guwahati
1
Swarm Intelligence
“Any attempt to design algorithms or distributed problem-solving devices inspired by the
collective behaviour of social insect colonies and other animal societies”*
Examples of Swarms
bees swarming around their hive
ant colony with individual agents as ants
flock of birds is a swarm of birds
immune system is a swarm of cells
crowd is a swarm of people
Properties of swarm intelligent behaviour
self-organization
• interactions are executed on the basis of purely local information without any relation to the global pattern
• positive feedback, negative feedback, fluctuations and multiple interactions
division of labour
• tasks performed simultaneously by specialized individuals
Swarm Intelligence: From Natural to Artificial Systems, New York, NY: Oxford University Press, 1999
An idea based on honey bee swarm for numerical optimization, Technical report-TR06, Erciyes University, Engineering Faculty, Computer Engineering Department, 2005 2
Particle Swarm Optimization
Proposed by J. Kennedy and R. Eberhart in 1995
Particle Swarm Optimization, Proceedings of ICNN'95 - International Conference on Neural Networks, Australia, 1942-1948 vol.4, 1995 3
Number of publications Number of publications
0
5000
20000
25000
30000
10000
15000
2000
4000
5000
6000
7000
3000
0
1000
2020
2018
2016
2014
2012
2010
2008
Year
2006
2004
2002
2000
1998
1996
Number of publications
0
2000
3000
4000
5000
6000
7000
1000
Particle Swarm Optimization
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011
2010
2009
2008
Year
2007
2006
2005
2004
2003
2002
2001
TLBO
2000
1999
1998
PSO
1997
1996
1995
4
Particle Swarm Optimization (PSO)
Models the social behaviour of bird flocking or fish schooling.
Each particle/bird has a position and velocity associated with it.
Particles change the position by adjusting their velocity to
seek food
avoid predators
identify optimized environmental parameters
Each particle memorizes the best location identified by it.
Particles communicate the information regarding the best location explored by them.
Velocity of the particles are modified by using
flying experience of the particle
flying experience of the group
5
Particle Swarm Optimization (PSO)
Initial position and velocity of particles are generated randomly within the search space.
vi Velocity of the ith particle
Particle velocity (v) is determined as w Inertia of the particles
vi wvi c1r1 pbest ,i X i c2 r2 g best X i c1 and c2 Acceleration coefficients
r1 and r2 Random numbers [0,1] of size (1xD)
Position of a particle is modified as pbest,i Personal best of ith particle
6
Velocity of a particle
vi wvi c1r1 pbest ,i X i c2 r2 g best X i
A. P. Engelbrecht, Particle Swarm Optimization, Computational Intelligence: An Introduction, Second Edition, chapter 16, 2007 7
Possible cases
Cases Better than its Better than Remarks
Personal best Global best
Case 1 Do not update pbest and gbest
Update pbest
Case 2 Do not update gbest
Case 3 Update pbest and gbest
Case 4 (Cannot happen) Do not update pbest or gbest
4 Case 3:
min f x xi2 ; 0 xi 10, i 1,2,3,4
i 1
Case 2: Let X = [1 3], f = 10
pbest = [4 5], fpbest = 41
Case 1: Let X = [4 3], f = 25 gbest = [2 3], fgbest = 13
pbest = [4 5], fpbest = 41
Let X = [5 6], f = 61 f < fpbest
gbest = [2 3], fgbest = 13
pbest = [4 5], fpbest = 41
gbest = [2 3], fgbest = 13 f < fpbest fpbest = 10 and pbest = [1 3]
f > fpbest fpbest = 25 and pbest = [4 3] f < fgbest
f > fgbest f > fgbest fgbest = 10 and gbest = [1 3]
8
Working of PSO: Sphere Function
f x x12 x22 x32 x42
4
Consider min f x x ; 0 xi 10, i 1, 2,3, 4
2
i
i 1
Step 1: Fix population size, inertia weight, acceleration coefficient, maximum iterations
NP = 5, w = 0.7, c1 = 1.5, c2 = 1.5, T = 10
Step 2: Generate random positions within the domain. Evaluate the fitness.
4 0 0 8 80
3 140
1 9 7
P 0 3 1 5 f 35
2 1 4 9 102
6 2 8 3 113
9
Determine personal and global best solutions
Step 3: Generate random velocities within the domain of the variables.
4 0 0 8 80 9 6 1 8
3 140 5 0
1 9 7
1 3
P 0 3 1 5 f 35 v 7 4 1 4
2 1 4 9 102 3 0 2 1
6 2 8 3 113 1 6 8 7
Step 4: Determine the personal and global best of all the solutions.
4 0 0 8 80
3 1 9 7 140
Pbest P 0 3 1 5 f pbest 35 gbest 0 3 1 5 f gbest 35
2 1 4 9 102
6 2 8 3 113
10
First Solution: Generation
Step 5: Generate two sets of random vectors w = 0.7, c1 = 1.5, c2 = 1.5, T = 10
xnew is within bounds xnew violates the upper bound xnew violates the lower bound
xnew xnew
lb ub lb ub
No bounding required Shift xnew to upper bound Shift xnew to lower bound
12
First Solution: Updating
Step 8: Check bounds, bound for violation 0 xi 10 v1 1.5 5.1 1.75 3.8
X 1 4 0 0 8 f1 80
X1 = [5.5 5.1 1.75 11.8] X1 = [5.5 5.1 1.75 10] pbest ,1 4 0 0 8 f pbest1 80
gbest 0 3 1 5 f gbest 35
Step 11: No update of pbest,1 as new solution is not better. pbest ,1 4 0 0 8 f pbest1 80
Step 12: No update in gbest as new solution is not better. gbest 0 3 1 5 f gbest 35
13
Second Solution: Generation
Step 1: Generate two sets of random vectors w = 0.7, c1 = 1.5, c2 = 1.5, T = 10
Step 7: Update pbest,4 as the new solution is better than pbest,4 pbest ,4 1.7 1.3 2.25 4.3
f pbest 4 28.13
Step 8: Update gbest as the new solution is better
gbest 1.7 1.3 2.25 4.3
19
f pbest 4 28.13 gbest 35 f gbest 28.13
Fifth Solution: Generation
w = 0.7, c1 = 1.5, c2 = 1.5, T = 10
Step 1: Generate two sets of random vectors
v5 1 6 8 7
r1 = [0.3 0.8 0.2 0.1] r2 = [0.5 0.1 0.2 0.7]
X 5 6 2 8 3 f 113
pbest ,5 6 2 8 3 f pbest5 113
Step 2: Determine velocity
gbest 1.7 1.3 2.25 4.3 f gbest 28.13
v5 = 0.7 x [1 6 8 7] +
1.5 x [0.3 0.8 0.2 0.1] x ([6 2 8 3] – [6 2 8 3]) +
1.5 x [0.5 0.1 0.2 0.7] x ([1.7 1.3 2.25 4.3] – [6 2 8 3])
v5 = [-2.52 4.09 3.87 6.26]
vi wvi c1r1 pbest ,i X i c2 r2 gbest X i
Step 3: Determine position X i X i vi
Step 7: No update of pbest,5 as new solution is not better. pbest ,5 6 2 8 3 f pbest5 113
Step 8: No update of gbest,5 as new solution is not better. gbest 1.7 1.3 2.25 4.3 f gbest 28.13
21
Completion of first iteration
4 0 0 8 80 4 0 0 8 80 9 6 1 8
3 7 140 3
1 9 7 140 5 0
gbest 0 3 1 5
1 9 1 3
P 0 3 1 5 f 35 Pbest 0 3 1 5 f pbest 35 v 7 4 1 4
f gbest 35
2 1 4 9 102 2 1 4 9 102 3 0 2 1
6 2 8 3 113 6 2 8 3 113 1 6 8 7
1.5 x [0.7 0.2 0.8 0.1] x ([4 0 0 8] – [5.5 5.1 1.75 10]) +
1.5 x [0.9 0.3 0.2 0.5] x ([1.7 1.3 2.25 4.3] – [5.5 5.1 1.75 10])
v1 =[-5.65 0.33 -0.73 3.68]
25
User-specified parameter: Acceleration coefficients (c1 and c2)
vi wvi c1r1 pbest ,i X i c2 r2 g best X i
X i X i vi
Cases Outcome
c1=c2=0 Particles move in the same direction until it hits the search space boundary
Particles are independent hill climbers
c1>0 & c2=0
Particles perform local search
Entire swarm becomes one stochastic hill climber
c1=0 & c2>0
All particles get attracted to a single point
c 1 = c2 Particle is attracted towards the average pbest,i and gbest
c1>>c2 Particles attracted towards its pbest,i which results in excessive wandering
c1<<c2 Particles attracted towards gbest and cause premature convergence towards optima
Low values
Smooth particle trajectories
of c1 and c2
High values
Abrupt movements
of c1 and c2
Computational Intelligence: An Introduction, Second Edition, John Wiley & Sons, 2007 26
Impact of c1 and c2
Np = 10, T = 50
vi wvi c1r1 pbest ,i X i c2r2 g best X i
X i X i vi
f xi 16 xi2 5 xi
1 D 4
2 i 1
5 xi 5 i 1,2,..., D
Global minimium
f * 39.16599
x* 2.903534,..., 2.903534
0 k 1
1 2
4 Commonly used values
k 1, 2.05, 2.05
1 2
The particle swarm - explosion, stability, and convergence in a multidimensional complex space, in IEEE Transactions on Evolutionary Computation, vol. 6, no. 1, pp. 58-73. 2002
Particle Swarm Optimization in MATLAB - Yarpiz Video Tutorial - Part 3/3, https://www.youtube.com/watch?v=ICBYrKsFPqA 29
Different values of w
Np = 10, T = 50
vi wvi c1r1 pbest ,i X i c2r2 g best X i
X i X i vi
f xi 16 xi2 5 xi
1 D 4
2 i 1
5 xi 5 i 1,2,..., D
Global minimium
f * 39.16599
x* 2.903534,..., 2.903534
f xi 16 xi2 5 xi
1 D 4
2 i 1
5 xi 5 i 1,2,..., D
Global minimium
f * 39.16599
x* 2.903534,..., 2.903534
Surface plot: https://www.sfu.ca/~ssurjano/stybtang.html 31
Constriction coefficients
Np = 10, T = 50
k=1, ϕ1 = ϕ2 = 2.05
vi wvi c1r1 pbest ,i X i c2 r2 gbest X i
X i X i vi
f xi 16 xi2 5 xi
1 D 4
2 i 1
5 xi 5 i 1,2,..., D
Global minimium
f * 39.16599
x* 2.903534,..., 2.903534
Surface plot: https://www.sfu.ca/~ssurjano/stybtang.html 32
TLBO vs PSO
TLBO PSO
Phases Teacher, Learner No phases (Position and velocity update)
Convergence Monotonic Monotonic (with gbest and pbest)
Population size, termination criteria,
Parameters Population size, termination criteria
inertia weight, acceleration coefficients
using velocity vector, personal best and
Generation of new Only using other solutions, mean and
global best (need not be the part of
solution best solution (part of population)
population)
Solution update in
Twice Once
one iteration
Selection Greedy New solution is always accepted (µ, λ)
Number of function
Np + 2NpT Np + NpT
evaluations
33
Further reading
Particle swarm optimization, Proceedings of ICNN'95 - International Conference on Neural
Networks, Perth, WA, Australia, 4, 1942-1948, 1995
A dynamic neighbourhood learning based particle swarm optimizer for global numerical
optimization, Information Sciences, 209, 16-36 ,2012
34
Thank You !!!
35