Algorithm Search⌘K

Algorithmcore

Eisenberg-Gale convex program

Also called Eisenberg-Gale program.

Finds equilibrium allocations of a linear Fisher market by maximizing the budget-weighted sum of log utilities. Its dual variables are prices.

Time
O(T (n + m) n^2 m^2) worst
Space
O(n m) extra
Where
T = the number of rounds of mirror ascent; m = the number of goods; n = the number of buyers
Properties
deterministiciterative
Origin
Edmund Eisenberg, David Gale, 1959

The Eisenberg-Gale program is a convex optimization problem whose optimal solutions are exactly the equilibrium allocations of a Fisher market with linear utilities. It maximizes the sum over buyers of the budget times the logarithm of the utility, subject only to the supply of each good. The Lagrange multipliers of the supply constraints are the equilibrium prices. So a market equilibrium, defined by the selfish choices of buyers at given prices, is also the optimum of one global objective, and anything that solves convex programs computes it: the ellipsoid method, interior point methods (Ye 2008), first-order methods, and the combinatorial DPSV algorithm and Orlin's algorithm, which are guided by its optimality conditions. With equal budgets the objective is the Nash social welfare, which links Fisher markets to maximum Nash welfare, CEEI and proportional fairness.

In plain words

Each buyer brings money and likes some goods more than others. Instead of searching for prices, give the goods out so that a single score is as high as possible. The score adds up, for each buyer, her money times the logarithm of how happy she is. The logarithm means that taking from a happy buyer to help an unhappy one often raises the score, and the money weights give richer buyers more say. The best split of the goods is exactly what the buyers would choose if the right prices were posted. Those prices can be read off the best split: a good costs what the buyer who wants it most is willing to pay per unit at that split.

The problem

There are nn buyers and mm goods, with one unit of each good. Buyer ii has a budget ei>0e_i > 0 and a linear utility Ui(xi)=∑juijxijU_i(x_i) = \sum_j u_{ij} x_{ij} with uij≥0u_{ij} \ge 0. Every buyer likes some good and every good is liked by some buyer. The Eisenberg-Gale program is

max⁡  ∑ieilog⁡∑juijxijsubject to∑ixij≤1 for every good j,x≥0.\max \; \sum_i e_i \log \sum_j u_{ij} x_{ij} \quad \text{subject to} \quad \sum_i x_{ij} \le 1 \text{ for every good } j, \qquad x \ge 0 .

With a multiplier pj≥0p_j \ge 0 for the supply of good jj, the KKT conditions are

  1. pj>0  ⟹  ∑ixij=1p_j > 0 \implies \sum_i x_{ij} = 1;
  2. eiuij/Ui≤pje_i u_{ij} / U_i \le p_j for all i,ji, j, that is, uij/pj≤Ui/eiu_{ij} / p_j \le U_i / e_i;
  3. xij>0  ⟹  eiuij/Ui=pjx_{ij} > 0 \implies e_i u_{ij} / U_i = p_j.

Condition 2 says that no good gives buyer ii more utility per unit of money (bang per buck) than Ui/eiU_i / e_i, and condition 3 says that she buys only goods that reach it. Multiplying condition 3 by xijx_{ij} and summing over jj gives ∑jpjxij=ei\sum_j p_j x_{ij} = e_i: she spends exactly her budget. These are the equilibrium conditions of the Fisher market. The task is to find the prices pp and an optimal allocation xx, exactly.

The algorithm

The implementation solves the program by mirror ascent with the entropy on each good (mirror descent for a maximization, also called exponentiated gradient), in floating point, and then rounds to an exact answer that it certifies with a maximum flow in exact arithmetic. Here f(x)f(x) is the objective, g=∇fg = \nabla f, and KL(y∥x)=∑ijyijlog⁡(yij/xij)\mathrm{KL}(y \| x) = \sum_{ij} y_{ij} \log(y_{ij} / x_{ij}).

  1. EISENBERG-GALE(utilities u, budgets e)
  2. 1x_ij ← 1 / (number of buyers who like j) for every edge u_ij > 0, else 0
  3. 2η ← 1
  4. 3for round = 1, 2, ... do
  5. 4g_ij ← e_i u_ij / U_i(x) for every edge
  6. 5y_ij ← x_ij exp(η g_ij) / Σ_k x_kj exp(η g_kj) for every edge (normalized per good)
  7. 6if f(y) < f(x) + g·(y - x) - KL(y ‖ x) / η then η ← η / 2 and go to L5
  8. 7x ← y; η ← 2η
  9. 8every 5 rounds: for δ = 10^-2, ..., 10^-14: S ← {x_ij > δ}; p ← the prices that S forces;
  10. if p passes the exact max-flow check, return p and the flow allocation

Line L5 is the closed-form maximizer of g⋅y−KL(y∥x)/ηg \cdot y - \mathrm{KL}(y \| x)/\eta over allocations that give out each good completely. Line L6 is a backtracking test: it accepts the step only if the program's objective is at least the model that the step maximized, which makes ff increase in every round.

