Skip to main content
. 2024 Oct 23;24(21):6801. doi: 10.3390/s24216801
Algorithm 1: Framework of the SSA
  • Input: 

    Tmax: the maximum iterations; PD: the number of producers; SD: the number of sparrows who perceive the danger; R2: the alarm value; N: total number of sparrows

  • Output: 

    Xbest: the current global optimal location; fg: fitness (Xbest)

while (t < Tmax)
graphic file with name sensors-24-06801-i001.jpg Rank the fitness values and find the current best individual and the current worst individual.
R2 = rand (1)  # Update the alarm value randomly
for i=1:PD
 Using Equation (8), update the sparrow’s location
end
for i=(PD+1):N
 Using Equation (9), update the sparrow’s location
end
for i=1:SD
 Using Equation (10), update the sparrow’s location
end for
Get the current new location
If the new location is better than before, update it
t = t + 1
end while
Return Xbest, fg