Algorithm Search⌘K

Modelcore

Congestion game

Also called atomic congestion game, Rosenthal congestion game.

A finite game where each player picks a set of resources and pays the sum of their costs, and each resource cost depends only on how many players use it.

A congestion game models players who share resources, such as links of a network, machines or facilities. Each player picks a set of resources, and each resource charges all its users the same cost, which depends only on the number of its users. The model is atomic: each player is one indivisible unit and its choice changes the loads. That is the difference from the selfish routing model, where traffic is a continuum of tiny users. The result that makes the model useful is Rosenthal's theorem: every congestion game is a potential game and has a pure Nash equilibrium.

The machine

  • Players. A finite set N={1,…,n}N = \{1, \ldots, n\}.
  • Resources. A finite set EE of mm resources. Each resource ee has a cost function ce:{1,…,n}→Rc_e : \{1, \ldots, n\} \to \mathbb{R}, where ce(j)c_e(j) is the cost that each user of ee pays when jj players use it. The standard assumptions are that cec_e is nonnegative and nondecreasing; Rosenthal's theorem needs neither.
  • Strategies. Player ii has a finite set SiS_i of nonempty subsets of EE. A profile is s=(s1,…,sn)s = (s_1, \ldots, s_n) with si∈Sis_i \in S_i, and players use pure strategies unless the text says otherwise.
  • Loads and costs. The load of ee is xe(s)=∣{i:e∈si}∣x_e(s) = |\{i : e \in s_i\}|. Player ii pays ci(s)=∑e∈sice(xe(s))c_i(s) = \sum_{e \in s_i} c_e(x_e(s)) and minimizes it. All players know the game.

Common special cases:

  • Network games. EE is the edge set of a directed graph, and SiS_i is the set of paths from sis_i to tit_i. The game is symmetric if all players have the same source and sink.
  • Symmetric games. All SiS_i are equal.
  • Singleton games. Every strategy is one resource, for example parallel links or identical machines.
  • Matroid games. Each SiS_i is the set of bases of a matroid on EE, for example spanning trees.
  • Affine costs. ce(x)=aex+bec_e(x) = a_e x + b_e with ae,be≥0a_e, b_e \ge 0; linear if be=0b_e = 0.

A congestion game is a normal-form game with a short description: the cost tables and the strategy sets. Network games describe SiS_i by the graph, so a player can have exponentially many strategies.

What it counts

  • The cost of each player, ci(s)c_i(s), which defines the equilibria.
  • The social cost C(s)=∑ici(s)=∑e∈Exe(s) ce(xe(s))C(s) = \sum_i c_i(s) = \sum_{e \in E} x_e(s)\, c_e(x_e(s)), which defines the optimum and so the price of anarchy (the worst equilibrium over the optimum) and the price of stability (the best equilibrium over the optimum). Some papers use the largest player cost, max⁡ici(s)\max_i c_i(s), in its place.
  • Rosenthal's potential Φ(s)=∑e∈E∑j=1xe(s)ce(j)\Phi(s) = \sum_{e \in E} \sum_{j=1}^{x_e(s)} c_e(j), the tool of most proofs. A unilateral deviation changes Φ\Phi by exactly the change in the deviator's cost. With nonnegative nondecreasing costs, Φ(s)≤C(s)≤n Φ(s)\Phi(s) \le C(s) \le n\, \Phi(s), and with affine costs C(s)≤2 Φ(s)C(s) \le 2\, \Phi(s).
  • The number of steps of best-response dynamics, and the time to compute an equilibrium.

Relation to other models

  • Potential games. Every congestion game is an exact potential game, and Monderer and Shapley proved the converse up to isomorphism: every finite exact potential game is isomorphic to a congestion game. The two classes are the same up to renaming.
  • Nonatomic selfish routing. In the selfish routing model the traffic is divisible, the equilibrium is a Wardrop equilibrium, and the potential is the Beckmann potential, an integral in place of Rosenthal's sum. Atomic games can have several equilibria with different costs, and their price of anarchy for affine costs is 5/25/2, against 4/34/3 in the nonatomic model.
  • Load balancing. A load balancing game is a singleton game, usually with weighted jobs and the makespan as social cost.
  • Network design. The Shapley network design game is a congestion game with decreasing costs ce(x)=ce/xc_e(x) = c_e / x: users share the cost of an edge.
  • Weighted and player-specific games. If players have weights and a resource cost depends on the total weight, pure equilibria may not exist (Libman and Orda 2001; Goemans, Mirrokni and Vetta 2005); with affine costs a weighted potential exists (Fotakis, Kontogiannis and Spirakis 2005). If each player has its own cost function per resource, the game leaves the model; for singleton strategies a pure equilibrium still exists (Milchtaich 1996).