Line L8 rounds. A guessed support SS forces the prices: on each connected part of SS, every buyer gets the same bang per buck on all her edges, which fixes the ratios of the prices, and the prices of the part add up to the budgets of its buyers. The check then computes, in Fraction, the maximum bang per buck αi=max⁡juij/pj\alpha_i = \max_j u_{ij} / p_j of each buyer and a maximum flow in the network source →\to good jj (capacity pjp_j) →\to buyer ii (only if uij/pj=αiu_{ij} / p_j = \alpha_i) →\to sink (capacity eie_i). The prices are accepted if they sum to ∑iei\sum_i e_i and the flow has value ∑iei\sum_i e_i; then xijx_{ij} is the flow from jj to ii divided by pjp_j.

Example

Three buyers and two goods: u1=(2,1)u_1 = (2, 1), u2=(1,2)u_2 = (1, 2), u3=(1,1)u_3 = (1, 1), budgets e=(1,1,2)e = (1, 1, 2). Line L1 gives every buyer 1/31/3 of each good. In the table, buyer 3 holds the same amount of both goods at every round, ff is the objective, and the last column is the KKT estimate max⁡ieiui1/Ui\max_i e_i u_{i1} / U_i of p1p_1 (by symmetry, p2p_2 has the same estimate).

round η\eta used buyer 1 (x11,x12)(x_{11}, x_{12}) buyer 3, each good ff estimate of p1p_1
0 (0.3333,0.3333)(0.3333, 0.3333) 0.33330.3333 −0.81093-0.81093
1 0.5 (0.3072,0.1863)(0.3072, 0.1863) 0.50650.5065 −0.41874-0.41874 2.49782.4978
2 1 (0.4649,0.0809)(0.4649, 0.0809) 0.45420.4542 −0.17082-0.17082 2.20172.2017
3 1 (0.4375,0.0283)(0.4375, 0.0283) 0.53420.5342 −0.07106-0.07106 2.21402.2140
4 0.5 (0.4840,0.0180)(0.4840, 0.0180) 0.49800.4980 −0.03621-0.03621 2.02852.0285
5 1 (0.4947,0.0067)(0.4947, 0.0067) 0.49870.4987 −0.01337-0.01337 2.00802.0080

At round 5, line L8 with δ=10−2\delta = 10^{-2} drops the edge (1,2)(1, 2) and keeps S={(1,1),(2,2),(3,1),(3,2)}S = \{(1, 1), (2, 2), (3, 1), (3, 2)\}. SS is connected; the bang per buck conditions give p1=p2p_1 = p_2 (from buyer 3), and the prices add up to the total budget 44, so p=(2,2)p = (2, 2). At these prices, buyer 1 spends 11 on good 1, buyer 2 spends 11 on good 2, and buyer 3, who is indifferent, spends 11 on each good. The flow saturates, so the answer is certified: x1=(1/2,0)x_1 = (1/2, 0), x2=(0,1/2)x_2 = (0, 1/2), x3=(1/2,1/2)x_3 = (1/2, 1/2), all utilities are 11, and the optimal value is 00. The ascent itself would need many more rounds to reach this point in floating point.

Correctness

The proof is in proofs/correctness.md. It shows:

  1. The program solves the market. An allocation is optimal if and only if, with some prices, it is a Fisher market equilibrium, and the prices are then the KKT multipliers. Because log⁡\log is strictly concave, the optimal utilities UiU_i are unique, and so are the prices pj=max⁡ieiuij/Uip_j = \max_i e_i u_{ij} / U_i. The allocation need not be unique.
  2. Each round improves the objective. Line L6 can always be met by a small enough η\eta, and when it holds, f(y)≥f(x)f(y) \ge f(x), because yy maximizes the model that line L6 compares with.
  3. The output is exact. Whatever line L8 guesses, it returns only prices that pass the max-flow check, and passing it means each buyer spends her whole budget on goods of maximum bang per buck and every good is sold. By point 1 the returned xx is optimal.
  4. It terminates. The iterates converge to an optimal allocation xˉ\bar{x}; once they are close, a threshold between their distance to xˉ\bar{x} and the smallest positive entry of xˉ\bar{x} recovers the support of xˉ\bar{x}, which forces the equilibrium prices. This needs the smallest positive entry of xˉ\bar{x} to be above about 2⋅10−142 \cdot 10^{-14}, and the implementation stops with an error otherwise.
Proof: The Eisenberg-Gale program gives the Fisher equilibrium, and the certified mirror ascent returns it exactlyfull

Fix nn buyers with budgets ei>0e_i > 0 and mm goods with one unit each, and linear utilities Ui(x)=∑juijxijU_i(x) = \sum_j u_{ij} x_{ij} with uij≥0u_{ij} \ge 0. Every buyer likes some good and every good is liked by some buyer. Let E={(i,j):uij>0}E = \{(i, j) : u_{ij} > 0\} be the edges, f(x)=∑ieilog⁡Ui(x)f(x) = \sum_i e_i \log U_i(x), and X={x≥0:∑ixij≤1 for all j}X = \{x \ge 0 : \sum_i x_{ij} \le 1 \text{ for all } j\}.

Claim 1 (Eisenberg and Gale). The program max⁡x∈Xf(x)\max_{x \in X} f(x) has an optimum. An allocation x∈Xx \in X is optimal if and only if there are prices pp such that (p,x)(p, x) is a Fisher market equilibrium. The optimal utilities are unique, and the equilibrium prices are unique: pj=max⁡ieiuij/Ui∗p_j = \max_i e_i u_{ij} / U^*_i.

