I would like to further constrain the system below with the following additional constraint, which makes use of the absolute value operator:
abs(x1)+abs(x2)+abs(x3) <= 10
Is there a feasible way to implement these additional absolute value constraints in R?
System of equations:
maximize: x1 + 9x2 + x3;
subject to:
x1 + 2x2 + 3x3 <= 9
3x1 + 2x2 + 2x3 <= 15
R Code:
require(lpSolve)
# objective function, constants, constraints
obj = c(1,9,1)
con = matrix(c(1,2,3,3,2,2), nrow=2, byrow=TRUE)
rel = c("<=", "<=")
rhs = c(9,15)
Solution:
my.lp = lp("max", obj, con, rel, rhs)
my.lp$objval
my.lp$solution
Obviously this is a simple example to illustrate the problem I pulled after searching online. It seems there is an approach in lp_solve
itself, as evidenced here in the lp_solve
online help guide. However, I would prefer to keep the problem framed in R if possible.