Algorithm for Swarming

StartInitialize Swarm with random position (x_0) and velocity vectors (v_0)for each particle t in search_space:// evaluate fitness if fitness(x[t]) > fitness(gbest): gbest = x[t]if fitness(x_t) > fitness(pbest):pbest = x[t]// update velocityv[t+1] = w*v[t] + c1*rand(0,1)*(pbest-x[t]) + c2*rand(0,1)*(gbest - x[t])// update positionx[t+1] = x[t] + v[t+1] // do this again for next particle// terminate loopoutput = gbest;show(output)End
---
::Terms::gbest - global best positive pbest - self best positionc1 and c2 - acceleration coeeficientsw - intertia; weight