fminsearch.RdFind minimum of multivariable functions using derivative-free methods.
fminsearch(fn, x0, ..., lower = NULL, upper = NULL,
method = c("Nelder-Mead", "Hooke-Jeeves"),
minimize = TRUE, maxiter = 1000, tol = 1e-08)function whose minimum or maximum is to be found.
point considered near to the optimum.
additional variables to be passed to the function.
lower and upper bounds constraints.
"Nelder-Mead" (default) or "Hooke-Jeeves"; can be abbreviated.
logical; shall a minimum or a maximum be found.
maximal number of iterations
relative tolerance.
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.
List with
location of the location of minimum resp. maximum.
function value at the optimum.
number of function calls.
info about convergence: not used at the moment.
special information from the solver.
Nocedal, J., and S. Wright (2006). Numerical Optimization. Second Edition, Springer-Verlag, New York.
fminsearch mimics the Matlab function of the same name.
# 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
#> [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 $fmin
## [1] 1.414292 2.000231 [1] 1.478036e-08
fminsearch(rosena, c(-1.2, 1), a = sqrt(2), method="Hooke-Jeeves")
#> $xmin
#> [1] 1.414219 2.000015
#>
#> $fmin
#> [1] 2.652417e-11
#>
#> $count
#> [1] 947
#>
#> $convergence
#> [1] 0
#>
#> $info
#> $info$solver
#> [1] "Hooke-Jeeves"
#>
#> $info$iterations
#> [1] 26
#>
#>
## $xmin $fmin
## [1] 1.414215 2.000004 [1] 1.79078e-12