Algorithm Search⌘K

Definitionadvanced

Gross substitutes

Also called gross substitutes condition.

A valuation has gross substitutes if raising some prices never makes the buyer drop an item whose price stayed the same. With such buyers, a Walrasian equilibrium of indivisible goods exists.

Gross substitutes is a condition on a buyer's valuation over bundles of indivisible goods: when some prices go up, the buyer never gives up a good whose price did not change. It is the condition under which markets for indivisible goods behave like markets for divisible goods: a Walrasian equilibrium exists, an ascending auction finds it, and welfare can be maximized with polynomially many demand queries. It is stronger than submodularity, which only asks for decreasing marginal values, and weaker than unit demand, the case of the DGS auction.

Definition

There are mm indivisible goods. A valuation is a function vv from bundles S⊆{1,…,m}S \subseteq \{1, \ldots, m\} to the reals with v(∅)=0v(\varnothing) = 0. At a price vector pp, the utility of SS is v(S)−p(S)v(S) - p(S) with p(S)=∑j∈Spjp(S) = \sum_{j \in S} p_j, and the demand set is

D(v,p)=arg⁡max⁡S (v(S)−p(S)).D(v, p) = \arg\max_{S} \, \bigl(v(S) - p(S)\bigr).

Gross substitutes (Kelso and Crawford 1982). vv has gross substitutes when for all price vectors p≤p′p \le p' and every S∈D(v,p)S \in D(v, p) there is T∈D(v,p′)T \in D(v, p') with

