Algorithm Search⌘K

Algorithmcore

Uniform price auction

Also called multi-unit uniform price auction.

Sells k identical units to the k highest marginal bids at one price, the highest losing bid or the lowest winning bid. Truthful for unit demand; bidders who want several units shade their bids.

Time
O(d log d) worst
Space
O(d) extra
Where
d = the total number of marginal bids; k = the number of units; n = the number of bidders
Properties
comparison baseddeterministiciterative
Origin
Milton Friedman, Robert Wilson, Lawrence Ausubel, Peter Cramton, 1960

The uniform price auction sells kk identical units of one good. Each bidder reports a list of marginal bids, one for each extra unit it wants, and the auction accepts the kk highest marginal bids. Every unit sold costs the same price: the highest losing bid in one version, the lowest winning bid in the other. With the highest losing bid and bidders who want one unit each, it is the (k+1)(k + 1)-th price auction, which is DSIC and a case of the VCG mechanism. When a bidder wants several units, its own losing bid can set the price of its winning units, so it gains by bidding less for its later units. This demand reduction makes the auction inefficient in equilibrium. Governments use the format for bonds and for some electricity and emission permit markets.

In plain words

A seller has many copies of the same thing. Each buyer says how much it would pay for a first copy, for a second copy, and so on. The seller gives the copies to the highest offers, and then everyone pays the same price per copy, set by the offers that just missed or just made it. If every buyer wants only one copy, honest offers are best, exactly as in a sealed second-price auction. A buyer that wants many copies has a reason to lie. Its offer for the last copy can become the price that it pays on all its other copies. By asking for fewer copies, it can make the price fall a lot and gain more than it gives up. This is why such auctions can sell to the wrong buyers.

The problem

There are kk identical units and nn bidders with quasilinear utility. Bidder ii has marginal values vi,1≥vi,2≥⋯v_{i,1} \ge v_{i,2} \ge \cdots: it values xx units at vi,1+⋯+vi,xv_{i,1} + \cdots + v_{i,x}. It reports marginal bids bi,1≥bi,2≥⋯≥0b_{i,1} \ge b_{i,2} \ge \cdots \ge 0, in total dd numbers. The auction must choose how many units xix_i each bidder gets, with ∑ixi≤k\sum_i x_i \le k, and one price pp per unit, so that bidder ii pays p xip\,x_i. The aims are to give the units to the highest reported marginal bids, and to set a price at which no winning bid is below the price and no losing bid is above it.

The algorithm

  1. UNIFORM-PRICE(b, k)
  2. 1E ← all triples (b_{i,j}, i, j) for every bidder i and unit j
  3. 2sort E by bid, highest first; ties go to the smaller i, then the smaller j
  4. 3q ← min(k, |E|)
  5. 4for each of the first q triples (·, i, ·): x_i ← x_i + 1
  6. 5if the rule is HIGHEST-LOSING: p ← the bid of triple k + 1, or 0 if |E| ≤ k
  7. 6else (LOWEST-WINNING): p ← the bid of triple q, or 0 if q = 0
  8. 7return x, p, and the payments p · x_i

The tie rule of line L2 puts a bidder's unit jj before its unit j+1j + 1 when the bids are equal, so every bidder wins a prefix of its list. Sorting is the simplest way to write line L2; a selection of the (k+1)(k + 1)-th largest bid does the same work in linear time.

Example

Unit demand. Four bidders want one unit each and bid 7,5,3,37, 5, 3, 3 for k=2k = 2 units. The bids 7 and 5 win. Under the highest losing rule both winners pay 3, the best losing bid. Under the lowest winning rule both pay 5.

Demand reduction. Take k=2k = 2, a bidder AA that values each of two units at 10, and a bidder BB that values one unit at 6. Use the highest losing rule.

