hookejeeves.RdAn implementation of the Hooke-Jeeves algorithm for derivative-free optimization.
hooke_jeeves(x0, fn, ..., lb = NULL, ub = NULL, tol = 1e-08,
maxfeval = 10000, target = Inf, info = FALSE)starting vector.
nonlinear function to be minimized.
additional arguments to be passed to the function.
lower and upper bounds.
relative tolerance, to be used as stopping rule.
maximum number of allowed function evaluations.
iteration stops when this value is reached.
logical, whether to print information during the main loop.
This method computes a new point using the values of f at suitable
points along the orthogonal coordinate directions around the last point.
List with following components:
minimum solution found so far.
value of f at minimum.
number of function evaluations.
NOT USED at the moment.
special info from the solver.
C.T. Kelley (1999), Iterative Methods for Optimization, SIAM.
Quarteroni, Sacco, and Saleri (2007), Numerical Mathematics, Springer-Verlag.
Hooke-Jeeves is notorious for its number of function calls. Memoization is often suggested as a remedy.
For a similar implementation of Hooke-Jeeves see the `dfoptim' package.
## 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,0,0), rosenbrock)
#> $xmin
#> [1] 1 1 1 1
#>
#> $fmin
#> [1] 7.460699e-14
#>
#> $count
#> [1] 2307
#>
#> $convergence
#> [1] 0
#>
#> $info
#> $info$solver
#> [1] "Hooke-Jeeves"
#>
#> $info$iterations
#> [1] 26
#>
#>
## $xmin
## [1] 1.000002 1.000003 1.000007 1.000013
## $fmin
## [1] 5.849188e-11
## $count
## [1] 1691
## $convergence
## [1] 0
## $info
## $info$solver
## [1] "Hooke-Jeeves"
## $info$iterations
## [1] 26
hooke_jeeves(rep(0,4), lb=rep(-1,4), ub=0.5, rosenbrock)
#> $xmin
#> [1] 0.50000000 0.26221320 0.07797602 0.00608027
#>
#> $fmin
#> [1] 1.667875
#>
#> $count
#> [1] 522
#>
#> $convergence
#> [1] 0
#>
#> $info
#> $info$solver
#> [1] "Hooke-Jeeves"
#>
#> $info$iterations
#> [1] 26
#>
#>
## $xmin
## [1] 0.50000000 0.26221320 0.07797602 0.00608027
## $fmin
## [1] 1.667875
## $count
## [1] 536
## $convergence
## [1] 0
## $info
## $info$solver
## [1] "Hooke-Jeeves"
## $info$iterations
## [1] 26