Algorithmcore
Tatonnement
Also called Walrasian tatonnement, Walrasian auctioneer.
Raises the prices of goods in excess demand and lowers the others. In continuous time it converges under gross substitutes; discrete versions also need small enough steps.
- Time
- O(T n m) worst
- Space
- O(m) extra
- Where
- T = the number of rounds; m = the number of goods; n = the number of buyers
- Model
- Real RAM
- Properties
- deterministiciterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Leon Walras, Kenneth Arrow, Leonid Hurwicz, H. D. Block, Herbert Scarf, 1874
Tatonnement, French for groping, is the oldest algorithm for finding market prices. An imaginary auctioneer calls out prices, asks every agent what she would buy, and then raises the price of each good that is wanted more than it is supplied and lowers the price of each good that is left over. No trade happens until the prices balance. Walras (1874) used the process to argue that markets find their competitive equilibrium, and it is the model behind most later price-adjustment algorithms. Its rest points are exactly the equilibria, but it does not always reach them. Arrow, Block and Hurwicz (1959) proved that the continuous-time process converges when goods are gross substitutes, and Scarf (1960) built a market in which it cycles forever. Discrete versions, the ones a computer runs, also need step sizes small enough for the market at hand.
In plain words
The auctioneer starts with some prices. Each person says how much of each good she wants at these prices. If people want more of a good than there is, its price goes up a bit. If some of it is left over, its price goes down a bit. Then everyone answers again. When every good is used up exactly, the prices are right and trade starts. This works well when goods can replace each other, like tea and coffee: when tea becomes expensive, people buy more coffee. It can fail when goods are used together, like left and right shoes. Then the prices can go round in circles. Steps that are too large can also make prices jump past the right value again and again.
The problem
There are divisible goods with supplies . The market is given by its excess demand : at positive prices , is the total demand for good minus . The algorithm uses as a black box, one call per round. The usual assumptions are those of a market with locally nonsatiated agents and well-defined demand:
- is continuous on positive prices and (demand is never negative);
- for (only relative prices matter);
- Walras' law: (every agent spends all her money).
The task is to find with , or an approximate equilibrium with for every . In a Fisher market with buyers, the demand of each buyer is computed from her budget and utility at , so a round costs time for the usual utility classes.
The demand is gross substitutes (for divisible goods) if raising the price of one good never lowers the demand for any other good; strict gross substitutes asks that it strictly raises it. CES utilities with give gross substitutes, and Cobb-Douglas utilities () are the borderline case. The gross substitutes page treats the version of this condition for indivisible items.
The algorithm
TATONNEMENT(excess demand z, supplies s, start p0 > 0, step λ ∈ (0, 1), rounds T, tolerance ε)- 1
p ← p0 - 2
for t = 0, 1, ..., T - 1 do - 3
z ← z(p) - 4
if |z_j| / s_j ≤ ε for every good j then return (p, t, converged) - 5
p_j ← p_j · (1 + λ · min(z_j / s_j, 1)) for every good j - 6
return (p, T, whether |z_j(p)| / s_j ≤ ε for every j)
Line L5 is a multiplicative rule of the kind studied by Cole and Fleischer (2008). The relative excess demand is capped at , so one round at most multiplies a price by . Since , the factor is at least , so prices stay positive. The classical additive rule is the Euler method for the differential equation , the continuous tatonnement of Arrow and Hurwicz. The implementation has both rules, in floating point, and excess demand functions for Cobb-Douglas, CES and linear Fisher markets and for Scarf's economy.
Example
Take the Fisher check value: budgets and , one unit of each of two goods, linear utilities and . The equilibrium prices are . As long as lies strictly between and , buyer 1 spends her budget on good 1 and buyer 2 on good 2, so . With and , line L5 gives , which halves the distance to . From , .
| 0 | ||
| 1 | ||
| 2 | ||
| 3 |
With , line L4 stops after 29 updates. Note that the linear demand is not a function where a buyer is indifferent, for example at ; the implementation raises an error there, and tatonnement as defined here needs a demand function.
Scarf's economy. Three agents and three goods; agent owns one unit of good and wants goods and (indices mod 3) in equal amounts, a Leontief utility. The equilibrium prices are the multiples of . Along the continuous process both and stay constant, so from the prices circle the equilibrium forever. The additive rule with is worse: grows from to about after 100 rounds and after 1000, and prices turn negative after about rounds.
Correctness
The proof is in proofs/correctness.md. It shows:
- With , prices stay positive, and a price vector is a rest point of line L5 if and only if it is an equilibrium. When line L4 returns, is an -approximate equilibrium.
- In a Fisher market with Cobb-Douglas utilities, with the money spent on good , and once line L5 shrinks by the factor each round. The prices converge to the equilibrium at a geometric rate.
- The continuous process converges to the equilibrium ray under strict gross substitutes (Arrow, Block and Hurwicz 1959). The proof uses the Lyapunov function : the goods with the highest ratio to the equilibrium prices have negative excess demand, so their prices fall.
- In Scarf's economy, Walras' law gives , and gives . The orbit from a point off the equilibrium ray never reaches it, and the additive rule increases by in every round.
Proof: Rest points of tatonnement are equilibria, and when it convergesfull
Fix goods with supplies and an excess demand function on positive price vectors with . Line L5 of the algorithm maps to with and .
Claim 1 (positive prices). If then . Proof. , so the factor is at least .
Claim 2 (rest points). For , if and only if . Proof. with holds exactly when , that is, when .
Claim 3 (output). If line L4 returns at round , then for every , so is an -approximate equilibrium. If line L6 reports convergence, the same holds for the returned . Proof. Both lines test exactly this condition on the returned vector.
The algorithm runs at most rounds, so it always stops. Whether it converges depends on the market, as the next claims show.
Claim 4 (Cobb-Douglas Fisher markets). Let buyer have budget and spend the fixed share of it on good , with , and let each good have supply and . Then , the unique equilibrium is , and from any the iterates of line L5 converge to . Once , .
Proof. Buyer buys units of good , so the demand for good is and , which is exactly when . Each coordinate of depends only on its own price, so fix .
If , then and , so . The new price lies between and , so it is again at least .
If , then and . After at most such rounds the price is at least , and it is then below .
After that, shrinks by the factor in every round, so it is at most after more rounds.
Claim 5 (the check value). In the Fisher market with budgets , unit supplies and linear utilities , , with and , the iterates are . Proof. While , buyer 1 has bang per buck on good 1 and buyer 2 has on good 2, so each buyer spends her budget on her own good, and . This is the case of Claim 4, so as long as . The formula holds at , and by induction for every : the iterates have and , so stays inside and both prices stay above .
Claim 6 (Arrow, Block and Hurwicz). Let be continuously differentiable on , homogeneous of degree , satisfy Walras' law , and have strict gross substitutes: for all . Let be an equilibrium. Then the equilibrium prices are exactly the multiples of , and every solution of with converges to with .
Proof. Step 1. Let not be a multiple of . Let and the set of goods that attain it. Then for every . Indeed, let , so by homogeneity, for , and for , a nonempty set. On the segment , , the derivative of for is , since every term has a positive derivative and a negative difference. So . In the same way, the goods with the smallest ratio have . In particular is not an equilibrium, which proves the first statement.
Step 2. Let and . Along a solution, has the right derivative , the largest derivative among the coordinates that attain the maximum, and by Step 1 this is negative whenever is not a multiple of . So does not increase, and in the same way does not decrease. Also . Hence the solution stays in the compact set of positive vectors, on which is , so the solution exists for all .
Step 3. is nonincreasing and bounded below, so it has a limit . Let be a limit point of for some ; it exists because is compact, and by continuity. Suppose is not a multiple of . By Step 2, the solution that starts at has for some . Solutions depend continuously on the initial point, so and , against for all . So every limit point is a multiple of with norm , and the only such point is . A path in a compact set whose only limit point is converges to it.
Discrete rules with a fixed step need more: a step that is too large can overshoot even under gross substitutes. Codenotti, McCune and Varadarajan (2005) and Cole and Fleischer (2008) prove convergence of discrete rules with suitable steps; the implementation only tests convergence on CES markets with a small step.
Claim 7 (Scarf's economy cycles). Let agent (indices mod 3) own one unit of good and have the Leontief utility . Then
the equilibria are the multiples of , both and are constant along , and the additive rule satisfies .
Proof. Agent has income and buys units of goods and . Good is bought by agents and , so its excess demand is , which is the formula above. For , means , that is , that is . With three goods, these three equations say that all prices are equal. So the equilibria are exactly the multiples of .
Walras' law: , because the two sums are the same sum over the three pairs of neighbors. Then , and .
For the product, after shifting the index of the second sum by one, and each term is , which sums to around the cycle. So .
On the sphere of positive vectors, the product has its unique maximum at the equilibrium , by the inequality of arithmetic and geometric means applied to . A solution that starts at a positive point off the equilibrium ray keeps its norm and its smaller product, so it stays at a positive distance from every equilibrium and never converges. The additive rule increases by in every round in which is not an equilibrium.
Complexity
A round costs one evaluation of plus time; in a Fisher market with linear, CES or Cobb-Douglas utilities an evaluation takes , so rounds take time and extra space. The number of rounds is the hard part. In the Cobb-Douglas case it is once prices are within a factor 2 of equilibrium. Codenotti, McCune and Varadarajan (2005) proved that a discrete tatonnement reaches an approximate equilibrium in polynomial time for markets with weak gross substitutes, and Cole and Fleischer (2008) bounded the rate of convergence of multiplicative updates for several classes of markets. Without gross substitutes there is no bound in general: the process may cycle.
Properties
- Local information. Each price moves only according to the excess demand of its own good. No agent reports her utility; the auctioneer only asks for demands.
- Rest points are equilibria. With positive prices, is fixed by line L5 exactly when .
- Scale invariant. Since is homogeneous of degree , multiplying by a constant multiplies every iterate by it.
- Not monotone. Unlike the DGS auction, prices can go up and down.
- Float arithmetic. The output is approximate. To get an exact equilibrium of a linear market, use a combinatorial method such as the DPSV algorithm.
Variants and improvements
- Continuous time. , or for sign-preserving functions . Arrow and Hurwicz (1958) and Arrow, Block and Hurwicz (1959) proved global stability under gross substitutes.
- Gradient view. For Fisher markets, Cheung, Cole and Devanur (2020) showed that a multiplicative tatonnement is a generalized gradient descent on a convex function of the prices. This gives convergence for some markets beyond gross substitutes. Proportional response dynamics is a related method that updates bids instead of prices, as mirror descent on a convex program.
- Ascending auctions. With indivisible items and money, the Kelso-Crawford process and the DGS auction only raise prices, in discrete steps, and stop at an exact Walrasian equilibrium.
- Global methods. For markets without gross substitutes, the Scarf algorithm finds approximate equilibria by simplicial path following, at the cost of an exponential worst case.
When to use it
Use it as a model of how prices react in a decentralized market, and as an algorithm when the demand has gross substitutes and only demand queries are available, for example in a simulation where agents are black boxes. For exact equilibria of linear Fisher markets use the Eisenberg-Gale program or a combinatorial algorithm. For markets with complements, use a method with a convergence guarantee for that class, or expect cycles.
Pitfalls
- A step that is too large in line L5 makes prices overshoot. In the tests, CES Fisher markets with converge with , but one of them fails to converge in 5000 rounds with . Gross substitutes alone does not make every discrete step size work.
- Without the cap in line L5, a good with huge excess demand at a tiny price gets a huge jump, and the next round may overshoot by a large factor.
- The additive rule can make prices negative. In Scarf's economy it does so after enough rounds, and even before that it spirals outward.
- The stopping test in line L4 must be relative to the supplies . An absolute test on means different things for goods with supplies of very different size.
- Line L3 needs a demand function. With linear utilities the demand is a set at prices where a buyer is indifferent, and these are exactly the equilibrium prices of many markets; the excess demand there must be chosen, and a naive choice can make the prices jump around the equilibrium.
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/tatonnement/. The authors are listed in prov/ZA6PKF.jsonl.
"""Discrete tatonnement: move each price in the direction of its excess demand.
A market is given by an excess demand function z(p) -> list of floats, one per good, and the
supply s_j of each good. The multiplicative rule p_j <- p_j (1 + step * min(z_j / s_j, 1)) keeps
prices positive for 0 < step < 1. The additive rule p <- p + step * z is the Euler scheme of the
continuous process dp/dt = z(p) of Arrow, Block and Hurwicz. All arithmetic is floating point;
convergence means max_j |z_j| / s_j <= tol.
"""
def tatonnement(excess, p0, step, rounds, tol, supply=None):
"""Run the multiplicative rule. Return (p, t, converged), where t is the number of updates."""
m = len(p0)
s = supply or [1.0] * m
p = [float(q) for q in p0] # @line L1
for t in range(rounds): # @line L2
z = excess(p) # @line L3
if max(abs(z[j]) / s[j] for j in range(m)) <= tol: # @line L4
return p, t, True
p = [p[j] * (1 + step * min(z[j] / s[j], 1.0)) for j in range(m)] # @line L5
z = excess(p)
return p, rounds, max(abs(z[j]) / s[j] for j in range(m)) <= tol # @line L6
def tatonnement_additive(excess, p0, step, rounds):
"""Run the additive rule p <- p + step * z(p) and return the list of all price vectors."""
path = [[float(q) for q in p0]]
for _ in range(rounds):
p = path[-1]
z = excess(p)
path.append([p[j] + step * z[j] for j in range(len(p))])
return path
# Excess demand functions of some markets with one unit of each good.
def fisher_cobb_douglas(a, budgets):
"""Fisher market, buyer i spends the share a[i][j] of her budget on good j."""
def z(p):
return [sum(a[i][j] * budgets[i] for i in range(len(a))) / p[j] - 1 for j in range(len(p))]
return z
def fisher_ces(a, budgets, rho):
"""Fisher market with CES utilities (sum_j a_ij x_ij^rho)^(1 / rho), 0 != rho < 1.
For 0 < rho < 1 the goods are gross substitutes."""
sigma = 1 / (1 - rho)
def z(p):
out = [-1.0] * len(p)
for i, row in enumerate(a):
denom = sum(row[k] ** sigma * p[k] ** (1 - sigma) for k in range(len(p)) if row[k] > 0)
for j in range(len(p)):
if row[j] > 0:
out[j] += budgets[i] * row[j] ** sigma * p[j] ** (-sigma) / denom
return out
return z
def fisher_linear(u, budgets):
"""Fisher market with linear utilities, where each buyer has a single best good. The demand is
not a function at prices where a buyer is indifferent, so those prices raise an error."""
def z(p):
out = [-1.0] * len(p)
for i, row in enumerate(u):
bang = [row[j] / p[j] for j in range(len(p))]
best = max(bang)
top = [j for j in range(len(p)) if bang[j] == best]
if len(top) > 1:
raise ValueError("buyer %d has several best goods" % i)
out[top[0]] += budgets[i] / p[top[0]]
return out
return z
def scarf(p):
"""Scarf's exchange economy: consumer j owns one unit of good j and wants goods j and j + 1 in
equal amounts (indices mod 3). The equilibrium prices are the multiples of (1, 1, 1)."""
m = len(p)
return [p[j - 1] / (p[j - 1] + p[j]) - p[(j + 1) % m] / (p[j] + p[(j + 1) % m]) for j in range(m)]
test_tatonnement.py 105 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/tatonnement/. The authors are listed in prov/ZA6PKF.jsonl.
import random
import unittest
from tatonnement import (fisher_cobb_douglas, fisher_ces, fisher_linear, scarf, tatonnement,
tatonnement_additive)
class TestTatonnement(unittest.TestCase):
def test_check_value(self):
# Linear Fisher market of the page: while p_1 / p_2 stays in (1/2, 2), z_j = 1 / p_j - 1
# and the step with factor 1/2 halves the distance to (1, 1).
z = fisher_linear([[2, 1], [1, 2]], [1, 1])
p = [0.8, 1.4]
for t in range(1, 8):
p, _, _ = tatonnement(z, p, 0.5, 1, 0.0)
self.assertAlmostEqual(p[0], 1 - 0.2 / 2 ** t, delta=1e-12)
self.assertAlmostEqual(p[1], 1 + 0.4 / 2 ** t, delta=1e-12)
p, t, ok = tatonnement(z, [0.8, 1.4], 0.5, 200, 1e-9)
self.assertTrue(ok)
self.assertAlmostEqual(p[0], 1.0, delta=1e-8)
self.assertAlmostEqual(p[1], 1.0, delta=1e-8)
def test_linear_tie_has_no_demand_function(self):
z = fisher_linear([[2, 1], [1, 2]], [1, 1])
with self.assertRaises(ValueError):
z([2.0, 1.0])
def test_cobb_douglas_contracts(self):
rng = random.Random(1)
for _ in range(20):
n, m = rng.randint(1, 4), rng.randint(1, 4)
a = []
for _ in range(n):
w = [rng.random() for _ in range(m)]
a.append([v / sum(w) for v in w])
budgets = [rng.uniform(0.5, 3) for _ in range(n)]
c = [sum(a[i][j] * budgets[i] for i in range(n)) for j in range(m)]
z = fisher_cobb_douglas(a, budgets)
step = rng.uniform(0.1, 0.9)
p = [cj * rng.uniform(0.5, 3) for cj in c]
for _ in range(10):
q, _, _ = tatonnement(z, p, step, 1, 0.0)
for j in range(m):
self.assertAlmostEqual(q[j] - c[j], (1 - step) * (p[j] - c[j]), delta=1e-9)
p = q
p, _, ok = tatonnement(z, p, step, 10000, 1e-10)
self.assertTrue(ok)
for j in range(m):
self.assertAlmostEqual(p[j], c[j], delta=1e-8)
def test_ces_markets_converge(self):
rng = random.Random(2)
for rho in [0.75, 0.5, 0.25, -1.0]:
for _ in range(5):
a = [[rng.uniform(0.1, 1) for _ in range(3)] for _ in range(3)]
budgets = [rng.uniform(0.5, 2) for _ in range(3)]
z = fisher_ces(a, budgets, rho)
p, _, ok = tatonnement(z, [1.0, 1.0, 1.0], 0.2, 5000, 1e-9)
self.assertTrue(ok)
self.assertAlmostEqual(sum(p), sum(budgets), delta=1e-7)
def test_large_step_can_fail(self):
# With rho = 3/4 demand is elastic, and the step 1/2 overshoots on one of these markets.
rng = random.Random(2)
results = []
for _ in range(5):
a = [[rng.uniform(0.1, 1) for _ in range(3)] for _ in range(3)]
budgets = [rng.uniform(0.5, 2) for _ in range(3)]
z = fisher_ces(a, budgets, 0.75)
results.append(tatonnement(z, [1.0, 1.0, 1.0], 0.5, 5000, 1e-9)[2])
self.assertIn(False, results)
def test_scarf_identities(self):
rng = random.Random(3)
for _ in range(100):
p = [rng.uniform(0.1, 5) for _ in range(3)]
z = scarf(p)
self.assertAlmostEqual(sum(p[j] * z[j] for j in range(3)), 0.0, delta=1e-12)
self.assertAlmostEqual(sum(z[j] / p[j] for j in range(3)), 0.0, delta=1e-9)
z2 = scarf([7 * q for q in p])
for j in range(3):
self.assertAlmostEqual(z[j], z2[j], delta=1e-12)
self.assertEqual(scarf([1.0, 1.0, 1.0]), [0.0, 0.0, 0.0])
def test_scarf_does_not_converge(self):
step = 0.1
path = tatonnement_additive(scarf, [1.2, 1.0, 0.8], step, 1000)
for t in range(1000):
p, q = path[t], path[t + 1]
z = scarf(p)
norm_p = sum(v * v for v in p)
norm_q = sum(v * v for v in q)
# Walras' law makes the additive step move away from the origin.
self.assertAlmostEqual(norm_q, norm_p + step * step * sum(v * v for v in z), delta=1e-9)
self.assertGreater(norm_q, norm_p)
self.assertGreater(max(abs(v) for v in z), 0.05)
_, _, ok = tatonnement(scarf, [1.2, 1.0, 0.8], 0.1, 3000, 1e-3)
self.assertFalse(ok)
if __name__ == "__main__":
unittest.main()
History
Walras (1874) described the groping of prices by which a market finds its equilibrium, with no trade before prices balance. Arrow and Hurwicz (1958) and Arrow, Block and Hurwicz (1959) studied the process as a differential equation and proved that it is globally stable when goods are gross substitutes. Scarf (1960) showed with an economy with complementary goods that the process can cycle forever, so no general stability theorem holds. Computer science returned to tatonnement as a distributed algorithm: Codenotti, McCune and Varadarajan (2005) proved polynomial-time convergence to approximate equilibria for weak gross substitutes, Cole and Fleischer (2008) studied fast multiplicative updates and ongoing markets, and Cheung, Cole and Devanur (2020) explained tatonnement in Fisher markets as gradient descent.
References
- Leon Walras, Elements d'economie politique pure, Corbaz, Lausanne, 1874, the theory of exchange (the groping, or tatonnement, by which prices of goods in excess demand rise and the others fall)
- Kenneth J. Arrow and Leonid Hurwicz, On the stability of the competitive equilibrium, I, Econometrica 26(4), 522-552 (1958), the whole paper (local and global stability of the continuous process, gross substitutes)
- Kenneth J. Arrow, H. D. Block and Leonid Hurwicz, On the stability of the competitive equilibrium, II, Econometrica 27(1), 82-109 (1959), the whole paper (global stability of continuous tatonnement for any number of goods under gross substitutes)
- Herbert Scarf, Some examples of global instability of the competitive equilibrium, International Economic Review 1(3), 157-172 (1960), the whole paper (exchange economies with complementary goods in which the continuous process cycles)
- Bruno Codenotti, Benton McCune and Kasturi Varadarajan, Market equilibrium via the excess demand function, Proceedings of the 37th ACM Symposium on Theory of Computing (STOC 2005), 74-83, the whole paper (a discrete tatonnement that reaches an approximate equilibrium in polynomial time under weak gross substitutes)
- Richard Cole and Lisa Fleischer, Fast-converging tatonnement algorithms for one-time and ongoing market problems, Proceedings of the 40th ACM Symposium on Theory of Computing (STOC 2008), the whole paper (multiplicative price updates and their rate of convergence)
- Yun Kuen Cheung, Richard Cole and Nikhil R. Devanur, Tatonnement beyond gross substitutes? Gradient descent to the rescue, Games and Economic Behavior 123 (2020), the whole paper (tatonnement in Fisher markets as gradient descent on a convex function)
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 ZA6PKF Edit this page History Report an error Markdown