Proofs: Auction algorithm
These are the human proofs of Auction algorithm, at full length.
The auction algorithm runs in O(n^3 C + n^2) time full
This proof shows: time.worst.
Let be an matrix of integers with no forbidden pairs, and let . Each arithmetic operation and comparison on the scaled benefits and prices costs on the word RAM; by the argument of Claim 4 of the correctness proof every price stays between 0 and , so prices and scaled benefits fit in words when and the benefits do.
Setup. Lines L1 to L3 cost , for the scaled matrix, and so does finding the smallest and largest benefit.
Number of iterations. With no forbidden pairs, and in Claim 4 of the correctness proof, so the loop of line L4 runs at most times. For it runs zero times.
One iteration. Lines L5 and L6 scan the entries of row and the prices twice, . Lines L7 to L9 and the queue operations cost . So an iteration costs .
Line L10 checks pairs and sums benefits, .
Total. time. The extra space is the scaled matrix, , plus for the prices, the two assignment arrays and the queue.
Forbidden pairs. The replacement entry widens the range to , so the same count gives time, with the range of the allowed benefits.
The auction algorithm returns an optimal assignment full
This proof shows: correctness, termination.
Let be an matrix of integers with forbidden pairs, and let and be the smallest and largest allowed entries ( if there are none). Line L2 replaces each forbidden entry by ; call the result , and let . For the queue is empty, the empty assignment is returned, and it is the only one; assume . For an assignment , a permutation, write .
Claim 1 (the queue). At the start of each iteration of line L4, the queue holds exactly the unassigned persons, each once, and the assignment is one-to-one: each assigned person holds one object and each object has at most one owner. Proof. True after line L3. In an iteration, the bidder leaves the queue unassigned, line L8 unassigns the previous owner of , if any, and puts it in the queue, and line L9 gives to alone. Since was unassigned, , and no other pair changes.
Claim 2 (every bid raises a price). In line L7 the increment is at least 1. Proof. is the largest value in the row, so ; for , .
Claim 3 (1-CS invariant). At the start of each iteration, every assigned person holding satisfies . Proof. True at the start, when nobody is assigned. Consider a bid by for . After line L7, , while every has by the choice of ; for there is no such . So satisfies the condition. Every other assigned person holds an object , by Claim 1, whose price did not change, and the only price that changed went up, so did not grow and still satisfies the condition. The outbid person is no longer assigned.
Claim 4 (termination). The loop ends after at most iterations, where . Proof. An object that has had an owner always has one: line L8 removes an owner only in the same iteration in which line L9 gives the object to the bidder. Suppose at some iteration an object has never been bid for. Then , and a bid by for has , so the new price is . By Claim 2 the -th bid for leaves , so each object gets at most bids while some object has never been bid for. Each iteration is one bid. So after at most iterations every object has been bid for, hence has an owner; by Claim 1 the objects have distinct owners, all persons are assigned, and the queue is empty.
Claim 5 (near optimality). At the end, the assignment is a permutation, and for every permutation . Proof. By Claims 1 and 4, is a permutation. Let . By Claim 3, for every , and by the definition of , . Summing over , and using that and are both permutations, so ,
Dividing by gives , and both sides are integers, so .
Claim 6 (forbidden pairs). If some permutation uses no forbidden pair, then every permutation that uses one has a smaller . Proof. A permutation with no forbidden pair has . A permutation with at least one forbidden pair has , since .
Theorem. The algorithm terminates. If some permutation avoids the forbidden pairs, it returns one that maximizes among them; otherwise it reports infeasibility. Proof. Termination is Claim 4. If a feasible permutation exists, the returned maximizes by Claim 5, so by Claim 6 it uses no forbidden pair, line L10 returns it, and on feasible permutations equals the original objective, so is optimal. If no feasible permutation exists, uses a forbidden pair and line L10 reports infeasibility, which is correct.