## Rosenbrock Banana objective function
rbf <- function(x) {(1 - x[1]) ^ 2 + 100 * (x[2] - x[1] ^ 2) ^ 2}
x0 <- c(-1.2, 1)
lb <- c(-3, -3)
ub <- c(3, 3)
## The function as written above has a minimum of 0 at (1, 1)
isres(x0 = x0, fn = rbf, lower = lb, upper = ub)
## Now subject to the inequality that x[1] + x[2] <= 1.5
hin <- function(x) {x[1] + x[2] - 1.5}
S <- isres(x0 = x0, fn = rbf, hin = hin, lower = lb, upper = ub,
maxeval = 2e5L, deprecatedBehavior = FALSE)
S
sum(S$par)
Run the code above in your browser using DataLab