powered by
Use hill climbing to find the global minimum
hillclimbing(f, x, h = 1, m = 1000)
function representing the derivative of f
f
an initial estimate of the minimum
the step size
the maximum number of iterations
the x value of the minimum found
x
Hill climbing
Other optimz: bisection(), goldsect, gradient, newton(), sa(), secant()
bisection()
goldsect
gradient
newton()
sa()
secant()
# NOT RUN { f <- function(x) { (x[1]^2 + x[2] - 11)^2 + (x[1] + x[2]^2 - 7)^2 } hillclimbing(f, c(0,0)) hillclimbing(f, c(-1,-1)) hillclimbing(f, c(10,10)) # }
Run the code above in your browser using DataLab