Skip to main content
. 2019 Jun 18;19(12):2727. doi: 10.3390/s19122727
Algorithm 1: BAS
Input: Set the maximum number of iterations tmax. Define the evaluation function f(.). Randomly set N beetle positions xti(i = 1, 2, …, N). Set t = 0. Set the value of c according to the optimization purpose. Record the initial sensing length of antennae d0, the initial step size δ0. Record the initial optimum solution, xbest, and the initial optimum value, gbest.
Output:xbest, gbest.
1: while (t < Tmax)
2:  For i = 1: N
3:  Update the searching direction bi using Equation (11)
4:  Update the right antenna position xri using Equation (12)
5:  Update the left antenna position xli using Equation (13)
6:  Update the next position xit+1of the beetle xit using Equation (14).
7:  End for
8:  For i = 1: N
9:   Calculate the function value f(xit+1) of ith beetle.
10:   If f(xit+1)is better than gbest
11:      xbest = xit+1
12:      gbest = f(xit+1)
13:   End if
14:     End for
15:  Update the sensing length of the antennae dt using Equation (15).
16:  Update the step size of searching δt using Equation (16).
17:  t = t + 1
18: End while