0% found this document useful (0 votes)
123 views38 pages

Pso PPT

The document discusses Particle Swarm Optimization (PSO), an algorithm inspired by swarm behavior in nature. PSO uses a number of agents or particles that constitute a swarm searching for the best solution. Each particle adjusts its position and velocity based on its own experience and the experiences of neighboring particles. The algorithm is initialized with a random population of particles with positions and velocities. It then iteratively updates the particles' velocities and positions until stopping criteria are met to find the global best solution. An example application to minimize a function is provided to illustrate the PSO algorithm steps.

Uploaded by

shakur mahmood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views38 pages

Pso PPT

The document discusses Particle Swarm Optimization (PSO), an algorithm inspired by swarm behavior in nature. PSO uses a number of agents or particles that constitute a swarm searching for the best solution. Each particle adjusts its position and velocity based on its own experience and the experiences of neighboring particles. The algorithm is initialized with a random population of particles with positions and velocities. It then iteratively updates the particles' velocities and positions until stopping criteria are met to find the global best solution. An example application to minimize a function is provided to illustrate the PSO algorithm steps.

Uploaded by

shakur mahmood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Particle Swarm optimization

Contents
 Introduction to Optimization
 Particle Swarm Optimization
 Illustration of Algorithm
 Mathematical Interpretation
 Example
 Dataset Illustration
Introduction to Optimization

 The optimization can be defined as a mechanism through which the maximum or minimum value of a
given function or process can be found.

 The function that we try to minimize or maximize is called as objective function.


 Variable and parameters.
 Statement of optimization problem
Minimize f(x)
subject to g(x)<=0
h(x)=0.
 Two main phases Exploration and Exploitation
Introduction to Optimization

Application to optimization: Particle Swarm Optimization

Proposed by James Kennedy & Russell Eberhart (1995)

Combines self-experiences with social experiences


Particle Swarm Optimization(PSO)

 Inspired from the nature social behavior and dynamic movements with communications of insects,
birds and fish.
Particle Swarm Optimization(PSO)
 Uses a number of agents (particles) that constitute a
swarm moving around in the search space looking for the
best solution

 in search space adjusts its “flying” according to its


 Each particle
own flying experience as well as the flying experience of other
particles.

 Each particle has three parameters position, velocity, and previous


best position, particle with best fitness value is called as global best
position.
Contd..

 Collection of flying particles (swarm) - Changing solutions

Search area - Possible solutions

 Movement towards a promising area to get the global optimum.

 Each particle adjusts its travelling speed dynamically corresponding to the flying
experiences of itself and its colleagues.

 Each particle keeps track:

its best solution, personal best, pbest.

the best value of any particle, global best, gbest.

 Each particle 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.


Algorithm - Parameters
f : Objective function

Xi: Position of the particle or agent.


Vi: Velocity of the particle or agent.
A: Population of agents.
W: Inertia weight.
C1: cognitive constant.
R1, R2: random numbers.
C2: social constant.
Algorithm - Steps

1. Create a ‘population’ of agents (particles) uniformly distributed over X