Proof. The point x0x^0 that splits each good evenly among the buyers who like it has Ui(x0)>0U_i(x^0) > 0 for all ii. The set {x∈X:f(x)≥f(x0)}\{x \in X : f(x) \ge f(x^0)\} is closed (on it every UiU_i is bounded below by a positive number, since every other term of ff is bounded above) and bounded, and ff is continuous there, so an optimum exists. The constraints are linear, so the KKT conditions are necessary and sufficient for optimality of the concave objective: xx is optimal if and only if there is p≥0p \ge 0 with

(K1) pj>0  ⟹  ∑ixij=1p_j > 0 \implies \sum_i x_{ij} = 1; (K2) eiuij/Ui≤pje_i u_{ij} / U_i \le p_j for all i,ji, j; (K3) xij>0  ⟹  eiuij/Ui=pjx_{ij} > 0 \implies e_i u_{ij} / U_i = p_j.

KKT implies equilibrium. By (K2), uij/pj≤Ui/eiu_{ij} / p_j \le U_i / e_i for every good, so αi=Ui/ei\alpha_i = U_i / e_i bounds the bang per buck, and by (K3) every good that ii buys reaches it. Multiplying (K3) by xijx_{ij} and summing gives ∑jpjxij=(ei/Ui)∑juijxij=ei\sum_j p_j x_{ij} = (e_i / U_i) \sum_j u_{ij} x_{ij} = e_i. A buyer with linear utility who spends her whole budget on goods of maximum bang per buck has an optimal bundle, since any bundle of cost at most eie_i gives utility at most αiei\alpha_i e_i. Every good jj is liked by some ii, so pj≥eiuij/Ui>0p_j \ge e_i u_{ij} / U_i > 0, and by (K1) it is sold completely. So (p,x)(p, x) is an equilibrium.

Equilibrium implies KKT. Let (p,x)(p, x) be an equilibrium. Every good is liked by someone, so every price is positive (a free good would be demanded without limit), and every good is sold completely, which is (K1). Buyer ii spends eie_i only on goods of maximum bang per buck αi\alpha_i, so Ui=αieiU_i = \alpha_i e_i. Then eiuij/Ui=uij/αi≤pje_i u_{ij} / U_i = u_{ij} / \alpha_i \le p_j, with equality when xij>0x_{ij} > 0; these are (K2) and (K3). So xx is optimal, with multipliers pp.

