Skip to contents

With a falling from 2 to 0, A = 2 a r - a, C = 2 r: for p < 1/2 a whale encircles the best (|A| < 1) or a random whale by X_ref - A |C X_ref - X|; otherwise it follows the spiral |X* - X| exp(b l) cos(2 pi l) + X*.

Usage

WhaleOptimization(f, bounds, b = 1, n_pop = 20, max_iter = 200, seed = 0)

Arguments

f

Objective to minimise.

bounds

List of c(low, high) pairs or a two-column matrix.

b

Spiral shape.

n_pop

Population size.

max_iter

Iterations.

seed

Philox seed.

Value

list(x, fun, estimate, history, n_fev, method).

References

Mirjalili, S. and Lewis, A. (2016). The whale optimization algorithm. Advances in Engineering Software 95, 51-67.

Examples

WhaleOptimization(function(x) sum(x^2), list(c(-5, 5), c(-5, 5)), max_iter = 50)$fun
#> [1] 2.397934e-11