Proofs: Smith's rule
These are the human proofs of Smith's rule, at full length.
Smith's rule minimizes the weighted sum of completion times full
This proof shows: correctness, termination.
We use the pseudocode of the page. The input is a set of jobs; job has a processing time and a real weight . For an order of , the completion time of is , and the cost is . Write . For jobs , since , the test of line L1 holds if and only if . Call an order sorted when .
Claim. The algorithm stops, it returns a sorted order together with , and . Moreover, an order is optimal if and only if it is sorted.
Step 1: termination and the output. Line L1 is a sort with the key , so it stops and gives a sorted order . The loop of line L3 runs times. By induction on , after line L4 of iteration the value of is , and after line L5 the value of is . For this is .
Step 2: the adjacent swap. Let be an order, let , and let be with the jobs and exchanged. Let . Each job other than and has the same set of predecessors in both orders, so the same completion time. In , and . In , and . So
Dividing by , has the sign of .
Step 3: every optimal order is sorted. A set of orders is finite and not empty, so an optimal order exists. Suppose is not sorted. Then some has , and by Step 2 the swap of positions and gives an order of strictly smaller cost. This contradicts the optimality of . So each optimal order is sorted.
Step 4: all sorted orders have the same cost. Let and be sorted orders. Group the jobs into blocks of equal ratio. In a sorted order, the jobs of each block are consecutive, and the blocks appear in decreasing order of ratio, so and have the same blocks in the same positions and differ only in the order inside the blocks. Inside one block, sort the jobs of into their order in by adjacent swaps, as bubble sort does; each swap exchanges two adjacent jobs of equal ratio, so by Step 2 it does not change the cost, and it keeps the order sorted. After finitely many swaps, becomes . So .
Step 5: conclusion. By Step 3, the optimal order is sorted. By Step 4, , so is optimal. For the second part of the claim: an optimal order is sorted by Step 3, and a sorted order has the cost by Step 4, so it is optimal.
Cost. Line L1 does comparisons with a comparison sort such as merge sort, and each comparison is two multiplications. The loop does iterations of arithmetic operations. So the time is arithmetic operations.