0

Formula, Objective and Constraints

library(lpSolve)
obj.fun<-c(420,360,300,420,360,300,420,360,300)
constr<- 
matrix(c(1,1,1,1,1,1,1,1,1,20,15,12,20,15,12,20,15,
12,1,1,1,1,1,1,1,1,1,.0013,-.001,
           .0013,-.002,
           nrow=11,byrow=TRUE))
constr.dir<-c("<=","<=","<=","<=","<=","<=","<=","<=","<=","=","=")
rhs<-c(750,900,450,13000,12000,5000,900,1200,750,0,0)
    
probsol<-lp("max",obj.fun,constr,constr.dir,rhs,compute.sens = TRUE)
probsol$solution
1] 0 0 0 0 0 0 0 1 0

This is my answer, but I know it's wrong, and I don't know what I'm missing.

Isaiah
  • 2,091
  • 3
  • 19
  • 28
JFabian
  • 1
  • 1

1 Answers1

0

Your second constraint has as coefficients 2, so shouldn’t your constraint matrix start with 1,1,1,2,2,2,…?

In order to add the last two constraints, you would need to manipulate the terms to derive the coefficients. For example, the last constraint becomes (1/750-3/450)x1+…

Also your objective function should have three components only.

Karsten W.
  • 17,826
  • 11
  • 69
  • 103