Use hill climbing to find the global minimum

hillclimbing(f, x, h = 1, m = 1000)

Arguments

f

function representing the derivative of f

x

an initial estimate of the minimum

h

the step size

m

the maximum number of iterations

Value

the x value of the minimum found

Details

Hill climbing

See also

Other optimz: bisection(), goldsect, gradient, newton(), sa(), secant()

Examples

f <- function(x) {
    (x[1]^2 + x[2] - 11)^2 + (x[1] + x[2]^2 - 7)^2
}
hillclimbing(f, c(0,0))
#> [1] -3.773609 -3.279415
hillclimbing(f, c(-1,-1))
#> [1] -3.778311 -3.281417
hillclimbing(f, c(10,10))
#> [1] -2.803689  3.135395