Algorithm Search⌘K

Techniqueadvanced

Ironing

Also called Myerson ironing.

Replaces the virtual valuation of an irregular distribution by the slope of the concave hull of its revenue curve. The result is monotone and keeps the optimal revenue.

Ironing turns the virtual valuation of a distribution that is not regular into a nondecreasing function, the ironed virtual valuation, without loss of optimal revenue. It draws the revenue curve R(q)R(q) in quantile space, replaces it by its least concave majorant Rˉ\bar R, and uses the slope of Rˉ\bar R in place of the slope of RR. On the intervals where Rˉ\bar R lies above RR, the ironed value is constant, and an optimal mechanism treats all values in such an interval alike. Myerson's lemma says that a truthful allocation must be monotone in the value. Ironing is the step that makes the revenue-maximizing allocation of Myerson's optimal auction monotone when the raw virtual valuation is not.

In plain words

A seller wants to rank bidders by how much revenue each one brings. For most distributions of values, a bidder with a higher value brings more. For some distributions it does not: a value in a thin middle range can look worse to the seller than a lower value. But an auction cannot reward a lower bid over a higher one, or bidders would lie. Ironing fixes this by pooling. It finds the ranges where the ranking goes the wrong way and gives every value in such a range the same average score. The scores then never go down as the value goes up, and the seller loses nothing, because the best possible auction would treat these values alike anyway. The name comes from pressing out the bumps of a curve.

When it applies

  • A revenue problem with independent single-parameter agents whose value distribution is not regular, for example a bimodal one or a discrete one with a small middle mass.
  • Any problem that asks to maximize E[φ(v)x(v)]\mathbb{E}[\varphi(v) x(v)] over nondecreasing xx, where φ\varphi is not monotone. Ironing gives the optimal value E[φˉ(v)x(v)]\mathbb{E}[\bar\varphi(v) x(v)], attained by any xx that is optimal for φˉ\bar\varphi and constant on the ironed intervals.
  • One buyer with a constraint on the sale probability: the best revenue with sale probability qq is Rˉ(q)\bar R(q), reached by a random price between two hull vertices. This is the building block of sequential posted pricing.

The template

For a discrete distribution on s1<⋯<sKs_1 < \cdots < s_K, the revenue curve has the points (0,0)(0, 0) and (qk,skqk)(q_k, s_k q_k) with qk=Pr⁡[v≥sk]q_k = \Pr[v \ge s_k].

  1. IRON(s_1 < ... < s_K, f_1, ..., f_K)
  2. 1P ← (0, 0), then (q_k, s_k q_k) for k = K down to 1 ▷ increasing q
  3. 2H ← vertices of the upper concave hull of P (monotone chain)
  4. 3for each pair (a, b) of consecutive vertices of H:
  5. 4give every curve segment from a to b the slope of the chord from a to b
  6. 5if b ≥ a + 2: record the values of those segments as one ironed interval
  7. 6return the slopes, in increasing order of value, and the ironed intervals

The ironed value of sks_k is φˉ(sk)\bar\varphi(s_k), the slope assigned to its segment. On an ironed interval it equals the ff-weighted mean of the raw virtual values φ(sk)=(skqk−sk+1qk+1)/fk\varphi(s_k) = (s_k q_k - s_{k+1} q_{k+1})/f_k of that interval. For a continuous distribution the same holds with Rˉ\bar R the least concave function above RR and φˉ(v)=Rˉ′(1−F(v))\bar\varphi(v) = \bar R'(1 - F(v)). The proof that the slopes are nondecreasing, that they keep the virtual surplus of every allocation that is constant on ironed intervals, and that they never lower it for monotone allocations is in proofs/correctness.md.

Classic examples

  • A discrete irregular distribution. Values 2,3,52, 3, 5 with probabilities 1/2,1/6,1/31/2, 1/6, 1/3 have q=(1,1/2,1/3)q = (1, 1/2, 1/3) and revenue curve points (0,0)(0, 0), (1/3,5/3)(1/3, 5/3), (1/2,3/2)(1/2, 3/2) and (1,2)(1, 2). The raw virtual values are (1,−1,5)(1, -1, 5). The point (1/2,3/2)(1/2, 3/2) lies below the chord from (1/3,5/3)(1/3, 5/3) to (1,2)(1, 2), of slope 1/21/2, so the values 2 and 3 form one ironed interval and φˉ=(1/2,1/2,5)\bar\varphi = (1/2, 1/2, 5). Check: (1⋅12+(−1)⋅16)/(12+16)=1/2(1 \cdot \frac12 + (-1) \cdot \frac16)/(\frac12 + \frac16) = 1/2.
  • The optimal auction. With two bidders from the distribution above, Myerson's auction ranks by φˉ\bar\varphi, so bids 2 and 3 tie, and the expected revenue is 3. The Vickrey auction earns 89/3689/36. Ranking by the raw φ\varphi is not monotone: the value 3 has φ=−1\varphi = -1 and never wins, while the value 2 can win, so no payment rule makes that ranking truthful.
  • A single buyer. The best posted price is a hull vertex: for the distribution above, price 2 sells for sure and earns 2, price 5 earns 5/35/3, and price 3 earns only 3/23/2, the point below the hull. To sell with probability exactly 1/21/2, the best a seller can do is the price 5 or 2 with probability 3/43/4 and 1/41/4, which earns Rˉ(1/2)=7/4\bar R(1/2) = 7/4, while the price 3 earns 3/23/2.
  • A negative ironed value. Values 1,2,51, 2, 5 with probabilities 1/2,1/4,1/41/2, 1/4, 1/4 have φ=(0,−1,5)\varphi = (0, -1, 5) and φˉ=(−1/3,−1/3,5)\bar\varphi = (-1/3, -1/3, 5). A single buyer is offered the price 5, for revenue 5/45/4.

Variations

  • Isotonic regression. The ironed values are the weighted isotonic regression of the raw virtual values with weights fkf_k: the nondecreasing sequence closest to φ\varphi in weighted squared error. The pool adjacent violators algorithm computes it by merging adjacent blocks that are out of order into their weighted mean, which gives the same answer as the hull.
  • Myerson's form. Myerson writes the quantile as t=F(v)t = F(v) and takes the convex hull of H(t)=∫0tφ(F−1(u)) duH(t) = \int_0^t \varphi(F^{-1}(u))\, du. This is the same construction seen from the other end of the quantile axis.
  • Ironing in other mechanism design problems. The same pooling of types appears as bunching in monopoly screening and in nonlinear pricing, whenever a pointwise optimum violates the monotonicity that incentive compatibility needs.
  • Ex ante relaxation. The concave hull Rˉ\bar R is also the revenue curve of a seller who may randomize over prices. The ex ante relaxation of a multi-bidder problem uses Rˉi\bar R_i for each bidder.

Pitfalls

  • Ironing in value space. The hull must be taken of the revenue curve in quantile space, or of the integral of φ\varphi against the quantile. Taking the hull of φ\varphi as a function of the value, or averaging φ\varphi without the weights ff, gives wrong values.
  • Tie rule inside an ironed interval. An optimal auction must treat all values in an ironed interval alike. A rule that breaks ties among equal ironed values in favor of the higher raw value is no longer constant on the interval, and its revenue drops below the ironed virtual surplus.
  • "Convex" or "concave". The hull is concave in the revenue curve picture and convex in Myerson's picture. The two are the same object, but mixing the conventions flips the sign of the slopes.
  • Exact arithmetic. For discrete distributions the hull test compares products of rationals. Floating point can merge or split ironed intervals by mistake.
  • Regular distributions. If the distribution is regular, ironing changes nothing. A test that finds ironed intervals for a regular distribution has a bug.

Code

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.

ironing.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/ironing/. The authors are listed in prov/Y8ZAS3.jsonl.

