BSO is the combination of BAS and PSO. It improves the BAS algorithm by expanding an individual to a group in the way of PSO. Note: In a word, 'swarm' in BSAS is more like that a beetle has many antennae pairs(searching direction) while the 'swarm' in BSO means group just like PSO.

BSOoptim(fn, init = NULL, constr = NULL, lower = c(-50, -50),
  upper = c(50, 50), n = 300, s = floor(10 + 2 *
  sqrt(length(lower))), w = c(0.9, 0.4), w_vs = 0.4, step = 10,
  step_w = c(0.9, 0.4), c = 8, v = c(-5.12, 5.12), trace = T,
  seed = NULL, pen = 1e+06)

Arguments

fn

objective function; function need to be optimized

init

default = NULL, it will generate randomly; Or you can specify it as a matrix. For example, if your problem is defined as m beetles and n dimensions, you can specify init as a \(m*n\) matrix.

constr

constraint function. For example, you can formulate \(x<=10\) as \(constr = function(x) return(x - 10)\).

lower

lower of parameters to be estimated

upper

upper of parameters

n

maximum number of iterations

s

a positive integer, beetles number. Default = \(floor(10+2*\sqrt{dimensions})\)

w

a vector for calculating inertia weight, \((\omega_{max},\omega_{min})\), default c(0.9,0.4). the strategy of decreasing inertia weight is as follows. $$\omega = \omega_{max} - (\omega_{max}-\omega_{min})\frac{k}{n}$$. \(k\) is the current number of iteration and \(n\) is the maximum number of iterations.

w_vs

a positive constant belongs to [0,1]. Default = 0.4. $$X_{is}^{k+1}=X_{is}^k+ \lambda V_{is}^k+(1-\lambda)\xi_{is}^k$$ w_vs is \(\lambda\), which means the weight of speed(PSO) and beetle movement(BAS).

step

initial step-size of beetles

step_w

a vector used for step-size updating, default c(0.9,0.4). $$\delta_{k+1} = \eta \delta_{k}$$ $$\eta = \delta_{w1}(\frac{\delta_{w0}}{\delta_{w1}})^{\frac{1}{1+10*k/n}}$$ step_w = \((\delta_{w0},\delta_{w1})\)

c

ratio of step-size and searching distance.$$d = \frac{step}{c}$$

v

the speed range of beetles. Default = c(-5.12, 5.12)

trace

default = T; trace the process of BAS iteration.

seed

random seed; default = NULL

pen

penalty conefficient usually predefined as a large enough value, default 1e6

Value

A list including best beetle position ($par) and corresponding objective function value($value).

References

Wang T, Yang L, Liu Q. Beetle Swarm Optimization Algorithm:Theory and Application.2018. arXiv:1808.00206v1.https://arxiv.org/abs/1808.00206

Examples

#======== examples start ======================= # >>>> example with constraint: Mixed integer nonlinear programming <<<< pressure_Vessel <- list( obj = function(x){ x1 <- floor(x[1])*0.0625 x2 <- floor(x[2])*0.0625 x3 <- x[3] x4 <- x[4] result <- 0.6224*x1*x3*x4 + 1.7781*x2*x3^2 +3.1611*x1^2*x4 + 19.84*x1^2*x3 }, con = function(x){ x1 <- floor(x[1])*0.0625 x2 <- floor(x[2])*0.0625 x3 <- x[3] x4 <- x[4] c( 0.0193*x3 - x1,#<=0 0.00954*x3 - x2, 750.0*1728.0 - pi*x3^2*x4 - 4/3*pi*x3^3 ) } ) result<- BSOoptim(fn = pressure_Vessel$obj, init = NULL, constr = pressure_Vessel$con, lower = c( 1, 1, 10, 10), upper = c(100, 100, 200, 200), n = 1000, w = c(0.9,0.4), w_vs = 0.9, step = 100, step_w = c(0.9,0.4), c = 35, v = c(-5.12,5.12), trace = F,seed = 1, pen = 1e6) result$par; result$value
#> [1] 13.955250 7.550179 42.098446 176.636596
#> [1] 6059.131
# >>>> example without constraint: Michalewicz function <<<< mich <- function(x){ y1 <- -sin(x[1])*(sin((x[1]^2)/pi))^20 y2 <- -sin(x[2])*(sin((2*x[2]^2)/pi))^20 return(y1+y2) } result <- BSOoptim(fn = mich, init = NULL, lower = c(-6,0), upper = c(-1,2), n = 100, step = 5, s = 10,seed = 1, trace = F) result$par; result$value
#> [1] -4.965998 1.570796
#> [1] -1.967851
#======== examples end =======================