BASoptim2: Implementation of the BAS with momentum (also named as...

Description Usage Arguments Value Examples

Description

BAS with momentum introduces 'velocity' to the detecting rules of basic BAS. It is more like the individual version of BSO The paper of this algorithm is not available now. If you have any question, please contact Xiaoxiao Li (xiaoxiaoli1993@sina.com)

Usage

1
2
3
4
5
BASoptim2(fn, init = NULL, lower = c(-6, 0), upper = c(-1, 2),
  constr = NULL, c = 2, l0 = 0, l1 = 0, eta_l = 0.95,
  step0 = 5e-05, step = 0.8, eta_step = 0.95, n = 200,
  seed = NULL, trace = T, steptol = step0/2, pen = 1e+05,
  w0 = 0.7, w1 = 0.2, c0 = 0.6)

Arguments

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).

c

the ratio of step-size and search distance d.

d = \frac{step}{c}

l0

position jitter factor constant.Default = 0.

l1

initial position jitter factor.Default = 0.

eta_l

attenuation coefficient of jitter factor.

l^t = η_l * l^{t-1} + l_0

step0

the minimal resolution of step-size

step

initial step-size of beetle.

step = η_{step}(step-step0) + step0

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,seed = 1, the results will remain the same no matter how many times you repeat your experiments.

trace

default = T; trace the process of BAS iteration.

steptol

default = step0/2; 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

w0

inertia weight; default = 0.7

w1

weight of the difference between left and right antenae. default = 0.2

v = w_0v-w_1dir(f_{left}-f_{right})

c0

the ratio of maximal speed and initial step.

v_{max} = c_0step

Value

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

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
#======== 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)
}
fit<-
  BASoptim2(fn = mich,
            lower = c(-6,0),
            upper = c(-1,2),
            n = 100,
            trace = F,
            c = 0.4,#d = 1.2/0.4 = 3
            step = 1.2,
            seed = 1,
            w0 = 0.4,w1 = 0.2, c0 = 0.6)
fit$par;fit$value
func1 <- function(x){
  sum(x^2)
}
fit<-
  BASoptim2(fn = func1,
            lower = c(-100,-100),
            upper = c(100,100),
            n = 100,
            trace = F,
            c = 20,
            step = 100,
            seed = 1,
            w0 = 0.5,w1 = 0.2, c0 = 0.6)
fit$par;fit$value
func2 <- function(x){
  sum((abs(x)-5)^2)
}
fit<-
  BASoptim2(fn = func2,
            lower = c(-10,-10),
            upper = c(10,10),
            n = 100,
            trace = F,
            c = 5,
            step = 5,
            seed = 1,
            w0 = 0.2,w1 = 0.2, c0 = 0.6)
fit$par;fit$value
#======== examples end =======================

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