From the paper "Prakash, D. B., and C. Lakshminarayana. "Multiple DG placements in distribution system for power loss reduction using PSO algorithm." Procedia technology 25 (2016): 785-792", PSO algorithm is given below
Step 1: Input data such as line impedance, line power.
Step 2: Calculate voltages at each node and total power loss in the distribution network using forward backward sweep method.
Step 3: Initialize population size.
Step 4: Initialize number of particles to be optimized.
Step 5: Set bus count x=2.
Step 6: Set generation count y=0.
Step 7: Generate random position and velocity for each particle.
Step 8: Calculate power loss for each particle using Active power loss minimization.
Step 9: Initialize current position of each particle as ‘Pbest’.
Step 10: Assign ‘Gbest’ as best amont ‘Pbest’.
Step 11: Update velocity and position of each particle using  velocity and position update equations respectively.
Step 12: If generation count reaches maximum limit, go to Step 13 or else increase the counter by one and go to Step 7.
Step 13: If bus count reaches maximum limit, go to Step 14 or else increase the counter by one and go to Step 6.
Step 14: Display the results.
I have a 0.4 KV electrical network and I need to use particle swarm optimization algorithm on it to find the optimal place and size for DGs but I'm new to optimization subject I tried a lot but I couldn't know how to do it could anyone help me with it please
optimal location of DGs