Mathematical Proof: Weighted Shortest Processing Time First (WSPT) Rule
Problem Statement
Given n jobs with processing times and weights (for ), we want to find a schedule that minimizes the total weighted completion time:
where is the completion time of job .
Claim: The WSPT rule (scheduling jobs in non-decreasing order of ) is optimal.
Proof by Exchange Argument
Setup
Let be any optimal schedule that is not in WSPT order. We will show that we can transform into a WSPT schedule with no increase in objective value, contradicting the optimality of .
Since is not in WSPT order, there exist two adjacent jobs and in such that:
- Job is scheduled immediately before job
- (violates WSPT order)
Analysis of Job Swap
Let’s analyze what happens when we swap jobs and .
Before swap (schedule ):
- Job completes at time
- Job completes at time
- Contribution to objective:
After swap (schedule ):
- Job completes at time
- Job completes at time
- Contribution to objective:
where is the time when the first of these two jobs starts.
Calculating the Change in Objective
The change in objective value when swapping jobs and is:
Expanding:
Simplifying:
Key Inequality
Since we assumed , we have:
Cross-multiplying (since ):
Rearranging:
Therefore:
Conclusion of Exchange Step
Since , swapping jobs and decreases the objective value. This means schedule is strictly better than , contradicting the assumption that was optimal.
Completing the Proof
By repeatedly applying this exchange argument to any pair of adjacent jobs that violate the WSPT order, we can transform any schedule into a WSPT schedule without increasing the objective value.
Since we started with an optimal schedule and only made improvements (or no change), the resulting WSPT schedule must also be optimal.
Moreover, since any non-WSPT schedule can be improved, every optimal schedule must be in WSPT order.
Formal Statement of Optimality
Theorem: A schedule is optimal for minimizing if and only if jobs are sequenced in non-decreasing order of .
Application to the Shoe Repair Problem
In the context of BOJ problem 14908:
- (processing time for task )
- (penalty cost per day for task )
- Objective: minimize total compensation =
Therefore, the optimal strategy is to sort tasks by in ascending order.
Complexity
The WSPT algorithm has time complexity due to the sorting step, where is the number of jobs.