Description Usage Arguments Value References Examples
You could find more information about BAS in https://arxiv.org/abs/1710.10724.
1 2 3 4 |
fn |
objective function; function need to be optimized |
init |
default = NULL, it will generate randomly; Of course, you can specify it. |
lower |
lower of parameters to be estimated; Default = c(-6,0) because of the test on Michalewicz function of which thelower is c(-6,0); By the way, you should set one of init or lower parameter at least to make the code know the dimensionality of your problem. |
upper |
upper of parameters; Default = c(-1,2). |
constr |
constraint function. For example, you can formulate x<=10 as constr = function(x) return(x - 10). |
d0 |
a constant to gurantee that sensing length of antennae d doesn't equal to zero. More specifically, d^t = η_d * d^{t-1} + d_0 where attenuation coefficient η_d belongs to [0,1] |
d1 |
initial value of antenae length. You can specify it according to your problem scale |
eta_d |
attenuation coefficient of sensing length of antennae |
l0 |
position jitter factor constant.Default = 0. |
l1 |
initial position jitter factor.Default = 0. x = x - step * dir * sign(fn(left) - fn(right)) + l *random(npars) |
eta_l |
attenuation coefficient of jitter factor. l^t = η_l * l^{t-1} + l_0 |
step |
initial step-size of beetle |
eta_step |
attenuation coefficient of step-size. step^t = η_{step} * step^{t-1} |
n |
iterations times |
seed |
random seed; default = NULL ; The results of BAS depend on random init value and random directions.
Therefore, if you set a random seed, for example, |
trace |
default = T; trace the process of BAS iteration. |
steptol |
default = 0.01; Iteration will stop if step-size in current moment is less than steptol. |
pen |
penalty conefficient usually predefined as a large enough value, default 1e5 |
A list including best beetle position (parameters) and corresponding objective function value.
X. Y. Jiang, and S. Li, BAS: beetle antennae search algorithm for optimization problems, arXiv:1710.10724v1.
1 2 3 4 5 6 7 8 9 10 11 12 | #======== examples start =======================
# BAS application on Michalewicz function
library(rBAS)
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)
}
BASoptim(fn = mich,
lower = c(-6,0), upper = c(-1,2),
seed = 1, n = 100,trace = FALSE)
#======== examples end =======================
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.