bids of AA bid of BB sorted triples units of AA, BB price utility of AA
(10,10)(10, 10) 66 10A,10A,6B10_A, 10_A, 6_B 2,02, 0 6 20−12=820 - 12 = 8
(10,0)(10, 0) 66 10A,6B,0A10_A, 6_B, 0_A 1,11, 1 0 10−0=1010 - 0 = 10

By giving up its second unit, AA makes its own bid 0 the highest losing bid, and the price falls from 6 to 0. The second profile is a Nash equilibrium. Its welfare is 10+6=1610 + 6 = 16, while the optimum gives both units to AA for 20.

Correctness

The proof is in proofs/correctness.md. It shows these facts.

  • The allocation is the best for the reports. Each bidder wins a prefix of its list, and the winning triples are the qq highest bids, so the allocation maximizes the sum of the accepted marginal bids.
  • The price clears the market. Every winning bid is at least pp and every losing bid is at most pp. So at the price pp, each bidder's reported demand is the number of units it got, up to ties.
  • Unit demand is truthful. If each bidder wants one unit, bidder ii wins when its bid is above the kk-th highest other bid θ\theta and loses when it is below, and a winner pays θ\theta under the highest losing rule. This is the threshold form of Myerson's lemma, and truthful bidding is a dominant strategy.
  • The lowest winning rule is not truthful, even for unit demand: with one unit and bids 5 and 3, the winner pays its own bid and gains by bidding 4.
  • Multi-unit demand is not truthful under either rule, by the demand reduction example.
Proof: The uniform price auction sells to the highest marginal bids at a clearing price, and it is truthful only for unit demandfull

We use the pseudocode of the page. Bidder ii reports a list of marginal bids bi,1≥bi,2≥⋯≥bi,di≥0b_{i,1} \ge b_{i,2} \ge \cdots \ge b_{i,d_i} \ge 0, where bi,jb_{i,j} is its offer for its jj-th unit. There are kk units. Line L2 sorts all triples (bi,j,i,j)(b_{i,j}, i, j) by bid, highest first, then by ii, then by jj. Call the first q=min⁡(k,∣E∣)q = \min(k, |E|) triples winning and the rest losing.

Claim 1 (the allocation). Each bidder wins a prefix of its list: if (bi,j,i,j)(b_{i,j}, i, j) wins and j′<jj' < j, then (bi,j′,i,j′)(b_{i,j'}, i, j') wins. The allocation xx maximizes the reported welfare ∑i∑j≤xibi,j\sum_i \sum_{j \le x_i} b_{i,j} over all allocations with ∑ixi≤k\sum_i x_i \le k and xi≤dix_i \le d_i.

Proof. If j′<jj' < j, then bi,j′≥bi,jb_{i,j'} \ge b_{i,j}, and on a tie the smaller unit index comes first in the order of line L2. So the triple of unit j′j' is earlier than the triple of unit jj, and it wins if that one wins. Any feasible allocation yy selects at most kk triples, one for each unit given out, and its welfare is the sum of their bids. The sum of at most kk entries of EE is at most the sum of the qq largest bids, because all bids are at least 0. Lines L3 and L4 select exactly the qq largest bids, and by the first part they form an allocation. □\square

Claim 2 (the price clears the market). Under the highest losing rule (line L5), every winning bid is at least pp and every losing bid is at most pp. Under the lowest winning rule (line L6), the same holds when at least one unit is sold. Every winner pays pp for each unit, so a bidder that wins xix_i units pays p xip\,x_i (line L7).

Proof. The list is sorted. Under line L5, pp is the bid of triple k+1k + 1, the first losing triple, or p=0p = 0 if no triple loses; in both cases every winning bid is at least pp (bids are at least 0) and every losing bid is at most pp. Under line L6, pp is the bid of the last winning triple, which is at most every earlier bid and at least every later bid. □\square

So with truthful bids, the units go to the kk highest marginal values, and every bidder demands, at the price pp, the number of units it gets, up to ties.

