Definition · The two-machine flow shopn jobs; job j needs p1_j on machine one and then p2_j on machine two, in that order. Both machines run one job at a time, nothing is interrupted, everything is available at time zero, and every job visits the machines in the same order — which is what makes it a flow shop.
The same order is used on both machines. A schedule that resequenced between the machines could in principle do better on more than two machines; on two it cannot, which is why one permutation is the whole decision here.
Write the order as k = 1, 2, …, n. Machine one finishes job k at C1(k) = C1(k−1) + p1(k), with C1(0) = 0, so it is the running total. Machine two cannot start job k until both that job has left machine one and machine two has finished job k−1:
C1(k) = C1(k−1) + p1(k)
C2(k) = max( C1(k), C2(k−1) ) + p2(k)
makespan = C2(n)
idle on machine 2 = C2(n) − sum p2 and sum p2 does not move
The max is where the whole problem lives. When C1(k) wins, machine two was idle waiting for the job; when C2(k−1) wins, machine two was busy and the job waited instead. Waiting jobs cost nothing in this objective; a waiting machine costs the makespan.
Definition · Johnson's ruleSplit the jobs. Those with p1 < p2 form the front group and are ordered by p1 ascending. The rest, with p1 ≥ p2, form the back group and are ordered by p2 descending. The schedule is the front group followed by the back group, and it minimises the makespan.
Five jobs, and where the four hours went
jobs A 5:2 B 1:6 C 9:7 D 3:8 E 10:4 p1:p2
quicker on machine 1: B (1 < 6) and D (3 < 8) → front, by p1 up: B, D
the rest: A, C, E → back, by p2 down: C (7), E (4), A (2)
JOHNSON B D C E A
M1 B[0,1] D[1,4] C[4,13] E[13,23] A[23,28]
M2 B[1,7] D[7,15] C[15,22] E[23,27] A[28,30]
makespan 30 idle on M2 = 1 + 1 + 1 = 3 work on M2 = 27
TYPED A B C D E
M1 A[0,5] B[5,6] C[6,15] D[15,18] E[18,28]
M2 A[5,7] B[7,13] C[15,22] D[22,30] E[30,34]
makespan 34 idle on M2 = 5 + 2 = 7 work on M2 = 27
best of all 120 orders 30, attained by 2 of them — Johnson's is one
The two schedules do the same 27 hours of work on machine two and differ only in how long that machine spent waiting. In the typed order it waits five hours at the start, because A occupies machine one for five hours before anything can be handed over. Johnson puts B first, which occupies machine one for one hour, and machine two starts at 1 instead of at 5.
Example · The starved second machine, on purposeThe lab has a preset built to make this visible: four jobs where the typed order begins with an eight-hour job on machine one that needs one hour on machine two. Machine two stands idle for the whole eight hours, and the typed order finishes at 35 with 18 hours of idle time against 17 hours of work.
Johnson's rule turns it round completely: D C B A, finishing at 24 with 7 hours of idle. Same jobs, same work, eleven hours saved, and the enumeration confirms that 24 is the best any of the twenty-four orders can do.
Checking the picture before believing the number
A recursion that produces a number is easy to get subtly wrong, so the lab reads the drawing back. It checks that machine one runs with no gaps, that machine two never overlaps itself, that no job reaches machine two before it has left machine one, and that the makespan taken off the last bar is the makespan the recursion reported. Then it checks work + idle = makespan exactly, which is the identity the rule is built on.
It also runs every one of the n! orders through the same two-machine clock and reports the best, the count and how many orders tie for it. On the lab's instance two orders attain 30, and Johnson's is one of them. Reporting the tie count matters: naming a single order and implying it is the unique optimum is a claim nobody made.
Where this stops
Three machines in series is a different problem and this rule does not extend to it. There is a special case — when the middle machine is dominated by one of the others — in which a two-machine reduction works, and the general case is hard in the sense “Algorithms and Complexity” gave the word. The lab offers two machines and says so rather than offering a third with a rule that is not a theorem.
The tie case is worth one line. When p1 = p2 for every job, as in the lab's third preset, the front group is empty and the rule sorts everything into the back group by p2 descending. That order attains the optimum, and so does every other order: all twenty-four tie at 21. The rule is not doing any work there, and the panel's tie count says so.