My question is how do I add in additional constraints that if the factory switches off then its needs to stay off for 3 months, and if it switches back on then it needs to stay on for 4 months?
One possible solution is the following. Let us define our binary decision variable by
xi,t={1if factory i is operating in month t0otherwise |
Method 1
We really want to forbid short run patterns such as 010 (i.e. off-on-off), 0110, 01110 and 101, 1001. Forbidding patterns 010, 0110, 01110 will ensure a factory is up at least 4 consecutive periods. By not allowing 101,1001 we really make sure that a down time period is at least three months. We can model these restrictions in a linear fashion as follows (2):
Forbid 010 | −xi,t+xi,t+1−xi,t+2≤0 |
Forbid 0110 | −xi,t+xi,t+1+xi,t+2−xi,t+3≤1 |
Forbid 01110 | −xi,t+xi,t+1+xi,t+2+xi,t+3−xi,t+4≤2 |
Forbid 101 | xi,t−xi,t+1+xi,t+2≤1 |
Forbid 1001 | xi,t−xi,t+1−xi,t+2+xi,t+3≤1 |
Method 2
A different approach is as follows. First define binary variables:
δoni,t={1if factory i is turned on in month t0otherwiseδoffi,t={1if factory i is turned off in month t0otherwise |
Mathematically we write this as:
δoni,t=(1−xi,t−1)⋅xi,tδoffi,t=xi,t−1⋅(1−xi,t) |
We can linearize these non-linear equations by:
δoni,t≤1−xi,t−1δoni,t≤xi,tδoni,t≥xi,t−xi,t−1δoffi,t≤xi,t−1δoffi,t≤1−xi,tδoffi,t≥xi,t−1−xi,t |
With these variables we can implement the implications:
δoni,t=1⟹xi,t+xi,t+1+xi,t+2+xi,t+3=4δoffi,t=1⟹xi,t+xi,t+1+xi,t+2=0 |
This can be linearized as:
xi,t+1+xi,t+2+xi,t+3≥3δoni,txi,t+1+xi,t+2≤2(1−δoffi,t) |
Note that I dropped xi,t in both inequalities. These are already known from the definition of δoni,t and δoffi,t.
In the comments it is mentioned by Rob Pratt that we can strengthen this a bit (the math does not look very good in a comment, so I repeat it here):
xi,t+1≥δoni,txi,t+2≥δoni,txi,t+3≥δoni,txi,t+1≤1−δoffi,txi,t+2≤1−δoffi,t |
References
- How do I add a constraint to keep a factory switched on or off for a certain period of time in PuLP? https://stackoverflow.com/questions/44281389/how-do-i-add-a-constraint-to-keep-a-factory-switched-on-or-off-for-a-certain-per/44293592
- Integer cuts, http://yetanothermathprogrammingconsultant.blogspot.com/2011/10/integer-cuts.html
No comments:
Post a Comment