Step 1 % Assign values for the PSO parameters % |
Initialize: swarm size (N) and step size; learning rate () dimension for the search |
space (d); inertia weight (W); |
% Initialize random values and current fitness % |
= rand (d, N); = rand (d, N); Current fitness = 0 * ones (N, 1) |
Step 2 % Initialize Swarm Velocity and Position % |
Current position = 10 * (rand (d, N) − 0.25) |
Current velocity = 0.5 * rand (d, N) |
Step 3 Evaluate the objective function of every particle and record each particle’s and . |
Evaluate the desired optimization fitness function in “d”—dimension variables |
Step 4 Compare the fitness of particle with its and replace the local best value as given below. |
for i = 1 : N |
If current fitness (i) < local best fitness (i); |
Then local best fitness = current fitness; % |
Replacement % |
local best position = current position (i); % |
Replacement % |
end |
Step 5 Compare the fitness of particle with its and replace the global best value as given below. |
for i = 1 : N |
If current fitness (i) < global best fitness (i); |
Then global best fitness = current fitness; % |
Replacement % |
global best position = current position (i); % |
Replacement % |
end |
Step 6 Update the current velocity and position of the particles according to (6) and (8) |
Step 7 Repeat step–2 to 6 until the predefined value of the performance index has been reached. |
Record the optimized , , values. |