fminsearch: Derivative-free Nonlinear Function Minimization

Description Usage Arguments Details Value Note References See Also Examples

View source: R/fminsearch.R

Description

Find minimum of multivariable functions using derivative-free methods.

Usage

1
2
3
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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

Example output

$xmin
[1] 1.414292 2.000231

$fmin
[1] 1.478036e-08

$count
[1] 194

$convergence
[1] 0

$info
$info$solver
[1] "Nelder-Mead"

$info$restarts
[1] 0


$xmin
[1] 1.414213 1.999999

$fmin
[1] 6.033619e-14

$count
[1] 1175

$convergence
[1] 0

$info
$info$solver
[1] "Hooke-Jeeves"

$info$iterations
[1] 26

pracma documentation built on Dec. 11, 2021, 9:57 a.m.