set_f {ao}R Documentation

Specify function.

Description

This function specifies the function to be optimized.

Usage

set_f(f, ..., npar, lower = -Inf, upper = Inf, iterlim = NULL, check = FALSE)

Arguments

f

A function to be optimized, returning a single numeric value. Its first argument should be a numeric vector of length npar. Additional arguments can be specified via the ... argument. Gradient or Hessian of f can be specified via attributes gradient and hessian for the function value. They are used for optimization if specified.

...

Additional arguments to be passed to f.

npar

The number of variables of f.

lower

Lower bounds on the variables, which can be a single numeric value (a joint bound for all parameters) or a numeric vector of length npar (for individual bounds).

upper

Upper bounds on the variables, analogue to lower.

iterlim

The maximum number of iterations for the numerical optimizer for each sub-problem. No limit per default.

check

If TRUE checks the configuration. This will take at most 20 seconds in most cases. Set to FALSE if you are confident about the configuration to save computation time.

Value

An object of class ao_f.

Examples

himmelblau <- function(x) (x[1]^2 + x[2] - 11)^2 + (x[1] + x[2]^2 - 7)^2
set_f(f = himmelblau, npar = 2, lower = -5, upper = 5)

[Package ao version 0.2.1 Index]