0% found this document useful (0 votes)
18 views7 pages

Particle Swarm Optimization

Pso numerical examples

Uploaded by

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

Particle Swarm Optimization

Pso numerical examples

Uploaded by

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

Particle Swarm Optimization (PSO) is a population-based meta-heuristic approach, inspired by

the bird flocking or fish schooling. Each particle ( X i ) of a swarm can move in a D-dimensional
search space. The movement of each particle depends on its velocity and position. The position
of i-th particle of a D-dimensional search space represents a candidate solution,
X i =[ x i ,1 , x i ,2 , xi , 3 , . . .. , x i , D ]. The initial velocity of each particle is represented as
V i=[v i ,1 , v i ,2 , v i ,3 , . .. . , v i , D ]. In each iteration, a particle updates its position by remembering the
following two best values,

i. The best position of a particle achieved so far is called Personal best ( P best i) and its
corresponding objective function value is Pval i.
ii. The best position obtained so far considering all particles of the swarm is called Global
best (Gbest ), and its corresponding objective function value is Gval .
After finding the Pbest i and Gbest each particle updates its velocity and positions using Eq.1
and Eq.2.
t +1 t
V i =w∗V i +C 1∗r 1 ()∗( Pbest i−X i ) + C2∗r 2 ()∗( Gbest −X i ) (1)
t +1 t +1
X i = X i +V i (2)

Where,Gbest =[ g1 , g 2 , g3 ,. . . . , g D ], V ti represents the velocity of i-th particle at t -th


iteration, w is the inertia weight. The parameters C 1 and C 2 are the cognitive and social
acceleration coefficients respectively. r 1(),r 2() are two random functions in the range (0 , 1).

Parameters of PSO
i. Dimension of problem (D)
ii. Population size (N)
iii. Lower limits of each element present in D dimensional vector ( Fd 1)
iv. upper limits of each element present in D dimensional vector ( Fd 2)
v. velocity of i-th particle (V i)
vi. Cognitive (C 1) and social acceleration coefficients (C 2) of PSO
vii. Inertia weight of PSO (w )

Steps of PSO Algorithms

Step 1. Initialization

i. Initialize the PSO parameters


ii. Initialize the position of each particle in randomly
iii. Calculate the objective function value of each particle
iv. Initialize the personal best of each particle
v. Find the global best particle
Step 2. Update the particles

i. Update the position of each particle using Equation 1 and 2.


ii. Calculate the objective function value of each particle
iii. Update the personal best if the new position is found better than the current personal best
iv. Update the Global best if the new position is found better than the current Global best

Repeat Step 2 until meet the stopping criteria.

Stopping criteria: Maximum number of iteration/ Maximum Function evaluation

The pseudo code of the procedure is as follows

For each particle


Initialize particle
END
Do
For each particle
Calculate fitness value
If the fitness value is better than the personal best fitness value
Set current value as the new personal best
End
Choose the particle with the best fitness value of all the particles as the gBest
For each particle
Calculate particle velocity according equation (1)
Update particle position according equation (2)
End
While stopping criteria is not attained

Example

1. Find the minimum of the function using Particle Swarm Optimization


D
f ( x )=∑ x2i
i=1

Consider the following parameters values of PSO

i. Dimension of problem (D)= 3


ii. Population size (N)=4
iii. Lower limits of each element present in D dimensional vector ( Fd 1)=1
iv. upper limits of each element present in D dimensional vector ( Fd 2)=10
v. Initial velocity of each particle (V )=0;
vi. Cognitive (C 1) and social acceleration coefficients (C 2) of PSO =2
vii. Inertia weight of PSO (w )=0.8

Step 1. Initialize the population

Generate D number of random numbers between Fd 1 and Fd 2 for each particle X i

X 1 =[2.2 4.5 6.7]

X 2 =[1.8 3.5 6.2]

X 3 =[5.21.5 5.5]

X 4=[6.4 1.5 2.6]

Calculate the objective function value of each particle


2 2 2
f ( X 1 )=2.2 + 4.5 + 6.7 =4.84+20.25+ 44.89=69.98
2 2 2
f ( X 2 )=1.8 +3.5 +6.2 =3.24+12.25+38.44=53.93
2 2 2
f ( X 3 )=5.2 +1.5 +5.5 =27.04+2.25+30.25=59.54
2 2 2
f ( X 4 ) =6.4 +1.5 +2.6 =40.96 +2.25+6.76=49.97

Initialize the personal best of each particle

Initially the position of each particle will be the personal best solution each particle

Pbest 1=X 1 and Pval 1=f ( X 1 )

Pbest 2=X 2 and Pval 2=f ( X 2 )

Pbest 3=X 3 and Pval 3=f ( X 3 )

Pbest 4= X 4 and Pval 4=f ( X 4 )

Initialize the Global best of each particle

