Skip to main content
. 2026 Sep 19;11(9):676. doi: 10.3390/biomimetics11090676
Algorithm 1 Sunn Pest Optimization (SPO)
Require: f(x), D, lb, ub, N, T, all parameters
Ensure: Xbest, fbest
  •   1:

    Xi∼U(lb,ub), i=1…N               ▹ Initial population

  •   2:

    fiti←f(Xi)∀i

  •   3:

    Xbest←Xargminifiti, fbest←minifiti

  •   4:

    Δ(0)←1N∑i∥Xi−μ(0)∥2              ▹ Equation (8), t=0

  •   5:

    div_threshold←max(Δ(0)·ε,10−10)          ▹ Equation (9)

  •   6:

    stag←0, fprev←fbest

  •   7:

    for t=0 to T−1 do

  •   8:

          w(t)←wmax−t·(wmax−wmin)/T          ▹ Equation (2)

  •   9:

          if t<0.4T then

  • 10:

                X← LevyMigration(X, Xbest, w(t))       ▹ Equations (3)–(5)

  • 11:

          else

  • 12:

                X← DifferentialMigration(X, Xbest, w(t))       ▹ Equation (6)

  • 13:

          end if

  • 14:

          fiti←f(Xi)∀i; update Xbest, fbest

  • 15:

          Δ(t)←1N∑i∥Xi−μ(t)∥2              ▹ Equation (8)

  • 16:

          stag←(fbest<fprev−10−10)?0:stag+1          ▹ Equation (7)

  • 17:

          if Δ(t)<div_threshold then

  • 18:

                stag←max(stag,24)              ▹ diversity-override

  • 19:

          end if

  • 20:

           if stag≥8 then

  • 21:

                [X,fit]← Carabid(X,fit)          ▹ Equations (10) and (11)

  • 22:

          end if

  • 23:

          if stag≥16 then

  • 24:

                [X,fit]← Beauveria(X,fit,Xbest)       ▹ Equations (12)–(14)

  • 25:

          end if

  • 26:

          if stag≥24 then

  • 27:

                [X,fit]← Parasitoid(X,fit); stag←0     ▹ Equations (15)–(17)

  • 28:

          end if

  • 29:

          Elitism: worst 0.1N← best 0.1N             ▹ Equation (18)

  • 30:

           fprev←fbest

  • 31:

    end for

  • 32:

    return Xbest, fbest