Hello
I am trying to solve a simple non linear programming problem using R.
#Maximize profit p
x1=14
x2<=20
x3>=5000
p=x2*x3-x1*x3
Below is the R code I have tried, let me know where I am going wrong.
library(ROI)
library(ROI.plugin.nloptr)
prob<-OP(objective=F_objective(F=function(x){x[2]*x[3]-x[1]*x[3]},n=3),
constraints=F_constraint(F=function(x){c(x[1],x[2],x[3])}, dir=c("<=","<=",">="),rhs=c(14,20,5000),J=function(x)c(1,0,0,0,1,0,0,0,1)),maximum=TRUE)
ROI_solve(prob,solver="nloptr",start=c(10,10,4000))