BSOoptim: Implementation of the Beetle Swarm Optimization(BSO)...

Description Usage Arguments Value References Examples

Description

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.

Usage

1
2
3
4
5
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*√{dimensions})

w

a vector for calculating inertia weight, (ω_{max},ω_{min}), default c(0.9,0.4). the strategy of decreasing inertia weight is as follows.

ω = ω_{max} - (ω_{max}-ω_{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+ λ V_{is}^k+(1-λ)ξ_{is}^k

w_vs is λ, 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).

δ_{k+1} = η δ_{k}

η = δ_{w1}(\frac{δ_{w0}}{δ_{w1}})^{\frac{1}{1+10*k/n}}

step_w = (δ_{w0},δ_{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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#======== 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
# >>>> 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
#======== examples end =======================

jywang2016/rBAS documentation built on May 21, 2019, 1:43 a.m.