0

I am working on a problem I have design shifts. The approach I am taking is

  1. shift start and end time - is already defined. (I have 10 shifts at duration of 7 hours that are overlappiing)
  2. I using lpsolver in R to compute the FTE numbers.

Out of the 10 shifts that has been defined I want the algorithm to give me FTE only for 4 shifts, meaning, i want to add a constraint as no. of shifts is 4. There is no constraint which shift is being selected

My current code is as follows

o=c(1,1,1,1,1,1,1)
C=rbind(c(0,0,0,1,1,1,1),
        c(0,0,0,1,1,1,1),
        c(0,0,0,0,1,1,1),
        c(0,0,0,0,1,1,1),
        c(0,0,0,0,0,1,1),
        c(1,0,0,0,0,1,1),
        c(1,0,0,0,0,0,1),
        c(1,0,0,0,0,0,1),
        c(1,1,0,0,0,0,1),
        c(1,1,0,0,0,0,1),
        c(1,1,0,0,0,0,0),
        c(1,1,0,0,0,0,0),
        c(1,1,1,0,0,0,0),
        c(1,1,1,0,0,0,0),
        c(1,1,1,0,0,0,0),
        c(1,1,1,1,0,0,0),
        c(0,1,1,1,0,0,0),
        c(0,1,1,1,1,0,0),
        c(0,0,1,1,1,0,0),
        c(0,0,1,1,1,1,0),
        c(0,0,1,1,1,1,0),
        c(0,0,1,1,1,1,0),
        c(0,0,1,1,1,1,0),
        c(0,0,0,1,1,1,1)


)

 d=rep(">=",24)


r=c(58,60,62,65,72,80,87,93,93,92,90,86,80,74,68,64,61,60,60,58,55,53,52,55)


sol=lpSolve::lp("min",o,C,d,r,compute.sens = TRUE)
sol$solution

Can please let me know how to add a constraint on number of shifts to be considered

Thanks

0 Answers0