Skip to main content
. 2024 Sep 15;16(18):3117. doi: 10.3390/nu16183117
Algorithm 1. PSO-SA Algorithm
itr = 1
 Initialize swarm size, T,ᾳ
 Initialize particle Position and Velocity
 Stop Condition = maxiterations or predefine error
 while Not stop Condition do
    for each particle I = 1 to swarm size, do
       Evaluate f(particle(i))
     if the f(particle(i)) is better than the f(Pbest) then
        Update current Pbest.
    end
    if f(Pbest) is better than f(Gbest) then
       Gbest = Pbest
    end
  end
  if f(Gbest) > predefine error then
    Generate neighborhoods(Gbest, ᾳ)
    For j = 1 to neighborhoods size do
       Evaluate f(Neighborhood(j))
       if the f(Neighborhood(j)) is better than the f(Gbest) then
      Gbest = Neighborhood(j)
       Elseaccept the Neighborhood with a probability p defined by
      ∆E = f(Neighborhood(i).Pbest) − f(Gbest)
      P = e−∆E/T
       end
       update T
   end
  update ᾳ
  itr = itr + 1
endupdate ᾳ
itr = itr + 1
end