Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fminsearch

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

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

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.