The RANKING algorithm for online bipartite matching (1 - 1/e, tight) #
This module formalizes the randomized RANKING algorithm of Karp, Vazirani, and Vazirani
[KVV90], proves its exact 1 - 1/e competitive ratio via the randomized
primal-dual analysis of Devanur, Jain, and Kleinberg [DJK13], and proves the
matching 1 - 1/e + o(1) Yao minimax upper bound for all randomized online bipartite matching
algorithms against an oblivious adversary.
Proof structure #
- Key-based greedy matching (
rankingByKey,rankingDet,rankingAlg): Given an injective priority keykey : L → ℕ,rankingByKey key hkeygreedily matches each arriving online vertex to its unmatched neighbor minimizingkey.rankingAlg Lsamples a rankingπ : L ≃ Fin (Fintype.card L)uniformly at random and runsrankingDet π. - Dominance and monotonicity (
rankingByKey_monotone_choice,rankingByKey_dominance): ComparingrankingByKeyonarrivalsand ondeleteOffline u arrivalsvia a three-state alternating-path invariant (same,justU,shifted w) proves both:- Monotonicity: if online vertex
jis matched towwithoutu, then withuit is matched to someawithkey a ≤ key w. - Dominance: if
u ∈ arrivals[j]remains unmatched inarrivals, thenarrivalsanddeleteOffline u arrivalsproduce identical matchings andjis matched to somewwithkey w < key u.
- Monotonicity: if online vertex
- Discrete randomized primal-dual fitting (
djkWeight,rankingGridAlg,rankingGrid_competitive_ratio): Sampling i.i.d. uniform discrete ranksy : L → Fin K(breaking ties by a fixed orderord : L ≃ Fin n) with discrete weightdjkWeight K r = (K / (K + 1)) ^ (K - r), we define explicit primal-dual variablesdjkDualLeftanddjkDualRightsumming to the matching size (sum_djkDual_eq_card) whose average overy u ∈ Fin Kis at least1 - (K / (K + 1)) ^ Kfor every edge (sum_djkDual_update_ge). Averaging overyyields ratio1 - (K / (K + 1)) ^ KforrankingGridAlg L K. - Exact
1 - 1/ecompetitive ratio (ranking_competitive_ratio): Conditioned ony : L → Fin Kbeing injective (which happens with probabilityK.descFactorial n / K ^ n → 1asK → ∞),rankingGridDet y ordinduces a uniform random permutationπ : L ≃ Fin n. Passing to the limitK → ∞gives the exact bound(1 - Real.exp (-1)) * M.card ≤ expectedMatchingSize (rankingAlg L) arrivalsfor every finiteL, every arrival sequencearrivals, and every matchingM. - Tight
1 - 1/eYao minimax upper bound (triArrivals,det_triArrivals_avg_le_harmonic,exists_rand_harmonic_upper_bound,exists_rand_exp_upper_bound,not_rand_competitive_of_gt_one_sub_exp_neg_one): On a uniformly permuted upper-triangular graphtriArrivals n σ(which always has a perfect matching of sizen), the symmetryσ ↦ σ * Equiv.swap t jyields the exact telescoping recurrence(n - t) * E[U_{t+1}] = (n - t - 1) * (E[U_t] - p_t), implying∑ t, p_t / (n - t) ≤ 1and henceE[|M|] ≤ n - s * (harmonic n - harmonic s)for everys ≤ n(in particular3/4 * OPTatn = 2, and(1 - 1/e) * n + 2for alln ≥ 1). Yao's principle transfers this bound to every randomized online algorithm.
Main definitions #
Cslib.Algorithms.Online.BipartiteMatching.minByKey,rankingByKey,rankingDet,rankingAlg: deterministic key-ordered matching and the randomizedRANKINGalgorithm.Cslib.Algorithms.Online.BipartiteMatching.deleteOffline: deleting an offline vertex from an arrival sequence.Cslib.Algorithms.Online.BipartiteMatching.djkWeight,rankingGridDet,rankingGridAlg,djkDualLeft,djkDualRight: discrete DJK randomized primal-dual construction.Cslib.Algorithms.Online.BipartiteMatching.triArrivals,triPerfectMatching: the permuted upper-triangular hard family for Yao's minimax upper bound.
Main results #
Cslib.Algorithms.Online.BipartiteMatching.rankingByKey_monotone_choice,rankingByKey_dominance: monotonicity and dominance lemmas forRANKING.Cslib.Algorithms.Online.BipartiteMatching.sum_djkDual_eq_card,sum_djkDual_update_ge,rankingGrid_competitive_ratio: discrete primal-dual feasibility and1 - (K / (K + 1)) ^ Kbound.Cslib.Algorithms.Online.BipartiteMatching.ranking_competitive_ratio:RANKINGachieves exact competitive ratio1 - 1/eon every finite bipartite graph.Cslib.Algorithms.Online.BipartiteMatching.det_triArrivals_avg_le_harmonic,exists_rand_harmonic_upper_bound,exists_rand_exp_upper_bound,not_rand_competitive_of_gt_one_sub_exp_neg_one: no randomized online matching algorithm beats1 - 1/eagainst an oblivious adversary.
References #
Key-ordered greedy matching and RANKING #
Computable minimum-key element of a finite set U : Finset L for an injective key
key : L → ℕ. Returns none iff U = ∅.
Deterministic greedy online matching algorithm matching each arriving vertex to the unmatched
neighbor minimizing key.
Deterministic RANKING with a fixed ranking bijection π : L ≃ Fin (Fintype.card L).
The randomized RANKING algorithm [KVV90]: sample a ranking
π : L ≃ Fin (Fintype.card L) uniformly at random and run rankingDet π.
Dominance and monotonicity (three-state alternating-path invariant) #
Delete offline vertex u from every neighborhood in an arrival sequence.
Monotonicity lemma [DJK13]: if online vertex j is matched to w when
offline vertex u is deleted, then in the full graph j is matched to some vertex a of priority
key a ≤ key w.
Dominance lemma [DJK13]: if (u, j) is an edge (u ∈ arrivals[j]) and
offline vertex u remains unmatched by rankingByKey key hkey on arrivals, then:
- deleting
uleaves all match choices unchanged; and - in
deleteOffline u arrivals, online vertexjis matched to some offline vertexwof strictly higher priority (key w < key u).
Discrete Devanur–Jain–Kleinberg randomized primal-dual analysis #
Discrete DJK dual weight g_K(r) = (K / (K + 1)) ^ (K - r) for rank r ≤ K.
Deterministic RANKING on discrete ranks y : L → Fin K with tie-breaker ord.
Randomized RANKING sampling i.i.d. uniform discrete ranks y : L → Fin K with fixed
tie-breaker ord.
DJK dual variable α(y, u) for offline vertex u: djkWeight K (y u) if u is matched,
else 0.
DJK dual variable β(y, j) for online vertex j: 1 - djkWeight K (y a) if j is matched
to a, else 0.
Exact primal-dual equality: for every discrete rank vector y, the dual variables sum to
the matching size |M(y)|.
Expected dual feasibility on every edge [DJK13]: for any edge (u, j)
(u ∈ arrivals[j]) and any ranks y on the other vertices, summing α + β over all K
choices of y u is at least K * (1 - (K / (K + 1)) ^ K).
Discrete RANKING competitive ratio: with uniform i.i.d. ranks in Fin K,
rankingGridAlg L K achieves expected matching size at least (1 - (K / (K + 1)) ^ K) * |M| for
every matching M.
Exact 1 - 1/e competitive ratio of RANKING #
Karp–Vazirani–Vazirani (1990) / Devanur–Jain–Kleinberg (2013) exact 1 - 1/e theorem:
for every finite offline vertex set L, every arrival sequence arrivals, and every matching
M of graphOfArrivals arrivals, rankingAlg L achieves expected matching size at least
(1 - e⁻¹) * |M|.
Tight 1 - 1/e Yao minimax upper bound (permuted upper-triangular graph) #
Permuted upper-triangular arrival sequence triArrivals n σ on Fin n: online vertex j is
adjacent to {σ(i) | j ≤ i < n}, i.e. {u | j ≤ σ⁻¹(u)}.
The canonical perfect matching {(σ(j), j) | j : Fin n} of triArrivals n σ.
Harmonic deterministic average upper bound on triArrivals n σ [KVV90]:
for every n ≥ 1, every s ≤ n, and every deterministic online algorithm A : DetAlg (Fin n),
the average matching size of A over all n! permutations σ is at most
n - s * (harmonic n - harmonic s).
Yao harmonic upper bound for all randomized algorithms: for every n ≥ 1, every s ≤ n,
and every randomized online matching algorithm μ : RandAlg (Fin n), there exists a permutation
σ such that triArrivals n σ admits a perfect matching of size n while
μ.expectedMatchingSize (triArrivals n σ) ≤ n - s * (harmonic n - harmonic s).
Explicit 1 - 1/e + 2/n Yao upper bound: for every n ≥ 1 and every randomized online
matching algorithm μ : RandAlg (Fin n), there exists a permutation σ such that
triArrivals n σ admits a perfect matching of size n while
μ.expectedMatchingSize (triArrivals n σ) ≤ (1 - e⁻¹) * n + 2.
Tight 1 - 1/e randomized impossibility [KVV90]: no randomized online
bipartite matching algorithm μ : RandAlg (Fin n) (where RandAlg L := PMF (DetAlg L) ranges over
discrete, countably supported mixtures of deterministic online algorithms against an oblivious
adversary) achieves competitive ratio strictly above 1 - 1/e, even with an arbitrary additive
slack b.