Global best value (Gval ¿=min ( f ( X ) )=49.97 is the corresponding objective function value of
X4

Global best solution (Gbest )= position of the X 4 particle= [6.4 1.5 2.6]
2. PSO Main Loop

While (stopping criteria)

 Update the position of each particle at t+1 th iteration


 Calculate the velocity of each particle

i. For 1st particle ( X 1)


t +1 t
V i =w∗V i +C 1∗r 1 ()∗( Pbest i−X i ) + C2∗r 2 ()∗( Gbest −X i )
1
V 1=0.8∗[00 0 ]+2∗0.23∗( [2.2 4.5 6.7]−[2.2 4.5 6.7] ) +2∗0.42∗([6.4 1.5 2.6]−[2.2 4.5 6.7] )

¿ [ 0 0 0 ] + [ 0 0 0 ] +0.84∗[4.2−3−4.1]

¿ [3.528−2.16−3.444]
t +1 t +1
X i = X i +V i

New updated position of X 1 at 1st iteration will be the

X 1 =[ 2.2 4.56.7 ] +[3.528−2.16−3.444 ]


1

¿ [5.728 2.34 3.256 ]

f (X ¿ ¿ 1 )=5.728 +2.34 +3.256 =32.80+5.475+10.60=48.875 ¿


1 2 2 2

Compare the current objective function with personal best value

f (X ¿ ¿ 1 )≤ Pbest 1 ¿ yes
1

Update the Pbest 1 and Pval 1

Pbest 1=[5.728 2.34 3.256]

Pval 1=48.875

Compare the current objective function with Global best value

f (X ¿ ¿ 1 )≤ Gval ¿ Yes
1

Update Global best solution (Gbest ) and Global best value (Gval ¿

Gbest =[5.728 2.34 3.256]

Gval=48.875
ii. For 2nd particle ( X 2 )

Calculate the velocity of each particle


t +1 t
V i =w∗V i +C 1∗r 1 ()∗( Pbest i−X i ) + C2∗r 2 ()∗( Gbest −X i )
1
V 2=0.8∗[0 0 0]+2∗0.35∗( [1.8 3.5 6.2]−[1.8 3.5 6.2] ) +2∗0.54∗([5.728 2.34 3.256]−[1.8 3.5 6.2] )

¿ [ 0 0 0 ] + [ 0 0 0 ] +1.08∗[3.928−1.16−2.944 ]

¿ [4.242−1.252−3.179 ]
t +1 t +1
X i = X i +V i

New updated position of X 2 at 1st iteration will be the

X 2 =[ 1.8 3.5 6.2 ] +[4.242−1.252−3.179 ]


1

¿ [6.042 2.248 3.021]

f ( X ¿ ¿ 2 )=6.042 +2.248 +3.021 =36.50+5.053+ 9.126=50.679¿


1 2 2 2

Compare the current objective function with personal best value

f (X ¿ ¿ 2 )≤ Pbest2 ¿ yes
1

Update the Pbest 2 and Pval 2

Pbest 2=[6.042 2.248 3.021]

Pval 2=50.679

Compare the current objective function with Global best value

f (X ¿ ¿ 2 )≤ Gval ¿ No
1

Global best solution (Gbest ) and Global best value (Gval ¿ remain unchanged

iii. For 3rd particle ( X 3 )

Calculate the velocity of each particle


t +1 t
V i =w∗V i +C 1∗r 1 ()∗( Pbest i−X i ) + C2∗r 2 ()∗( Gbest −X i )
1
V 3=0.8∗[0 0 0]+2∗0.68∗( [5.21.5 5.5]−[5.21.5 5.5 ] ) +2∗0.57∗( [5.7282.34 3.256]−[5.21.5 5.5] )
¿ [ 0 0 0 ] + [ 0 0 0 ] +1.14∗[0.528 0.84−2.244 ]

¿ [0.601 0.9576−2.558]
t +1 t +1
X i = X i +V i

New updated position of X 3 at 1st iteration will be the

X 3 =[ 5.2 1.5 5.5 ] +[0.601 0.9576−2.558]


1

¿ [5.801 2.457 2.942]

f ( X ¿ ¿ 3 )=5.801 +2.457 +2.942 =33.651+ 6.036+8.655=48.342 ¿


1 2 2 2

Compare the current objective function with personal best value

f (X ¿ ¿ 3 )≤ Pbest 3 ¿ yes
1

Update the Pbest 3 and Pval 3

Pbest 3=[5.801 2.457 2.942]

Pval 3=48.342

Compare the current objective function with Global best value

f (X ¿ ¿ 3 )≤ Gval ¿ Yes
1

Update Global best solution (Gbest ) and Global best value (Gval ¿

Gbest =[5.801 2.457 2.942]

Gval=48.342

iv. For 4th particle ( X 4)

Calculate the velocity of each particle


t +1 t
V i =w∗V i +C 1∗r 1 ()∗( Pbest i−X i ) + C2∗r 2 ()∗( Gbest −X i )
1
V 4 =0.8∗[0 0 0]+2∗0.68∗( [6.4 1.5 2.6 ]−[6.4 1.5 2.6] ) +2∗0.94∗( [5.801 2.457 2.942]−[6.4 1.5 2.6] )

¿ [ 0 0 0 ] + [ 0 0 0 ] +1.88∗[−0.599 0.957 0.342]

¿ [−1.127 1.799 0.642]


t +1 t +1
X i = X i +V i
New updated position of X 4 at 1st iteration will be the

X 4=[ 6.4 1.5 2.6 ] +[−1.127 1.7990.642]


1

¿ [5.273 3.299 3.242]

f (X ¿ ¿ 4 )=5.273 +3.299 +3.242 =27.80+10.883+ 10.51=49.193 ¿


1 2 2 2

Compare the current objective function with personal best value

f (X ¿ ¿ 4 )≤ Pbest 4 ¿ yes
1

Update the Pbest 4 and Pval 4

Pbest 4=[5.273 3.299 3.242]

Pval 4=49.193

Compare the current objective function with Global best value

f ( X ¿ ¿ 4 )≤ Gval ¿ No
1

Global best solution (Gbest ) and Global best value (Gval ¿ remain unchanged

So, after the 1st iteration Global best solution (Gbest ) and Global best value (Gval ¿ are

Gbest =[5.801 2.457 2.942]

Gval=48.342

You might also like