Step 1:

An initial population of particles with values of positions and velocities on dimensions in the solution space are randomly generated. The iteration counter is set as k = 0.

Step 2:

The objective value is calculated for each particle. Else, that particle becomes as infeasible.

Step 3:

Comparison of objective value of each particle is done with individual best values. The current pbest value is set, if the calculated objective value is lower than Pbest value and the corresponding particle position is reordered.

Step 4:

The particle associated with the minimum individual best is selected. This value is set as Pbest and the current overall best is selected as Gbest.

Step 5:

Maximum fitness and average fitness values are calculated. Error is calculated using the equation below.

Error = (maximum fitness - average fitness).

Step 6:

If this error is less than a specified tolerance then go to step 9. Formed offspring is an exact copy of parents.

Step 7:

Update the velocity and position of particle. New fitness values are calculated for the new positions of all the particles. If the new fitness value for any particle is better than previous Pbest value then Pbest value for that particle is set to present fitness value. Similarly, Gbest value is identified from the latest Pbest values.

Step 8:

The iteration count is incremented and if iteration count is not reached maximum then go to step 2.

Step 9:

Global best particle gives the optimal sizing of DGs in candidate locations.