title: “R Notebook” output: html_notebook

library(lpSolve)

defining the objective

obj.fun <- c(12, 15)

defining the contraint matrix

constr <- matrix(c(4, 3, 2, 5), nrow=2, byrow=TRUE)

less than or equal to

constr.dir <- c(“<=”, “<=”)

defining right hand side

rhs <- c(12, 10)

solving with lp

solution <- lp(“max”, obj.fun, constr, constr.dir, rhs)

print(solution)

printing X1 and X2 and the maximum value of Z:

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, “”) }