I would like to use lpSolveAPI in R to solve a facility optimization problem that includes a cost burden to set-up product manufacture in the source location. I am looking for advice on how to model this in the lprec object. I'll use the example problem on page 80 here:
Minimize {1300000 x11 + 1040000 x12 + 780000 x13 +
780000 x21 + 1300000 x22 + 1040000 23 +
1040000 x31 + 780000 x32 + 1300000 x33 +
1300000 x41 + 780000 x42 + 780000 x43 +
500000 y1 + 500000 y2 + 500000 y3}
Subject to:
x 11 + x 12 + x 13 = l
x 21 + x 22 + x 23 = 1
x 31 + x 32 + x 33 = 1
x 41 + x 42 + x 43 = 1
I have set up my lprec object as follows:
library(lpSolveAPI)
lprec <- make.lp(0, 15)
set.objfn(lprec, c(1300000, 1040000, 780000,
780000, 1300000, 1040000,
1040000, 780000, 1300000,
1300000, 780000, 780000,
500000, 500000, 500000
))
add.constraint(lprec, c(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "=", 1)
add.constraint(lprec, c(0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), "=", 1)
add.constraint(lprec, c(0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0), "=", 1)
add.constraint(lprec, c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0), "=", 1)
set.type(lprec, c(1:15), "binary")
However, I'm not sure how to model these constraints with lpSolveAPI:
1000 x11 + 1000 x21 +500 x31 +500 x41 <= 1500 y1
1000 x12 + 1000 x22 + 500 x32 + 500 x42 <= 1500 y2
1000 x13 + 1000 x23 + 500 x33 + 500 x43 <= 1500 y3
Any advice is much appreciated!