Particle Swarm Optimization

Particle Swarm Optimization (PSO) is an evolutionary numeric optimization algorithm. The algorithm is based on the motion of bird flocks, bee swarms etc. Slides on introductory discussion regarding PSO can be downloaded: Download ppt.

PSO algorithm is very simple to implement. In most cases, it is the fitness function that is difficult to implement. The fitness function depends on the objective of the work. The following example problem shows how a fitness function can be defined for a specific design goal.

An example of application of PSO is discussed next. The simple circuit based problem should help beginners to understand basic implementation method of PSO. The MATLAB code used to solve the problem is also provided. However, it is encouraged that interested students should try to implement the code on their own.

Example: A Circuit Optimization Problem:

Consider the following circuit.

The circuit parameters have the following values:

R2 = 100Ω

R3 = 47Ω

R4 = 32Ω

R6 = 22Ω

R7 = 132Ω

V1 = 8 volt

V2 = 12 volt

The other circuit parameters are variables. The range of values of those parameters are:

R1 = 10Ω to 50Ω

R5 = 90Ω to 150Ω

R8 = 160Ω to 250Ω

v3 = 12 volt to 18 volt

Find the value of these 4 parameters so that the power delivered by V1 is 10% of the power delivered by V3. (If power delivered by V1 and V3 are PV1 and PV3 respectively, then it is required that PV1 = 0.1 PV3.)


To solve this problem, we use PSO. The solution space will be 4 dimensional. The range of the values of the parameters defines the solution region.

First we need to find the power delivered by the sources by solving the circuit. We use Mesh current analysis. The mesh equations are:

The equations can be written in matrix form as:

This equation is comparable to Ai = V. Using matrix inversion, we can solve i (the current matrix). If we put values of all the parameters, the mesh current can be solved using simple computer code. From the currents we can calculate the power delivered by the voltage sources.

Now, we need to define the fitness function. We require that the power of the voltage sources V1 and V3 have the relation: PV1 = 0.1 PV3. We define fitness function as: fitness = -abs(PV1 - 0.1PV3). Here abs denotes absolute value. We note that when our condition is satisfied, the fitness function will have zero value. In other cases, we will a negative fitness value. So, maximizing this fitness function will give us the desired results.

The MATLAB codes of this problem can be downloaded: Download

Note that all the files must be in the same folder in order for the main code to run on MATLAB.

This page was last updated on: 12th October, 2011.