Claim 3 (unit demand: truthful bidding is dominant under the highest losing rule). Suppose every bidder wants at most one unit and reports one bid. Fix bidder ii with value vv and the bids of the others. Then bidding vv gives at least the utility of any other bid, and at least 0.

Proof. Let θ\theta be the kk-th highest bid of the other bidders, and θ=0\theta = 0 if there are fewer than kk others. Bidder ii wins if b>θb > \theta and loses if b<θb < \theta: in the first case at most k−1k - 1 other bids are at least bb, and in the second case at least kk other bids are above bb. If bidder ii wins, at most k−1k - 1 other triples are ahead of it, so the kk winning triples are ii and the k−1k - 1 highest other bids, and the first losing triple is the kk-th highest other bid; if there are fewer than kk others, no triple loses and the price is 0=θ0 = \theta. So the price is θ\theta, which does not depend on bb. If v>θv > \theta, the bid vv wins and gives v−θ>0v - \theta > 0, and any other bid gives v−θv - \theta or 0. If v<θv < \theta, the bid vv gives 0, and a winning bid gives v−θ<0v - \theta < 0. If v=θv = \theta, every bid gives 0. □\square

This is the (k+1)(k + 1)-th price auction, the case of the VCG mechanism for identical units and unit demand.

Claim 4 (the lowest winning rule is not truthful, even for unit demand). With one unit and bids (5,3)(5, 3), the first bidder wins and pays its own bid 5, so its utility is 0. With the bid 4 it still wins and pays 4, so its utility is 1.

Claim 5 (demand reduction: with multi-unit demand, truthful bidding is not dominant). Take k=2k = 2, a bidder AA with marginal values (10,10)(10, 10) and a bidder BB with one value 6. Under the highest losing rule, truthful bids give AA both units at the price 6, so AA gets 20−12=820 - 12 = 8. If AA bids (10,0)(10, 0), the sorted bids are 10,6,010, 6, 0, so AA and BB win one unit each and the price is the losing bid 0. Then AA gets 10 > 8. The bids ((10,0),6)((10, 0), 6) form a Nash equilibrium: BB already gets its whole value 6, and AA can get two units only with a second bid of at least 6, and then the losing bid 6 of BB sets the price to 6 and AA gets 8. With one unit, AA gets at most 10. The equilibrium welfare is 10+6=1610 + 6 = 16, below the optimum 20. □\square

The reason is that a bidder's own losing bid on a later unit can set the price it pays on its earlier units. With unit demand this cannot happen, because a bidder that wins has no losing bid.

Complexity

Sorting dd triples takes O(dlog⁡d)O(d \log d) time and O(d)O(d) extra space, and lines L4 to L7 take O(d+n)O(d + n) time. With a linear-time selection of the kk-th and (k+1)(k + 1)-th largest bids and a partition of the list around them, the time is O(d+n)O(d + n). Ties at the boundary must still be broken by the rule of line L2.

Properties

  • Clearing price. Every winner pays the same price per unit, and the price lies between the best losing bid and the worst winning bid.
  • DSIC for unit demand under the highest losing rule, with the same threshold argument as the Vickrey auction.
  • Not DSIC for multi-unit demand. A bidder's losing bids on later units can set the price of its winning units, so in equilibrium bidders shade their bids for later units (Ausubel, Cramton, Pycia, Rostek and Weretka 2014).
  • Inefficient in equilibrium when bidders want several units, because demand reduction moves units from high to low marginal values.
  • Low-price equilibria. In the model of a divisible good with bidders that submit demand curves, Wilson (1979) found equilibria in which the price is far below the values, because each bidder faces a steep supply from the others.

