library(lpSolve)
## Warning: package 'lpSolve' was built under R version 3.3.2
obj.fun <- c(2,3,1,4) #as in P = 2w + 3x + y + 4z
constr <- matrix(c(1,0,-1,1,-1,2,0,1,0,1,2,0.5), ncol=4, byrow=TRUE) #as in WH,MH,PM
constr.dir<-c("<=", "<=", "<=") #signs given for each constraint (relations)
rhs <- c(5,6,8) #as in the right-hand side
Now, let’s solve the model
Prod.Sol <- lp("max", obj.fun, constr, constr.dir, rhs, compute.sens = TRUE)
Let’s access R output of the solution
Prod.Sol$solution
## [1] 6 6 1 0