"""Ironing of the virtual values of a discrete value distribution.

A distribution is a list of (value, probability) pairs with distinct values and positive
probabilities that sum to 1, as ints or Fractions. The revenue curve has the points (0, 0) and
(q_k, s_k q_k) with q_k = Pr[v >= s_k]. The virtual value of s_k is the slope of the curve on the
quantile interval of s_k, and the ironed virtual value is the slope of the concave hull there.
"""

from fractions import Fraction
from typing import Sequence

Dist = Sequence[tuple]


def normalize(dist: Dist):
    """Return (values, probs) sorted by value, as Fractions, after checking the input."""
    pairs = sorted((Fraction(v), Fraction(p)) for v, p in dist)
    values = [v for v, _ in pairs]
    probs = [p for _, p in pairs]
    if not pairs or len(set(values)) != len(values):
        raise ValueError("the support must be nonempty with distinct values")
    if any(p <= 0 for p in probs) or sum(probs) != 1:
        raise ValueError("the probabilities must be positive and sum to 1")
    return values, probs


def revenue_curve(dist: Dist):
    """Return the points (q, R) from (0, 0) to (1, s_1), in increasing order of q."""
    values, probs = normalize(dist)
    pts = [(Fraction(0), Fraction(0))]
    q = Fraction(0)
    for s, f in zip(reversed(values), reversed(probs)):
        q += f
        pts.append((q, s * q))
    return pts


def concave_hull(pts):
    """Return the indices of the vertices of the upper concave hull of points sorted by q."""
    hull = []
    for k, (x, y) in enumerate(pts):
        while len(hull) >= 2:
            (x1, y1), (x2, y2) = pts[hull[-2]], pts[hull[-1]]
            if (y2 - y1) * (x - x1) <= (y - y1) * (x2 - x1):
                hull.pop()
            else:
                break
        hull.append(k)
    return hull


def virtual_values(dist: Dist):
    """Return the virtual values of the support values, in increasing order of value."""
    pts = revenue_curve(dist)
    slopes = [(pts[j][1] - pts[j - 1][1]) / (pts[j][0] - pts[j - 1][0]) for j in range(1, len(pts))]
    return list(reversed(slopes))


def iron(dist: Dist):
    """Return (ironed virtual values, ironed intervals).

    The ironed values are in increasing order of value. An ironed interval is a pair (lo, hi) of
    value indices, lo < hi, such that one hull segment spans the values s_lo, ..., s_hi, so they
    share one ironed virtual value. Inside the interval the revenue curve lies on or below the hull.
    """
    pts = revenue_curve(dist)  # @line L1
    K = len(pts) - 1
    hull = concave_hull(pts)  # @line L2
    slope = [None] * (K + 1)
    intervals = []
    for a, b in zip(hull, hull[1:]):  # @line L3
        m = (pts[b][1] - pts[a][1]) / (pts[b][0] - pts[a][0])
        for j in range(a + 1, b + 1):  # @line L4
            slope[j] = m
        if b - a >= 2:
            # curve point j belongs to value index K - j; the segment covers points a + 1 .. b
            intervals.append((K - b, K - (a + 1)))  # @line L5
    return list(reversed(slope[1:])), sorted(intervals)  # @line L6
test_ironing.py 101 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/ironing/. The authors are listed in prov/Y8ZAS3.jsonl.

import random
import unittest
from fractions import Fraction as F

from ironing import concave_hull, iron, revenue_curve, virtual_values

IRREGULAR = [(2, F(1, 2)), (3, F(1, 6)), (5, F(1, 3))]


def random_dist(rng, k, denom=12):
    values = sorted(rng.sample(range(1, 20), k))
    cuts = sorted(rng.sample(range(1, denom), k - 1))
    parts = [b - a for a, b in zip([0] + cuts, cuts + [denom])]
    return [(v, F(p, denom)) for v, p in zip(values, parts)]


def hull_height(pts, hull, q):
    """The value at q of the piecewise linear function through the hull vertices."""
    for a, b in zip(hull, hull[1:]):
        (x1, y1), (x2, y2) = pts[a], pts[b]
        if x1 <= q <= x2:
            return y1 + (y2 - y1) * (q - x1) / (x2 - x1)
    raise AssertionError("q outside [0, 1]")


