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 .
- Resources. A finite set of resources. Each resource has a cost function , where is the cost that each user of pays when players use it. The standard assumptions are that is nonnegative and nondecreasing; Rosenthal's theorem needs neither.
- Strategies. Player has a finite set of nonempty subsets of . A profile is with , and players use pure strategies unless the text says otherwise.
- Loads and costs. The load of is . Player pays and minimizes it. All players know the game.
Common special cases:
- Network games. is the edge set of a directed graph, and is the set of paths from to . The game is symmetric if all players have the same source and sink.
- Symmetric games. All are equal.
- Singleton games. Every strategy is one resource, for example parallel links or identical machines.
- Matroid games. Each is the set of bases of a matroid on , for example spanning trees.
- Affine costs. with ; linear if .
A congestion game is a normal-form game with a short description: the cost tables and the strategy sets. Network games describe by the graph, so a player can have exponentially many strategies.
What it counts
- The cost of each player, , which defines the equilibria.
- The social cost , 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, , in its place.
- Rosenthal's potential , the tool of most proofs. A unilateral deviation changes by exactly the change in the deviator's cost. With nonnegative nondecreasing costs, , and with affine costs .
- 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 , against 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 : 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 is one (Rosenthal's theorem). In fact the pure equilibria are exactly the profiles from which no unilateral deviation lowers .
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:
BEST-RESPONSE-DYNAMICS(game, s)- 1
repeat - 2
for each player i in turn: - 3
b ← a strategy of i that minimizes c_i(b, s_-i) - 4
if c_i(b, s_-i) < c_i(s): s_i ← b ▷ Φ falls by exactly the gain of i - 5
until no player moved in a full round; return s
The file proofs/correctness.md proves that each move lowers 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 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 .
| profile | player costs | social cost | potential | 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 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 , but one costs 3 and the other 4, so the optimum is 3, the price of anarchy is 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 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 , every pure equilibrium costs at most 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 . The price of stability for affine costs is (lower bound by Christodoulou and Koutsoupias, ESA 2005; upper bound by Caragiannis and others, ICALP 2006). For polynomial costs of degree with nonnegative coefficients, the price of anarchy grows exponentially in (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 , resources , costs for each , and finite strategy sets of subsets of . For a profile , is the number of players with , player pays , and
Lemma. If , then .
Proof. Only the resources in exactly one of and change load. For the load goes from to , which adds the term to ; this is what pays for in . For the load goes from to , which removes the term ; this is what paid for in . For the load and the price to do not change. Summing over gives the claim.
The dynamics stops. Line L3 picks, for the current player , a strategy that minimizes , and line L4 moves to only when the gain is positive. By the lemma falls by exactly , which is what the code records and the tests check. So 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 by at least 1, so the number of moves is also at most 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 , the best response of line L3 had , and since minimizes over all of , no strategy of costs less than . 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.
Equilibria are local minima of . By the lemma, a unilateral deviation lowers the deviator's cost if and only if it lowers . So is a pure Nash equilibrium if and only if no unilateral deviation lowers . The tests check this set equality by brute force.
Potential and social cost. Let . If each is nonnegative and nondecreasing, then and , so . If with , then , so .
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.
# 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
- 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
- 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
- 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
- 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
- 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
- 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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H2 full proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag AE0S3S Edit this page History Report an error Markdown