Variants and improvements

  • Pay-as-bid (discriminatory) auction. Each winner pays its own winning bids. Bidders then shade all their bids, not only the later ones. Neither format dominates the other in revenue or efficiency in general (Ausubel, Cramton, Pycia, Rostek and Weretka 2014).
  • Vickrey auction for identical units. Each bidder pays, for its xx-th unit, the xx-th highest losing bid of the others. This is the VCG mechanism for this setting and is DSIC for any nonincreasing marginal values, at the cost of different prices for the same good.
  • Ascending clock auction. The price rises, and bidders report how many units they want at each price, until demand falls to kk. With straightforward bidding it ends at the uniform price; Ausubel's clinching auction changes the payments so that sincere bidding becomes an equilibrium.
  • Reserve price. The seller adds kk bids of its own at the reserve, which bounds the price from below.

When to use it

Use it to sell many identical units when one public price matters, for example for government bonds, when buyers want a single price for fairness or for resale. With unit demand, use the highest losing rule, which is truthful. When large bidders want many units, expect demand reduction, and consider a clock auction with clinching or a Vickrey auction for identical units.

Pitfalls

  • The price rule matters. "Uniform price" can mean the highest losing bid or the lowest winning bid. Only the first is truthful for unit demand.
  • The bidder's own bids set the price. With multi-unit demand the price can be a losing bid of a winner. Do not treat the auction as a (k+1)(k + 1)-th price auction in that case.
  • Ties at the boundary. When several bids equal the kk-th bid, the tie rule decides who wins, but the price does not depend on who wins the tie.
  • Marginal bids must not increase. A list with an increasing step does not describe a valuation with decreasing marginal values, and the prefix property of line L2 fails; the code rejects such a list.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

uniform_price_auction.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/uniform-price-auction/. The authors are listed in prov/6TRC5Q.jsonl.

from fractions import Fraction
from typing import Sequence, Union

Number = Union[int, Fraction]

HIGHEST_LOSING = "highest-losing"
LOWEST_WINNING = "lowest-winning"


def uniform_price_auction(
    bids: Sequence[Sequence[Number]], k: int, rule: str = HIGHEST_LOSING
) -> tuple[list[int], Number, list[Number]]:
    """Sell k identical units at one price.

    bids[i] is the list of marginal bids of bidder i: bids[i][j] is what
    bidder i offers for its (j + 1)-th unit. Each list must be nonincreasing.
    The k highest marginal bids win one unit each. A tie between equal bids
    goes to the smaller bidder index, then to the smaller unit index, which
    for a nonincreasing list is the same as the earlier unit.

    With rule HIGHEST_LOSING the price is the highest losing bid, or 0 if
    every bid wins. With rule LOWEST_WINNING the price is the lowest winning
    bid, or 0 if no bid wins. Every unit sold costs the same price.

    Return (units, price, payments): units[i] is the number of units of
    bidder i and payments[i] = units[i] * price.
    """
    if k < 0:
        raise ValueError("k must be nonnegative")
    if rule not in (HIGHEST_LOSING, LOWEST_WINNING):
        raise ValueError("unknown price rule")
    for row in bids:
        for j in range(1, len(row)):
            if row[j] > row[j - 1]:
                raise ValueError("marginal bids must be nonincreasing")
    entries = [(row[j], i, j) for i, row in enumerate(bids) for j in range(len(row))]  # @line L1
    entries.sort(key=lambda e: (-e[0], e[1], e[2]))  # @line L2
    sold = min(k, len(entries))  # @line L3
    units = [0] * len(bids)
    for _, i, _ in entries[:sold]:  # @line L4
        units[i] += 1  # @line L4
    price: Number = 0
    if rule == HIGHEST_LOSING:  # @line L5
        if len(entries) > k:  # @line L5
            price = entries[k][0]  # @line L5
    elif sold > 0:  # @line L6
        price = entries[sold - 1][0]  # @line L6
    payments = [u * price for u in units]  # @line L7
    return units, price, payments  # @line L7


def utility(
    values: Sequence[Number], bids: Sequence[Sequence[Number]], i: int, k: int,
    rule: str = HIGHEST_LOSING,
) -> Number:
    """Quasilinear utility of bidder i whose true marginal values are values.

    The bidder gets values[0] + ... + values[u - 1] for u units and pays
    u times the price.
    """
    units, _, payments = uniform_price_auction(bids, k, rule)
    return sum(values[:units[i]]) - payments[i]
