I have an optimization problem which I'm trying to solve with lpSolve.
Imagine you have 17 machines. On some of these machines you can produce product i, on some of them not (here the objective function is 0, on the others it has a certain value with is the runtime). These machines have a different runtime to produce this product, so I want to find out which machine to choose by minimizing the runtime.
So the formula looks like this: enter image description here s.d.: enter image description here -> r defines the runtime of product i on machine j, which should be smaller than 20 and greater than 10 in this example. -> d defines product i on machine j
My code looked like this, but I guess I'm on the wrong path:
f_obj <- c(29.1, 29.1, 0.0, 15.0, 15.0, 15.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 15.0, 0.0, 0.0)
f_con <- matrix(c(1,1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0), ncol=17, byrow=TRUE)
f_rhs <- c(20)
f_dir <- c("<=")
solution2 <- lp("min",f_obj2,f_con,f_dir,f_rhs)
The solution should look like this:
solution2$solution
[1] 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Where the "1" is telling on which machine the product should be produced.
Can anyone help? Thank you!
Okay I tried to code it with some smaller data (17x2 matrix) for 2 products. My constraint looks like this:
with 5000 as a large number (here the actual value is 0).
My objective fct looks like this (not sure if right?):
Additionally the constraints:
f_rhs <- rep(c(5700), times=17) #(because actually time constraint is smaller than 5700 per machine)
f_dir <- rep(c("<="), times=17)
But my solution looks like this:
solution2$solution
[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Do you know where is the error?