Known results in the model

Pure equilibria exist. Every congestion game has a pure Nash equilibrium, because a minimizer of Φ\Phi is one (Rosenthal's theorem). In fact the pure equilibria are exactly the profiles from which no unilateral deviation lowers Φ\Phi.

Best-response dynamics converges. The game has the finite improvement property: every sequence of strict improvements ends, at an equilibrium. The round-robin version is:

  1. BEST-RESPONSE-DYNAMICS(game, s)
  2. 1repeat
  3. 2for each player i in turn:
  4. 3b ← a strategy of i that minimizes c_i(b, s_-i)
  5. 4if c_i(b, s_-i) < c_i(s): s_i ← b ▷ Φ falls by exactly the gain of i
  6. 5until no player moved in a full round; return s

The file proofs/correctness.md proves that each move lowers Φ\Phi by exactly the gain of the player who moves, and that the loop ends at a pure equilibrium. With integer costs it ends after at most Φ(s0)\Phi(s^0) moves, a pseudo-polynomial bound.

Atomic Pigou example. Two players choose between link 1, with cost 2 for any load, and link 2, with cost c(x)=xc(x) = x.

profile player costs social cost CC potential Φ\Phi pure equilibrium
both on link 1 2, 2 4 4 no
one on each link 2, 1 3 3 yes
both on link 2 2, 2 4 3 yes

From "both on link 1", player 1 moves to link 2: its cost falls from 2 to 1, and Φ\Phi falls from 4 to 3. Then player 2 would pay 2 on link 2, no less than on link 1, and the dynamics stops at the split. Both equilibria minimize Φ\Phi, but one costs 3 and the other 4, so the optimum is 3, the price of anarchy is 4/34/3 and the price of stability is 1. In the nonatomic Pigou example the equilibrium is unique; here the indivisible players make a second, worse equilibrium.

Computing an equilibrium. Finding a pure equilibrium is PLS-complete, for general games, for symmetric games and for network games with different sources and sinks, and best-response dynamics can need exponentially many steps (PLS-completeness of congestion games). Symmetric network games are easy: a min-cost flow gives the minimizer of Φ\Phi in polynomial time. In matroid games, best-response dynamics converges after polynomially many moves (Ackermann, Roglin and Vocking 2008). Computing a mixed Nash equilibrium of a congestion game is CLS-complete (Babichenko and Rubinstein, STOC 2021).

Price of anarchy and stability. With affine costs and social cost CC, every pure equilibrium costs at most 5/25/2 times the optimum, and this is tight (price of anarchy of linear congestion games; Christodoulou and Koutsoupias 2005, Awerbuch, Azar and Epstein 2005). The bound extends to mixed, correlated and coarse correlated equilibria by the smoothness framework. With weighted players it is (3+5)/2(3 + \sqrt{5})/2. The price of stability for affine costs is 1+1/3≈1.5771 + 1/\sqrt{3} \approx 1.577 (lower bound by Christodoulou and Koutsoupias, ESA 2005; upper bound by Caragiannis and others, ICALP 2006). For polynomial costs of degree dd with nonnegative coefficients, the price of anarchy grows exponentially in dd (Awerbuch, Azar and Epstein 2005).

Proof: Each best response lowers Rosenthal's potential by the mover's gain, so best-response dynamics stops at a pure Nash equilibriumfull

Let a congestion game have players 1,…,n1, \ldots, n, resources EE, costs ce(1),…,ce(n)c_e(1), \ldots, c_e(n) for each e∈Ee \in E, and finite strategy sets SiS_i of subsets of EE. For a profile ss, xe(s)x_e(s) is the number of players ii with e∈sie \in s_i, player ii pays ci(s)=∑e∈sice(xe(s))c_i(s) = \sum_{e \in s_i} c_e(x_e(s)), and

Φ(s)=∑e∈E∑j=1xe(s)ce(j).\Phi(s) = \sum_{e \in E} \sum_{j=1}^{x_e(s)} c_e(j).

Lemma. If t=(si′,s−i)t = (s_i', s_{-i}), then Φ(t)−Φ(s)=ci(t)−ci(s)\Phi(t) - \Phi(s) = c_i(t) - c_i(s).

Proof. Only the resources in exactly one of sis_i and si′s_i' change load. For e∈si′∖sie \in s_i' \setminus s_i the load goes from xe(s)x_e(s) to xe(s)+1x_e(s) + 1, which adds the term ce(xe(s)+1)=ce(xe(t))c_e(x_e(s) + 1) = c_e(x_e(t)) to Φ\Phi; this is what ii pays for ee in tt. For e∈si∖si′e \in s_i \setminus s_i' the load goes from xe(s)x_e(s) to xe(s)−1x_e(s) - 1, which removes the term ce(xe(s))c_e(x_e(s)); this is what ii paid for ee in ss. For e∈si∩si′e \in s_i \cap s_i' the load and the price to ii do not change. Summing over ee gives the claim. □\square

The dynamics stops. Line L3 picks, for the current player ii, a strategy bb that minimizes ci(b,s−i)c_i(b, s_{-i}), and line L4 moves to t=(b,s−i)t = (b, s_{-i}) only when the gain g=ci(s)−ci(t)g = c_i(s) - c_i(t) is positive. By the lemma Φ\Phi falls by exactly gg, which is what the code records and the tests check. So Φ\Phi strictly falls at each move. The set of profiles is finite, so no profile repeats and the number of moves is less than the number of profiles. With integer costs each move lowers Φ\Phi by at least 1, so the number of moves is also at most Φ(s0)−min⁡sΦ(s)≤Φ(s0)\Phi(s^0) - \min_s \Phi(s) \le \Phi(s^0) when costs are nonnegative.

It stops at an equilibrium. Line L1 ends after a full round of line L2 in which no player moved. In that round, for each player ii, the best response bb of line L3 had ci(b,s−i)≥ci(s)c_i(b, s_{-i}) \ge c_i(s), and since bb minimizes over all of SiS_i, no strategy of ii costs less than ci(s)c_i(s). The profile did not change during the round, so this holds for every player at the same profile, which is the definition of a pure Nash equilibrium. ■\blacksquare

Equilibria are local minima of Φ\Phi. By the lemma, a unilateral deviation lowers the deviator's cost if and only if it lowers Φ\Phi. So ss is a pure Nash equilibrium if and only if no unilateral deviation lowers Φ\Phi. The tests check this set equality by brute force.

Potential and social cost. Let C(s)=∑ici(s)=∑exece(xe)C(s) = \sum_i c_i(s) = \sum_e x_e c_e(x_e). If each cec_e is nonnegative and nondecreasing, then ∑j≤xce(j)≤x ce(x)\sum_{j \le x} c_e(j) \le x\, c_e(x) and x ce(x)≤x∑j≤xce(j)x\, c_e(x) \le x \sum_{j \le x} c_e(j), so Φ(s)≤C(s)≤(max⁡exe) Φ(s)\Phi(s) \le C(s) \le (\max_e x_e)\, \Phi(s). If ce(x)=aex+bec_e(x) = a_e x + b_e with ae,be≥0a_e, b_e \ge 0, then ∑j≤xce(j)=aex(x+1)/2+bex≥(aex2+bex)/2\sum_{j \le x} c_e(j) = a_e x (x + 1)/2 + b_e x \ge (a_e x^2 + b_e x)/2, so C(s)≤2Φ(s)C(s) \le 2 \Phi(s).

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.

atomic_congestion_game.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/atomic-congestion-game/. The authors are listed in prov/AE0S3S.jsonl.

"""Atomic congestion games: costs, Rosenthal's potential and best-response dynamics.

A game is a pair (costs, strategies). costs[e][j - 1] is c_e(j), the cost that each of the
j players on resource e pays. strategies[i] is the list of the strategies of player i, and
each strategy is a set of resource indices. A profile is a tuple whose entry i is the index
of the strategy that player i plays. Players minimize their costs.
"""

import itertools
from fractions import Fraction


def loads(game, profile):
    """Return the number of players on each resource."""
    costs, strategies = game
    x = [0] * len(costs)
    for i, k in enumerate(profile):
        for e in strategies[i][k]:
            x[e] += 1
    return x


def player_cost(game, profile, i):
    """Return c_i(profile), the sum of c_e(x_e) over the resources of player i."""
    costs, strategies = game
    x = loads(game, profile)
    return sum((Fraction(costs[e][x[e] - 1]) for e in strategies[i][profile[i]]), Fraction(0))


def social_cost(game, profile):
    """Return the sum of the players' costs, which is the sum of x_e c_e(x_e) over the resources."""
    costs, _ = game
    x = loads(game, profile)
    return sum((x[e] * Fraction(costs[e][x[e] - 1]) for e in range(len(costs)) if x[e] > 0), Fraction(0))


def rosenthal_potential(game, profile):
    """Return Phi = sum over resources e of c_e(1) + ... + c_e(x_e)."""
    costs, _ = game
    x = loads(game, profile)
    return sum((Fraction(c) for e in range(len(costs)) for c in costs[e][: x[e]]), Fraction(0))


def all_profiles(game):
    _, strategies = game
    return list(itertools.product(*[range(len(s)) for s in strategies]))


def pure_nash(game):
    """All pure Nash equilibria, by checking every unilateral deviation of every profile."""
    _, strategies = game
    out = []
    for p in all_profiles(game):
        if all(
            player_cost(game, p[:i] + (k,) + p[i + 1 :], i) >= player_cost(game, p, i)
            for i in range(len(strategies))
            for k in range(len(strategies[i]))
        ):
            out.append(p)
    return out


def best_response_dynamics(game, start):
    """Run round-robin best-response dynamics from start.

    Return (profile, steps), where profile is a pure Nash equilibrium and steps lists
    (player, gain, drop of Phi) for each move. The theorem says that gain equals the drop.
    """
    _, strategies = game
    s = tuple(start)
    steps = []
    changed = True
    while changed:  # @line L1
        changed = False
        for i in range(len(strategies)):  # @line L2
            current = player_cost(game, s, i)
            best = min(range(len(strategies[i])), key=lambda k: (player_cost(game, s[:i] + (k,) + s[i + 1 :], i), k))  # @line L3
            t = s[:i] + (best,) + s[i + 1 :]
            gain = current - player_cost(game, t, i)
            if gain > 0:  # @line L4
                steps.append((i, gain, rosenthal_potential(game, s) - rosenthal_potential(game, t)))
                s = t
                changed = True
    return s, steps  # @line L5
test_atomic_congestion_game.py 97 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/atomic-congestion-game/. The authors are listed in prov/AE0S3S.jsonl.

import itertools
import random

from atomic_congestion_game import (
    all_profiles,
    best_response_dynamics,
    loads,
    player_cost,
    pure_nash,
    rosenthal_potential,
    social_cost,
)

# Atomic Pigou: link 0 costs 2 for any load, link 1 costs its load.
PIGOU = ([[2, 2], [1, 2]], [[{0}, {1}], [{0}, {1}]])


def test_atomic_pigou():
    table = {p: (social_cost(PIGOU, p), rosenthal_potential(PIGOU, p)) for p in all_profiles(PIGOU)}
    assert table == {(0, 0): (4, 4), (0, 1): (3, 3), (1, 0): (3, 3), (1, 1): (4, 3)}
    assert pure_nash(PIGOU) == [(0, 1), (1, 0), (1, 1)]
    profile, steps = best_response_dynamics(PIGOU, (0, 0))
    assert profile == (1, 0)
    assert steps == [(0, 1, 1)]


def random_game(rng, n, r, k, affine):
    if affine:
        costs = []
        for _ in range(r):
            a, b = rng.randint(0, 3), rng.randint(0, 3)
            costs.append([a * j + b for j in range(1, n + 1)])
    else:
        costs = [sorted(rng.randint(0, 8) for _ in range(n)) for _ in range(r)]
    subsets = [set(c) for size in range(1, r + 1) for c in itertools.combinations(range(r), size)]
    strategies = [rng.sample(subsets, k) for _ in range(n)]
    return costs, strategies


def test_potential_changes_by_the_deviators_gain():
    rng = random.Random(1973)
    for _ in range(50):
        n = rng.randint(2, 4)
        game = random_game(rng, n, rng.randint(2, 4), rng.randint(2, 3), rng.random() < 0.5)
        for p in all_profiles(game):
            for i in range(n):
                for k in range(len(game[1][i])):
                    q = p[:i] + (k,) + p[i + 1 :]
                    assert rosenthal_potential(game, q) - rosenthal_potential(game, p) == player_cost(game, q, i) - player_cost(game, p, i)


def test_equilibria_are_the_local_minima_of_the_potential():
    rng = random.Random(7)
    for _ in range(50):
        n = rng.randint(2, 4)
        game = random_game(rng, n, rng.randint(2, 4), rng.randint(2, 3), False)
        local = []
        for p in all_profiles(game):
            phi = rosenthal_potential(game, p)
            if all(
                rosenthal_potential(game, p[:i] + (k,) + p[i + 1 :]) >= phi
                for i in range(n)
                for k in range(len(game[1][i]))
            ):
                local.append(p)
        assert local == pure_nash(game)
        assert local


def test_best_response_dynamics():
    rng = random.Random(2016)
    for _ in range(60):
        n = rng.randint(2, 4)
        game = random_game(rng, n, rng.randint(2, 4), rng.randint(2, 3), rng.random() < 0.5)
        start = tuple(rng.randrange(len(s)) for s in game[1])
        profile, steps = best_response_dynamics(game, start)
        assert profile in pure_nash(game)
        for _, gain, drop in steps:
            assert gain > 0 and gain == drop
        assert sum(d for _, _, d in steps) == rosenthal_potential(game, start) - rosenthal_potential(game, profile)


def test_potential_and_social_cost():
    rng = random.Random(3)
    for _ in range(40):
        n = rng.randint(2, 4)
        affine = rng.random() < 0.5
        game = random_game(rng, n, rng.randint(2, 4), rng.randint(2, 3), affine)
        for p in all_profiles(game):
            phi, cost = rosenthal_potential(game, p), social_cost(game, p)
            assert phi <= cost <= max(loads(game, p)) * phi
            if affine:
                assert cost <= 2 * phi
            assert cost == sum(player_cost(game, p, i) for i in range(n))

References

  1. Robert W. Rosenthal, A class of games possessing pure-strategy Nash equilibria, International Journal of Game Theory 2 (1973), 65-67, the definition of congestion games and the potential that proves they have pure equilibria
  2. Dov Monderer and Lloyd S. Shapley, Potential games, Games and Economic Behavior 14(1) (1996), 124-143, the isomorphism between finite exact potential games and congestion games
  3. Alex Fabrikant, Christos Papadimitriou and Kunal Talwar, The complexity of pure Nash equilibria, Proceedings of the 36th Annual ACM Symposium on Theory of Computing (STOC 2004), 604-612, PLS-completeness of finding a pure equilibrium, and the polynomial case of symmetric network games
  4. George Christodoulou and Elias Koutsoupias, The price of anarchy of finite congestion games, Proceedings of the 37th Annual ACM Symposium on Theory of Computing (STOC 2005), 67-73, the price of anarchy 5/2 for linear costs
  5. Baruch Awerbuch, Yossi Azar and Amir Epstein, The price of routing unsplittable flow, Proceedings of the 37th Annual ACM Symposium on Theory of Computing (STOC 2005), 57-66, the price of anarchy 5/2 for linear costs, (3 + 5^(1/2))/2 for weighted players, and the bounds for polynomial costs
  6. Tim Roughgarden, Twenty Lectures on Algorithmic Game Theory, Cambridge University Press, 2016, Lecture 12 (atomic selfish routing), Lecture 13 (potential games) and Lecture 16 (best-response dynamics)

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 proofH2 full proof
  • correctness: no review record reviews/AE0S3S/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)
WritingW4 complete
  • a review of the text: no review record reviews/AE0S3S/text.yaml