Uniqueness. If xx and x′x' are both optimal with U(x)≠U(x′)U(x) \ne U(x'), then (x+x′)/2(x + x')/2 is feasible and, because log⁡\log is strictly concave, has a strictly larger objective. So U∗=U(x)U^* = U(x) is the same for all optimal xx. For each good jj, some buyer buys it, and by (K2) and (K3) pj=max⁡ieiuij/Ui∗p_j = \max_i e_i u_{ij} / U^*_i. □\square

Claim 2 (the step of line L5). For x>0x > 0 on EE and η>0\eta > 0, the vector yy of line L5 is the unique maximizer of Ψ(y)=g⋅y−KL(y∥x)/η\Psi(y) = g \cdot y - \mathrm{KL}(y \| x) / \eta over Δ={y≥0 on E:∑iyij=1 for all j}\Delta = \{y \ge 0 \text{ on } E : \sum_i y_{ij} = 1 \text{ for all } j\}, where KL(y∥x)=∑(i,j)∈Eyijlog⁡(yij/xij)\mathrm{KL}(y \| x) = \sum_{(i, j) \in E} y_{ij} \log(y_{ij} / x_{ij}), and for every z∈Δz \in \Delta,

g⋅(z−y)≤(KL(z∥x)−KL(z∥y)−KL(y∥x))/η.g \cdot (z - y) \le \big(\mathrm{KL}(z \| x) - \mathrm{KL}(z \| y) - \mathrm{KL}(y \| x)\big) / \eta .

Proof. Ψ\Psi splits into one strictly concave function per good. Setting the derivative of the Lagrangian to 00 gives yij∝xijeηgijy_{ij} \propto x_{ij} e^{\eta g_{ij}}, which is line L5; it is positive, so it is the maximizer. The first-order condition at yy is gij−(log⁡(yij/xij)+1)/η=μjg_{ij} - (\log(y_{ij}/x_{ij}) + 1)/\eta = \mu_j for a constant μj\mu_j per good, so for z∈Δz \in \Delta, ηg⋅(z−y)=∑ij(zij−yij)log⁡(yij/xij)\eta g \cdot (z - y) = \sum_{ij} (z_{ij} - y_{ij}) \log(y_{ij} / x_{ij}), since ∑i(zij−yij)=0\sum_i (z_{ij} - y_{ij}) = 0 kills the constants. Expanding the three KL terms shows that the right side equals the same sum. □\square

Claim 3 (line L6 and monotonicity). For each xx with all Ui(x)>0U_i(x) > 0, line L6 accepts every η\eta below some η0(x)>0\eta_0(x) > 0, and η0\eta_0 can be chosen uniformly on the set {x:f(x)≥f(x0)}\{x : f(x) \ge f(x^0)\}. If line L6 accepts, then f(y)≥f(x)f(y) \ge f(x).

Proof. On {f≥f(x0)}\{f \ge f(x^0)\} every Ui≥umin⁡>0U_i \ge u_{\min} > 0, and every gradient entry satisfies 0≤gij≤G=max⁡i,jeiuij/umin⁡0 \le g_{ij} \le G = \max_{i,j} e_i u_{ij} / u_{\min}. By line L5, yij/xij∈[e−ηG,eηG]y_{ij} / x_{ij} \in [e^{-\eta G}, e^{\eta G}], so ∥y−x∥1≤m(eηG−1)\|y - x\|_1 \le m (e^{\eta G} - 1), and for η\eta small every point between xx and yy has Ui≥umin⁡/2U_i \ge u_{\min} / 2. There the Hessian of ff in direction dd is −∑iei(∑juijdij)2/Ui2≥−L∥d∥12-\sum_i e_i (\sum_j u_{ij} d_{ij})^2 / U_i^2 \ge -L \|d\|_1^2 with L=4max⁡i,jeiuij2/umin⁡2L = 4 \max_{i,j} e_i u_{ij}^2 / u_{\min}^2, so f(y)≥f(x)+g⋅(y−x)−L2∥y−x∥12f(y) \ge f(x) + g \cdot (y - x) - \frac{L}{2} \|y - x\|_1^2. By Pinsker's inequality on each good and the Cauchy-Schwarz inequality over the mm goods, KL(y∥x)≥∥y−x∥12/(2m)\mathrm{KL}(y \| x) \ge \|y - x\|_1^2 / (2m). So line L6 holds once η≤1/(mL)\eta \le 1/(mL) and η\eta is small enough for the bound on UiU_i.

If line L6 accepts, then f(y)≥f(x)+η−1(ηg⋅(y−x)−KL(y∥x))=f(x)+Ψ(y)−Ψ(x)≥f(x)f(y) \ge f(x) + \eta^{-1}(\eta g \cdot (y - x) - \mathrm{KL}(y \| x)) = f(x) + \Psi(y) - \Psi(x) \ge f(x), because yy maximizes Ψ\Psi and KL(x∥x)=0\mathrm{KL}(x \| x) = 0. □\square

So every iterate stays in {f≥f(x0)}\{f \ge f(x^0)\}, and the accepted steps satisfy ηt≥ηmin⁡=η0/2\eta_t \ge \eta_{\min} = \eta_0 / 2.

Claim 4 (convergence of the iterates). In exact arithmetic, xtx^t converges to an optimal allocation xˉ\bar{x}.

Proof. At an optimum all goods are sold (Claim 1), so the optimal allocations lie in Δ\Delta; let x∗x^* be one. By concavity, f(x∗)≤f(x)+g⋅(x∗−x)f(x^*) \le f(x) + g \cdot (x^* - x). Adding the acceptance test of line L6 and Claim 2 with z=x∗z = x^* gives

f(x∗)−f(y)≤g⋅(x∗−y)+KL(y∥x)/η≤(KL(x∗∥x)−KL(x∗∥y))/η.f(x^*) - f(y) \le g \cdot (x^* - y) + \mathrm{KL}(y \| x)/\eta \le \big(\mathrm{KL}(x^* \| x) - \mathrm{KL}(x^* \| y)\big)/\eta .

So KL(x∗∥xt)\mathrm{KL}(x^* \| x^t) is nonincreasing for every optimal x∗x^*, and ∑tηt(f∗−f(xt+1))≤KL(x∗∥x0)\sum_t \eta_t (f^* - f(x^{t+1})) \le \mathrm{KL}(x^* \| x^0), so f(xt)→f∗f(x^t) \to f^*. The iterates lie in a compact set, and every limit point is optimal because ff is continuous there. Let xˉ\bar{x} be a limit point, xtk→xˉx^{t_k} \to \bar{x}. Then KL(xˉ∥xtk)→0\mathrm{KL}(\bar{x} \| x^{t_k}) \to 0 (the terms with xˉij=0\bar{x}_{ij} = 0 vanish, and the others are continuous at xˉ\bar{x}), and since KL(xˉ∥xt)\mathrm{KL}(\bar{x} \| x^t) is nonincreasing in tt, it tends to 00. By Pinsker's inequality, xt→xˉx^t \to \bar{x}. □\square

Claim 5 (soundness of line L8). If line L8 returns (p,x)(p, x), then (p,x)(p, x) is a Fisher market equilibrium, and xx is an optimal solution of the program.

Proof. The check accepts only positive prices with ∑jpj=∑iei\sum_j p_j = \sum_i e_i and a flow of value ∑iei\sum_i e_i in the network source →j\to j (capacity pjp_j) →i\to i (only on edges with uij/pj=αiu_{ij} / p_j = \alpha_i, the maximum bang per buck of ii) →\to sink (capacity eie_i). Both the source arcs and the sink arcs have total capacity ∑iei\sum_i e_i, so all of them are saturated. Let xijx_{ij} be the flow on j→ij \to i divided by pjp_j. Then buyer ii spends exactly eie_i, only on goods of maximum bang per buck, so her bundle is optimal; and good jj receives pjp_j, so ∑ixij=1\sum_i x_{ij} = 1. All arithmetic is exact. By Claim 1, xx is optimal. □\square

Claim 6 (completeness of line L8). Let xˉ\bar{x} be the limit of Claim 4 and β\beta its smallest positive entry. If β>2⋅10−14\beta > 2 \cdot 10^{-14}, line L8 returns after finitely many rounds.

Proof. xˉ\bar{x} is optimal, so by Claim 1 it is an equilibrium allocation with the unique prices p∗p^*. Let S∗={(i,j):xˉij>0}S^* = \{(i, j) : \bar{x}_{ij} > 0\}. On each connected part CC of S∗S^*, every edge has uij/pj∗=αiu_{ij} / p^*_j = \alpha_i (Claim 1, K3), so the ratios that line L8 computes along S∗S^* are consistent and proportional to p∗p^*. The buyers of CC spend all their money on goods of CC, and the goods of CC are paid for only by buyers of CC, so the prices of CC add up to the budgets of its buyers. Every good is in some part, since it is sold. So the prices forced by S∗S^* are exactly p∗p^*, and p∗p^* passes the check because the money flows of xˉ\bar{x} saturate the network.

Pick the threshold δ=10−k\delta = 10^{-k} with k≤14k \le 14 and δ<β/2\delta < \beta / 2; it exists because β>2⋅10−14\beta > 2 \cdot 10^{-14}. By Claim 4, after some round ∥xt−xˉ∥∞<min⁡(δ,β−δ)\|x^t - \bar{x}\|_\infty < \min(\delta, \beta - \delta). Then the entries of xtx^t outside S∗S^* are below δ\delta and those in S∗S^* are above β−(β−δ)=δ\beta - (\beta - \delta) = \delta, so {xijt>δ}=S∗\{x^t_{ij} > \delta\} = S^*. At the next round divisible by 5, line L8 tries all thresholds from 10−210^{-2} down, and it returns at the latest at δ\delta, by Claim 5 with a correct answer. ■\blacksquare

The proofs assume exact arithmetic for the ascent. The implementation runs the ascent in floating point, with a relative slack of 10−1210^{-12} in the test of line L6; this can only change which support is guessed and when, while Claim 5, which uses exact arithmetic, still guarantees that every returned answer is correct.

Complexity

A round of lines L4 to L7 costs O(nm)O(nm) arithmetic operations per backtracking step, and the number of backtracking steps per round is O(1)O(1) on average because η\eta doubles after each accepted step. Mirror ascent has f∗−f(xT)≤KL(x∗∥x0)/(ηmin⁡T)f^* - f(x^T) \le \mathrm{KL}(x^* \| x^0) / (\eta_{\min} T), where ηmin⁡\eta_{\min} is the smallest step accepted, and KL(x∗∥x0)≤mlog⁡n\mathrm{KL}(x^* \| x^0) \le m \log n. This bounds the objective, not the number of rounds until the support is found, which depends on how small the positive entries of the optimum are. Each check of line L8 runs Edmonds-Karp on n+m+2n + m + 2 nodes and up to nm+n+mnm + n + m arcs, O((n+m)n2m2)O((n + m) n^2 m^2) exact operations on rationals. Line L8 runs every 5 rounds with a fixed number of thresholds, so TT rounds take O(Tnm)O(Tnm) time for the mirror steps and O(T(n+m)n2m2)O(T (n + m) n^2 m^2) time for the checks.

For guaranteed bounds, the program can be solved exactly in polynomial time by the ellipsoid method or by interior point methods, because its optimum is rational with polynomial bit length. The DPSV algorithm solves it combinatorially with polynomially many max-flow computations, and Orlin's algorithm in strongly polynomial time.

Properties

  • Equilibrium as an optimum. The market equilibrium maximizes a global objective. Existence of the equilibrium follows at once: the feasible set is compact and has points where every Ui>0U_i > 0.
  • Unique prices and utilities, possibly many allocations. In the example the allocation is unique. With two identical buyers who both buy two goods, they can swap amounts of the two goods at the price ratio without changing their utilities, so the allocation is not unique.
  • Pareto optimal and, with equal budgets, envy-free: it is the CEEI allocation and the maximum Nash welfare allocation of divisible goods.
  • Rational. For rational uu and ee, the prices and some optimal allocation are rational, because they solve a linear system once the support is known.
  • Beyond linear utilities. The same program, with UiU_i replaced by any concave utility that is homogeneous of degree one (for example CES or Leontief), still captures the Fisher equilibrium (Eisenberg 1961).

Variants and improvements

  • Homogeneous utilities. Eisenberg (1961) proved the program for all concave, homogeneous of degree one utilities. For utilities that are not homogeneous, such as additively separable concave ones, no such program is known in general, and SPLC Fisher markets are PPAD-hard; see PPAD-hardness of market equilibria.
  • Shmyrev's program. A different convex program in the bids bijb_{ij} (money spent) has the same equilibria for linear utilities; mirror descent on it is proportional response dynamics.
  • Combinatorial algorithms. The DPSV algorithm raises prices while keeping KKT conditions 2 and 3 for the current equality graph, and Orlin's algorithm adds scaling to make the bound strongly polynomial.
  • Nash bargaining. With equal budgets the objective is the logarithm of the Nash product; see the Nash bargaining solution and proportional fairness, where Kelly used the same objective for bandwidth.

When to use it

Use the program to prove facts about Fisher markets (existence, uniqueness of prices, efficiency) and to compute equilibria with an off-the-shelf convex solver when an approximate answer is enough. Use the rounding and max-flow check of line L8 when an exact answer is needed and the market is small. For large linear markets with exact answers, use a combinatorial algorithm; for distributed settings, use proportional response dynamics.

Pitfalls

  • Skipping the exact check of line L8 and returning the rounded support or the float prices can give a wrong answer: a threshold that is too large drops a needed edge and splits a part of SS, and the prices it forces are then off.
  • A fixed step in line L5 without the test of line L6 can fail: the gradient eiuij/Uie_i u_{ij} / U_i is huge when UiU_i is small, and a large step can move almost all of every good away from a buyer, so that the objective falls.
  • A zero start on an edge in line L1 stays zero forever, because line L5 is multiplicative. Every edge with uij>0u_{ij} > 0 must start positive.
  • If some good is liked by no buyer, its supply constraint has multiplier 00 and the good is left unsold; the reading of multipliers as positive prices assumes every good is liked.
  • Reading prices from the dual is only right for an optimal xx. At a non-optimal point, the estimates max⁡ieiuij/Ui\max_i e_i u_{ij} / U_i need not add up to the total budget.

Implementations

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.

eisenberg_gale_program.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/eisenberg-gale-program/. The authors are listed in prov/R0QFZC.jsonl.
"""Solve the Eisenberg-Gale convex program of a linear Fisher market and read off the prices.

Buyers are 0, ..., n - 1 and goods are 0, ..., m - 1, with one unit of each good. u[i][j] >= 0 is
the utility of buyer i for all of good j and e[i] > 0 is her budget. Every buyer likes some good
and every good is liked by some buyer. The program is

    maximize   sum_i e_i log(sum_j u_ij x_ij)
    subject to sum_i x_ij <= 1 for every good j,  x >= 0.

The solver runs mirror ascent with the entropy on each good (exponentiated gradient) in floating
point, with a backtracking step size. From time to time it rounds: it guesses the support of the
optimum, computes the exact prices that this support forces, and accepts them only if they pass
an exact check of the equilibrium conditions (the KKT conditions of the program) in Fractions.
"""

import math
from collections import deque
from fractions import Fraction


def objective(u, e, x):
    n, m = len(u), len(u[0])
    return sum(e[i] * math.log(sum(u[i][j] * x[i][j] for j in range(m))) for i in range(n))


def max_flow(num_nodes, cap, s, t):
    """Edmonds-Karp maximum flow on exact capacities; returns the value and the flow on each arc."""
    res, adj = {}, [[] for _ in range(num_nodes)]
    for (a, b), c in cap.items():
        adj[a].append(b)
        adj[b].append(a)
        res[(a, b)] = c
        res.setdefault((b, a), Fraction(0))
    value = Fraction(0)
    while True:
        prev, queue = {s: None}, deque([s])
        while queue and t not in prev:
            a = queue.popleft()
            for b in adj[a]:
                if b not in prev and res[(a, b)] > 0:
                    prev[b] = a
                    queue.append(b)
        if t not in prev:
            return value, {arc: c - res[arc] for arc, c in cap.items()}
        path, b = [], t
        while prev[b] is not None:
            path.append((prev[b], b))
            b = prev[b]
        push = min(res[arc] for arc in path)
        for a, b in path:
            res[(a, b)] -= push
            res[(b, a)] += push
        value += push


def certify(u, e, p):
    """If p are equilibrium prices, return the exact allocation x[i][j] (amounts of goods);
    else return None. The test is a maximum flow on the edges of maximum bang per buck."""
    n, m = len(u), len(u[0])
    if any(q is None or q <= 0 for q in p):
        return None
    alpha = [max(Fraction(u[i][j]) / p[j] for j in range(m)) for i in range(n)]
    src, snk = 0, n + m + 1
    cap = {(src, 1 + j): p[j] for j in range(m)}
    for i in range(n):
        cap[(1 + m + i, snk)] = e[i]
        for j in range(m):
            if u[i][j] > 0 and Fraction(u[i][j]) / p[j] == alpha[i]:
                cap[(1 + j, 1 + m + i)] = sum(e) + 1
    if sum(p) != sum(e):
        return None
    value, flow = max_flow(snk + 1, cap, src, snk)
    if value != sum(e):
        return None
    return [[flow.get((1 + j, 1 + m + i), Fraction(0)) / p[j] for j in range(m)] for i in range(n)]


def prices_from_support(u, e, support):
    """The prices forced by a set of spending edges: on each connected part, a buyer gets the same
    bang per buck on all her edges, and the prices add up to the money of the part's buyers."""
    n, m = len(u), len(u[0])
    nbr = {}
    for i, j in support:
        nbr.setdefault(("b", i), []).append(("g", j))
        nbr.setdefault(("g", j), []).append(("b", i))
    rel, p = {}, [None] * m
    for start in [("g", j) for j in range(m)]:
        if start in rel or start not in nbr:
            continue
        rel[start] = Fraction(1)
        comp, stack = [start], [start]
        while stack:
            a = stack.pop()
            for b in nbr[a]:
                i, j = (a[1], b[1]) if a[0] == "b" else (b[1], a[1])
                val = Fraction(u[i][j]) / rel[a]  # price from bang, or bang from price
                if b not in rel:
                    rel[b] = val
                    comp.append(b)
                    stack.append(b)
                elif rel[b] != val:
                    return None
        goods = [a for a in comp if a[0] == "g"]
        money = sum(e[a[1]] for a in comp if a[0] == "b")
        scale = money / sum(rel[a] for a in goods)
        for a in goods:
            p[a[1]] = rel[a] * scale
    return p


def eisenberg_gale(u, e, max_rounds=200000, check_every=5):
    """Return (p, x): the exact equilibrium prices and an exact optimal allocation of the program."""
    n, m = len(u), len(u[0])
    e = [Fraction(b) for b in e]
    ef = [float(b) for b in e]
    edges = [(i, j) for i in range(n) for j in range(m) if u[i][j] > 0]
    x = [[0.0] * m for _ in range(n)]
    for j in range(m):  # @line L1
        likers = [i for i in range(n) if u[i][j] > 0]
        for i in likers:
            x[i][j] = 1.0 / len(likers)
    eta = 1.0  # @line L2
    f = objective(u, ef, x)
    for rnd in range(1, max_rounds + 1):  # @line L3
        util = [sum(u[i][j] * x[i][j] for j in range(m)) for i in range(n)]
        g = [[ef[i] * u[i][j] / util[i] for j in range(m)] for i in range(n)]  # @line L4
        while True:
            y = [[0.0] * m for _ in range(n)]
            for j in range(m):  # @line L5
                top = max(eta * g[i][j] for i, jj in edges if jj == j)
                w = {i: x[i][j] * math.exp(eta * g[i][j] - top) for i, jj in edges if jj == j}
                total = sum(w.values())
                for i in w:
                    y[i][j] = w[i] / total
            if min(sum(u[i][j] * y[i][j] for j in range(m)) for i in range(n)) <= 0:
                eta /= 2
                continue
            fy = objective(u, ef, y)
            lin = sum(g[i][j] * (y[i][j] - x[i][j]) for i, j in edges)
            kl = sum(y[i][j] * math.log(y[i][j] / x[i][j]) for i, j in edges if y[i][j] > 0)
            if fy >= f + lin - kl / eta - 1e-12 * abs(f):  # @line L6
                break
            eta /= 2
        x, f, eta = y, fy, eta * 2  # @line L7
        if rnd % check_every == 0:
            for k in range(2, 15):  # @line L8
                support = [(i, j) for i, j in edges if x[i][j] > 10.0 ** (-k)]
                p = prices_from_support(u, e, support)
                if p is not None and None not in p:
                    exact = certify(u, e, p)
                    if exact is not None:
                        return p, exact
    raise RuntimeError("no exact certificate found")
test_eisenberg_gale_program.py 131 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/eisenberg-gale-program/. The authors are listed in prov/R0QFZC.jsonl.

import math
import random
import unittest
from fractions import Fraction
from itertools import combinations

from eisenberg_gale_program import eisenberg_gale, objective, prices_from_support

# The example of the page: 3 buyers and 2 goods.
EXAMPLE_U = [[2, 1], [1, 2], [1, 1]]
EXAMPLE_E = [1, 1, 2]


def is_equilibrium(u, e, p, x):
    """Exact KKT check, with x in amounts of goods: positive prices, every good sold out, every
    buyer spends exactly her budget and only on goods of maximum bang per buck."""
    n, m = len(u), len(u[0])
    if any(q <= 0 for q in p):
        return False
    for j in range(m):
        if sum(x[i][j] for i in range(n)) != 1:
            return False
    for i in range(n):
        best = max(Fraction(u[i][j]) / p[j] for j in range(m))
        if sum(p[j] * x[i][j] for j in range(m)) != e[i]:
            return False
        for j in range(m):
            if x[i][j] < 0 or (x[i][j] > 0 and Fraction(u[i][j]) / p[j] != best):
                return False
    return True


def brute_force_prices(u, e):
    """Every price vector forced by some set of edges that passes the check with a forest flow."""
    n, m = len(u), len(u[0])
    all_edges = [(i, j) for i in range(n) for j in range(m) if u[i][j] > 0]
    found = set()
    for k in range(1, len(all_edges) + 1):
        for H in combinations(all_edges, k):
            if k > n + m - 1:
                continue
            p = prices_from_support(u, e, H)
            if p is None or None in p:
                continue
            x = forest_flow(n, m, e, p, H)
            if x is not None and is_equilibrium(u, e, p, x):
                found.add(tuple(p))
    return found


def forest_flow(n, m, e, p, H):
    left = set(H)
    need = {("b", i): Fraction(e[i]) for i in range(n)}
    need.update({("g", j): p[j] for j in range(m)})
    x = [[Fraction(0)] * m for _ in range(n)]
    while left:
        deg = {}
        for i, j in left:
            deg[("b", i)] = deg.get(("b", i), 0) + 1
            deg[("g", j)] = deg.get(("g", j), 0) + 1
        leaf = next((v for v, d in deg.items() if d == 1), None)
        if leaf is None:
            return None
        i, j = next(ed for ed in left if ("b", ed[0]) == leaf or ("g", ed[1]) == leaf)
        if need[leaf] < 0:
            return None
        x[i][j] = need[leaf] / p[j]
        need[("b", i)] -= need[leaf]
        need[("g", j)] -= p[j] * x[i][j]
        left.discard((i, j))
    return x if all(v == 0 for v in need.values()) else None


def random_market(rng, n, m):
    while True:
        u = [[rng.choice([0, 1, 2, 3, 4]) for _ in range(m)] for _ in range(n)]
        if all(any(r) for r in u) and all(any(u[i][j] for i in range(n)) for j in range(m)):
            return u, [rng.randint(1, 3) for _ in range(n)]


class TestEisenbergGale(unittest.TestCase):
    def test_check_value(self):
        p, x = eisenberg_gale([[2, 1], [1, 2]], [1, 1])
        self.assertEqual(p, [1, 1])
        self.assertEqual(x, [[1, 0], [0, 1]])

    def test_example(self):
        p, x = eisenberg_gale(EXAMPLE_U, EXAMPLE_E)
        self.assertEqual(p, [2, 2])
        self.assertTrue(is_equilibrium(EXAMPLE_U, EXAMPLE_E, p, x))
        # Buyer 1 buys only good 1 and buyer 2 only good 2; buyer 3 takes the rest.
        self.assertEqual(x[0], [Fraction(1, 2), 0])
        self.assertEqual(x[1], [0, Fraction(1, 2)])

    def test_random_against_brute_force(self):
        rng = random.Random(3)
        for _ in range(25):
            n, m = rng.randint(1, 3), rng.randint(1, 3)
            u, e = random_market(rng, n, m)
            p, x = eisenberg_gale(u, e)
            self.assertTrue(is_equilibrium(u, e, p, x))
            self.assertEqual(brute_force_prices(u, e), {tuple(p)})

    def test_optimal_against_random_points(self):
        rng = random.Random(5)
        for _ in range(10):
            u, e = random_market(rng, 3, 3)
            p, x = eisenberg_gale(u, e)
            best = objective(u, e, [[float(v) for v in row] for row in x])
            for _ in range(200):
                y = [[rng.random() * (u[i][j] > 0) for j in range(3)] for i in range(3)]
                for j in range(3):
                    s = sum(y[i][j] for i in range(3))
                    for i in range(3):
                        y[i][j] /= s
                if all(sum(u[i][j] * y[i][j] for j in range(3)) > 0 for i in range(3)):
                    self.assertLessEqual(objective(u, e, y), best + 1e-9)

    def test_identical_buyers(self):
        # Prices are unique, but the allocation is not: any split that spends both budgets works.
        p, x = eisenberg_gale([[1, 1], [1, 1]], [1, 1])
        self.assertEqual(p, [1, 1])
        self.assertTrue(is_equilibrium([[1, 1], [1, 1]], [1, 1], p, x))
        self.assertTrue(math.isclose(objective([[1, 1], [1, 1]], [1, 1], [[1, 0], [0, 1]]), 0.0))


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

History

Eisenberg and Gale (1959) studied the pari-mutuel method of betting, in which bettors with budgets and subjective probabilities place bets on horses and the odds are set by the money bet. They showed that the equilibrium odds come from maximizing ∑ieilog⁡Ui\sum_i e_i \log U_i, which gives the existence and uniqueness of the equilibrium odds. Eisenberg (1961) extended the program to homogeneous utilities. Computer science took it up in the 2000s: Devanur, Papadimitriou, Saberi and Vazirani (journal version 2008) gave a combinatorial primal-dual algorithm guided by its KKT conditions, Ye (2008) gave interior point algorithms, and Orlin (2010) gave a strongly polynomial algorithm. Later work on fair division uses the same objective as the maximum Nash welfare rule.

References

  1. Edmund Eisenberg and David Gale, Consensus of subjective probabilities: the pari-mutuel method, Annals of Mathematical Statistics 30(1), 165-168 (1959), the whole paper (the convex program whose solution gives the equilibrium odds of a pari-mutuel market)
  2. Edmund Eisenberg, Aggregation of utility functions, Management Science 7(4), 337-350 (1961), the whole paper (the program for utilities that are homogeneous of degree one)
  3. Noam Nisan, Tim Roughgarden, Eva Tardos and Vijay V. Vazirani (eds.), Algorithmic Game Theory, Cambridge University Press, 2007, Chapter 5, Vijay V. Vazirani, Combinatorial algorithms for market equilibria (the program and its KKT conditions), and Chapter 6, Bruno Codenotti and Kasturi Varadarajan, Computation of market equilibria by convex programming
  4. Nikhil R. Devanur, Christos H. Papadimitriou, Amin Saberi and Vijay V. Vazirani, Market equilibrium via a primal-dual algorithm for a convex program, Journal of the ACM 55(5), Article 22 (2008), the whole paper (a combinatorial algorithm for the program, guided by its KKT conditions)
  5. Yinyu Ye, A path to the Arrow-Debreu competitive market equilibrium, Mathematical Programming 111(1), 315-348 (2008), the whole paper (interior point algorithms for the Fisher and exchange models)

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 proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
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)
WritingW2 basic
  • a scene preset for the example