class TestIroning(unittest.TestCase):
    def test_example(self):
        self.assertEqual(virtual_values(IRREGULAR), [1, -1, 5])
        self.assertEqual(iron(IRREGULAR), ([F(1, 2), F(1, 2), 5], [(0, 1)]))

    def test_regular_is_unchanged(self):
        d = [(1, F(1, 4)), (2, F(1, 4)), (3, F(1, 4)), (4, F(1, 4))]
        self.assertEqual(iron(d), (virtual_values(d), []))
        self.assertEqual(iron([(7, 1)]), ([7], []))

    def test_long_ironed_interval(self):
        d = [(1, F(3, 10)), (2, F(1, 10)), (3, F(1, 10)), (4, F(1, 10)), (6, F(2, 5))]
        bar, intervals = iron(d)
        self.assertEqual(bar, [F(-7, 3)] * 4 + [6])
        self.assertEqual(intervals, [(0, 3)])

    def test_hull_properties(self):
        rng = random.Random(1)
        for _ in range(300):
            d = random_dist(rng, rng.randint(1, 7))
            probs = [p for _, p in sorted(d)]
            phi = virtual_values(d)
            bar, intervals = iron(d)
            pts = revenue_curve(d)
            hull = concave_hull(pts)
            # the hull lies on or above every point and touches the two end points
            for q, r in pts:
                self.assertGreaterEqual(hull_height(pts, hull, q), r)
            self.assertEqual(hull[0], 0)
            self.assertEqual(hull[-1], len(pts) - 1)
            # ironed values are nondecreasing and equal the raw ones outside ironed intervals
            self.assertTrue(all(a <= b for a, b in zip(bar, bar[1:])))
            inside = {k for lo, hi in intervals for k in range(lo, hi + 1)}
            for k in range(len(d)):
                if k not in inside:
                    self.assertEqual(bar[k], phi[k])
            # on each ironed interval the mean of phi equals the ironed value
            for lo, hi in intervals:
                mass = sum(probs[lo:hi + 1])
                mean = sum(phi[k] * probs[k] for k in range(lo, hi + 1)) / mass
                self.assertEqual(mean, bar[lo])
            # both have mean equal to the lowest value
            low = min(v for v, _ in d)
            self.assertEqual(sum(f * x for f, x in zip(probs, phi)), low)
            self.assertEqual(sum(f * x for f, x in zip(probs, bar)), low)

    def test_virtual_surplus_inequality(self):
        rng = random.Random(2)
        for _ in range(300):
            d = random_dist(rng, rng.randint(1, 6))
            probs = [p for _, p in sorted(d)]
            phi = virtual_values(d)
            bar, intervals = iron(d)
            # a random nondecreasing allocation x in [0, 1]
            x = sorted(F(rng.randint(0, 6), 6) for _ in d)
            self.assertGreaterEqual(sum(f * a * b for f, a, b in zip(probs, x, bar)),
                                    sum(f * a * b for f, a, b in zip(probs, x, phi)))
            # constant on ironed intervals gives equality
            for lo, hi in intervals:
                for k in range(lo, hi + 1):
                    x[k] = x[lo]
            self.assertEqual(sum(f * a * b for f, a, b in zip(probs, x, bar)),
                             sum(f * a * b for f, a, b in zip(probs, x, phi)))

    def test_bad_input(self):
        with self.assertRaises(ValueError):
            iron([])
        with self.assertRaises(ValueError):
            iron([(1, F(1, 3)), (2, F(1, 3))])


if __name__ == "__main__":
    unittest.main()

