You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
R142: Partition -> Scheduling to Minimize Weighted Completion Time (this model is the target)
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.
Important
Build as optimization, not decision.
Value = Min<u64>.Objective: Minimize total weighted completion time Σ C(t)·w(t).
Do not add a
bound/thresholdfield — 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:
SchedulingToMinimizeWeightedCompletionTimeReference: 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
dims() = [m; n](an array of n entries, each equal to m).Schema (data type)
Type name:
SchedulingToMinimizeWeightedCompletionTimeVariants: none (no type parameters)
lengthsVec<u64>weightsVec<u64>num_processorsusizeComplexity
num_processors^num_tasksExtra 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
→ ILPrule will be bundled in the model PR per project convention.)Example Instance
Input:
T = {t_0, t_1, t_2, t_3, t_4} (n = 5 tasks), m = 2 processors.
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}
Processor 1: {t_1, t_3}
Total weighted completion time = 27 + 20 = 47.
Verification (Python brute-force over all 2^5 = 32 assignments):
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).