Learn R Programming

ABCoptim (version 0.14.0)

abc_cpp: Artificial Bee Colony Optimization

Description

Implements Karaboga (2005) Artificial Bee Colony (ABC) Optimization algorithm.

Usage

abc_cpp(par, fn, ub = 1e+20, lb = -1e+20, FoodNumber = 20L, limit = 100L, maxCycle = 1000L, criter = 50L)
abc_optim(par, fn, ..., FoodNumber = 20, lb = -1e+20, ub = +1e+20, limit = 100, maxCycle = 1000, optiinteger = FALSE, criter = 50)
"print"(x, ...)

Arguments

par
Initial values for the parameters to be optimized over
fn
A function to be minimized, with first argument of the vector of parameters over which minimization is to take place. It should return a scalar result.
ub
Upper bound of the parameters to be optimized.
lb
Lower bound of the parameters to be optimized.
FoodNumber
Number of food sources to exploit. Notice that the param NP has been deprecated.
limit
Limit of a food source.
maxCycle
Maximum number of iterations.
criter
Stop criteria (numer of unchanged results) until stopping
...
Further arguments to be passed to 'fn'.
optiinteger
Whether to optimize binary parameters or not.
x
An object of class abc_answer.

Value

An list of class abc_answer, holding the following elements: , holding the following elements:

Details

This implementation of the ABC algorithm was developed based on the basic version written in C and published at the algorithm's official website (see references).

abc_optim and abc_cpp are two different implementations of the algorithm, the former using pure R code, and the later using C++, via the Rcpp package. Besides of the output, another important difference between the two implementations is speed, with abc_cpp showing between 50% and 100% faster performance.

If D (the number of parameters to be optimzed) is greater than one, then lb and ub can be either scalars (assuming that all the parameters share the same boundaries) or vectors (the parameters have different boundaries each other).

References

D. Karaboga, An Idea based on Honey Bee Swarm for Numerical Optimization, tech. report TR06,Erciyes University, Engineering Faculty, Computer Engineering Department, 2005 http://mf.erciyes.edu.tr/abc/pub/tr06_2005.pdf

Artificial Bee Colony (ABC) Algorithm (website) http://mf.erciyes.edu.tr/abc/index.htm

Basic version of the algorithm implemented in C (ABC's official website) http://mf.erciyes.edu.tr/abc/form.aspx

Examples

Run this code

# EXAMPLE 1: The minimum is at (pi,pi) ----------------------------------------
fun <- function(x) {
  -cos(x[1])*cos(x[2])*exp(-((x[1] - pi)^2 + (x[2] - pi)^2))
}

ans0 <- abc_optim(rep(0,2), fun, lb=-10, ub=10, criter=50)
ans0[c("par", "counts", "value")]

ans1 <- abc_cpp(rep(0,2), fun, lb=-10, ub=10, criter=50)
ans1[c("par", "counts", "value")]

# EXAMPLE 2: global minimum at about (-15.81515)
fw <- function (x)
  10*sin(0.3*x)*sin(1.3*x^2) + 0.00001*x^4 + 0.2*x+80

ans <- abc_optim(50, fw, lb=-100, ub=100, criter=100)
ans[c("par", "counts", "value")]

# EXAMPLE 3: 5D sphere, global minimum at about (0,0,0,0,0)
fs <- function(x) sum(x^2)

ans <- abc_optim(rep(10,5), fs, lb=-100, ub=100, criter=200)
ans[c("par", "counts", "value")]

Run the code above in your browser using DataLab