Definitioncore
Potential game
Also called exact potential game, Monderer-Shapley potential game.
A game with a function on profiles whose change under any unilateral deviation equals the change in the deviator's cost.
A potential game is a game with one function on the strategy profiles that tracks the cost of whichever player moves: when one player changes strategy, the function changes by exactly the change in that player's cost. It is the property, not a result. The finite improvement property is a weaker property of the dynamics that every finite potential game has. Rosenthal's theorem is the result that every atomic congestion game is a potential game, and congestion games are the main example: Monderer and Shapley showed that every finite exact potential game is isomorphic to one.
Definition
A game in normal form has players , strategy sets , and costs on the profiles . Each player minimizes its own cost. For a profile , a player and a strategy , the profile is a unilateral deviation of .
A function is an exact potential of the game if for every profile , every player and every ,
The game is an (exact) potential game if it has an exact potential. Monderer and Shapley also defined three weaker forms. In each, the condition is on every unilateral deviation from to :
- Weighted potential, with weights : .
- Ordinal potential: if and only if .
- Generalized ordinal potential: implies .
Each form implies the next. Monderer and Shapley wrote payoffs that players maximize; with costs the signs flip, and players move to lower values of .
The definition has four direct consequences, each with a short proof.
- Uniqueness. Any two exact potentials differ by a constant. Two profiles are joined by a chain of unilateral deviations, one coordinate at a time, and along the chain the change of is fixed by the costs.
- Equilibria are local minima. Call a local minimum of if no unilateral deviation lowers . With an ordinal potential, is a pure Nash equilibrium if and only if it is a local minimum, because a deviation lowers the deviator's cost exactly when it lowers . With a generalized ordinal potential every local minimum is an equilibrium. So a finite game with a generalized ordinal potential has a pure equilibrium: a global minimum of .
- Coordination plus dummy. A game has an exact potential if and only if for functions that do not depend on . If is an exact potential, set ; a deviation of changes and by the same amount, so it does not change . The converse is immediate. So every potential game is a game of identical costs plus, for each player, a cost that the player cannot influence.
- The cycle test. In a finite game, an exact potential exists if and only if, for every two players , every profile and every , , the four deviations , made by , , , in turn, have deviators' cost changes that sum to zero.
Proof of the cycle test. If exists, the four changes are the four changes of around a closed path, which sum to zero. For the converse, number the strategies of each player from 0, let , and define as the sum of the deviators' cost changes along the canonical path from to that sets coordinate 1 to , then coordinate 2 to , and so on, skipping steps that change nothing. Two observations hold for any path of unilateral deviations. Swapping two adjacent steps of different players, both of which change something, does not change the sum, by the 4-cycle condition. Merging two adjacent steps of the same player, , into one step does not change the sum, because both give , and a merged step contributes 0 and can be dropped. Now let with . The canonical path to followed by the step goes from to . Swap the last step back past the steps of players , then merge it with the step of player . The result is the canonical path to , with the same sum. So , and is an exact potential.
Testing a finite game
The proof of uniqueness gives a direct test: fix the value at one profile, spread values along unilateral deviations, and check every deviation.
EXACT-POTENTIAL(S_1, ..., S_n, c)- 1
Φ(s0) ← 0 for the profile s0 = (0, ..., 0); Q ← [s0] - 2
while Q is not empty: take a profile s from Q - 3
for each player i and each s_i' ≠ s_i, with t = (s_i', s_-i): - 4
if Φ(t) is not set: Φ(t) ← Φ(s) + c_i(t) - c_i(s); put t in Q - 5
else if Φ(t) ≠ Φ(s) + c_i(t) - c_i(s): return "no exact potential" - 6
return Φ
The search takes steps, which is linear in the size of the cost table times . The file proofs/correctness.md proves that it returns a potential exactly when one exists. With exact rational costs no tolerance is needed.
Examples and non-examples
The prisoner's dilemma. In cost form, with C to cooperate and D to defect, the costs (player 1, player 2) are at (C, C), at (C, D), at (D, C) and at (D, D). The function , , is an exact potential: each change from C to D lowers the deviator's cost by 1 and lowers by 1. Its minimum (D, D) is the only pure equilibrium, although (C, C) has a lower total cost, so the potential is not the social cost.
Congestion games. In an atomic congestion game, , where is the number of players on resource , is an exact potential. This is Rosenthal's theorem. The routing games of selfish routing with finitely many players and the Shapley network design game are special cases.
Identical costs. If all players have the same cost function , then is an exact potential. Coordination games are of this type.
An ordinal potential that is not exact. Two players choose A or B. Player 1 pays 0 at (A, A), 1 at (B, A), 0 at (A, B) and 2 at (B, B). Player 2 pays 0 at (A, A), 1 at (A, B), 0 at (B, A) and 1 at (B, B). Around the cycle (A, A), (B, A), (B, B), (A, B), (A, A), the deviators' cost changes are , , and , which sum to , so by the cycle test there is no exact potential. But each player pays more when it plays B, so the number of players who play B is an ordinal potential, and (A, A) is the unique pure equilibrium.
Matching pennies. Player 1 pays 0 when the two coins match and 1 otherwise, and player 2 pays the opposite. From every profile one player gains by switching, so the four profiles form a cycle of strict improvements, and there is no pure equilibrium. By consequence 2, the game has no generalized ordinal potential.
An infinite non-example. One player picks and pays . Then is an exact potential, but no strategy is best and there is no equilibrium. The existence of a pure equilibrium needs a finite game, or a compact strategy space with a continuous potential.
Weighted congestion games. If players have weights and the cost of a resource depends on the total weight on it, the game can have no pure equilibrium and then has no potential (Libman and Orda 2001; Goemans, Mirrokni and Vetta 2005). With affine costs it has a weighted potential (Fotakis, Kontogiannis and Spirakis 2005).
Related definitions
- Finite improvement property: every path of strict unilateral improvements is finite. A finite game has it if and only if it has a generalized ordinal potential (Monderer and Shapley 1996).
- Pure Nash equilibrium: in a potential game, the local minima of the potential, as shown above.
- Best-response dynamics: in a finite potential game it stops at an equilibrium, because falls at each step. The number of steps can be exponential: computing a pure equilibrium of a congestion game is PLS-complete.
- Beckmann potential: the potential of nonatomic selfish routing, an integral in place of a sum; its minimizers are the Wardrop equilibria.
- Price of stability: the potential function method bounds it. If for the social cost and every profile , then a global minimizer of has for an optimum , so the price of stability is at most . The harmonic bound for network design comes from this argument.
- Fictitious play: Monderer and Shapley also showed that fictitious play converges in beliefs in games with identical interests (Journal of Economic Theory 68 (1996), 258-265), and so in weighted potential games, which have the same best responses.
Proof: The search over unilateral deviations finds an exact potential exactly when one existsfull
Let a finite cost game have players , strategy sets and costs , where . Call two profiles neighbours if they differ in the strategy of exactly one player ; for neighbours and that differ in player , write . Then . A function on is an exact potential if and only if for all neighbours .
Every profile gets a value. From the start profile , any profile is reached by changing the coordinates one at a time, so the neighbour graph is connected. Line L4 gives a value to each new neighbour of a profile taken from the queue and puts it in the queue, so, unless line L5 stops the search, every profile of the connected graph gets a value and is taken from the queue once.
If the code returns , it is an exact potential. Let and be neighbours. Both are taken from the queue at some time. When is taken, line L3 looks at . Either has no value yet and line L4 sets , or it has one and line L5 checks the same equation. So holds for every pair of neighbours.
If the code returns None, no exact potential exists. Suppose is an exact potential. By induction on the order in which line L4 sets values, for every profile with a value: it holds at , and line L4 sets . So every check of line L5 compares with , which are equal, and line L5 never returns None.
Uniqueness. The same induction shows that any two exact potentials differ by a constant, because both are fixed by their value at along the search tree.
Cost. Each profile is taken from the queue once and has neighbours, so the search does steps.
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/potential-game/. The authors are listed in prov/9E88DE.jsonl.
"""Exact potentials of finite cost games.
A game is a pair (sizes, cost). sizes[i] is the number of pure strategies of player i,
numbered from 0, and cost maps each profile (a tuple) to the tuple of the players' costs,
which each player minimizes. An exact potential is a function phi on profiles with
phi(t) - phi(s) = cost[t][i] - cost[s][i] whenever t differs from s only in the strategy of i.
"""
import itertools
from fractions import Fraction
def profiles(sizes):
"""All pure profiles, in lexicographic order."""
return list(itertools.product(*[range(k) for k in sizes]))
def deviations(sizes, s):
"""Yield (i, t) for every profile t that differs from s only in the strategy of player i."""
for i, k in enumerate(sizes):
for a in range(k):
if a != s[i]:
yield i, s[:i] + (a,) + s[i + 1 :]
def exact_potential(sizes, cost):
"""Return an exact potential as a dict from profiles to Fraction, with value 0 at the first profile, or None."""
start = tuple(0 for _ in sizes)
phi = {start: Fraction(0)} # @line L1
queue = [start]
while queue: # @line L2
s = queue.pop()
for i, t in deviations(sizes, s): # @line L3
value = phi[s] + Fraction(cost[t][i]) - Fraction(cost[s][i])
if t not in phi: # @line L4
phi[t] = value
queue.append(t)
elif phi[t] != value: # @line L5
return None
return phi # @line L6
def is_exact_potential(sizes, cost, phi):
"""Check the defining equation on every unilateral deviation, exactly."""
return all(
phi[t] - phi[s] == cost[t][i] - cost[s][i] for s in profiles(sizes) for i, t in deviations(sizes, s)
)
def four_cycle_sums(sizes, cost):
"""Return the set of sums of the deviators' cost changes around all 4-cycles of two players."""
sums = set()
for s in profiles(sizes):
for i, j in itertools.combinations(range(len(sizes)), 2):
for a in range(sizes[i]):
for b in range(sizes[j]):
if a == s[i] or b == s[j]:
continue
p = s[:i] + (a,) + s[i + 1 :]
q = p[:j] + (b,) + p[j + 1 :]
r = s[:j] + (b,) + s[j + 1 :]
total = (
(cost[p][i] - cost[s][i])
+ (cost[q][j] - cost[p][j])
+ (cost[r][i] - cost[q][i])
+ (cost[s][j] - cost[r][j])
)
sums.add(Fraction(total))
return sums
def pure_nash(sizes, cost):
"""All pure Nash equilibria, by brute force over unilateral deviations."""
return [s for s in profiles(sizes) if all(cost[t][i] >= cost[s][i] for i, t in deviations(sizes, s))]
test_potential_game.py 111 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/potential-game/. The authors are listed in prov/9E88DE.jsonl.
import itertools
import random
from fractions import Fraction
from potential_game import (
deviations,
exact_potential,
four_cycle_sums,
is_exact_potential,
profiles,
pure_nash,
)
C, D = 0, 1
PD = {(C, C): (1, 1), (C, D): (3, 0), (D, C): (0, 3), (D, D): (2, 2)}
MATCHING_PENNIES = {(0, 0): (0, 1), (1, 1): (0, 1), (0, 1): (1, 0), (1, 0): (1, 0)}
ORDINAL_ONLY = {(0, 0): (0, 0), (1, 0): (1, 0), (0, 1): (0, 1), (1, 1): (2, 1)}
def shifted(phi, s):
return {t: v - phi[s] for t, v in phi.items()}
def test_prisoners_dilemma():
phi = exact_potential((2, 2), PD)
phi = {t: v + 2 for t, v in phi.items()}
assert phi == {(C, C): 2, (C, D): 1, (D, C): 1, (D, D): 0}
assert pure_nash((2, 2), PD) == [(D, D)]
def test_no_exact_potential():
assert exact_potential((2, 2), MATCHING_PENNIES) is None
assert pure_nash((2, 2), MATCHING_PENNIES) == []
assert exact_potential((2, 2), ORDINAL_ONLY) is None
assert four_cycle_sums((2, 2), ORDINAL_ONLY) == {1, -1}
count_b = {s: sum(s) for s in ORDINAL_ONLY}
for s in ORDINAL_ONLY:
for i, t in deviations((2, 2), s):
assert (ORDINAL_ONLY[t][i] < ORDINAL_ONLY[s][i]) == (count_b[t] < count_b[s])
def random_congestion_game(rng, n, r, k):
"""n players, r resources with cost tables, k strategies (nonempty resource sets) per player."""
table = [[rng.randint(0, 6) for _ in range(n)] for _ in range(r)]
subsets = [frozenset(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)]
sizes = tuple(k for _ in range(n))
cost, rosenthal = {}, {}
for s in profiles(sizes):
load = [sum(1 for i in range(n) if e in strategies[i][s[i]]) for e in range(r)]
cost[s] = tuple(sum(table[e][load[e] - 1] for e in strategies[i][s[i]]) for i in range(n))
rosenthal[s] = Fraction(sum(table[e][j] for e in range(r) for j in range(load[e])))
return sizes, cost, rosenthal
def test_congestion_games_have_the_rosenthal_potential():
rng = random.Random(1973)
for _ in range(40):
n = rng.randint(2, 4)
sizes, cost, rosenthal = random_congestion_game(rng, n, rng.randint(2, 4), rng.randint(2, 3))
for s in profiles(sizes):
for i, t in deviations(sizes, s):
assert rosenthal[t] - rosenthal[s] == cost[t][i] - cost[s][i]
phi = exact_potential(sizes, cost)
assert phi is not None
start = profiles(sizes)[0]
assert shifted(phi, start) == shifted(rosenthal, start)
low = min(phi.values())
minimizers = [s for s in phi if phi[s] == low]
assert set(minimizers) <= set(pure_nash(sizes, cost))
def test_coordination_plus_dummy():
rng = random.Random(1996)
for _ in range(40):
sizes = tuple(rng.randint(2, 4) for _ in range(rng.randint(2, 3)))
base = {s: rng.randint(-5, 5) for s in profiles(sizes)}
dummy = [dict() for _ in sizes]
cost = {}
for s in profiles(sizes):
parts = []
for i in range(len(sizes)):
key = s[:i] + s[i + 1 :]
if key not in dummy[i]:
dummy[i][key] = rng.randint(-5, 5)
parts.append(base[s] + dummy[i][key])
cost[s] = tuple(parts)
phi = exact_potential(sizes, cost)
assert is_exact_potential(sizes, cost, phi)
start = profiles(sizes)[0]
assert shifted(phi, start) == shifted({s: Fraction(v) for s, v in base.items()}, start)
def test_four_cycle_characterization():
rng = random.Random(44)
seen = {True: 0, False: 0}
for trial in range(150):
sizes = tuple(rng.randint(2, 3) for _ in range(rng.randint(2, 3)))
base = {s: rng.randint(0, 4) for s in profiles(sizes)}
cost = {s: tuple(base[s] for _ in sizes) for s in base}
if trial % 2:
s = rng.choice(profiles(sizes))
i = rng.randrange(len(sizes))
cost[s] = cost[s][:i] + (cost[s][i] + rng.randint(1, 3),) + cost[s][i + 1 :]
exists = exact_potential(sizes, cost) is not None
assert exists == (four_cycle_sums(sizes, cost) <= {0})
seen[exists] += 1
assert seen[True] > 0 and seen[False] > 0
References
- Dov Monderer and Lloyd S. Shapley, Potential games, Games and Economic Behavior 14(1) (1996), 124-143, Section 2 (exact, weighted, ordinal and generalized ordinal potentials, the finite improvement property, the cycle test and the uniqueness of the potential) and the isomorphism between finite potential games and congestion games
- Robert W. Rosenthal, A class of games possessing pure-strategy Nash equilibria, International Journal of Game Theory 2 (1973), 65-67, congestion games and the potential function that proves they have pure equilibria
- Tim Roughgarden, Twenty Lectures on Algorithmic Game Theory, Cambridge University Press, 2016, Lecture 13 (potential games and the existence of pure Nash equilibria) and Lecture 16 (best-response dynamics)
- Noam Nisan, Tim Roughgarden, Eva Tardos and Vijay V. Vazirani (eds.), Algorithmic Game Theory, Cambridge University Press, 2007, Chapter 19 (Eva Tardos and Tom Wexler, Network formation games and the potential function method)
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 9E88DE Edit this page History Report an error Markdown