## Section 3. A simple example library("Rmalschains") set.seed(3) rastrigin <- function(x) 10 * length(x) + sum(x^2 - 10 * cos(2 * pi * x)) par(mar = c(0, 1, 0, 1)) x <- seq(-5.12, 5.12, length= 60) y <- x f <- function(x, y) r <- 20 + x^2+y^2 - cos(2*pi*x) - cos(2*pi*y) z <- outer(x, y, f) z[is.na(z)] <- 1 op <- par(bg = "white") persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue", xlab = "x1", ylab = "x2", zlab = "f(x1,x2)") res <- malschains(rastrigin, lower = rep(-5.12, 30), upper = rep(5.12, 30), maxEvals = 200000, verbosity = 0, control = malschains.control(popsize = 50, istep = 300, ls = "cmaes", optimum = 0)) res