Suppose I want to minimize the following function:
-(5-(x1-2)^2-2*(x2-1)^2)
s.a. x1+4*x2 < 3
For unrestricted optimization problems I can use the following code.
fr <- function(x){
x1 <- x[1]
x2 <- x[2]
-(5-(x1-2)^2-2*(x2-1)^2)
}
optim(c(1,1),fr)
How to optimize with the constraint?