Skip to content

[Model] SchedulingToMinimizeWeightedCompletionTime #505

@isPANN

Description

@isPANN

Important

Build as optimization, not decision. Value = Min<u64>.
Objective: Minimize total weighted completion time Σ C(t)·w(t).
Do not add a bound/threshold field — let the solver find the optimum directly. See #765.

Motivation

SCHEDULING TO MINIMIZE WEIGHTED COMPLETION TIME (P197) from Garey & Johnson, A5 SS13. An NP-complete scheduling optimization problem: given tasks with integer lengths and weights on m identical processors (no precedence), find a schedule minimizing the total weighted completion time. NP-complete even for m = 2 by reduction from PARTITION, and NP-complete in the strong sense for m arbitrary [Lenstra, Rinnooy Kan, and Brucker, 1977].

Associated rules:

Definition

Name: SchedulingToMinimizeWeightedCompletionTime

Reference: Garey & Johnson, Computers and Intractability, A5 SS13

Mathematical definition:

INSTANCE: Set T of tasks, number m ∈ Z⁺ of processors, for each task t ∈ T a length l(t) ∈ Z⁺ and a weight w(t) ∈ Z⁺.

OBJECTIVE: Find an m-processor schedule σ for T that minimizes the total weighted completion time: ∑_{t ∈ T} C(t) · w(t), where C(t) = σ(t) + l(t) is the completion time of task t, and σ(t) is the start time of t in the schedule. Within each processor, tasks are processed sequentially with no idle time.

NOTE: For a given assignment of tasks to processors, the optimal ordering on each processor is given by Smith's rule: sort tasks in non-decreasing order of l(t)/w(t) (length-to-weight ratio).

Variables

  • Count: n = |T| (one variable per task)
  • Per-variable domain: {0, 1, ..., m − 1} — the processor index to which the task is assigned
  • Meaning: p_t ∈ {0, ..., m − 1} is the processor assignment for task t. Given an assignment, the schedule on each processor is determined by Smith's rule (sort by non-decreasing l(t)/w(t) ratio). Therefore the only free variables are the processor assignments, giving dims() = [m; n] (an array of n entries, each equal to m).

Schema (data type)

Type name: SchedulingToMinimizeWeightedCompletionTime
Variants: none (no type parameters)

Field Type Description
lengths Vec<u64> Length l(t) of each task t ∈ T
weights Vec<u64> Weight w(t) of each task t ∈ T
num_processors usize Number of identical processors m

Complexity

  • Best known exact algorithm: Brute-force enumeration of all m^n processor assignments, with Smith's rule ordering on each processor. NP-complete for m = 2 by reduction from PARTITION; NP-complete in the strong sense for arbitrary m [Lenstra, Rinnooy Kan, and Brucker, 1977]. For fixed m, solvable in pseudo-polynomial time by dynamic programming over load vectors.
  • Complexity expression: num_processors^num_tasks
  • Special cases: Solvable in polynomial time if all lengths are equal (by matching) or if all weights are equal [Conway et al., 1967; Horn, 1973; Bruno et al., 1974].

Extra Remark

Full book text:

INSTANCE: Set T of tasks, number m in Z+ of processors, for each task t in T a length l(t) in Z+ and a weight w(t) in Z+, and a positive integer K.
QUESTION: Is there an m-processor schedule sigma for T such that the sum, over all t in T, of (sigma(t) + l(t))*w(t) is no more than K?

Reference: [Lenstra, Rinnooy Kan, and Brucker, 1977]. Transformation from PARTITION.

Comment: Remains NP-complete for m = 2, and is NP-complete in the strong sense for m arbitrary [Lageweg and Lenstra, 1977]. The problem is solvable in pseudo-polynomial time for fixed m. These results continue to hold if "preemptive" schedules are allowed [McNaughton, 1959]. Can be solved in polynomial time if all lengths are equal (by matching techniques). If instead all weights are equal, it can be solved in polynomial time even for "different speed" processors [Conway, Maxwell, and Miller, 1967] and for "unrelated" processors [Horn, 1973], [Bruno, Coffman, and Sethi, 1974]. The "preemptive" case for different speed processors also can be solved in polynomial time [Gonzalez, 1977]. If precedence constraints are allowed, the original problem is NP-complete in the strong sense even if all weights are equal, m = 2, and the partial order is either an "in-tree" or an "out-tree" [Sethi, 1977a]. If resources are allowed, the same subcases mentioned under RESOURCE CONSTRAINED SCHEDULING are NP-complete, even for equal weights [Blazewicz, 1977a].

How to solve

  • It can be solved by (existing) bruteforce. (Enumerate all m^n assignments of tasks to processors; for each assignment, order tasks on each processor by Smith's rule; compute total weighted completion time; return the minimum.)
  • It can be solved by reducing to integer programming. (Binary ILP: x_{t,p} ∈ {0,1} for assignment, ordering variables for sequencing on each processor, and linearized completion time constraints. Direct → ILP rule will be bundled in the model PR per project convention.)
  • Other: Pseudo-polynomial DP for fixed m; polynomial when all lengths or all weights are equal.

Example Instance

Input:
T = {t_0, t_1, t_2, t_3, t_4} (n = 5 tasks), m = 2 processors.

Task Length l(t) Weight w(t) l/w ratio
t_0 1 6 0.167
t_1 2 4 0.500
t_2 3 3 1.000
t_3 4 2 2.000
t_4 5 1 5.000

Smith's rule ordering (by non-decreasing l/w): t_0 < t_1 < t_2 < t_3 < t_4.

Optimal assignment (minimum weighted completion time = 47):

Processor 0: {t_0, t_2, t_4}

  • Smith's rule order: t_0 (l/w=0.167), t_2 (l/w=1.0), t_4 (l/w=5.0)
  • t_0 completes at 1, contribution = 1 × 6 = 6
  • t_2 completes at 4, contribution = 4 × 3 = 12
  • t_4 completes at 9, contribution = 9 × 1 = 9
  • Subtotal = 27

Processor 1: {t_1, t_3}

  • Smith's rule order: t_1 (l/w=0.5), t_3 (l/w=2.0)
  • t_1 completes at 2, contribution = 2 × 4 = 8
  • t_3 completes at 6, contribution = 6 × 2 = 12
  • Subtotal = 20

Total weighted completion time = 27 + 20 = 47.

Verification (Python brute-force over all 2^5 = 32 assignments):

  • Optimal value: 47, achieved by 2 assignments (mirror pair swapping processor labels)
  • Suboptimal assignments: 30
  • Cost range: [47, 71], 6 distinct cost values
  • The distinct l/w ratios ensure Smith's rule gives a unique ordering on each processor, exercising the weighted aspect of the problem.

Expected Outcome

Optimal objective value: 47 (minimization). The optimal assignment is P0 = {t_0, t_2, t_4}, P1 = {t_1, t_3} (or mirror).

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoodAn issue passed all checks.modelA model problem to be implemented.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions