hjalgorithm: Hooke and Jeeves algorithm (Pattern search)

Description Usage Arguments Value References Examples

View source: R/hjalgorithm.R

Description

hjalgorithm is a function based on the algorithm of Hooke and Jeeves for numerical optimization of functions without the use of the gradient.

Usage

1
2
hjalgorithm(obj, x, h = 0.25, eps = 1e-06, constraint = NULL, c1 = 1.1,
  c2 = 0.5)

Arguments

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
xmin: lower restriction
xmax: upper restraint

c1

A constant to update the search step size

c2

A constant to update the search step size

Value

Returns a list with the (approximate) optimum and the number of objective function evaluations.

References

  1. Wikipedia, Pattern search (optimization), https://en.wikipedia.org/wiki/Pattern_search_(optimization).

Examples

 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)

brunasqz/NonlinearOpMethods documentation built on Oct. 27, 2019, 5:46 a.m.