Skip to main content
. 2023 Jun 25;23(13):5881. doi: 10.3390/s23135881
Algorithm 8 PSO main steps
  • Define: ω, ϕ1, ϕ2, f(x), M

  • Initialize randomically the Np particles in the search space

  • Initialize Pibest=f(xi)

  • Initialize Sbest as Gbest=best(Pibest) or Lbest=best(Pibestneighbors)

  • t: = 1

  • while (tNGmax) and (solution not yet found) do

  •    for each particle xi do

  •      Compute vi(t+1)=ω·vi(t)+ϕ1·r1·(Pibestxi(t))+ϕ2·r2·(Sibestxi(t))

  •      Apply velocity control

  •      Compute new position xi(t+1)=xi(t)+vi(t+1)

  •      Update Pibest e Sbest

  •    end for

  •    Obtain Sbest among Pibest for all particle i

  •    t: = t + 1

  • end while

  • Return the position of the best particle