{j∈S:pj=pj′}⊆T.\{j \in S : p_j = p'_j\} \subseteq T.

In words: after a price rise, the buyer can keep every demanded good whose price did not rise. The condition allows ties in the demand set, so it asks only for some demanded bundle TT.

Several conditions are equivalent to gross substitutes:

  • Local exchange conditions (Reijnierse, van Gellekom and Potters 2002). For every bundle SS and distinct goods i,j,k∉Si, j, k \notin S (writing SijSij for S∪{i,j}S \cup \{i, j\}),
v(Sij)+v(S)≤v(Si)+v(Sj),v(Sij)+v(Sk)≤max⁡(v(Sik)+v(Sj), v(Sjk)+v(Si)).v(Sij) + v(S) \le v(Si) + v(Sj), \qquad v(Sij) + v(Sk) \le \max\bigl(v(Sik) + v(Sj),\ v(Sjk) + v(Si)\bigr).

These conditions involve only bundles that differ by at most three goods, so they can be checked with O(2mm3)O(2^m m^3) value queries.

  • M-natural concavity (Fujishige and Yang 2003). Gross substitutes valuations are exactly the M-natural concave set functions of discrete convex analysis, which gives a link to valuated matroids.
  • Single improvement (Gul and Stacchetti 1999). If a bundle is not demanded, the buyer can raise her utility by adding one good, removing one good, or swapping one good for another.

Examples and non-examples

  • Additive valuations, v(S)=∑j∈Swjv(S) = \sum_{j \in S} w_j, have gross substitutes: each good is bought on its own.
  • Unit demand, v(S)=max⁡j∈Swjv(S) = \max_{j \in S} w_j: the buyer wants one good. This is the case of the assignment game.
  • Assignment (OXS) valuations: the buyer has several slots, slot ss values good jj at wsjw_{sj}, and v(S)v(S) is the largest total value of putting goods of SS in distinct slots. Firms that fill several positions in a job market have such valuations. They include additive and unit-demand valuations.
  • Weighted matroid rank functions and, more generally, valuated matroids. For example, v(S)v(S) is the total weight of the kk heaviest goods of SS.
  • Complements are excluded. If v({a,b})=3v(\{a, b\}) = 3 and v({a})=v({b})=0v(\{a\}) = v(\{b\}) = 0, then at prices (1,1)(1, 1) the buyer wants both, and when the price of bb rises to 33 she drops aa, whose price did not change.
  • Submodular is not enough. The budget-additive valuation v(S)=min⁡(w(S),4)v(S) = \min(w(S), 4) with weights (2,2,3)(2, 2, 3) is submodular. But with S=∅S = \varnothing and goods a,b,ca, b, c, v(ab)+v(c)=7v(ab) + v(c) = 7 while v(ac)+v(b)=v(bc)+v(a)=6v(ac) + v(b) = v(bc) + v(a) = 6, so it breaks the second local condition.
  • Sums of gross substitutes valuations need not have it. Paes Leme (2017) gives the sum v=ra+2rb+3rcv = r^a + 2r^b + 3r^c of three matroid rank functions on goods a,b,ca, b, c, where rir^i is 11 on a single good and on the pair without ii and 22 on the other pairs and on {a,b,c}\{a, b, c\}. At prices (4,5,4)(4, 5, 4) the demand set is {a},{c},{a,c},{b,c}\{a\}, \{c\}, \{a, c\}, \{b, c\}. When the price of cc rises very high, the only demanded bundle is {a}\{a\}, so the bundle {b,c}\{b, c\} loses bb, whose price did not change.

The Python code for this page checks both forms on small examples. One check tests the definition directly on a grid of price vectors for 3 goods. The other tests the local conditions. On all 148 monotone valuations on 3 goods with values in {0,1,2}\{0, 1, 2\}, exactly 34 pass the local conditions, and the two checks agree on a random sample of these valuations.

  • Walrasian equilibrium. Kelso and Crawford (1982) showed that an equilibrium exists when every buyer has gross substitutes; see competitive equilibrium. Gul and Stacchetti (1999) showed the converse in a strong form: if a class of valuations contains all unit-demand valuations and always has an equilibrium, it lies inside gross substitutes.
  • Ascending auctions. The Kelso-Crawford process and the exact auction of Gul and Stacchetti (2000) need gross substitutes so that no bidder must give back a good. In a combinatorial auction with gross substitutes bidders, welfare maximization is solvable in polynomial time with demand queries, and the linear program over bundles has an integral optimum.
  • Submodularity. Every gross substitutes valuation is submodular (Gul and Stacchetti 1999); the budget-additive example shows the converse fails.
  • Gross substitutes for divisible goods. In general equilibrium theory, gross substitutes is a condition on aggregate demand: raising one price does not lower the demand for any other good. It makes the tatonnement process converge. The condition on this page is the version for one buyer and indivisible goods.
  • Substitutes in matching with contracts. Hatfield and Milgrom (2005) use a substitutes condition on choice functions over contracts; with money, it is related to gross substitutes.

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.

gross_substitutes.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/gross-substitutes/. The authors are listed in prov/9N457B.jsonl.
"""Two checks of the gross substitutes property for a valuation on a few goods.

A valuation is a function v from a frozenset of the goods 0, ..., m - 1 to a number, with
v(empty set) = 0. At prices p the utility of a bundle S is v(S) - sum of p over S, and the
demand set D(p) holds the bundles of maximum utility. The valuation has gross substitutes when
for all prices p <= p' and every S in D(p) some T in D(p') contains {j in S : p_j = p'_j}.

check_by_prices tests this definition directly on a finite set of price vectors. It is a brute
force check, meant for 3 goods. check_local tests the local exchange conditions of Reijnierse,
van Gellekom and Potters (2002), which are equivalent to gross substitutes.
"""

from fractions import Fraction
from itertools import combinations, product
from typing import Callable, Optional

Valuation = Callable[[frozenset], object]


def bundles(m: int) -> list[frozenset]:
    return [frozenset(c) for k in range(m + 1) for c in combinations(range(m), k)]


def demand(v: Valuation, prices, m: int) -> list[frozenset]:
    """All bundles of maximum utility at the given prices."""
    util = {S: v(S) - sum((prices[j] for j in S), Fraction(0)) for S in bundles(m)}
    best = max(util.values())
    return [S for S, u in util.items() if u == best]


def check_by_prices(v: Valuation, m: int, points) -> Optional[tuple]:
    """Test the definition on all price vectors with coordinates in points.

    Return None if no violation is found, or a witness (p, q, S): p <= q, S is in D(p), and no
    bundle of D(q) contains the goods of S whose price did not change.
    """
    vecs = list(product(sorted(set(points)), repeat=m))
    dem = {p: demand(v, p, m) for p in vecs}
    for p in vecs:
        for q in vecs:
            if all(a <= b for a, b in zip(p, q)):
                for S in dem[p]:
                    keep = frozenset(j for j in S if p[j] == q[j])
                    if not any(keep <= T for T in dem[q]):
                        return (p, q, S)
    return None


def check_local(v: Valuation, m: int) -> Optional[tuple]:
    """Test the conditions of Reijnierse, van Gellekom and Potters on every bundle S and
    distinct goods i, j, k outside S:

        v(S + i + j) + v(S) <= v(S + i) + v(S + j)
        v(S + i + j) + v(S + k) <= max(v(S + i + k) + v(S + j), v(S + j + k) + v(S + i))

    Return None if both hold everywhere, or a witness (S, i, j) or (S, i, j, k).
    """
    for S in bundles(m):
        out = [x for x in range(m) if x not in S]
        for i, j in combinations(out, 2):
            if v(S | {i, j}) + v(S) > v(S | {i}) + v(S | {j}):
                return (S, i, j)
            for k in out:
                if k in (i, j):
                    continue
                lhs = v(S | {i, j}) + v(S | {k})
                rhs = max(v(S | {i, k}) + v(S | {j}), v(S | {j, k}) + v(S | {i}))
                if lhs > rhs:
                    return (S, i, j, k)
    return None
test_gross_substitutes.py 110 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/gross-substitutes/. The authors are listed in prov/9N457B.jsonl.

import random
import unittest
from fractions import Fraction
from itertools import product

from gross_substitutes import bundles, check_by_prices, check_local, demand

GRID = [0, 1, 2, 3]  # integer prices up to one more than every marginal value of the small tests


def table(m, vals):
    """A valuation given by its values on the nonempty bundles, in the order of bundles(m)."""
    d = dict(zip(bundles(m)[1:], vals))
    d[frozenset()] = 0
    return lambda S: d[frozenset(S)]


def is_monotone(v, m):
    B = bundles(m)
    return all(v(S) <= v(T) for S in B for T in B if S <= T)


def rank_sum_example():
    """The sum of matroid ranks v = r_a + 2 r_b + 3 r_c on goods a, b, c (0, 1, 2) from the
    survey of Paes Leme (2017). Here r_i(S) is 0 on the empty set, 1 on a single good and on
    the pair without i, and 2 otherwise."""

    def r(i, S):
        if not S:
            return 0
        if len(S) == 1 or S == frozenset({0, 1, 2}) - {i}:
            return 1
        return 2

    return lambda S: r(0, S) + 2 * r(1, S) + 3 * r(2, S)


class TestGrossSubstitutes(unittest.TestCase):
    def test_both_checks_agree_on_small_valuations(self):
        rng = random.Random(1)
        monotone = []
        for vals in product(range(3), repeat=7):
            v = table(3, vals)
            if is_monotone(v, 3):
                monotone.append(v)
        self.assertEqual(len(monotone), 148)
        sample = rng.sample(monotone, 40)
        for v in sample:
            self.assertEqual(check_by_prices(v, 3, GRID) is None, check_local(v, 3) is None)
        # Half-integer prices give the same answer on a few of them.
        for v in sample[:5]:
            half = [Fraction(k, 2) for k in range(7)]
            self.assertEqual(check_by_prices(v, 3, half) is None, check_local(v, 3) is None)

    def test_count_of_gs_valuations(self):
        count = 0
        for vals in product(range(3), repeat=7):
            v = table(3, vals)
            if is_monotone(v, 3) and check_local(v, 3) is None:
                count += 1
        self.assertEqual(count, 34)

    def test_known_classes_pass(self):
        rng = random.Random(2)
        for _ in range(60):
            m = rng.randint(1, 4)
            w = [rng.randint(0, 9) for _ in range(m)]
            k = rng.randint(1, m)
            additive = lambda S, w=w: sum(w[j] for j in S)
            unit = lambda S, w=w: max([0] + [w[j] for j in S])
            uniform_rank = lambda S, k=k: min(len(S), k)
            # Weighted rank of a uniform matroid: the best k items.
            best_k = lambda S, w=w, k=k: sum(sorted((w[j] for j in S), reverse=True)[:k])
            for v in (additive, unit, uniform_rank, best_k):
                self.assertIsNone(check_local(v, m))

    def test_complements_break_both(self):
        both = lambda S: 3 if len(S) == 2 else 0
        self.assertIsNotNone(check_local(both, 2))
        self.assertIsNotNone(check_by_prices(both, 2, [0, 1, 2, 3]))

    def test_rank_sum_example(self):
        v = rank_sum_example()
        self.assertEqual([v(S) for S in bundles(3)], [0, 6, 6, 6, 9, 10, 11, 12])
        p = (4, 5, 4)
        q = (4, 5, 13)
        dp = demand(v, p, 3)
        self.assertEqual(
            sorted(dp, key=sorted), sorted([frozenset({0}), frozenset({2}), frozenset({0, 2}), frozenset({1, 2})], key=sorted)
        )
        self.assertEqual(demand(v, q, 3), [frozenset({0})])
        self.assertIsNotNone(check_by_prices(v, 3, [0, 4, 5, 13]))
        self.assertIsNotNone(check_local(v, 3))

    def test_submodular_is_not_enough(self):
        # A budget-additive valuation: submodular, but not gross substitutes.
        v = lambda S: min(sum([2, 2, 3][j] for j in S), 4)
        B = bundles(3)
        for S in B:
            for T in B:
                self.assertLessEqual(v(S | T) + v(S & T), v(S) + v(T))
        self.assertIsNotNone(check_local(v, 3))
        self.assertIsNotNone(check_by_prices(v, 3, [0, 1, 2, 3, 4, 5]))


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

References

  1. Alexander S. Kelso and Vincent P. Crawford, Job matching, coalition formation, and gross substitutes, Econometrica 50(6), 1483 to 1504 (1982), the whole paper (the condition for firms that hire many workers, and the existence of equilibrium)
  2. Faruk Gul and Ennio Stacchetti, Walrasian equilibrium with gross substitutes, Journal of Economic Theory 87(1), 95 to 124 (1999), the whole paper (equivalent conditions, and gross substitutes as the largest class that contains unit demand and always has an equilibrium)
  3. Hans Reijnierse, Anita van Gellekom and Jos A. M. Potters, Verifying gross substitutability, Economic Theory 20(4), 767 to 776 (2002), the whole paper (the local conditions on triples of goods)
  4. Satoru Fujishige and Zaifu Yang, A note on Kelso and Crawford's gross substitutes condition, Mathematics of Operations Research 28(3), 463 to 469 (2003), the whole paper (gross substitutes is the same as M-natural concavity)
  5. Renato Paes Leme, Gross substitutability, an algorithmic survey, Games and Economic Behavior 106, 294 to 316 (2017), Definition 1.3, Theorem 1.4 and Section 2 (examples, and the sum of matroid ranks that is not gross substitutes)

Where this leads

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 proofH0 no proof
  • add a proof in proofs/ (06.5)
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)
WritingW4 complete
  • a review of the text: no review record reviews/9N457B/text.yaml