library(lpSolve)
- Max(13X1 + 23X2 + 30X3)
- 5X1 + 15X2 + 4X3 <= 480 (CO2)
- 4X1 + 4X2 + 10X3 <= 160 (Water)
- 35X1 + 20X2 + 15X3 <= 1190 (Flavor)
- 5X1 + 10X2 + 20X3 <= 200 (number of worker * work hours * 5 days)
- X1, X2, X3 >= 0 (We don't want a negative amount of batches)
obj_coeff <- c(13,23,30)
constraints <- matrix(
c(
5,15,4,
4,4,10,
35,20,15,
5,10,20
), nrow =4, byrow= TRUE
)
colnames(constraints) = c("Strwaberry" , "Orange" , "Grape")
rownames(constraints) = c("CO2" , "Water" , "Flavor" , "Production Time")
View(constraints)
direction_c <- c("<=","<=","<=","<=")
resources <- c(480,160,1190,200) # 200 = number of employee * work hours * work day
solve_lp <- lp(
"max", # find max result
obj_coeff,
constraints,
direction_c,
resources
)
solve_lp$objval # Objective value
solve_lp$solution # solution