2. Evaluate each particle’s position according to the objective function( say

Y=F(x) = -x^2+5x+20
y=f(x)= -x^2+5x+20

1. If a particle’s current position is better than its previous best position, update it.

2. Determine the best particle (according to the particle’s previous best positions).
Contd..

5. Update particles’ velocities:

6. Move particles to their new positions:

7. Go to step 2 until stopping criteria are satisfied.


Contd…

Particle’s velocity
:

1. Inertia • Makes the particle move in the same direction and


with the same velocity

• Improves the individual


2. Personal • Makes the particle return to a previous position,
Influence better than the current
• Conservative

3. Social
• Makes the particle follow the best neighbors
Influence direction
Acceleration coefficients
• When , c1=c2=0 then all particles continue flying at their current speed until they hit the search space’s boundary.
Therefore, the velocity update equation is calculated as:
t 1
 vij
t
vij
• When c1>0 and c2=0 , all particles are independent. The velocity update equation will be:

vij
t 1
 vij
t
 c1r1 j
t
P t
best ,i  xij
t

• When c1>0 and c2=0 , all particles are attracted to a single point in the entire swarm and
the update velocity will become

vij
t 1
 vij
t
 c 2r 2 j
t
g best  xij
t

• When c1=c2, all particles are attracted towards the average of pbest and gbest.
Contd…

 Intensification: explores the previous solutions, finds the best solution of a


given region

 Diversification: searches new solutions, finds the regions with potentially the
best solutions

 In PSO:


Example:
Contd..
Contd..
Contd..
Flow chart of Algorithm
Mathematical Example and Interpretation

Fitness Function

 De Jong Function
minF(x,y) = x^2+y^2

Where x and y are the dimensions of the problem. The surface and contour plot of the De Jong
function is given as:
Mathematical Example and Interpretation

Contd..

Rastrigin Function

D
t 1
( xi  10. cos(2.  .xi )

The surface and contour plot of the De Jong function is given as:
Mathematical Example and Interpretation

Contd…

Banana Function

The surface and contour plot of the Rosenbrock function or 2nd De Jong function
Or valley or banana functions given as:
Mathematical Example and Interpretation
Example 1

Find the minimum of the function

f ( x)   x 2  5 x  20
Using PSO algorithm. Use 9 particles with initial positions
x1  9.6, x2  6, x3  2.6, x4  1.1,
x5  0.6, x6  2.3, x7  2.8, x8  8.3, x9  10
Solution Choose the number of particles
x1  9.6, x2  6, x3  2.6, x4  1.1,
x5  0.6, x6  2.3, x7  2.8, x8  8.3, x9  10
Evaluate the objective function

 120 .16, f 2  46, f 3  0.24


0 0 0
f1
 13 .29, f 5  22 .64, f 6  26 .21,
0 0 0
f4
 26 .16, f 8  7.39, f 9  30
0 0 0
f7
Mathematical Example and Interpretation
Contd..

Let c1=c2=1 and set initial velocities of the particles to zero.

v1  0, v1  v 2 , v3 , v 4  v5  v6  v7  v8  v9  0
0 0 0 0 0 0 0 0 0 0

Step2. Set the iteration no as t=0+1 and go to step 3


.
Step 3. Find the personal best for each particle by

P 1 best ,1  9.6, P 1 best , 2  6, P 1 best , 3  2.6


So
P 1 best , 4  1.1, P 1 best , 5  0.6, P 1 best , 6  2.3
P 1 best , 7  2.8, P 1 best ,8  8.3, P 1 best , 9  10
Mathematical Example and Interpretation
Contd..

Step 4: Gbest =max(Pbest) so gbest =(2.3).

Step 5: updating the velocities of the particle by considering the value of random
numbers r1 = 0.213, r2= 0.876, c1=c2=1, w=1.

v1  0  0.213(9.6  9.6)  0.876(2.3  9.6)  10.4244


1

v2  7.2708, v3  4.2924, v5  1.4892, v6  0, v7  0.4380, v8  5.256, v9  6.7452


1 1 1 1 1 1 1

Step 6: update the values of positions as well


Mathematical Example and Interpretation
Contd..
So
 0.8244 , x 2  1.2708 , x 3  1.6924
1 1 1
x1
 1.8784 , x 5  2.0892 , x 6  2.3
1 1 1
x4
 2.362 , x8  3.044 , x 9  3.2548
1 1 1
x7

Step7: Find the objective function values of

f 1  23.4424 , f 2  24.739 , f 3  25.5978


1 1 1

f 4  25.8636 , f 5  26.0812 , f 6  26.21


1 1 1

f 7  26.231, f 8  25.9541, f 9  25.6803


1 1 1

Step 8: Stopping criteria


if the terminal rule is satisfied , go to step 2.
Otherwise stop the iteration and output the results.
Contd..
 Step2. Set the iteration no as t=1+1 =2 and go to step 3

Step 3. Find the personal best for each particle by

 0.8244 , P  1.2708, P 2 best , 3  1.6924


2
2
P best ,1 best , 2

P 2 best , 4  1.87884 , P 2 best , 5  2.0892 , P 2 best , 6  2.3


P 2 best , 7  2.362, P 2 best ,8  3.044, P 2 best , 9  3.2548

Step 4: find the global best

Gbest  2.362

Step 5: by considering the random numbers in range (0,1) as

 0.113, r2  0.706
2 2
r1
Contd..
 Find the velocities of the particles :

v1  11.5099, v2  8.0412, v3  4.7651, v4  3.3198


2 2 2 2

v5  1.6818, v6  0.0438, v7  0.4380, v8  5.7375, v9  7.3755


2 2 2 2 2

Step 6: update the values of positions as well

 12 .3343, x 2  9.312 , x 3  6.4575


2 2 2
x1
 5.1982 , x 5  3.7710 , x 6  2.3438
2 2 1
x4
 1.9240 , x8  2.6935 , x9  4.12078
2 2 2
x7
Contd…
 Step7: Find the objective function values of

 70 .4644 , f 2  20 .1532 , f 3  10 .5882


2 2 2
f1
 18 .9696 , f 5  24 .6346 , f 6  26.2256
2 2 2
f4
 25 .9182 , f 8  0.7224 , f 9  17 .5839
2 2 2
f7

Step 8: Stopping criteria

if the terminal rule is satisfied , go to step 2.


Otherwise stop the iteration and output the results
Contd..
 Step2. Set the iteration no as t=1+2 =3 and go to step 3

Step 3. Find the personal best for each particle by

P 3 best ,1  0.8244 , P 3 best , 2  1.2708, P 3 best , 3  1.6924


P 3 best , 4  1.87884 , P 3 best , 5  2.0892 , P 3 best , 6  2.3
P 3 best , 7  2.362, P 3 best ,8  3.044, P 3 best , 9  3.2548
Step 4: find the global best

Gbest  2.362
Step 5: by considering the random numbers in range (0,1) as

r1  0.178, r2  0.507
3 3
Find the velocities of the particles

v1  4.4052, v2  3.0862, v3  1.8405, v4  1.2909


3 3 3 3

v5  0.6681, v6  0.053, v7  0.1380, v8  2.1531, v9  2.7759


3 3 3 3 3

Step 6: update the values of positions as well

 16 .7395 , x 2  12 .3982 , x 3  8.298


3 3 3
x1
 6.4862 , x 5  4.4391, x 6  2.3968
3 3 3
x4
 1.786 , x8  4.8466 , x 9  6.8967
3 3 3
x7

Step7: Find the objective function values of


Contd..

 176 .5145 , f 2  71.7244 , f 3  7.3673


3 3 3
f1
 10.3367 , f 5  22.49, f 6  26..2393
3 3 3
f4
 25.7402 , f 8  27.7222 , f 9  62.0471
3 3 3
f7

Step 8: Stopping criteria

if the terminal rule is satisfied , go to step 2.


Otherwise stop the iteration and output the results
Mathematical Example and Interpretation
Example
Iteration First:

Fitness Function :De Jong function min F ( x , y ) x 2


 y 2

Where x and y are the dimensions of the problem , the velocities of all the particles are
initialized to zero and inertia (W) = 0.3, and the value of the cognitive and social constants
are
C1= 2 and C2 =2. The initial best solutions of all the particles are set to 1000
P1 fitness value = 12  12  2
Mathematical Example and Interpretation
Example
Iteration 2nd:
Mathematical Example and Interpretation
Example
Iteration 3rd:
Mathematical Example and Interpretation
Example
Iteration 3rd:
Psuedocode

1. P=particle initialization();
2. For I =1 to max
3 for each particle p in P do
fp=f(p)
4. If fp is better than f(pbest)
pbest =p;
5. end
6. end
7. gbest = best p in P.
8. for each particle p in P do
9.

10.

11. end
12. end
DataSet
Advantages and Disadvantages of PSO
Advantages

 Insensitive to scaling of design variables.


 Simple implementation.
 Easily parallelized for concurrent processing.
 Derivative free.
 Very few algorithm parameters.
 Very efficient global search algorithm.

Disadvantages

 Slow convergence in refined search stage (weak local


search ability).

You might also like