Sub topic 6
Scheduling on Identical Machines: List Scheduling and LPT
This chapter assumes you know the two lower bounds from the chapter on bounding the optimum, can read Python using heapq, and know that Partition is NP-complete.
The Makespan Problem
You have n jobs with processing times p_1, ..., p_n and m identical machines. Each job runs on exactly one machine. A machine's load is the sum of the jobs assigned to it. The makespan is the largest load, and the goal is to minimize it. Even with m = 2 the problem is NP-hard, because a schedule with makespan sum/2 exists exactly when the jobs can be split into two equal halves, which is the Partition problem.
Every analysis below uses two lower bounds on the optimum OPT:
OPT >= max_j p_j, because some machine must run the longest job.OPT >= (sum_j p_j) / m, because some machine must carry at least the average load.
List Scheduling
Graham's list scheduling takes the jobs in any order and gives each one to the machine whose current load is smallest.
Proof of the (2 - 1/m) bound: let machine i finish last, and let job j be the last job placed on it. When j was assigned, machine i had the smallest load, so its load at that moment was at most the average of the other jobs, (sum - p_j)/m. Therefore:
makespan <= (sum - p_j)/m + p_j = sum/m + (1 - 1/m) p_j <= OPT + (1 - 1/m) OPT.
The bound is tight. A bad case puts a long job last, after the short jobs have already spread evenly across the machines.
LPT: Longest Processing Time First
LPT sorts the jobs in decreasing order before running list scheduling. The code below uses a min-heap of (load, machine) pairs, so each assignment costs O(log m) and the whole algorithm runs in O(n log n).
import heapq
def lpt_schedule(jobs, m):
loads = [(0, i) for i in range(m)]
heapq.heapify(loads)
assignment = [[] for _ in range(m)]
for p in sorted(jobs, reverse=True):
load, i = heapq.heappop(loads)
assignment[i].append(p)
heapq.heappush(loads, (load + p, i))
makespan = max(load for load, _ in loads)
return makespan, assignment
print(lpt_schedule([7, 5, 4, 3, 3, 2], 3))The output is (9, [[7, 2], [5, 3], [4, 3]]). The average load is 8, but OPT = 9 here: any machine that runs the 7 together with another job has load at least 9, and if the 7 runs alone, the remaining 17 units on two machines force a load of at least 9.
Why LPT achieves 4/3 - 1/(3m)
Let job j be the job that finishes last. Jobs after j in the sorted order cannot raise the makespan, so you can drop them. Then p_j is the smallest remaining job.
- If
p_j > OPT/3, every job exceedsOPT/3, so an optimal schedule puts at most two jobs on each machine. In that case LPT can be shown to be optimal. - Otherwise
p_j <= OPT/3. The same argument as before givesmakespan <= OPT + (1 - 1/m) OPT/3 = (4/3 - 1/(3m)) OPT.
| Algorithm | Running time | Guarantee |
|---|---|---|
| List scheduling (any order) | O(n log m) | 2 - 1/m |
| LPT (sorted decreasing) | O(n log n) | 4/3 - 1/(3m) |
Exercise
Give an instance with m machines on which list scheduling, with jobs in the given order, has makespan exactly (2 - 1/m) * OPT.
Show answer
Use m(m-1) jobs of length 1 followed by one job of length m. The unit jobs spread evenly, so each machine reaches load m-1, and then the long job raises one machine to 2m-1. The optimum puts the long job alone on one machine and m unit jobs on each of the other m-1 machines, giving OPT = m. The ratio is (2m-1)/m = 2 - 1/m.
Exercise
Why can the LPT analysis assume that the job finishing last is the smallest job?
Show answer
Removing the jobs that come after it in sorted order does not change LPT's makespan, because they did not finish last. Removing jobs also cannot increase OPT. Any ratio proved for the smaller instance therefore holds for the original one.