Algorithmresearch
Approximate competitive equilibrium from equal incomes
Also called A-CEEI, Budish course allocation mechanism.
Gives agents slightly unequal budgets so that an approximate equilibrium exists for indivisible goods. It is used for course allocation.
- Time
- O(g^m n l m) worst
- Space
- O(n m) extra
- Where
- g = the number of grid prices per good; l = the length of the longest preference list; m = the number of goods; n = the number of agents
- Model
- Real RAM
- Properties
- deterministiciterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Eric Budish, 2011
Approximate competitive equilibrium from equal incomes, or A-CEEI, is Budish's answer to a problem of the competitive equilibrium from equal incomes (CEEI): with indivisible goods such as seats in courses, a CEEI often does not exist. A-CEEI changes two things. The budgets are made slightly unequal, all in for a small , and the market only has to clear approximately: the clearing error , the length of the vector of oversubscribed and unfilled seats, has to be small. Budish proved that for any preferences over bundles, an A-CEEI exists with , a bound that does not grow with the number of agents. It is used in practice to assign business school students to courses. Finding it is PPAD-complete, so real systems search for prices heuristically. The implementation on this page is a toy that tries every price vector on a grid.
In plain words
Every student gets almost the same amount of fake money, but no two students get exactly the same amount. Each course seat gets a price. At these prices, every student takes the best schedule she can pay for. If too many students want a course, its price is too low; if a course with a positive price has empty seats, its price is too high. The goal is prices at which every course is about full. With exactly equal money this can be impossible: if two students want the one seat of a course, either both can pay for it or neither can. Tiny differences in money break these ties, and then prices that almost clear the market always exist.
The problem
There are agents and goods, with identical seats of good . Agent accepts some bundles of goods, ranked by a strict order, and the empty bundle is always acceptable; is the largest size of an accepted bundle. Agent has a budget . At prices , the demand of agent is her highest ranked bundle with . The clearing error of is with
so empty seats count against a good only if it has a positive price. Prices with and equal budgets are a CEEI. An -CEEI is a vector of budgets in with prices whose clearing error is at most , where every agent gets her demand. The task is to find one with small .
The algorithm
The toy fixes the budgets and searches a grid of prices with step and largest price .
A-CEEI-GRID(preference lists, seats q, budgets b, step s, cap c)- 1
best ← none - 2
for each p in {0, s, 2s, ..., c}^m, in lexicographic order do - 3
x_i ← the first bundle on the list of agent i that costs at most b_i at p, or the empty bundle - 4
z_j ← (the number of agents with j in x_i) - q_j, raised to 0 if p_j = 0 and it is negative - 5
if best is none or ||z||² < the error of best then best ← (||z||², p, x) - 6
return the square root of the error of best, its prices and its bundles
Line L3 computes each agent's demand by walking her list from the top. Line L4 is the clearing error vector, and line L5 keeps the first price vector with the smallest error. All arithmetic is in exact fractions, so the comparisons of line L3 are exact. The implementation also gives the budgets , which are distinct and lie in , and Budish's bound .
Practical solvers do not search a grid. The method of Othman, Sandholm and Budish moves prices in the direction of the clearing error, as in tatonnement, within a tabu search, and computes each student's demand with an integer program.
Example
One seat, two agents. Both agents want the single seat of good 1. With equal budgets , a price of at most makes both demand it (), and a higher price makes neither demand it (, since the price is positive), so every price has and there is no CEEI. With budgets and , any price in gives the seat to agent 2 alone and . The toy with step returns . Here , so Budish's bound is ; since is an integer vector, the theorem promises budgets in at which some price clears the market exactly.
Three students and two courses. Course 1 has one seat and course 2 has three seats. All three students rank first, then , then .
| budgets | grid step | best prices | bundles of students 1, 2, 3 | |
|---|---|---|---|---|
| any | the same for all three students | |||
With equal budgets the three students always demand the same bundle, so course 1 is either taken by all three or by none, and the error is at least . With the budgets , the price for course 1 is above the budgets of students 1 and 2 but within the budget of student 3, and course 2 is free. Student 3 buys , the others buy , and both courses are exactly full. Here , , , and the bound is .
Correctness
The proof for the toy is in proofs/correctness.md. Every returned bundle is the demand of its agent at the returned prices, the returned is the smallest clearing error over the grid, and the search ends because the grid is finite. So the output is an -CEEI for the given budgets, and no grid price does better. The toy does not prove Budish's theorem; a grid can miss the prices that the theorem promises when the step is too coarse. The proof also shows the two statements of the example: with equal budgets and one wanted seat no price clears, and with distinct budgets a price between them does.
Budish's theorem. For any and any preferences, there are budgets in and prices with clearing error at most , where . Othman, Papadimitriou and Rubinstein restate it with the bound , which is the same as . The proof is not constructive: it relies on the Kakutani fixed point theorem.
Proof: The toy grid search returns demands at the best grid prices, and equal budgets can fail to clearfull
This proof is for the toy grid search of the pseudocode. It does not prove Budish's existence theorem, which is non-constructive and relies on the Kakutani fixed point theorem.
Fix agents, goods with seats, budgets , and for each agent a list of accepted bundles in strict order, best first. The empty bundle is accepted by every agent and ranked below every listed bundle. All numbers are exact rationals. For prices , the demand is the highest ranked accepted bundle with , and the clearing error is , where if and if , with . The grid is with .
Claim 1 (termination). The search ends after iterations of lines L3 to L5.
Proof. Line L2 enumerates the finite set once, and lines L3 to L5 do finite work: each agent's list is finite.
Claim 2 (lines L3 and L4). For each , line L3 computes for every agent, and line L4 computes .
Proof. The function demand walks the list of agent from the best bundle down and returns the first bundle whose cost is at most . Every bundle above it on the list costs more than , so it is the highest ranked affordable bundle. If no listed bundle is affordable, it returns the empty bundle, which costs and is the only affordable accepted bundle left. The comparisons are exact. Line L4 counts the agents whose bundle contains , subtracts , and raises a negative value to when , which is the definition of .
Claim 3 (output). Line L6 returns , where is the first vector of in lexicographic order with . So every returned bundle is the demand of its agent at the returned prices, no grid vector has a smaller clearing error, and if all budgets lie in , the output is an -CEEI.
Proof. By induction over the iterations of line L2, after each iteration best holds the squared error, the prices and the bundles of the first vector seen so far with the smallest squared error: the first vector is stored because best is empty (line L1), and a later vector replaces it only when its squared error is strictly smaller (line L5), so ties keep the earlier vector. By Claim 2 the stored bundles are the demands at the stored prices. The square root is increasing, so the smallest squared error gives the smallest . The definition of an -CEEI asks for budgets in , every agent at her demand, and clearing error at most , which the output satisfies.
Claim 4 (perturbed budgets). The budgets for are distinct and lie in for .
Proof. They increase strictly with , the first is , and the last is .
Claim 5 (equal budgets can fail). If all agents have the same budget and the same list, then at every price vector , not only on the grid, they all demand the same bundle. In the example with one seat and two agents who both accept only , every price has . In the example with three students, one seat of course 1, three of course 2, and the list for everyone, every price has .
Proof. The demand depends only on the list, the budget and , so it is the same for all agents. With one seat, if both agents demand and ; if neither does, the price is positive, and . In both cases .
With three students, let be the common demand. If , then and . If , then is not affordable, because it is ranked above and the empty bundle; so , and . In both cases .
Claim 6 (distinct budgets can clear). In the example with one seat and budgets , every price has ; with budgets and step , the search returns and . In the example with three students and budgets , the prices have , and the search with step returns them.
Proof. With one seat and , only agent 2 can pay for , so and . The grid values in are and ; every smaller grid value has by the case analysis of Claim 5 (both agents demand the seat), so by Claim 3 the first vector with error is .
With three students and : students 1 and 2 have budgets below , so they cannot pay for or , and they demand , which costs . Student 3 has and demands . So and . To see that it is the first vector of the grid with error , note that error needs exactly one student to demand a bundle with course 1. If , then students 2 and 3 can pay for and both demand a bundle with course 1, so . Hence , and the smallest grid value above with step is ; with the error is , and comes first in lexicographic order among the vectors with . By Claim 3, the search returns it.
The bound that the implementation computes is the bound of Budish's theorem; the toy does not reach it in general, because a coarse grid can miss the prices that the theorem promises.
Complexity
The toy tries price vectors, where , and for each it reads every preference list, with bundles of up to goods. That is time and extra space, which is exponential in . This is why it is a toy. In general the problem is hard: Othman, Papadimitriou and Rubinstein showed that computing an A-CEEI with the guarantee of Budish's theorem is PPAD-complete, and that it is NP-hard to tell an economy with an exact CEEI from one with no A-CEEI whose error is below a constant times . In the course allocation setting, also each demand query is an optimization over schedules, solved with mixed integer programming.
Properties
- Approximately efficient. Every agent gets her best affordable bundle, so the loss comes from the clearing error. The error bound does not grow with the number of agents, so in a large market it is small compared with the supply.
- Approximately fair. Because the budgets differ by at most , Budish shows two fairness criteria: envy is bounded by a single good (a guarantee of the EF1 type), and every agent gets at least her -maximin share.
- Strategyproof in large markets. An agent who is small compared with the market cannot change the prices, so she can do no better than report her true preferences.
- Unequal budgets are essential. With exactly equal budgets, agents with the same preferences always demand the same bundle, as in the example.
- The bound is close to tight. Budish shows economies where the error must be of order .
Variants and improvements
- Course Match. Budish, Cachon, Kessler and Othman built Course Match, a large scale implementation of A-CEEI for course allocation at business schools, on top of a heuristic price search.
- Divisible goods. With divisible goods and equal budgets, an exact CEEI exists, and for additive utilities it is the maximum Nash welfare allocation.
- Other mechanisms. Random serial dictatorship is simpler and strategyproof but less fair ex post, and combinatorial auctions use real money instead of equal budgets.
When to use it
Use A-CEEI when agents with almost equal rights must share indivisible goods with limited seats, preferences over bundles matter (schedules, shifts, slots), and money cannot be used, as in course allocation. Use the toy only to check the definitions on very small instances. For real instances, use a heuristic price search with an exact demand oracle, and accept a small clearing error.
Pitfalls
- Using equal budgets in line L3 can make the best error stay large, as in the example; the budgets must be distinct.
- Counting the empty seats of a free good as error in line L4 is wrong: a good with price may have empty seats.
- Using floating point in line L3 makes the test of affordability fail for bundles that cost exactly the budget; the toy uses exact fractions.
- A grid step in line L2 that is coarser than the differences between budgets can miss every price that separates the agents. In the example with three students and budgets , step jumps from to over the interval , and the best error on the grid is .
- Taking the smallest error in line L5 as the answer of Budish's theorem is wrong: the grid optimum can be larger than the bound when the grid is too coarse.
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.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/approximate-ceei/. The authors are listed in prov/DWVSMG.jsonl.
"""A toy search for approximate competitive equilibrium from equal incomes (A-CEEI).
This is a toy for tiny inputs only: it tries every price vector on a grid, so its cost grows
exponentially with the number of goods. Practical solvers (Othman, Sandholm and Budish) use a
heuristic search over prices instead.
Agents are 0, ..., n - 1 and goods (course seats) are 0, ..., m - 1, with capacities q[j].
prefs[i] lists the bundles that agent i accepts, best first, each a tuple of goods; the empty
bundle is always acceptable and need not be listed. budgets[i] is the budget of agent i; A-CEEI
uses budgets that are close to equal but not equal. All numbers are Fractions or integers.
"""
from fractions import Fraction
from itertools import product
from math import sqrt
def demand(prefs_i, budget, p):
"""The agent's favorite affordable bundle: the first bundle on her list that she can pay for."""
for bundle in prefs_i:
if sum(p[j] for j in bundle) <= budget:
return tuple(bundle)
return ()
def clearing_error(bundles, q, p):
"""The vector z of Budish: demand minus capacity for each good, where a good of price 0 may
have empty seats. The market clears exactly when z = 0."""
z = []
for j in range(len(q)):
zj = sum(1 for bundle in bundles if j in bundle) - q[j]
z.append(max(zj, 0) if p[j] == 0 else zj)
return z
def approximate_ceei(prefs, q, budgets, step, cap):
"""Return (alpha, p, bundles) for a price vector on the grid {0, step, ..., cap}^m with the
least clearing error alpha = ||z||_2 (ties go to the first vector in lexicographic order)."""
m = len(q)
grid = [step * k for k in range(int(cap / step) + 1)]
best = None # @line L1
for p in product(grid, repeat=m): # @line L2
bundles = [demand(prefs[i], budgets[i], p) for i in range(len(prefs))] # @line L3
z = clearing_error(bundles, q, p) # @line L4
err = sum(v * v for v in z)
if best is None or err < best[0]: # @line L5
best = (err, list(p), bundles)
return sqrt(best[0]), best[1], best[2] # @line L6
def perturbed_budgets(n, beta):
"""Budgets 1, 1 + beta / n, ..., 1 + (n - 1) beta / n: all distinct and within beta of 1."""
return [1 + Fraction(beta) * i / n for i in range(n)]
def budish_bound(k, m):
"""The bound of Budish's existence theorem on the clearing error: sqrt(sigma m) / 2, with
sigma = min(2k, m), where k is the largest number of goods in a bundle."""
return sqrt(min(2 * k, m) * m) / 2
test_approximate_ceei.py 70 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/approximate-ceei/. The authors are listed in prov/DWVSMG.jsonl.
import random
import unittest
from fractions import Fraction
from itertools import combinations, product
from math import sqrt
from approximate_ceei import approximate_ceei, budish_bound, clearing_error, demand, perturbed_budgets
ONE_SEAT = [[(0,)], [(0,)]] # two agents who both want the single seat of good 0
class TestApproximateCEEI(unittest.TestCase):
def test_equal_budgets_cannot_clear(self):
# The example of the page: with equal budgets every price leaves an error of 1.
alpha, p, bundles = approximate_ceei(ONE_SEAT, [1], [1, 1], Fraction(1, 10), Fraction(2))
self.assertEqual(alpha, 1.0)
for k in range(21):
price = Fraction(k, 10)
got = [demand(prefs, 1, [price]) for prefs in ONE_SEAT]
self.assertEqual(abs(clearing_error(got, [1], [price])[0]), 1)
def test_perturbed_budgets_clear(self):
budgets = [1, Fraction(11, 10)]
alpha, p, bundles = approximate_ceei(ONE_SEAT, [1], budgets, Fraction(1, 20), Fraction(2))
self.assertEqual(alpha, 0.0)
self.assertEqual(p, [Fraction(21, 20)])
self.assertEqual(bundles, [(), (0,)])
def test_three_students(self):
# Good 0 has one seat, good 1 has three; everyone ranks {0, 1} > {0} > {1}.
prefs = [[(0, 1), (0,), (1,)]] * 3
alpha_equal = approximate_ceei(prefs, [1, 3], [1, 1, 1], Fraction(1, 8), Fraction(3, 2))[0]
self.assertEqual(alpha_equal, 1.0)
budgets = perturbed_budgets(3, Fraction(3, 10))
alpha, p, bundles = approximate_ceei(prefs, [1, 3], budgets, Fraction(1, 40), Fraction(3, 2))
self.assertEqual(alpha, 0.0)
self.assertEqual(sorted(bundles), [(0, 1), (1,), (1,)])
self.assertEqual(bundles[2], (0, 1))
def test_grid_minimum(self):
rng = random.Random(5)
for _ in range(15):
n, m = rng.randint(2, 3), rng.randint(1, 2)
q = [rng.randint(1, 2) for _ in range(m)]
bundles = [b for k in (1, 2) for b in combinations(range(m), k)]
prefs = [rng.sample(bundles, len(bundles)) for _ in range(n)]
budgets = perturbed_budgets(n, Fraction(1, 5))
step, cap = Fraction(1, 4), Fraction(5, 2)
alpha, p, got = approximate_ceei(prefs, q, budgets, step, cap)
# the returned bundles are the agents' demands at the returned prices
self.assertEqual(got, [demand(prefs[i], budgets[i], p) for i in range(n)])
for i in range(n):
self.assertLessEqual(sum(p[j] for j in got[i]), budgets[i])
# no grid point does better
grid = [step * k for k in range(11)]
for r in product(grid, repeat=m):
z = clearing_error([demand(prefs[i], budgets[i], r) for i in range(n)], q, r)
self.assertGreaterEqual(sqrt(sum(v * v for v in z)), alpha - 1e-12)
def test_budish_bound_values(self):
self.assertEqual(budish_bound(1, 1), 0.5)
self.assertEqual(budish_bound(2, 3), 1.5)
self.assertEqual(budish_bound(1, 8), 2.0)
if __name__ == "__main__":
unittest.main()
History
Varian (1974) proposed the competitive equilibrium from equal division as a fair allocation of divisible goods. For indivisible goods, Budish first presented the A-CEEI mechanism in a working paper of 2009 and published it in 2011, with course allocation at business schools as the main application. Othman, Sandholm and Budish built a heuristic solver for real course allocation data in 2010. Othman, Papadimitriou and Rubinstein showed in 2014, in a journal version of 2016, that finding the approximate equilibrium of Budish's theorem is PPAD-complete. The mechanism is in use for assigning business school students to classes.
References
- Eric Budish, The combinatorial assignment problem: approximate competitive equilibrium from equal incomes, Journal of Political Economy 119(6), 1061-1103 (2011), the whole paper (the existence theorem for approximate CEEI and the fairness and incentive properties of the mechanism)
- Abraham Othman, Tuomas Sandholm and Eric Budish, Finding approximate competitive equilibria: efficient and fair course allocation, AAMAS 2010, 873-880, the whole paper (a tabu search over prices, with demands computed by integer programs)
- Abraham Othman, Christos Papadimitriou and Aviad Rubinstein, The complexity of fairness through equilibrium, ACM Transactions on Economics and Computation 4(4), Article 20 (2016), the whole paper (computing the A-CEEI of Budish's theorem is PPAD-complete, and a better approximation is NP-hard)
- Abraham Othman, Christos Papadimitriou and Aviad Rubinstein, The complexity of fairness through equilibrium, arXiv 1312.6249 (version of EC 2014), Definition 2 (clearing error), Definition 3 ((alpha, beta)-CEEI), Theorem 1 (Budish's existence theorem), Theorem 2 (PPAD-completeness), Theorem 3 (NP-hardness)
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 | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag DWVSMG Edit this page History Report an error Markdown