0

I want to add the dependency that x2 has the double value of x3 at all times. I have no idea how to include it in my code :)

install.packages("lpSolveAPI")
library(lpSolveAPI)

lpModel <- make.lp(ncol=4)

add.constraint(lpModel, c(6,1,3,5), "<=", 350) 
add.constraint(lpModel, c(4,2,3,7), "<=", 500) 
add.constraint(lpModel, c(2,2,3,4), "<=", 450) 

set.bounds(lpModel, lower=c(20,40,20,20))
set.type(lpModel,1:4,"integer")

set.objfn(lpModel, -(c(110,50,200,300)-c(90,40,160,240)))

solve.lpExtPtr(lpModel)
print(lpModel)

get.variables(lpModel)
get.objective(lpModel)

In the solution of get.variables(lpModel), x2 should have the double value of x3.

NovaX
  • 23
  • 2

0 Answers0