fminsearch: Derivative-free Nonlinear Function Minimization

View source: R/fminsearch.R

fminsearchR Documentation

Derivative-free Nonlinear Function Minimization

Description

Find minimum of multivariable functions using derivative-free methods.

Usage

fminsearch(fn, x0, ..., lower = NULL, upper = NULL,
           method = c("Nelder-Mead", "Hooke-Jeeves"),
           minimize = TRUE, maxiter = 1000, tol = 1e-08)

Arguments

fn

function whose minimum or maximum is to be found.

x0

point considered near to the optimum.

...

additional variables to be passed to the function.

lower, upper

lower and upper bounds constraints.

method

"Nelder-Mead" (default) or "Hooke-Jeeves"; can be abbreviated.

minimize

logical; shall a minimum or a maximum be found.

maxiter

maximal number of iterations

tol

relative tolerance.

Details

fminsearch finds the minimum of a nonlinear scalar multivariable function, starting at an initial estimate and returning a value x that is a local minimizer of the function. With minimize=FALSE it searches for a maximum, by default for a (local) minimum.

As methods/solvers "Nelder-Mead" and "Hooke-Jeeves" are available. Only Hooke-Jeeves can handle bounds constraints. For nonlinear constraints see fmincon, and for methods using gradients see fminunc.

Important: fminsearch may only give local solutions.

Value

List with

xopt

location of the location of minimum resp. maximum.

fmin

function value at the optimum.

count

number of function calls.

convergence

info about convergence: not used at the moment.

info

special information from the solver.

Note

fminsearch mimics the Matlab function of the same name.

References

Nocedal, J., and S. Wright (2006). Numerical Optimization. Second Edition, Springer-Verlag, New York.

See Also

nelder_mead, hooke_jeeves

Examples

# Rosenbrock function
rosena <- function(x, a) 100*(x[2]-x[1]^2)^2 + (a-x[1])^2  # min: (a, a^2)

fminsearch(rosena, c(-1.2, 1), a = sqrt(2), method="Nelder-Mead")
## $xmin                   $fmin
## [1] 1.414292 2.000231   [1] 1.478036e-08

fminsearch(rosena, c(-1.2, 1), a = sqrt(2), method="Hooke-Jeeves")
## $xmin                   $fmin
## [1] 1.414215 2.000004   [1] 1.79078e-12

pracma documentation built on March 19, 2024, 3:05 a.m.