knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

rBAS

An R module aimed at implementation of Beetle Antennae Search (BAS) Algorithm and its mutations, for example, Beetle Swarm Antenae Search (BSAS) Algorithm.


Installation

rBAS is currently not on CRAN. You can install rBAS from Github with:

devtools::install_github("jywang2016/rBAS")

Examples

Use help() to see the document pages about functions in rBAS.

library(rBAS) #load package

help(BASoptim)
help(BSASoptim)

Two typocal test functions are applied to validate the efficacy of BAS/BSAS algorithm

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)
}
test<-
  BASoptim(fn = mich,
           lower = c(-6,0), upper = c(-1,2),
           seed = 1, n = 100,trace = F)

test$par
test$value
summary(test$df)

Goldstein-Price function

gold <- function(x){
  x1 <- x[1]
  x2 <- x[2]
  y1 <- 1 + (x1 + x2 + 1)^2*(19 - 14*x1+3*x1^2 - 14*x2 + 6*x1*x2 + 3*x2^2)
  y2 <- 30 + (2*x1 -3*x2)^2*(18 - 32*x1 + 12*x1^2+48*x2-36*x1*x2 + 27*x2^2)
  return(y1*y2)
}
test<-
  BASoptim(fn = gold,
           lower = c(-2,-2), upper = c(2,2),
           seed = NULL, n = 100,trace = F)

test$par
test$value
summary(test$df)

Pressure Vessel

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.00954*x3 - x2,
      750.0*1728.0 - pi*x3^2*x4 - 4/3*pi*x3^3
    )
  }
)
result <- BSASoptim(fn = pressure_Vessel$obj,
                    k = 10,
                    lower =c( 1, 1, 10, 10),
                    upper = c(100, 100, 200, 200),
                    constr = pressure_Vessel$con,
                    n = 200,
                    step = 100,
                    d1 = 4,
                    pen = 1e6,
                    steptol = 1e-6,
                    n_flag = 2,
                    seed = 2,trace = FALSE)

result$par
result$value

BSAS algorithm

In order to save space, the BSAS algorithm code is executed with trace as FALSE because of too much trace information. You can set trace to TRUE and observe the trace messages.

test<-
  BSASoptim(fn = mich,
            lower = c(-6,0), upper = c(-1,2),
            seed = 12, n = 100,k=5,
            trace = F)

test$par
test$value
summary(test$df)
test<-
  BSASoptim(fn = gold,
            lower = c(-2,-2), upper = c(2,2),
            seed = 11, n = 100,k=2,
            trace = F)

test$par
test$value
summary(test$df)

More algorithms

If you want find more algorithm which is avaliable in rBAS.You can visit the Reference page. And click the function name. Furthermore, you can also get more examples of those algorithm application by this way. For example, the Pressure-Vessel problem solved by BSO algorithm can be found here.

BTW, in rBAS 0.1.8, bBAS which is designed for binary-programming is added.

Shiny interface

After rBAS 0.1.0, shiny interface is added into rBAS. Now, the users only need to define their objective problems in R code. And the rest of paramsters in BASoptim or BSASoptim functions can be adjust in the shiny interface.

For example, Michalewicz function can be imported to shiny with united theme as follows,

run_BAS_App(func = mich)

The theme argument is used to provides Bootstrap themes for shiny. More details can be found in shinythemes. Or you can use help(run_BAS_App) to check which themes you can choose.

To do list

Algorithm:

Application:

UI interface:

You can list your requirements in the issues. Furthermore, if you have a good idea or codes about BAS's mutations, pull requests and discussions are welcome. Contact me by email: jywang_2016@hust.edu.cn

Authors

Jiangyu Wang

github page

School of Energy and Power Engineering, Huazhong University of Science and Technology

Shuai Li

personal homepage & Googlescholar

Department of Computing, The Hong Kong Polytechnic University

Xiangyuan Jiang

Department of Computing, The Hong Kong Polytechnic University

Citation

citation(package = 'rBAS')

References

BAS

X. Y. Jiang, and S. Li, “BAS: beetle antennae search algorithm for optimization problems,” arXiv:1710.10724v1.

BSAS

J. Y. Wang, and H. X. Chen, “BSAS: Beetle Swarm Antennae Search Algorithm for Optimization Problems,” arXiv:1807.10470v1. Chinese Handbook of rBAS, please click here.

BAS-WPT

X. Y. Jiang, and S. Li, “Beetle Antennae Search without Parameter Tuning (BAS-WPT) for Multi-objective Optimization,” arXiv:1711.02395v1.

BSO

Wang T, Yang L, Liu Q. "Beetle Swarm Optimization Algorithm:Theory and Application," arXiv:1808.00206v1.

License

The project is released under the terms of the GPL-3.0.

Copyright © 2018 Jiangyu Wang



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