Description Usage Arguments Value References Examples
hjalgorithm
is a function based on the algorithm of Hooke and Jeeves
for numerical optimization of functions without the use of the gradient.
1 2 | hjalgorithm(obj, x, h = 0.25, eps = 1e-06, constraint = NULL, c1 = 1.1,
c2 = 0.5)
|
obj |
A objective function. |
x |
A number or vector with length n, indicating the current point. |
h |
A number, search step size |
eps |
A number, tolerance for h. |
constraint |
A list, with the following names |
c1 |
A constant to update the search step size |
c2 |
A constant to update the search step size |
Returns a list with the (approximate) optimum and the number of objective function evaluations.
Wikipedia, Pattern search (optimization), https://en.wikipedia.org/wiki/Pattern_search_(optimization).
1 2 3 4 5 6 7 8 9 10 11 12 13 | # The popular Rosenbrock function
f <- function(x)
{
x1 <- x[1]
x2 <- x[2]
return ( 100*(x2 - x1^2)^2 + (1 - x1)^2 )
}
x0 <- c(-1.2,1) #usual starting point
hjalgorithm(f, x0)
#With constraint
const <- list(xmin = c(2, 2), xmax = c(4,4))
x0 <- c(3,3)
hjalgorithm(f, c(3,3), constraint = const)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.