Job Scheduling
Job Scheduling
by Michael Soltys
January 20, 2005
Definition 1 A schedule is an array S(1), S(2), . . . , S(d) where d = max di (i.e. the latest dead-
line, beyond which no jobs can be scheduled), such that if S(t) = i, then job i is scheduled at time
t, 1 ≤ t ≤ d. If S(t) = 0, then no job is scheduled at time t.
Definition 2 A schedule S is feasible if (a) If S(t) = i > 0, then t ≤ di (i.e., every scheduled job
meets its deadline), and (b) If t1 6= t2 and S(t1 ) 6= 0, then S(t1 ) 6= S(t2 ) (i.e. each job is scheduled
at most once).
Definition 3 Let the total profit of schedule S be P (S) = gS(1) + gS(2) + . . .+ gS(d), where g0 = 0.
We want to find a feasible schedule S whose profit P (S) is as large as possible. This can be
accomplished with the following greedy algorithm:
Theorem 1 The greedy solution above is optimal (i.e. the profit P (S) of the schedule S computed
by this greedy algorithm is as large as possible).
Lemma 1 The following is a loop invariant of the above greedy algorithm: S is promising.
1
Exercise: Why does Lemma 1 imply Theorem 1? (Hint: simple observation).
Exercise: Make sure you can answer all the “why’s” in the above proof. Also, where in the
proof of the claim you use the fact that j 6= 0?