Exercises

  1. Show that for any distribution on [a,b][a, b] with a≥0a \ge 0, E[φ(v)]=E[φˉ(v)]=a\mathbb{E}[\varphi(v)] = \mathbb{E}[\bar\varphi(v)] = a. (Both are the rise of a curve from (0,0)(0, 0) to (1,a)(1, a).)
  2. Iron the distribution with values 1,2,3,4,61, 2, 3, 4, 6 and probabilities 3/10,1/10,1/10,1/10,2/53/10, 1/10, 1/10, 1/10, 2/5. (Answer: φˉ=(−7/3,−7/3,−7/3,−7/3,6)\bar\varphi = (-7/3, -7/3, -7/3, -7/3, 6), with one ironed interval of four values.)
  3. Show that the optimal revenue from one buyer with sale probability at most qq is Rˉ(q)\bar R(q) when Rˉ\bar R is nondecreasing up to qq, and that a lottery over at most two prices attains it.
  4. Run the pool adjacent violators algorithm on the raw virtual values (1,−1,5)(1, -1, 5) with weights (1/2,1/6,1/3)(1/2, 1/6, 1/3) and check that it gives (1/2,1/2,5)(1/2, 1/2, 5).
Proof: Correctness of ironing by the concave hullfull

Let the distribution have values s1<⋯<sKs_1 < \cdots < s_K with probabilities f1,…,fK>0f_1, \ldots, f_K > 0. Write qk=∑j≥kfjq_k = \sum_{j \ge k} f_j, so q1=1q_1 = 1, and put qK+1=0q_{K+1} = 0 and sK+1qK+1=0s_{K+1} q_{K+1} = 0. Line L1 builds the revenue curve: the points P0=(0,0)P_0 = (0, 0) and (qk,skqk)(q_k, s_k q_k) for k=K,…,1k = K, \ldots, 1, in increasing order of qq. The segment of value sks_k runs from (qk+1,sk+1qk+1)(q_{k+1}, s_{k+1} q_{k+1}) to (qk,skqk)(q_k, s_k q_k). It has length fkf_k and slope φk=(skqk−sk+1qk+1)/fk\varphi_k = (s_k q_k - s_{k+1} q_{k+1})/f_k, the virtual value. Let Rˉ\bar R be the least concave function on [0,1][0, 1] that lies on or above all the points, and let φˉk\bar\varphi_k be its slope on the segment of sks_k.

Claim 1: line L2 returns the vertices of Rˉ\bar R

The scan keeps a stack hh of point indices. Invariant: after point kk is processed, the stack holds the vertices of the upper hull of points 0,…,k0, \ldots, k, in order, with strictly decreasing slopes between consecutive entries. This holds after point 0. When point kk arrives, the loop removes the top entry tt while tt lies on or below the chord from the entry under it to point kk. Such a tt cannot be a vertex of the hull of points 0,…,k0, \ldots, k, because it lies on or below a segment between two points of the set. When the loop stops, the last two entries and point kk make a strict right turn, so the slopes still decrease strictly. Entries below were vertices before and stay vertices, since the new point lies to their right and the slopes decrease. So the invariant holds. At the end, the stack holds the vertices of the upper hull of all the points, from P0P_0 to (1,s1)(1, s_1), and the piecewise linear function through them is concave and lies on or above every point, so it is Rˉ\bar R. Each point enters and leaves the stack at most once, so the scan takes O(K)O(K) steps.

Claim 2: lines L3 to L6 give the slopes of Rˉ\bar R, and they are nondecreasing in the value

Between consecutive vertices aa and bb, Rˉ\bar R is the chord, so every segment of the curve from point aa to point bb gets the slope mm of the chord (line L4). The slopes of the hull decrease strictly from one chord to the next as qq grows. Since qkq_k decreases as kk grows, φˉ1≤⋯≤φˉK\bar\varphi_1 \le \cdots \le \bar\varphi_K. Line L6 reverses the list so that it is in increasing order of value.

If the chord from aa to bb spans one segment only (b=a+1b = a + 1), then φˉ=φ\bar\varphi = \varphi there. Otherwise line L5 records the value indices of points a+1,…,ba + 1, \ldots, b as an ironed interval. Curve point jj belongs to value index K−jK - j in increasing order, which is the conversion used in line L5. Every value outside the recorded intervals has its own chord, so φˉk=φk\bar\varphi_k = \varphi_k there.

Claim 3: the mean of φ\varphi on an ironed interval is the ironed value

