I'm trying to solve the following system of equations:
0.5 * x1 + 0.75 * x2 + 0.25 * x3 = 0.25
x1 + x2 + x3 = 1
I first randomly select $x3$ from a uniform distribution. Then I update my system of equations to solve for the remaining x1 and x2. I want to make sure that both x1 and x2 are between 0 and 1. Therefore, I set up the following system of equations to feed into lp
from lpSolve
. Note that I need to simultaneously maximize and minimize the objective function. But I am not sure how to do that with lp
.
########
# max x1 + x2 subject to the following constraints (I want to minimize this simultaneously, but not sure how to specify this in `lp`)
# 0.5*x1 + 0.75*x2 = 1 - 0.25*x3
# x1 + x2 = 1 - x3
# x1 + 0 * x2 > 0
# 0*x1 + x2 > 0
# x1 + 0 * x2 < 1
# 0*x1 + x2 < 1
libary(lpSolve)
set.seed(3)
x3 <- runif(1, 0.01, 0.99)
f.obj <- c(1, 1)
f.con <- matrix(c(2/4, 3/4, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1), nrow = 6, byrow = TRUE)
f.dir <- c("=", "=", ">", ">", "<", "<")
f.rhs <- c(0.25 - 1/4 * x3, 1 - x3, 0, 0, 1, 1)
lp ("min", f.obj, f.con, f.dir, f.rhs)$solution