Online budgeted ad allocation (AdWords): Greedy and MSVV #
This module formalizes the online budgeted ad allocation (AdWords) problem from Lahaie, Pennock, Saberi, and Vohra, Sponsored Search Auctions, §28.4.1 (pp. 707–711 and Exercise 28.6, p. 716):
- the offline fractional linear program relaxation (28.11) and its dual, weak duality,
complementary slackness, and the equivalence between the keyword-multiplicity form (demands
r_i) and the unit-demand arrival-sequence form (r_t = 1); - the Greedy online algorithm in both truncated-spend (
greedyTruncRule, capped bidmin (q j) (B j - s j), exact1 / 2-competitive wheneverb t j ≤ B jwith no small-bid assumption) and all-or-nothing (greedyAllOrNothingRule, reject ifs j + q j > B j, exact(1 - R) / (2 - R)-competitive wheneverb t j ≤ R * B jand0 ≤ R ≤ 1) models, plus the tight two-bidder worst-case family from p. 709; - Algorithm 1 (MSVV) scaling bids by
φ(x) = 1 - exp (x - 1)in both truncated-spend (msvvTruncRule,(1 - exp (-1)) * exp (-R)-competitive for allR ≥ 0) and all-or-nothing (msvvAllOrNothingRule,(1 - exp (-1)) * (1 - R) * exp (-R)-competitive for0 ≤ R ≤ 1) models, proved against arbitrary fractional LP solutions without assuming thatOPTexhausts budgets (Exercise 28.6, p. 716), together with theFilter.Tendstolimits→ 1 - exp (-1)asR → 0; - the continuous trade-off inequality (
msvvTrunc_tradeoff, the continuous analogue of Lemma 28.4, display (28.13), p. 710) and the discretek-bucket geometric-series step (discretePhi_tradeoffandtendsto_discretePhi_zero, displays (28.12)–(28.13), pp. 710–711).
Model #
An advertiser set ι ([Fintype ι] [LinearOrder ι]) has budgets budget : ι → ℝ (assumed
strictly positive in the competitive-ratio theorems). A keyword LP LP κ ι records bids
bid : κ → ι → ℝ, budgets budget : ι → ℝ, and keyword demands demand : κ → ℝ. Given a finite
query arrival sequence b : Fin T → ι → ℝ, the deterministic online algorithms maintain cumulative
spending spent : ι → ℝ via a shared step-runner (spentAt) and tie-break maximal scores toward
the smallest advertiser in ι using argmaxOver.
Because the online problem here deals with real-valued revenue maximization against a fractional LP
relaxation weighted by Real.exp, it is kept separate from Cslib.DataStructure.Online.Problem,
which models integer (ℕ-valued) step-cost minimization.
Source mapping and discrepancies verified on the page images #
Every locator below was verified on rendered page images of [LPSV07]:
- LP (28.11) and dual (§28.4.1, p. 708):
LP,LP.IsPrimalFeasible,LP.IsDualFeasible,LP.primalObj_le_dualObj, andLP.complementarySlackness. - Greedy
1/2ratio (§28.4.1, p. 709): without boundingb t j ≤ B j, the fractional LP (28.11) has integrality gapn(a single query wherenunit-budget bidders each bidnhas LP valuenviax t j = 1 / n, while any online allocation collects at most1). Withb t j ≤ B j, capped-bid truncated greedy achieves exact1 / 2(greedyTrunc_competitive). All-or-nothing greedy achieves the sharper bound(1 - R) / (2 - R) ≥ (1 - R) / 2underb t j ≤ R * B jand0 ≤ R ≤ 1(greedyAllOrNothing_competitive). - Two-bidder greedy example (§28.4.1, p. 709): with
B₁ = B₂ = 2,b₁₁ = 2,b₁₂ = 2 - ε,b₂₁ = 2,b₂₂ = ε(0 < ε < 2), the book states greedy earns2 + εand that assigning query 2 to bidder 1 and query 1 to bidder 2 yields4. The true sum is2 + (2 - ε) = 4 - ε(certified optimal by a dual witness for0 < ε ≤ 1; for1 < ε < 2,2 + ε > 4 - ε). The ratio(2 + ε) / (4 - ε)still converges to1 / 2asε → 0. - Algorithm 1 & Theorem 28.3 (upper bound half) (§28.4.1, pp. 709–711) and Exercise 28.6
(p. 716): the proof sketch in the book introduces discrete
k-bucketsΦ(s)(28.12) and assumes that the optimal solution exhausts all budgets; in addition, the second line of the aligned sum display on p. 710 prints∑_{j=0}^i Φ(i)where∑_{j=0}^i Φ(j)is intended. HeremsvvTrunc_competitiveandmsvvAllOrNothing_competitivegive exact, non-asymptotic finite-bid proofs via the continuous exponential primal-dual potentialβ_j(f) = (exp f - 1) / (exp 1 - 1)(without assuming budget exhaustion ork-discretization rounding).
Open work and limitations #
- No optimality lower bound: the remark preceding Theorem 28.3 on p. 709 ("no deterministic or
randomized algorithm can achieve a better competitive ratio") is not formalized here; only
the competitive-ratio guarantee (revenue lower bound) for Algorithm 1 is proved. The matching
lower bound stays open under issue
#7789. - No running-time claim: the algorithms are pure noncomputable functions over
ℝusingReal.exp; no Word-RAM or Turing-machine time bound is asserted.
Main definitions #
Cslib.Algorithms.Lean.OnlineMatching.AdWords.LP: the offline LP relaxation (28.11), withLP.IsPrimalFeasible,LP.IsDualFeasible,LP.primalObj,LP.dualObj,LP.unit, andLP.countLP.Cslib.Algorithms.Lean.OnlineMatching.AdWords.StepResult,argmaxOver,spentAt,finalSpent,revenue,choiceAt,paymentAt: shared deterministic sequential allocation runner.Cslib.Algorithms.Lean.OnlineMatching.AdWords.msvvWeight: the discount functionφ(x) = 1 - Real.exp (x - 1).Cslib.Algorithms.Lean.OnlineMatching.AdWords.greedyTruncRule,greedyAllOrNothingRule,msvvTruncRule,msvvAllOrNothingRule: the four online allocation rules.Cslib.Algorithms.Lean.OnlineMatching.AdWords.discretePhi: the discrete tradeoff functionΦ(s) = 1 - (1 - 1 / k) ^ (k - s)(display (28.12), p. 710).
Main results #
LP.primalObj_le_dualObj: weak duality for Eq. (28.11).LP.complementarySlackness: complementary slackness at primal–dual optimality (p. 708).LP.exists_unitPrimal_of_countLP: correspondence between the keyword-frequency LP and the unit-demand arrival-sequence LP.greedyTrunc_competitive,greedyAllOrNothing_competitive: competitive ratios for Greedy (1 / 2exact;(1 - R) / (2 - R)all-or-nothing).greedy_two_bidder_example,tendsto_two_bidder_ratio: tight two-bidder instance (p. 709).msvvTrunc_tradeoff: continuous trade-off inequality (analogue of Lemma 28.4, display (28.13)).msvvTrunc_competitive,msvvTrunc_competitive_countLP: exact(1 - exp (-1)) * exp (-R)revenue guarantee for MSVV Algorithm 1 (truncated spend), including Exercise 28.6.msvvAllOrNothing_competitive,msvvAllOrNothing_competitive_countLP: exact(1 - exp (-1)) * (1 - R) * exp (-R)revenue guarantee for MSVV Algorithm 1 (all-or-nothing), including Exercise 28.6.tendsto_greedyAllOrNothing_factor,tendsto_msvvTrunc_factor,tendsto_msvvAllOrNothing_factor: small-bid asymptotic limits asR → 0.discretePhi_tradeoff,discretePhi_tradeoff_zero,tendsto_discretePhi_zero: the discrete geometric-series step of NRTV pp. 710–711 and its limit1 - exp (-1).
References #
Offline fractional LP relaxation (NRTV Eq. 28.11) #
The offline fractional linear program for the online budgeted ad allocation problem
([LPSV07], §28.4.1, Eq. (28.11), p. 708): keywords κ with arrival
frequencies demand, advertisers ι with budgets budget, and bid matrix bid.
Weak duality for the AdWords LP relaxation Eq. (28.11) ([LPSV07], §28.4.1, p. 708).
Complementary slackness for Eq. (28.11) ([LPSV07], §28.4.1, p. 708):
at primal–dual equality primalObj x = dualObj α β, every pair (i, j) with x i j > 0
satisfies (1 - β j) * bid i j = α i and maximizes (1 - β k) * bid i k over all advertisers
k.
The keyword-frequency LP relaxation Eq. (28.11) induced by a sequence queries : Fin T → κ
of arriving keywords: demand i is the number of arrivals t : Fin T with queries t = i.
Every feasible fractional solution x to the keyword-frequency LP countLP spreads evenly
across matching arrival steps into a feasible solution y of the unit-demand LP unit with the
exact same primal objective value ([LPSV07], §28.4.1, p. 708).
Shared deterministic online allocation runner #
The deterministic argmax of score : ι → ℝ over a finite set S : Finset ι, breaking ties
toward the smallest advertiser in [LinearOrder ι], or none if S is empty.
Specification characterizing the exact tie-breaking choice argmaxOver S score = some j:
j ∈ S, score j maximizes score on S, and every strictly smaller k ∈ S has strictly
smaller score.
One-step outcome produced by an online allocation rule on a single arriving query.
Update the cumulative spend vector spent with a single StepResult.
Type alias for a deterministic online allocation rule: given current cumulative spending
spent : ι → ℝ and the arriving query's bid vector q : ι → ℝ, return a StepResult ι.
Cumulative spending vector after processing the first t.val queries (t : Fin (T + 1)).
Cumulative spending vector after processing all T queries.
Total online revenue collected after processing all T queries: ∑ j, finalSpent rule b j.
Chosen advertiser at query arrival step t : Fin T.
Payment collected at query arrival step t : Fin T.
Initial spending vector before any queries arrive is identically zero.
One-step recurrence updating cumulative spending after processing query t.
When an unallocated query always charges 0, revenue equals the sum of per-step payments.
The four online allocation rules #
The MSVV trade-off function φ(x) = 1 - exp (x - 1)
([LPSV07], §28.4.1, p. 709).
The MSVV trade-off weight φ(x) = 1 - exp (x - 1) is nonnegative for x ≤ 1.
The MSVV trade-off weight φ(x) = 1 - exp (x - 1) is antitone (nonincreasing).
Capped-bid truncated Greedy allocation rule: among advertisers with unexhausted budget
s j < B j, pick the one maximizing the effective payment min (q j) (B j - s j) (ties broken
toward the smallest advertiser), and charge that amount. Coincides with raw-bid Greedy whenever
the winning bid fits in remaining budget.
All-or-nothing Greedy allocation rule: among advertisers whose remaining budget fits the
full bid (s j + q j ≤ B j), pick the one maximizing q j (ties broken toward the smallest
advertiser), and charge q j.
MSVV Algorithm 1 ([LPSV07], §28.4.1, p. 709) with truncated spend:
among advertisers with unexhausted budget s j < B j, pick the one maximizing
q j * msvvWeight (s j / B j) (ties broken toward the smallest advertiser), and charge
min (q j) (B j - s j).
MSVV Algorithm 1 ([LPSV07], §28.4.1, p. 709) with all-or-nothing
spend: among advertisers with remaining budget s j + q j ≤ B j, pick the one maximizing
q j * msvvWeight (s j / B j) (ties broken toward the smallest advertiser), and charge q j.
Budget-safety invariants #
greedyTruncRule keeps every advertiser's cumulative spending inside [0, budget j].
greedyAllOrNothingRule keeps every advertiser's cumulative spending inside [0, budget j].
msvvTruncRule keeps every advertiser's cumulative spending inside [0, budget j].
msvvAllOrNothingRule keeps every advertiser's cumulative spending inside [0, budget j].
Greedy competitive ratios (NRTV §28.4.1, p. 709) #
Exact 1 / 2-competitive ratio for capped-bid truncated Greedy against the offline
fractional LP relaxation (28.11) ([LPSV07], §28.4.1, p. 709). Requires only
0 ≤ b t j ≤ budget j (no small-bid assumption and no assumption that OPT exhausts budgets).
Exact (1 - R) / (2 - R)-competitive ratio for all-or-nothing Greedy against the
offline fractional LP relaxation (28.11) ([LPSV07], §28.4.1, p. 709) when all
bids satisfy b t j ≤ R * budget j (0 ≤ R ≤ 1). Because 2 - R ≤ 2, this is strictly tighter
than the standard (1 - R) / 2 bound for non-zero R, and its factor tends to 1 / 2 as
R → 0 (tendsto_greedyAllOrNothing_factor).
As the bid-to-budget ratio R → 0, the all-or-nothing Greedy factor (1 - R) / (2 - R)
converges to 1 / 2.
Tight two-bidder worst-case example for Greedy (NRTV p. 709) #
Equal advertiser budgets B = ![2, 2] for the two-bidder example.
The off-diagonal integral allocation x 0 = ![0, 1], x 1 = ![1, 0] assigning query 1 to
bidder 2 and query 2 to bidder 1.
Tightness of the 1/2 ratio for Greedy ([LPSV07], §28.4.1, p. 709):
for 0 < ε < 2 with B = ![2, 2], b₁₁ = 2, b₁₂ = 2 - ε, b₂₁ = 2, b₂₂ = ε:
- Both
greedyTruncRuleandgreedyAllOrNothingRuleearn2 + ε. twoBidderOptAllocis LP-feasible and attains revenue4 - ε(correcting the printed4on NRTV p. 709).- For
0 < ε ≤ 1,4 - εis exact LP-optimal (every feasible fractional LP solutionxhasprimalObj x ≤ 4 - ε, certified by the dual witnessα = ![2 - ε, ε],β = ![1 - ε / 2, 0]).
The ratio (2 + ε) / (4 - ε) of the two-bidder greedy revenue to its true optimum 4 - ε
converges to 1 / 2 as ε → 0.
Exponential inequalities for the primal-dual MSVV proof #
Continuous trade-off inequality (analogue of NRTV Lemma 28.4) and Theorem 28.3 #
Continuous trade-off inequality for MSVV Algorithm 1 (truncated spend), the continuous
analogue of [LPSV07], Lemma 28.4, Eq. (28.13), p. 710. Holds against every
LP-feasible fractional solution x without assuming that OPT exhausts every budget.
MSVV Algorithm 1 competitive-ratio upper bound (truncated spend) — the revenue lower bound half of [LPSV07], Theorem 28.3 (pp. 709–711) and Exercise 28.6 (p. 716).
For every finite bid ratio R ≥ 0 with b t j ≤ R * budget j, every positive budget profile
budget, and every feasible fractional LP solution x to Eq. (28.11) (without assuming
OPT exhausts budgets):
(1 - exp (-1)) * exp (-R) * primalObj x ≤ revenue (msvvTruncRule budget) b.
The companion optimality lower bound ("no deterministic or randomized online algorithm beats
1 - 1/e") is not proved here and stays open under issue #7789. No running-time claim is
made.
MSVV Algorithm 1 competitive-ratio upper bound (truncated spend) lifted directly to the
keyword-frequency LP relaxation (28.11) countLP (demand i = #{t | queries t = i}).
MSVV Algorithm 1 competitive-ratio upper bound (all-or-nothing spend) — the revenue lower
bound half of [LPSV07], Theorem 28.3 (pp. 709–711) and Exercise 28.6
(p. 716), when a query is assigned to j only if s j + b t j ≤ budget j.
For every 0 ≤ R ≤ 1 with b t j ≤ R * budget j and every feasible fractional LP solution x
to Eq. (28.11) (without assuming OPT exhausts budgets):
(1 - exp (-1)) * (1 - R) * exp (-R) * primalObj x ≤ revenue (msvvAllOrNothingRule budget) b.
The matching optimality lower bound stays open under issue #7789. No running-time claim is made.
MSVV Algorithm 1 competitive-ratio upper bound (all-or-nothing spend) lifted directly to the
keyword-frequency LP relaxation (28.11) countLP (demand i = #{t | queries t = i}).
As the bid-to-budget ratio R → 0, the truncated-spend MSVV competitive factor converges to
1 - exp (-1) (1 - 1 / e).
As the bid-to-budget ratio R → 0, the all-or-nothing MSVV competitive factor converges to
1 - exp (-1) (1 - 1 / e).
Discrete k-bucket geometric series (NRTV displays 28.12–28.13, pp. 710–711) #
Discrete trade-off function Φ(s) = 1 - (1 - 1 / k) ^ (k - s)
([LPSV07], §28.4.1, display (28.12), p. 710).
The exact discrete geometric-series step proving NRTV p. 710–711 from display (28.13)
(correcting the printed inner index typo ∑_{j=0}^i Φ(i) → ∑_{j=0}^i Φ(j) on p. 710).
Given ∑ i, Φ(i) s_i ≤ ∑ i, Φ(i) w_i and w_i ≤ (∑_{j ≥ i} s_j) / k, yields
(1 - 1 / k) * Φ(0) * ∑ s_i ≤ ∑ (i / k) * s_i.
Exact error-free version of discretePhi_tradeoff when no budget is spent inside the empty
zero-interval (-1/k, 0] (w 0 = 0): Φ(0) * ∑ s_i ≤ ∑ (i / k) * s_i.
As the discretization k → ∞, discretePhi k 0 = 1 - (1 - 1 / k) ^ k converges to
1 - exp (-1) ([LPSV07], §28.4.1, p. 711).