On an ironed interval with values sℓ,…,shs_{\ell}, \ldots, s_h, the curve and the hull meet at both ends, the vertices aa and bb. So ∑k=ℓhfkφk\sum_{k = \ell}^{h} f_k \varphi_k, the rise of the curve over the interval, equals ∑k=ℓhfkφˉk=φˉℓ∑k=ℓhfk\sum_{k = \ell}^{h} f_k \bar\varphi_k = \bar\varphi_\ell \sum_{k = \ell}^{h} f_k, the rise of the hull. Over all values, both sums telescope from (0,0)(0, 0) to (1,s1)(1, s_1): ∑kfkφk=∑kfkφˉk=s1\sum_k f_k \varphi_k = \sum_k f_k \bar\varphi_k = s_1, the lowest value.

Claim 4: ironing never lowers the virtual surplus of a monotone allocation, and keeps it when the allocation is flat on ironed intervals

Let 0≤x1≤⋯≤xK0 \le x_1 \le \cdots \le x_K and put x0=0x_0 = 0. Write Gk=∑j≥kfjφj=skqkG_k = \sum_{j \ge k} f_j \varphi_j = s_k q_k and Gˉk=∑j≥kfjφˉj=Rˉ(qk)\bar G_k = \sum_{j \ge k} f_j \bar\varphi_j = \bar R(q_k), with GK+1=GˉK+1=0G_{K+1} = \bar G_{K+1} = 0. Summation by parts gives

∑kfkxk(φˉk−φk)=∑k≥1(xk−xk−1)(Gˉk−Gk).\sum_k f_k x_k (\bar\varphi_k - \varphi_k) = \sum_{k \ge 1} (x_k - x_{k-1}) (\bar G_k - G_k).

Each factor xk−xk−1x_k - x_{k-1} is nonnegative, and Gˉk−Gk≥0\bar G_k - G_k \ge 0 because the hull lies above the curve. So the sum is at least 0. The term k=1k = 1 is 0, since (1,s1)(1, s_1) is a vertex. For k≥2k \ge 2, Gˉk>Gk\bar G_k > G_k only if the point (qk,skqk)(q_k, s_k q_k) lies strictly below the hull, and then it is an inner point of an ironed interval that contains both sk−1s_{k-1} and sks_k. If xx is constant on each ironed interval, then xk=xk−1x_k = x_{k-1} for every such kk, and the sum is 0.

This is the step that lets Myerson's optimal auction replace φ\varphi by φˉ\bar\varphi: its allocation depends on the value only through φˉ\bar\varphi, so it is constant on ironed intervals, and its revenue is the expected ironed virtual surplus. For any other monotone allocation, the expected ironed virtual surplus is an upper bound on the revenue.

References

  1. Roger B. Myerson, Optimal auction design, Mathematics of Operations Research 6(1) (1981), 58-73, the ironing procedure, which replaces the integral of the virtual valuation in quantile space by its convex hull, for distributions that are not regular
  2. Jeremy Bulow and John Roberts, The simple economics of optimal auctions, Journal of Political Economy 97(5) (1989), 1060-1090, ironing as the use of the concave hull of the revenue curve of a monopolist, with marginal revenue in place of the virtual valuation
  3. Jason D. Hartline, Mechanism Design and Approximation, book draft, version with Chapters 1 to 7 revised in September 2021, https://jasonhartline.com/MDnA/, Chapter 3, Optimal mechanisms (revenue curves, the ironed revenue curve as a concave hull, and the optimality of ironed virtual surplus maximization)
  4. Noam Nisan, Tim Roughgarden, Eva Tardos and Vijay V. Vazirani (eds.), Algorithmic Game Theory, Cambridge University Press, 2007, Chapter 13, Jason D. Hartline and Anna R. Karlin, Profit maximization in mechanism design (the optimal mechanism for distributions that are not regular)

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 proofH2 full proof
  • correctness: no review record reviews/Y8ZAS3/proof-correctness.yaml
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)
WritingW3 standard
  • five exercises