test_uniform_price_auction.py 133 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/uniform-price-auction/. The authors are listed in prov/6TRC5Q.jsonl.

import itertools
import random
from fractions import Fraction

from uniform_price_auction import (
    HIGHEST_LOSING,
    LOWEST_WINNING,
    uniform_price_auction,
    utility,
)


def nonincreasing_vectors(grid, length):
    for v in itertools.product(grid, repeat=length):
        if all(v[j] >= v[j + 1] for j in range(length - 1)):
            yield list(v)


def best_total(bids, k):
    """Largest sum of accepted bids, by brute force over unit counts."""
    best = 0
    for counts in itertools.product(*[range(len(row) + 1) for row in bids]):
        if sum(counts) <= k:
            best = max(best, sum(sum(row[:c]) for row, c in zip(bids, counts)))
    return best


def test_example() -> None:
    bids = [[10, 10], [6]]
    assert uniform_price_auction(bids, 2) == ([2, 0], 6, [12, 0])
    assert uniform_price_auction(bids, 2, LOWEST_WINNING) == ([2, 0], 10, [20, 0])
    assert uniform_price_auction([[10, 0], [6]], 2) == ([1, 1], 0, [0, 0])
    assert uniform_price_auction([[7], [5], [3], [3]], 2) == ([1, 1, 0, 0], 3, [3, 3, 0, 0])


def test_edges() -> None:
    assert uniform_price_auction([], 3) == ([], 0, [])
    assert uniform_price_auction([[4]], 0) == ([0], 4, [0])
    assert uniform_price_auction([[4]], 0, LOWEST_WINNING) == ([0], 0, [0])
    assert uniform_price_auction([[4, 1]], 5) == ([2], 0, [0])
    assert uniform_price_auction([[4, 1]], 5, LOWEST_WINNING) == ([2], 1, [2])
    assert uniform_price_auction([[5], [5], [5]], 2) == ([1, 1, 0], 5, [5, 5, 0])
    half = Fraction(1, 2)
    assert uniform_price_auction([[half], [Fraction(1, 3)]], 1) == ([1, 0], Fraction(1, 3), [Fraction(1, 3), 0])
    try:
        uniform_price_auction([[1, 2]], 1)
    except ValueError:
        pass
    else:
        raise AssertionError("an increasing bid list must be rejected")


def test_allocation_and_clearing_price() -> None:
    rng = random.Random(1)
    for _ in range(1500):
        n = rng.randrange(0, 4)
        bids = [sorted((rng.randrange(0, 8) for _ in range(rng.randrange(0, 4))), reverse=True) for _ in range(n)]
        k = rng.randrange(0, 6)
        for rule in (HIGHEST_LOSING, LOWEST_WINNING):
            units, price, payments = uniform_price_auction(bids, k, rule)
            total = sum(len(row) for row in bids)
            assert sum(units) == min(k, total)
            assert sum(sum(row[:u]) for row, u in zip(bids, units)) == best_total(bids, k)
            assert payments == [u * price for u in units]
            # Every winning bid is at least the price, and every losing bid is
            # at most the price (when a unit is sold or the rule uses losers).
            for row, u in zip(bids, units):
                assert all(b >= price for b in row[:u])
                if rule == HIGHEST_LOSING or sum(units) > 0:
                    assert all(b <= price for b in row[u:])


def test_unit_demand_truthful_is_dominant() -> None:
    grid = range(0, 5)
    for k in (1, 2):
        for others in itertools.product(grid, repeat=2):
            for i in range(3):
                for value in grid:
                    truthful = [[b] for b in others[:i]] + [[value]] + [[b] for b in others[i:]]
                    u_true = utility([value], truthful, i, k)
                    assert u_true >= 0
                    for lie in grid:
                        bids = [[b] for b in others[:i]] + [[lie]] + [[b] for b in others[i:]]
                        assert u_true >= utility([value], bids, i, k)


