Learn R Programming

pracma (version 1.5.8)

hooke-jeeves: Hooke-Jeeves Method

Description

An implementation of the Hooke-Jeeves algorithm for derivative-free optimization.

Usage

hooke_jeeves(x0, f, h = 1, scale = 1,
             info = FALSE, tol = .Machine$double.eps^(2/3), ...)

Arguments

x0
start value.
f
function to be minimized.
h
starting step size.
scale
scale factor, of -1 the maximum will be searched for.
info
logical, whether to print information during the main loop.
tol
relative tolerance, to be used as stopping rule.
...
additional arguments to be passed to the function.

Value

  • List with following components:
  • xminminimum solution found.
  • fminvalue of f at minimum.
  • fcallsnumber of function calls.
  • niternumber of iterations performed.

Details

This method computes a new point using the values of f at suitable points along the orthogonal coordinate directions around the last point.

References

Quarteroni, Sacco, and Saleri (2007), Numerical Mathematics, Springer.

See Also

nelder_mead

Examples

Run this code
##  Rosenbrock function
rosenbrock <- function(x) {
    n <- length(x)
    x1 <- x[2:n]
    x2 <- x[1:(n-1)]
    sum(100*(x1-x2^2)^2 + (1-x2)^2)
}
hooke_jeeves(c(0, 0), rosenbrock)
# $xmin
# [1] 1 1
# $fmin
# [1] 1.328283e-16
# $fcalls
# [1] 31934
# $niter
# [1] 4344

Run the code above in your browser using DataLab