Skip to main content
. 2025 May 12;10(5):314. doi: 10.3390/biomimetics10050314
Algorithm 2 Binary Particle Swarm Optimization.

 Input: The population X={X1,X2,…,Xi}

 Output: The updated population X′={X1′,X2′,…,Xi′} and Xα

  •  1:

    Initialize binary random population X

  •  2:

    Evaluate the objective function of each individual and save the pbest of each solution

  •  3:

    Identify the gBest in the population

  •  4:

    Define c1, c2, wmax, and wmin

  •  5:

    for iteration (t) do

  •  6:

          Update w using Equation (4)

  •  7:

          for solution(i) do

  •  8:

                Update vi using Equation (3)

  •  9:

                Update Xi using Equation (2)

  • 10:

          end for

  • 11:

          Binarization of population X using Algorithm 1

  • 12:

          Evaluate the objective function of each individual and save the pbest of each solution

  • 13:

          Update gBest

  • 14:

    end for

  • 15:

    Return (gBest)