def test_lowest_winning_price_is_not_truthful() -> None:
    # One unit, values 5 and 3: the winner pays its own bid, so shading helps.
    assert utility([5], [[5], [3]], 0, 1, LOWEST_WINNING) == 0
    assert utility([5], [[4], [3]], 0, 1, LOWEST_WINNING) == 1


def test_demand_reduction() -> None:
    values_a, values_b = [10, 10], [6]
    truthful = utility(values_a, [values_a, values_b], 0, 2)
    reduced = utility(values_a, [[10, 0], values_b], 0, 2)
    assert (truthful, reduced) == (8, 10)
    # The reduced profile is a Nash equilibrium over a grid of bids.
    grid = range(0, 13)
    profile = [[10, 0], [6]]
    u_a = utility(values_a, profile, 0, 2)
    u_b = utility(values_b, profile, 1, 2)
    for lie in nonincreasing_vectors(grid, 2):
        assert utility(values_a, [lie, [6]], 0, 2) <= u_a
    for lie in grid:
        assert utility(values_b, [[10, 0], [lie]], 1, 2) <= u_b
    # The equilibrium allocation is not efficient: welfare 16 against 20.
    units, _, _ = uniform_price_auction(profile, 2)
    welfare = sum(values_a[:units[0]]) + sum(values_b[:units[1]])
    assert (welfare, best_total([values_a, values_b], 2)) == (16, 20)


def test_multi_unit_bidders_gain_only_by_lowering_bids() -> None:
    # With two units of demand, a profitable lie exists in some profiles, and
    # in each profile some best lie bids no more than the value on each unit.
    grid = range(0, 5)
    found = False
    for values in nonincreasing_vectors(grid, 2):
        for other in nonincreasing_vectors(grid, 2):
            for k in (1, 2, 3):
                u_true = utility(values, [values, other], 0, k)
                best = max(utility(values, [lie, other], 0, k) for lie in nonincreasing_vectors(grid, 2))
                shaded = max(
                    utility(values, [lie, other], 0, k)
                    for lie in nonincreasing_vectors(grid, 2)
                    if lie[0] <= values[0] and lie[1] <= values[1]
                )
                assert shaded == best
                found = found or best > u_true
    assert found

History

Milton Friedman argued around 1960 that the US Treasury should sell its securities at one price rather than at the bids, so that small bidders would not need to guess the market. Wilson (1979) modeled the sale of a divisible good to bidders who submit demand curves and found equilibria of the uniform price rule in which the price is far below the values. Theory and evidence on demand reduction followed in the 1990s and 2000s, and Ausubel, Cramton, Pycia, Rostek and Weretka (2014) compared the uniform price and pay-as-bid formats, showing that demand reduction makes both inefficient and that their ranking in revenue and efficiency depends on the setting.

References

  1. Lawrence M. Ausubel, Peter Cramton, Marek Pycia, Marzena Rostek and Marek Weretka, Demand reduction and inefficiency in multi-unit auctions, Review of Economic Studies 81(4) (2014), 1366-1400, demand reduction in the uniform price auction, the inefficiency it causes, and the comparison with the pay-as-bid auction
  2. Robert Wilson, Auctions of shares, Quarterly Journal of Economics 93(4) (1979), 675-689, equilibria of the auction of a divisible good at one price, with prices far below the values
  3. Vijay Krishna, Auction Theory, 2nd edition, Academic Press, 2010, the chapters on multiple-unit auctions (the uniform price, discriminatory and Vickrey auctions of identical units, and demand reduction)
  4. Tim Roughgarden, Twenty Lectures on Algorithmic Game Theory, Cambridge University Press, 2016, Lecture 9 (budget constraints and the uniform-price multi-unit auction)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example