mnof: Helper function to create numeric multi-objective...

View source: R/mnof.R

mnofR Documentation

Helper function to create numeric multi-objective optimization test function.

Description

This is a simplifying wrapper around makeMultiObjectiveFunction. It can be used if the function to generate is purely numeric to save some lines of code.

Usage

mnof(
  name = NULL,
  id = NULL,
  par.len = NULL,
  par.id = "x",
  par.lower = NULL,
  par.upper = NULL,
  n.objectives,
  description = NULL,
  fn,
  vectorized = FALSE,
  noisy = FALSE,
  fn.mean = NULL,
  minimize = rep(TRUE, n.objectives),
  constraint.fn = NULL,
  ref.point = NULL
)

Arguments

name

[character(1)]
Function name. Used for the title of plots for example.

id

[character(1) | NULL]
Optional short function identifier. If provided, this should be a short name without whitespaces and now special characters beside the underscore. Default is NULL, which means no ID at all.

par.len

[integer(1)]
Length of parameter vector.

par.id

[character(1)]
Optional name of parameter vector. Default is “x”.

par.lower

[numeric]
Vector of lower bounds. A single value of length 1 is automatically replicated to n.pars. Default is -Inf.

par.upper

[numeric]
Vector of upper bounds. A singe value of length 1 is automatically replicated to n.pars. Default is Inf.

n.objectives

[integer(1)]
Number of objectives of the multi-objective function.

description

[character(1) | NULL]
Optional function description.

fn

[function]
Objective function.

vectorized

[logical(1)]
Can the objective function handle “vector” input, i.~e., does it accept matrix of parameters? Default is FALSE.

noisy

[logical(1)]
Is the function noisy? Defaults to FALSE.

fn.mean

[function]
Optional true mean function in case of a noisy objective function. This functions should have the same mean as fn.

minimize

[logical]
Logical vector of length n.objectives indicating if the corresponding objectives shall be minimized or maximized. Default is the vector with all components set to TRUE.

constraint.fn

[function | NULL]
Function which returns a logical vector indicating whether certain conditions are met or not. Default is NULL, which means, that there are no constraints beside possible box constraints defined via the par.set argument.

ref.point

[numeric]
Optional reference point in the objective space, e.g., for hypervolume computation.

Examples

# first we generate the 10d sphere function the long way
fn = makeMultiObjectiveFunction(
  name = "Testfun",
  fn = function(x) c(sum(x^2), exp(sum(x^2))),
  par.set = makeNumericParamSet(
    len = 10L, id = "a",
    lower = rep(-1.5, 10L), upper = rep(1.5, 10L)
  ),
  n.objectives = 2L
)

# ... and now the short way
fn = mnof(
 name = "Testfun",
 fn = function(x) c(sum(x^2), exp(sum(x^2))),
 par.len = 10L, par.id = "a", par.lower = -1.5, par.upper = 1.5,
 n.objectives = 2L
)

smoof documentation built on March 31, 2023, 11:48 p.m.