Documentation

CslibFrontier.Algorithms.Lean.Scheduling.Precedence

List Scheduling with Precedence Constraints #

This module models non-preemptive scheduling of a finite set J of jobs with integer processing times p : J → ℕ and a precedence relation prec on m identical machines (P | prec | C_max) in discrete time. A schedule is given by start times s : J → ℕ. Job j occupies the unit time slots s j, …, s j + p j - 1. IsFeasible m prec p s requires each job to start after its predecessors finish and at most m jobs to run in each slot. IsGreedy adds Graham's list-scheduling condition: a machine idles in a slot only if every job not yet started has an unfinished predecessor ([Gra66], §I.1).

Main definitions #

Main results #

Implementation notes #

Time is discrete (ℕ), so processing times are natural numbers. Graham's bounds are scale-invariant, so this covers rational processing times after clearing denominators. Real-valued processing times are not modelled.

IsFeasible bounds the number of jobs running in each slot instead of assigning jobs to machines. For non-preemptive schedules the two are equivalent: the jobs are intervals, interval graphs are perfect, so if at most m intervals overlap at every point they can be coloured with m machines.

Graham's model fixes a priority list. IsGreedy keeps only the consequence used by the bounds, that no machine idles while a job is ready, so the theorems apply to every list schedule and to every other greedy rule.

References #

The jobs occupying the time slot [t, t + 1): job j, started at s j with processing time p j, occupies the slots s j ≤ t < s j + p j.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.mem_running {J : Type u_1} [Fintype J] {p s : J → ℕ} {t : ℕ} {j : J} :
j ∈ running p s t ↔ s j ≤ t ∧ t < s j + p j
structure Cslib.Algorithms.Lean.Scheduling.Precedence.IsFeasible {J : Type u_1} [Fintype J] (m : ℕ) (prec : J → J → Prop) (p s : J → ℕ) :

A non-preemptive schedule on m identical machines in integer time: job j runs without interruption in the slots s j, …, s j + p j - 1, after all its predecessors have finished, and at most m jobs run in any slot.

structure Cslib.Algorithms.Lean.Scheduling.Precedence.IsGreedy {J : Type u_1} [Fintype J] (m : ℕ) (prec : J → J → Prop) (p s : J → ℕ) extends Cslib.Algorithms.Lean.Scheduling.Precedence.IsFeasible m prec p s :

A greedy (list) schedule: a machine is left idle only when no job is ready. If fewer than m jobs run in slot t, every job not yet started has a predecessor that is unfinished at t.

The makespan: the latest completion time.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.le_makespan {J : Type u_1} [Fintype J] (p s : J → ℕ) (j : J) :
s j + p j ≤ makespan p s
theorem Cslib.Algorithms.Lean.Scheduling.Precedence.makespan_le_iff {J : Type u_1} [Fintype J] {p s : J → ℕ} {T : ℕ} :
makespan p s ≤ T ↔ ∀ (j : J), s j + p j ≤ T
theorem Cslib.Algorithms.Lean.Scheduling.Precedence.sum_card_running {J : Type u_1} [Fintype J] (p s : J → ℕ) :
∑ t ∈ Finset.range (makespan p s), (running p s t).card = ∑ j : J, p j

Summing the number of running jobs over the slots before the makespan counts each job's processing time once.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.IsGreedy.exists_chain {J : Type u_1} [Fintype J] {m : ℕ} {prec : J → J → Prop} {p s : J → ℕ} (hg : IsGreedy m prec p s) (hwf : WellFounded prec) :
∃ (c : List J), List.IsChain prec c ∧ m * makespan p s ≤ ∑ j : J, p j + (m - 1) * (List.map p c).sum

Graham's critical-chain bound ([Gra66], §II, proofs of the Proposition and Theorem; [CLRS09], Theorem 27.1): for a greedy schedule on m machines with well-founded precedences there is a precedence chain c (each job preceding the next) with m · C ≤ ∑ p + (m - 1) · ∑_{j ∈ c} p j.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.IsFeasible.sum_le_mul_makespan {J : Type u_1} [Fintype J] {m : ℕ} {prec : J → J → Prop} {p s : J → ℕ} (hf : IsFeasible m prec p s) :
∑ j : J, p j ≤ m * makespan p s

Work bound: in a feasible schedule on m machines, ∑ p ≤ m · C.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.IsFeasible.sum_chain_le_makespan {J : Type u_1} [Fintype J] {m : ℕ} {prec : J → J → Prop} {p s : J → ℕ} (hf : IsFeasible m prec p s) {c : List J} (hc : List.IsChain prec c) :

Span bound: in a feasible schedule, the jobs of a precedence chain run one after another, so their total processing time is at most the makespan.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.IsGreedy.mul_makespan_le {J : Type u_1} [Fintype J] {m : ℕ} {prec : J → J → Prop} {p s s' : J → ℕ} (hg : IsGreedy m prec p s) (hwf : WellFounded prec) (hf : IsFeasible m prec p s') :
m * makespan p s ≤ (2 * m - 1) * makespan p s'

Graham's bound with precedence constraints ([Gra66], §II, Theorem (p. 1570) with n = n'; restated in §III, p. 1581): a greedy schedule is within 2 - 1/m of every feasible schedule, m · C_greedy ≤ (2m - 1) · C.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.IsGreedy.mul_makespan_le_of_le {J : Type u_1} [Fintype J] {m m' : ℕ} {prec prec' : J → J → Prop} {p p' s s' : J → ℕ} (hg : IsGreedy m' prec' p' s) (hwf : WellFounded prec') (hprec : ∀ (i j : J), prec' i j → prec i j) (hp : ∀ (j : J), p' j ≤ p j) (hf : IsFeasible m prec p s') :
m' * makespan p' s ≤ (m + m' - 1) * makespan p s'

Graham's anomaly bound ([Gra66], §II, Theorem (p. 1570)): let s be a greedy schedule on m' machines for well-founded precedences prec' and processing times p', and s' any feasible schedule on m machines for stronger precedences prec ⊇ prec' and longer processing times p ≥ p'. Then m' · C ≤ (m + m' - 1) · C', i.e. C / C' ≤ 1 + (m - 1)/m'.

theorem Cslib.Algorithms.Lean.Scheduling.Precedence.exists_isGreedy {J : Type u_1} [Fintype J] (m : ℕ) (hm : 0 < m) (prec : J → J → Prop) (hwf : WellFounded prec) (p : J → ℕ) (hp : ∀ (j : J), 0 < p j) :
∃ (s : J → ℕ), IsGreedy m prec p s

Greedy schedules exist (list scheduling, [Gra66], §I.1): for well-founded precedences and positive processing times, a greedy schedule exists on any m ≥ 1 machines.