The modeling of a one machine scheduling problem with sequence dependent setup times is an interesting exercise in MIP modeling.
We have \(N\) jobs to schedule. Each job has a given processing time. In addition we have a setup time for the machine in between jobs. The twist is that the required setup time depends on how two consecutive jobs differ. If two jobs in a row are very similar, the intermediate setup time is small, while if they are very different, the setup time increases. An example of such a problem is running some kind of printing jobs. Changing from a black job to a white job requires extensive cleaning, while white followed by black does not require much cleaning at all. See e.g. [1].
Some extra things to think about:
Some random data can help to understand the problem a bit better.
Some jobs have release and due dates. The precedence restrictions say we need to do job 1 and 2 before job 3.
To model this, I use five sets of variables:
The idea is that a job sequence \(1-2-3\) is encoded as:
The model itself looks like:
In the above model I have color coded the identifiers: the variables are in red and the parameters are blue,
The big-M constant in constraint 7 was estimated by taking all processing times and adding up the largest setup times. This gives a bound on the total time we need.
Although a bit hidden from sight, this is essentially a Traveling Salesman Problem (TSP). The main issue with TSP formulations is to prevent subtours. A well-known form of subtour-elimination constraints is the Miller, Tucker, Zemlin approach [3]: \[\begin{align}\min & \sum_{i\ne j} c_{i,j} x_{i,j}\\ & \sum_{j\ne i} x_{i,j} = 1 &&\forall i\\ & \sum_{i\ne j} x_{i,j} = 1 &&\forall j\\ & u_i -u_j + n x_{i,j}\le n-1 && i\ne j, i,j>1\\& x_{i,j} \in \{0,1\}, u_i \ge 0 \end{align}\] The subtour elimination constraints can be rearranged as \[ u_j \ge u_i + 1 - n(1-x_{i,j}) \] This is now very much like equation 7.
Having explained why our formulation works, it is also clear we should not expect stellar performance. It is not surprising these type of models are often approached with (meta) heuristics to find good solutions instead of aiming to some form of optimality. The example data set with just \(N=15\) jobs is difficult to solve to optimality (takes about 3000 seconds). As usual the MIP solver finds good solutions quickly, so we can stop early if we want.
The solution looks like:
We can depict the solution as:
Each bar has two parts: the orange part indicates setup and the grey section is processing. Note again that the processing time is constant but the setup times depend on what has happened before. We see that jobs 1 and 2 are indeed processed before job 3. Jobs 3 and 6 have early due dates and we see they are processed early.
The MIP bounds are:
When we look at the blue line (best solution so far) we see that the solver had to do a bit of work to find a feasible integer solution. The first feasible solution was found after about 300 seconds. After that the objective quickly improved. After about 500 seconds not much was happening anymore: the solver just worked on tightening the lower bound (the best possible integer solution).
We have \(N\) jobs to schedule. Each job has a given processing time. In addition we have a setup time for the machine in between jobs. The twist is that the required setup time depends on how two consecutive jobs differ. If two jobs in a row are very similar, the intermediate setup time is small, while if they are very different, the setup time increases. An example of such a problem is running some kind of printing jobs. Changing from a black job to a white job requires extensive cleaning, while white followed by black does not require much cleaning at all. See e.g. [1].
Some extra things to think about:
- The last job performed (called initial below) may be important, as we may need to do a setup from the initial state to whatever the selected first job is.
- The setup times are organized as an \((N+1) \times N\) matrix (one extra row for the initial job).
- We can have due dates and release dates on the jobs. We need to finish a job before the due date and cannot start a job before its release date.
- We may have some precedence relations: some jobs must be finished before another.
- We want to sequence the jobs such that the completion time of the last job is minimized (of course subject to due date, release date and precedence constraints).
Some random data can help to understand the problem a bit better.
---- 24 PARAMETER proctime processing time
job1 2.546, job2 8.589, job3 5.953, job4 3.710, job5 3.630, job6 3.016, job7 4.148
job8 8.706, job9 1.604, job10 5.502, job11 9.983, job12 6.209, job13 9.920, job14 7.860
job15 2.176
---- 24 PARAMETER setup setup time
job1 job2 job3 job4 job5 job6 job7 job8 job9
initial 3.5591.6382.0003.6762.7412.4392.4061.5261.600
job1 1.4423.0101.6414.4902.0602.1433.3763.8913.513
job2 1.7283.5833.2434.0802.1913.6444.0233.5102.135
job3 1.2911.7033.1034.0011.7121.1373.3413.4852.557
job4 4.1342.2001.5023.9951.2771.8081.0202.0782.999
job5 4.9742.4802.4924.0882.5874.6521.4783.9421.222
job6 1.9032.5842.1041.6094.7452.6911.5392.5442.499
job7 1.4072.5362.2961.7691.4493.3863.0461.1804.132
job8 3.0261.6373.6283.0961.4984.9471.9123.7034.107
job9 3.9401.3421.6012.7371.7483.7714.0521.6192.558
job10 1.3483.1621.5073.9361.4532.9534.1822.9683.134
job11 1.0991.7111.2451.0674.3433.4071.1081.7844.803
job12 2.5734.2223.1642.5633.2314.7312.3951.0334.795
job13 3.3211.6663.5732.3774.6494.6001.0652.4753.658
job14 2.9861.1804.0953.1323.9873.8803.5261.4604.885
job15 4.1633.4411.2172.9411.2103.7941.7791.9044.255
+ job10 job11 job12 job13 job14 job15
initial 3.3564.3241.9233.6634.1032.215
job1 2.8552.6531.4712.2571.1862.354
job2 1.3461.4103.5653.1811.1264.169
job3 2.4351.9721.9861.5224.7342.520
job4 1.6051.6972.3232.2682.2884.856
job5 3.3051.2061.0242.6053.0803.516
job6 2.0744.7931.7562.1901.2982.605
job7 4.7833.3863.4292.4503.3763.719
job8 4.7301.8052.1891.7891.9853.586
job9 3.7824.3833.4514.9041.1081.750
job10 1.0423.1752.8054.9011.7351.654
job11 2.3423.3772.0373.5631.6212.840
job12 3.2882.3354.9354.0661.4404.979
job13 3.3741.1384.3674.7283.0322.198
job14 3.8274.9454.4193.4863.8053.804
job15 4.9674.0033.8731.0022.0554.295
---- 24 PARAMETER due due date
job3 28.569, job5 98.104, job6 27.644, job7 55.274, job8 57.364, job11 60.875, job12 96.637
job13 77.888
---- 24 PARAMETER release release time
job5 19.380, job8 48.657, job10 27.932, job13 24.876
---- 24 SET prec precedence restrictions
job3
job1 YES
job2 YES
Some jobs have release and due dates. The precedence restrictions say we need to do job 1 and 2 before job 3.
To model this, I use five sets of variables:
| Variable | Description |
|---|---|
| \(\color{DarkRed}{\mathit{First}}_j \in \{0,1\}\) | indicates the first job |
| \(\color{DarkRed}{\mathit{Last}}_j \in \{0,1\}\) | the last job |
| \(\color{DarkRed}{X}_{i,j} \in \{0,1\}\) | job \(j\) immediately follows job \(i\) |
| \(\color{DarkRed}{\mathit{StartTime}}_j \ge 0\) | the start time (after setup) of job \(j\) |
| \(\color{DarkRed}{\mathit{LastTime}}\) | Objective variable: completion time of last job |
The idea is that a job sequence \(1-2-3\) is encoded as:
- \(\color{DarkRed}{\mathit{First}}_1=1\)
- \(\color{DarkRed}{X}_{1,2}=\color{DarkRed}{X}_{2,3}=1\)
- \(\color{DarkRed}{\mathit{Last}}_3=1\)
The model itself looks like:
| No | Equation | Description |
|---|---|---|
| 1 | \[\min \color{DarkRed}{\mathit{LastTime}}\] | objective |
| 2 | \[\sum_j \color{DarkRed}{\mathit{First}}_j = 1\] | exactly one first job |
| 3 | \[\sum_j \color{DarkRed}{\mathit{Last}}_j = 1\] | exactly one last job |
| 4 | \[\color{DarkRed}{\mathit{Last}}_i+\sum_{j\ne i} \color{DarkRed}{X}_{i,j} = 1\>\>\forall i\] | job \(i\) is the last job or it has a successor \(j\) |
| 5 | \[\color{DarkRed}{\mathit{First}}_j+\sum_{i\ne j} \color{DarkRed}{X}_{i,j} = 1\>\>\forall j\] | job \(j\) is the first job or it has a predecessor \(i\) |
| 6 | \[\color{DarkRed}{\mathit{StartTime}}_j \ge \color{DarkBlue}{\mathit{setup}}_{\text{initial},j} \color{DarkRed}{\mathit{First}}_j \>\>\forall j\] | calculate start time of first job |
| 7 | \[\color{DarkRed}{\mathit{StartTime}}_j \ge \color{DarkRed}{\mathit{StartTime}}_i + \color{DarkBlue}{\mathit{proctime}}_i + \color{DarkBlue}{\mathit{setup}}_{i,j} - M(1-\color{DarkRed}{X}_{i,j})\>\>\forall i\ne j\] | calculate start time of job \(j\) with predecessor \(i\) |
| 8 | \[\color{DarkRed}{\mathit{LastTime}} \ge \color{DarkRed}{\mathit{StartTime}}_j + \color{DarkBlue}{\mathit{proctime}}_j\>\>\forall j\] | calculate completion time of last job |
| 9 | \[\color{DarkRed}{\mathit{StartTime}}_j \ge \color{DarkBlue}{\mathit{release}}_j \>\>\forall j \] | lower bound on start time |
| 10 | \[\color{DarkRed}{\mathit{StartTime}}_j \le \color{DarkBlue}{\mathit{due}}_j - \color{DarkBlue}{\mathit{proctime}}_j \>\>\forall j|\color{DarkBlue}{\mathit{due}}_j>0 \] | upper bound on start time |
| 11 | \[ \color{DarkRed}{\mathit{StartTime}}_j \ge \color{DarkRed}{\mathit{StartTime}}_i + \color{DarkBlue}{\mathit{proctime}}_i \>\> \forall \color{DarkBlue}{\mathit{prec}}_{i,j}\] | precedence constraints |
In the above model I have color coded the identifiers: the variables are in red and the parameters are blue,
The big-M constant in constraint 7 was estimated by taking all processing times and adding up the largest setup times. This gives a bound on the total time we need.
Although a bit hidden from sight, this is essentially a Traveling Salesman Problem (TSP). The main issue with TSP formulations is to prevent subtours. A well-known form of subtour-elimination constraints is the Miller, Tucker, Zemlin approach [3]: \[\begin{align}\min & \sum_{i\ne j} c_{i,j} x_{i,j}\\ & \sum_{j\ne i} x_{i,j} = 1 &&\forall i\\ & \sum_{i\ne j} x_{i,j} = 1 &&\forall j\\ & u_i -u_j + n x_{i,j}\le n-1 && i\ne j, i,j>1\\& x_{i,j} \in \{0,1\}, u_i \ge 0 \end{align}\] The subtour elimination constraints can be rearranged as \[ u_j \ge u_i + 1 - n(1-x_{i,j}) \] This is now very much like equation 7.
Having explained why our formulation works, it is also clear we should not expect stellar performance. It is not surprising these type of models are often approached with (meta) heuristics to find good solutions instead of aiming to some form of optimality. The example data set with just \(N=15\) jobs is difficult to solve to optimality (takes about 3000 seconds). As usual the MIP solver finds good solutions quickly, so we can stop early if we want.
The solution looks like:
---- 79 VARIABLE first.L first job
job6 1.000
---- 79 VARIABLE last.L last job
job14 1.000
---- 79 VARIABLE x.L sequencing
job1 job2 job3 job4 job5 job7 job8 job9 job10
job1 1.000
job2 1.000
job4 1.000
job6 1.000
job7 1.000
job10 1.000
job11 1.000
job12 1.000
job15 1.000
+ job11 job12 job13 job14 job15
job3 1.000
job5 1.000
job8 1.000
job9 1.000
job13 1.000
---- 79 VARIABLE starttime.L start of job (after setup)
job1 18.430, job2 8.112, job3 22.616, job4 88.083, job5 74.658, job6 2.511
job7 43.329, job8 48.657, job9 102.035, job10 93.399, job11 32.238, job12 79.312
job13 59.153, job14 104.746, job15 71.271
---- 79 VARIABLE lasttime.L = 112.607 last completion time
We can depict the solution as:
| Setup and processing for each job |
Each bar has two parts: the orange part indicates setup and the grey section is processing. Note again that the processing time is constant but the setup times depend on what has happened before. We see that jobs 1 and 2 are indeed processed before job 3. Jobs 3 and 6 have early due dates and we see they are processed early.
The MIP bounds are:
| Lower and upper bound. The upper bound is the best found solution. |
When we look at the blue line (best solution so far) we see that the solver had to do a bit of work to find a feasible integer solution. The first feasible solution was found after about 300 seconds. After that the objective quickly improved. After about 500 seconds not much was happening anymore: the solver just worked on tightening the lower bound (the best possible integer solution).
References
- A. P. Burger, C. G. Jacobs, J. H. Vuuren, S. E. Visagie, Scheduling Multi-colour Print Jobs with Sequence-dependent Setup Times, J. of Scheduling, vol. 18, no. 2, 2015, pp. 131-14
- Orman, A. J. and Williams, H. Paul (2004) A survey of different integer programming formulations of the travelling salesman problem. Operational Research working papers, LSEOR 04.67
- Miller C.E., A.W. Tucker and R.A. Zemlin (1960) Integer programming formulation of travelling salesman problems, J. ACM, 3, 326–329.