A company has received an order for three types of wallpapers: one (paper 1) has a blue background with yellow patterns, another (paper 2) a green background and blue and yellow patterns, and the last (paper 3) has a yellow background with blue and green patterns. Every paper type is produced as a continuous roll of paper that passes through several machines, each printing a different color. The order in which the papers are run through the machines depends on the design of the paper: for paper 1 first the blue background and then the yellow pattern is printed. After the green background for paper 2, first the blue and then the yellow patterns are printed. The printing of paper 3 starts with the yellow background, followed by the blue and then the green patterns.
Paper 3
Green Yellow
Paper 1
Paper 2 Paper 2
Paper 3
Paper 3 Paper 1 Paper 2
Paper 2 Paper 1 Paper 3
Blue
Figure 7.6:Production flows through printing machines
The processing times differ depending on the surface that needs to be printed. The times (in minutes) for applying every color of the three paper types are given in the following table.
Table 7.4:Times required for applying every color Machine Color Paper 1 Paper 2 Paper 3
1 Blue 45 20 12
2 Green - 10 17
3 Yellow 10 34 28
Knowing that every machine can only process one wallpaper at a time and that a paper cannot be pro- cessed by several machines simultaneously, how should the paper printing be scheduled on the machines in order to finish the order as early as possible?
7.3.1
Model formulation
Let JOBS be the set of jobs (paper types) and MACH the set of machines. We are going to use the variables
startmj for the start of job j on machine m (supposing the the schedule starts at time 0). We write DURmj for the processing duration of job j on machine m. The variable finish indicates the completion time of the entire schedule. Since we want to minimize the completion time, the objective function is simply (7.3.1).
minimize finish (7.3.1)
The schedule terminates when all paper types are completed, that is, when the last operation for every types finishes. The completion time of the schedule therefore needs to satisfy the following constraints (7.3.2) – (7.3.4).
finish ≥ start31+ DUR31 (7.3.2)
finish ≥ start32+ DUR32 (7.3.3)
finish ≥ start23+ DUR23 (7.3.4)
The constraints between processing operations are of two types: the so-called conjunctive constraints represent the precedences between the operations for a single paper type, and the disjunctive constraints express the fact that a machine can only execute a single operation at a time.
To start, we consider the conjunctive constraints. Paper 1 first goes onto the machine printing the blue color (machine 1), and then onto the one printing yellow (machine 3). This means that the processing of paper 1 on machine 1 needs to be finished when the processing on machine 3 starts, and hence, the constraint (7.3.5) needs to hold.
start11+ DUR11≤ start31 (7.3.5)
Similarly, paper 2 is first processed on machine 2, then on machine 1 and then on machine 3, which leads to the constraints (7.3.6) and (7.3.7).
start22+ DUR22≤ start12 (7.3.6)
start12+ DUR12≤ start32 (7.3.7)
For paper 3, that is processed in the order machine 3, machine 1, machine 2, we obtain the following constraints (7.3.8) and (7.3.9).
start33+ DUR33≤ start13 (7.3.8)
start13+ DUR13≤ start23 (7.3.9)
We now still need to model the disjunctions. Machine 1 has to process all three wallpaper types. Since a machine can only perform a single operation at any time, either paper 1 is printed before paper 2 or paper 2 is printed before paper 1. This is expressed by the following:
start11+ DUR11≤ start12∨ start12+ DUR12≤ start11
These two mutually exclusive constraints can be written as the constraints (7.3.10) and (7.3.11), where M is a large positive number and y1is a binary variable that takes the value 1 if paper 1 comes before paper 2 on machine 1, and 0 otherwise.
start11+ DUR11≤ start12+ M · (1 − y1) (7.3.10)
start12+ DUR12≤ start11+ M · y1 (7.3.11)
Let us see why this claim is correct. If paper 1 comes before paper 2 on machine 1, then y1has the value 1 and we obtain the constraints start11+ DUR11 ≤ start12 and start12+ DUR12 ≤ start11+ M. The first constraint requires that the processing of paper 2 on machine 1 takes places after the printing of paper 1 is terminated. Whatever value start11and start12may take, the second constraint is automatically fulfilled due to the large value M. If, on the contrary, paper 2 is processed before paper 1 on machine 1, then y1 has the value 0 and we obtain the constraints start11+ DUR11≤ start12+ M and start12+ DUR12≤ start11. This time, the first constraint is automatically fulfilled and the second guarantees that the processing of wallpaper 2 is terminated before the start of paper 1.
Proceeding in this way, we can translate all pairs of disjunctions between operations on the same machine by defining a binary variable yd for every disjunction (d = 1, . . . , ND). We thus obtain the following constraints (7.3.12) – (7.3.23):
start11+ DUR11≤ start13+ M · (1 − y2) (7.3.12)
start13+ DUR13≤ start11+ M · y2 (7.3.13)
start12+ DUR12≤ start13+ M · (1 − y3) (7.3.14)
start13+ DUR13≤ start12+ M · y3 (7.3.15)
start22+ DUR22≤ start23+ M · (1 − y4) (7.3.16)
start23+ DUR23≤ start22+ M · y4 (7.3.17)
start31+ DUR31≤ start32+ M · (1 − y5) (7.3.18)
start32+ DUR32≤ start31+ M · y5 (7.3.19)
start31+ DUR31≤ start33+ M · (1 − y6) (7.3.20)
start33+ DUR33≤ start31+ M · y6 (7.3.21)
start32+ DUR32≤ start33+ M · (1 − y7) (7.3.22)
start33+ DUR33≤ start32+ M · y7 (7.3.23)
The constraints (7.3.12) – (7.3.15) establish the rest of the disjunctions on machine 1, constraints (7.3.16) and (7.3.17) the disjunction of papers 2 and 3 on machine 2, and the constraints (7.3.18) – (7.3.23) the disjunctions between the processing of the three papers on machine 3.
To avoid numerical instabilities, the value of M should not be chosen too large. It is, for instance, possible to use as its value an upper bound UB on the schedule determined through some heuristic. In this case the following constraint (7.3.24) needs to be added to the mathematical model, which may also help to reduce the number of nodes explored by the tree search.
finish ≤ UB (7.3.24)
In our small example, we are going to use as the value for M the sum of all processing times as this gives a rough but safe upper bound.
To complete the formulation of the model, we need to add the non-negativity constraints for the start time variables (7.3.25) and constrain the ydto be binaries (7.3.26).
∀m ∈ MACH, j ∈ JOBS : startmj≥0 (7.3.25) ∀d ∈ {1, . . . , ND} : yd∈ {0, 1} (7.3.26)
By renumbering the operations (tasks) using a single subscript (resulting in the set TASKS) we obtain a more general model formulation. The precedence relations and disjunctions can be represented as a disjunctive graph G = (TASKS, ARCS, DISJS) where ARCS is the set of arcs (precedences) and DISJS the set of disjunctions. There is an arc (i, j) between two tasks i and j if i is the immediate predecessor of j. A disjunction [i, j] indicates that tasks i and j are disjoint. With these conventions we obtain the following model (7.3.27) – (7.3.32).
minimize finish (7.3.27)
∀j ∈ TASKS : startj+ DURj≤ finish (7.3.28)
∀(i, j) ∈ ARCS : starti+ DURi ≤ startj (7.3.29)
∀[i, j] ∈ DISJ : starti+ DURi≤ startj+ M · yij∧ startj+ DURj≤ starti+ M · (1 − yij) (7.3.30)
∀j ∈ TASKS : startj ≥0 (7.3.31)
∀[i, j] ∈ DISJ : yij∈ {0, 1} (7.3.32)
The objective function remains the same as before. The constraints (7.3.2) – (7.3.4) are generalized by the constraints (7.3.28): the completion time of the schedule is greater than or equal to the completion
time of the last operation for every paper time, and hence to the completion times of all operations. The constraints (7.3.29) state the conjunctions (precedences) and (7.3.30) the disjunctions. The last two sets of constraints are the non-negativity conditions for the start time variables (7.3.31) and the constraints turning the disjunction variables yijinto binaries.
7.3.2
Implementation
The following Mosel program implements the mathematical model given in lines (7.3.27) – (7.3.32) of the previous section, that is, it uses a single index set TASKS for numbering the operations instead of a double machine-paper type index for start time variables and durations. In the set of examples on the book’s website a second implementation is provided that uses the double subscript of the first mathematical model (lines (7.3.1) – (7.3.25) of the previous section).
The sequence of operations for every paper type is given in the form of a list of precedences: an entry in the table ARCijis defined if task i immediately precedes task j. The disjunctions are input in a similar way: an entry in the table DISJijis defined if and only if tasks i and j are processed on the same machine – and are therefore in disjunction.
model "B-3 Job shop" uses "mmxprs" declarations
TASKS=1..8 ! Set of tasks (operations) DUR: array(TASKS) of integer ! Durations of jobs on machines ARC: dynamic array(TASKS,TASKS) of integer ! Precedence graph
DISJ: dynamic array(TASKS,TASKS) of integer ! Disjunctions between jobs start: array(TASKS) of mpvar ! Start times of tasks
finish: mpvar ! Schedule completion time y: array(range) of mpvar ! Disjunction variables end-declarations
initializations from ’b3jobshop.dat’ DUR ARC DISJ
end-initializations
BIGM:= sum(j in TASKS) DUR(j) ! Some (sufficiently) large value ! Precedence constraints
forall(j in TASKS) finish >= start(j)+DUR(j)
forall(i,j in TASKS | exists(ARC(i,j)) ) start(i)+DUR(i) <= start(j) ! Disjunctions
d:=1
forall(i,j in TASKS | i<j and exists(DISJ(i,j)) ) do create(y(d)) y(d) is_binary start(i)+DUR(i) <= start(j)+BIGM*y(d) start(j)+DUR(j) <= start(i)+BIGM*(1-y(d)) d+=1 end-do
! Bound on latest completion time finish <= BIGM
! Solve the problem: minimize latest completion time minimize(finish)
end-model
The implementation of this model uses some features of the Mosel language that have not yet been introduced:
In thedeclarationsblock the reader may have noted the keywordsdynamic arrayandrange. Both indicate that the corresponding arrays are defined as dynamic arrays.rangeindicates an unknown index set that is a consecutive sequence of integers (which may include 0 or negative values). We do not have to enumerate the array of variables y so that there is no need to name its index set. We could proceed in the same way for the arrays ARC and DISJ, but since we know that their index sets are subsets of
TASKS (which is also used later on for enumerating the array entries) we use this name for the index sets.
However, the set TASKS is defined as a constant set directly at its declaration, which means that any array with this index will be created with a fixed size. For both arrays, ARC and DISJ only very few entries are defined, and it is therefore preferable to force them to be initialized dynamically with the data read from file – this is done with the keyworddynamic.
In theforallloops enumerating the precedence arcs and the disjunctions, we use the functionexists to test whether an array entry is defined. For arrays with few defined entries (sparse arrays) this is a very efficient way of enumerating these entries. Note that for an efficient use ofexiststhe index sets in the loop must be the same as those used in the definition of the array that the condition bears on.
Another new feature is theforall-doloop used in the formulation of the disjunctions: so far we have only seen the inline version that loops over a single statement. The full version needs to be used if the loop applies to a block of program statements.
7.3.3
Results
After solving this problem we obtain a total completion time of 97. The start and completion times for all jobs are given in the following table (there are several possible solutions).
Table 7.5: Starting times of operations Paper 1 Paper 2 Paper 3 Blue 42 – 87 10 – 30 30 – 42 Green – 0 – 10 42 – 59 Yellow 87 – 97 30 – 64 0 – 28
This schedule may be represented as a bar chart, also called a Gantt chart, that has the time as its horizon- tal axis. Every task (job) is represented by a rectangle, the length of which is proportional to its duration. All operations on a single machine are placed in the same line.
Yellow Green Blue 10 Paper 2 20 30 40 50 60 70 80 90
Paper 2 Paper 3 Paper 1 Paper 3
Paper 3 Paper 2 Paper 1
100
Figure 7.7: Gantt chart