fminsearch | R Documentation |
Find 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)
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. |
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
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. |
fminsearch
mimics the Matlab function of the same name.
Nocedal, J., and S. Wright (2006). Numerical Optimization. Second Edition, Springer-Verlag, New York.
nelder_mead
, hooke_jeeves
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.