Skip to contents

For every pair with f_j < f_i, firefly i moves by beta0 exp(-gamma r^2) (x_j - x_i) + alpha (u - 1/2)(hi - lo), r measured on the unit-scaled box; alpha decays by delta each iteration.

Usage

FireflyAlgorithm(
  f,
  bounds,
  alpha = 0.5,
  beta0 = 1,
  gamma = 1,
  delta = 0.97,
  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.

alpha

Initial randomisation weight.

beta0, gamma

Attractiveness parameters.

delta

Decay of alpha.

n_pop

Population size.

max_iter

Iterations.

seed

Philox seed.

Value

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

References

Yang, X.-S. (2009). Firefly algorithms for multimodal optimization. Stochastic Algorithms: Foundations and Applications (SAGA 2009), LNCS 5792, 169-178.

Examples

FireflyAlgorithm(function(x) sum(x^2), list(c(-5, 5), c(-5, 5)), n_pop = 10, max_iter = 20)$fun
#> [1] 0.001409822