R/example_problem.R

Defines functions f.rastringin f.sphere example_problem

Documented in example_problem

#' Example problem
#'
#' Example problem - minimization of shifted sphere and rastrigin functions.
#'
#' @param X population matrix (see [moead()] for details)
#'
#' @return Matrix of objective function values
#'
#' @export

example_problem <- function(X) {
  t(apply(X,
          MARGIN = 1,
          FUN = function(X){
            c(f.sphere(X), f.rastringin(X))
          }))
}

f.sphere     <- function(x){sum((x + seq_along(x) * 0.1) ^ 2)}

f.rastringin <- function(x){
  x.shift <- x - seq_along(x) * 0.1
  sum((x.shift) ^ 2 - 10 * cos(2 * pi * x.shift) + 10)}

Try the MOEADr package in your browser

Any scripts or data that you put into this service are public.

MOEADr documentation built on Jan. 9, 2023, 1:24 a.m.