## Rosenbrock Banana function
rbf <- function(x) {(1 - x[1]) ^ 2 + 100 * (x[2] - x[1] ^ 2) ^ 2}
## The function as written above has a minimum of 0 at (1, 1)
S <- bobyqa(c(0, 0), rbf)
S
## Rosenbrock Banana function with both parameters constrained to [0, 0.5]
S <- bobyqa(c(0, 0), rbf, lower = c(0, 0), upper = c(0.5, 0.5))
S
Run the code above in your browser using DataLab