title: “R Notebook” output: html_notebook
library(lpSolve)
obj.fun <- c(12, 15)
constr <- matrix(c(4, 3, 2, 5), nrow=2, byrow=TRUE)
constr.dir <- c(“<=”, “<=”)
rhs <- c(12, 10)
solution <- lp(“max”, obj.fun, constr, constr.dir, rhs)
print(solution)
if(solution\(status == 0) { cat("X1 =", solution\)solution[1], “”) cat(“X2 =”, solution\(solution[2], "\n") cat("Z =", solution\)objval, “”) } else { cat(“Z was not found. Status code:”, solution$status, “”) }