Skip to main content
. 2025 Nov 19;10(11):787. doi: 10.3390/biomimetics10110787
Algorithm 1 The pseudocode of the BCA
  •   1:

    Input: Population Size: N, Problem Dimension: D, Max Iteration: Max_Gen, The Number Of Soldiers: nSoldiers

  •   2:

    Output: Obtained best solution

  •   3:

    Initialize the BCB parameters

  •   4:

    Initialize the solutions’ positions randomly

  •   5:

    while t ← 1 to Max_Gen do

  •   6:

         for i ← 1 to nArmies do

  •   7:

               for j ← 1 to nSoldiers do

  •   8:

                     for d1 to D do

  •   9:

                           if rand < BCB then

  • 10:

                                 Update the position by Equation (1)

  • 11:

                                 Update the position that exceeds the search boundaries By Equation (3)

  • 12:

                           else

  • 13:

                                 Update the position by Equation (2)

  • 14:

                                 Update the position that exceeds the search boundaries By Equation (4)

  • 15:

                           end if

  • 16:

                     end for

  • 17:

               end for

  • 18:

         end for

  • 19:

         Update gBest and gBestPos.

  • 20:

    end while