Documentation

CslibFrontier.Computability.Complexity.Problems.JobSequencing

Sequencing with deadlines and penalties #

JobSequencing is Karp's problem JOB SEQUENCING [Kar72], the problem SEQUENCING TO MINIMIZE TARDY TASK WEIGHT of Garey and Johnson, Problem SS3: given jobs with (time, deadline, penalty) (Cslib.Complexity.JobSequencing.Job) and a bound (Cslib.Complexity.JobSequencingInstance), some order of the jobs, run one after another from time 0 without idle time, has total penalty at most bound, where a job pays its penalty when it completes after its deadline. All numbers are natural numbers in binary (encNat); orders are permutations (List.Perm) of the list of jobs, so repeated jobs are scheduled with multiplicity.

Karp's reduction from SubsetSum (his KNAPSACK) maps the numbers a and target t to jobs of time and penalty a and common deadline t, with penalty bound a.sum - t (SubsetSum.toJobSequencing). The jobs completed on time in an order hold numbers of total at most t, and the others pay their whole time as penalty, so the bound is met exactly when the jobs on time sum to t. A target above a.sum is mapped to a fixed instance without a feasible order, since then the subtraction would truncate.

NP membership uses the order itself as the witness (Turing.MultiTapeTM.Decoder.list): the verifier checks that it is a permutation of the jobs by counting occurrences, and computes its total penalty in closed form from prefix sums.

Main definitions #

Main results #

References #

A job in JobSequencing, with processing time, deadline, and tardiness penalty.

  • time : ℕ

    The processing time required by the job.

  • deadline : ℕ

    The deadline by which the job must complete to avoid paying its penalty.

  • penalty : ℕ

    The penalty incurred if the job completes strictly after its deadline.

Instances For
    theorem Cslib.Complexity.JobSequencing.Job.ext {x y : Job} (time : x.time = y.time) (deadline : x.deadline = y.deadline) (penalty : x.penalty = y.penalty) :
    x = y
    Instances For
      theorem Cslib.Complexity.JobSequencing.encJob_time_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Job} :
      theorem Cslib.Complexity.JobSequencing.encJob_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 x1 T1 S1 x2 T2 S2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encNat T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encNat T2 S2) :
      Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { time := x0 x, deadline := x1 x, penalty := x2 x }) encIn encJob (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
      @[reducible, inline]

      The tuple of the fields of encJob.

      Instances For
        theorem Cslib.Complexity.JobSequencing.encJob_mk_deg :
        Turing.MultiTapeTM.ComputableInDegree (fun (p : ℕ × ℕ × ℕ) => { time := p.1, deadline := p.2.1, penalty := p.2.2 }) encJobFields encJob 1 1
        theorem Cslib.Complexity.JobSequencing.encJob_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 x1 x2 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encNat budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encNat budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encNat budget) :
        Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { time := x0 x, deadline := x1 x, penalty := x2 x }) encIn encJob budget
        theorem Cslib.Complexity.JobSequencing.encJob_penalty_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Job} :

        Binary encoding of a job as (time, (deadline, penalty)).

        Instances For
          theorem Cslib.Complexity.JobSequencing.encJob_deadline_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Job} :

          The total penalty of the jobs run in the given order, one after another without idle time, from time s: a job pays its penalty when it completes after its deadline.

          Instances For

            The total penalty of the jobs run in the given order from time 0.

            Instances For

              The penalties of two consecutive runs add up; the second starts when the first ends.

              An instance of JobSequencing: a list of jobs to schedule and a penalty bound.

              • The jobs to schedule consecutively without idle time starting at time 0.

              • bound : ℕ

                The maximum allowed total tardiness penalty.

              Instances For
                @[reducible, inline]

                The tuple of the fields of encJobSequencing.

                Instances For
                  theorem Cslib.Complexity.encJobSequencing_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget : γ → ℕ} {x0 : γ → List JobSequencing.Job} {x1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn (Turing.MultiTapeTM.encList JobSequencing.encJob) budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encNat budget) :
                  Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { jobs := x0 x, bound := x1 x }) encIn encJobSequencing budget
                  theorem Cslib.Complexity.encJobSequencing_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 : γ → List JobSequencing.Job} {T0 S0 x1 T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn (Turing.MultiTapeTM.encList JobSequencing.encJob) T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) :
                  Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { jobs := x0 x, bound := x1 x }) encIn encJobSequencing (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
                  theorem Cslib.Complexity.encJobSequencing_jobs_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → JobSequencingInstance} :

                  Instances of JobSequencing are encoded as a list of jobs and a penalty bound, all in binary.

                  Instances For
                    theorem Cslib.Complexity.encJobSequencing_bound_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → JobSequencingInstance} :

                    Sequencing with deadlines and penalties [Kar72]: some order of the jobs has total penalty at most the bound.

                    Instances For

                      JobSequencing belongs to NP, with the order as the witness; a permutation of the jobs is encoded with the length of the encoded list of jobs.

                      Karp's reduction from SubsetSum to JobSequencing [Kar72]: each number a becomes a job of time and penalty a with the target t as deadline, and the penalty bound is a.sum - t. A target above the total is mapped to a single job that is always late.

                      Instances For

                        Sequencing with deadlines and penalties is NP-complete, with the numbers in binary [Kar72].