A car company produces 3 models, model A / B / C. Long-term projections indicate an expected demand of at least 100 model A cars, 80 model B cars and 120 model C cars each day. Because of limitations on production capacity, no more than 200 model A cars and 170 model B cars and 150 model C cars can be made daily. To satisfy a shipping contract, a total of at least 300 cars much be shipped each day. If each model A car sold results in a $1500 loss, but each model B car produces a $3800 profit, each model C car produces a $2500 profit, how many of each type should be made daily to maximize net profits?
I am using lpSolve in R so far. See the code below.
library(lpSolve) #Loading lpSolve library
obj.fun=c(-1500,3800,2500) #Loading the objective function in obj.fun
constr <- matrix(c(1,0,1,0,0,1,0,1,1,1), ncol=3, byrow=TRUE) #Loading the constraints constr.dir=c(">=","<=",">=","<=",">=", "<=",">=") constr.rhs=c(100,200,80,170,120,150,300) mod=lp("max",obj.fun,constr,constr.dir,constr.rhs,compute.sens = TRUE)
Using lp()
to solve our problem
mod$solution #Displaying the values of x, y.c y=170 C=200 z = (3800*y)-(2500*x) #Putting the values of x and y in the objective function options("scipen"=200, "digits"=4) cat("Net profit =", z) #Displaying the maximum profit
After running first code line get this message:
data length [10] is not a sub-multiple or multiple of the number of rows [4]number of columns of result is not a multiple of vector length (arg 2)[1] 0 170 200
Then run second code and get net profit of 446000.
Not sure if these are right. I think I understand how to do this problem with two car models but I do not understand how to do it with three car models A/B/C.