Skip to main content
. 2023 Jun 25;23(13):5881. doi: 10.3390/s23135881
Algorithm 5 BFOA main steps
  • Define f(x), NGmax

  • Define Nb, Ped, Ned, Nrep, Nchemo, Nsw e Kstep

  • Generate initial position xi of the Nb bacteria

  • t: = 1

  • while (tNGmax) and (solution not yet found) do

  •    for (l: = 1,,Ned) do

  •      for k: = 1,,Nrep do

  •         for j: = 1,,Nchemo do

  •           Compute f(i,j,k,l) and Compute em fprev with associated m1,m2,m3

  •           Generate mov(i) of random values in [1,1]

  •           Move bacteria using fi,j+1,k,l(m1,m2,m3)=fi,j,k,l(m1,m2,m3)+C(i)·mov(i)movT(i)·mov(i)

  •           for s: = 1,,Nsw do

  •              Move for Nsw steps and generate fdev

  •           end for

  •           if fdev>fprev then

  •              Goback to positions fdev for bacteria

  •              for s: = 1,,Nsw do

  •                Move for Nsw steps

  •              end for

  •           end if

  •         end for

  •         Reproduce using the best half of Nb the bacteria

  •      end for

  •      Eliminate Ped of the worst bacteria

  •      Generate the same fraction randomly

  •    end for

  •    t: = t + 1

  • end while

  • Return best position