Matching and Market Design: Introduction, Bipartite Matching NICOLE IMMORLICA, MICROSOFT RESEARCH NE NICOLE IMMORLICA, MSR NE RESEARCHER Background. Computer science, economics, applied research. Ph.D. 2005 (in computer science). Thesis: Computing with Strategic Agents. Postdocs 2005-2008. Studied applications of: theory to advertising markets at MSR, combinatorics to economics at CWI. Professor 2008-2012 (of computer science). Taught courses and advised students in CS-econ. Researcher 2012-present. Study CS-econ issues from the very theoretical to the very applied. NICOLE IMMORLICA, MSR NE RESEARCHER Research. What are realistic utopias for selfish societies? Mechanism Design: Can we systematically allocate scare resources to people who need it the most? Or sell the resources and generate high revenue? Social Networks: What behavioral patterns can be supported by various structures? What information can be learned? How does behavior impact structure? Market Design: What outcomes will be observed in matching markets, and how can we facilitate the matching process in practical settings? COURSE LOGISTICS Course. CS 286r: Topics at the Interface of Computer Science and Economics – Matching and Market Design. Website. www.Immorlica.com/marketDesign/Harvard Lectures. Fridays, 9am-noon, MD 221. Includes a 20 minute coffee break halfway through, and you’re all invited to join me for lunch afterwards. Teachers. Nicole Immorlica, Ran Shorrer, Brendan Lucier, Scott Kominers, and more! Workload. Readings/participation (around 20 pages/week), 2 problem sets (around 6 hrs each), course project (3 stages). Outline 1. Introduction: markets in practice and theory, discussion of market design 2. Bipartite Matching: elementary definitions, max cardinality & max weight matchings Part 1: Introduction. Markets agents objects Markets are a medium of exchange. Markets kidneys high ad slots schools workers agents objects students firms patients advertisers Sponsored Kidney School LaborExchange Markets Choice Search Examples Traditional markets: shopping malls, eBay, ad auctions, FCC spectrum auctions School choice: allocation of students to schools via centralized city-run program Labor markets: NRMP, cadet-branch matching Kidney exchange: matching of kidney donors to compatible recipients Market Design Al Roth Market Design Market design involves a responsibility for detail, a need to deal with all of a market’s complications, not just its principle features. Designers therefore cannot work only with the simple conceptual models used for theoretical insights into the general working of markets. Instead, market design calls for an engineering approach. – from The Economist as an Engineer, by Al Roth Market Design …this paper makes the case that experimental and computational economics are natural complements to game theory in the work of design. The paper also argues that some of the challenges facing both markets involve dealing with related kinds of complementarities, and that this suggests an agenda for future theoretical research. – from The Economist as an Engineer, by Al Roth Market Design Develop simple theory, …to deal with complexity in practice. Computer Science & Economics On Spherical Cows … Computer Science: computability P versus NP P: set of problems that can be solved efficiently (i.e., in polynomial time). NP: set of problems whose solutions can be checked efficiently. Computer Science: computability 3 6 8 1 2 9 4 3 2 7 8 5 9 4 5 8 9 Computer Science: computability 7 5 1 9 3 2 6 4 8 3 8 4 1 5 6 9 7 2 9 2 6 4 7 8 1 3 5 6 9 7 2 4 1 5 8 3 5 3 2 6 8 7 4 1 9 1 4 8 3 9 5 7 2 6 8 1 3 5 6 4 2 9 7 4 6 9 7 2 3 8 5 1 2 7 5 8 1 9 3 6 4 Computer Science: computability Traveling Salesman: find smallest route that visits each capitol. Computer Science: computability Student social network: Study groups of size two? Size three? Economics: rationality Many systems are composed of many independent self-interested agents These agents are • rational, i.e. they act in their own self-interest • and reason strategically, i.e. they take into account the actions of others Let’s play a game Experiment: The median game. 1. Guess an integer in [1, …, 100]. 2. Write your number on a piece of paper. P R I Z E : The people whose numbers are closest to 2/3 of the median win. The Median Game 25 45 Jose 0 Julian 50 Bruce Marcos 69 Nicole Calculating the winner: winner! 1. Sort the numbers: 0, 25, 45, 50, 69 2. Pick the middle one (the median): 45 3. Compute 2/3 of the median: 30 Are you a winner? Questions Given computability & rationality assumptions: • How will selfish agents behave? • What properties emerge as a result of selfish behavior? • Is it possible to formulate the rules of the system to encourage socially-optimal behavior? Market Design Develop simple theory, …to deal with complexity in practice. Market Design Complexities Thickness: need to attract a sufficient proportion of potential market participants to come together ready to transact with one another. – from What have we learned from market design?, by Al Roth Market Design Complexities Congestion: must provide enough time or fast enough transactions so that market participants can consider enough alternatives to arrive at satisfactory ones. – from What have we learned from market design?, by Al Roth Market Design Complexities Simplicity: must make it easy to participate in market as opposed to transacting outside of the marketplace or engaging in strategic behavior that reduces overall welfare. – from What have we learned from market design?, by Al Roth Market Design Complexities Others: • Asset to be traded • Nature of contracts • Medium of exchange • Measure of performance • Need for design • Market culture • Fairness and repugnance – from 1/22/14 post on The Leisure of the Theory Class, by Ricky Vohra Example: traditional markets Practice: FCC spectrum auctions, eBay, ad auctions etc.: sellers offer goods and services, buyers purchase via posted prices or auctions Example: traditional markets Issues: Strategic behavior, complex agent preferences, price discovery, packages and deals Example: traditional markets Theory: Existence of market-clearing prices, approximately optimal simple mechanisms, techniques to aid price discovery Example: school choice Practice: Boston, New York City, etc: students submit preferences about different schools; matched based on “priorities” (e.g., test scores, geography, sibling matches) Example: school choice Issues: NYC too slow to clear; Boston strategically complicated, result in unstable matches, many complaints in school boards Example: school choice Theory: theorists proposed alternate mechanisms including the Gale-Shapley algorithm for stable marriage, schools adopt these Example: entry-level labor markets Practice: National Residency Matching Program (NRMP): physicians look for residency programs at hospitals in the United States Example: entry-level labor markets Issues: 1950 1990 decentralized, centralized unraveling, clearinghouse, exploding offers 95% voluntary inefficiencies participation dropping participation sparks redesign to accommodate couples, system still in use Example: entry-level labor markets Theory: NRMP central clearinghouse algorithm corresponds to Gale-Shapley algorithm Example: kidney exchange Practice: In 2005: • 75,000 patients waiting for transplants • 16,370 transplants performed (9,800 from deceased donors, 6,570 from living donors) • 4,200 patients died while waiting Example: kidney exchange Issues: Source and allocation of kidneys: • cadaver kidneys: centralized matching mechanism based on priority queue • living donors: patient must identify donor, needs to be compatible • other: angel donors, black market sales Example: kidney exchange Theory: living donor exchanges: patient 1 donor 1 patient 2 donor 2 Example: kidney exchange Theory: living donor exchanges: adopted mechanism uses top-trading cycles, theory of maximum matching, results in improved welfare (many more transplants) Part 2: Bipartite Matching. Matching Boys Girls Questions. 1) What’s the most # of agents we can accommodate? 2) How can we find this allocation? Matching Bipartite Graph: Boys Girls left vertices right vertices edges Matching right vertices Bipartite Graph: 0 1 left vertices edges Matching matching = a set of edges that share no vertices. Matching maximal How to find a maximum matching? Idea: add edges until we can’t anymore. Matching maximal maximum How to find a maximum matching? Idea: add edges until we can’t anymore. Not maximum, but close! Matching maximal maximum Defn. A soln. S to a maximization problem is an α-approximation if its value is at least an α fraction of the optimal value. Thm. Maximal matching (½)-approximates maximum matching. Matching How to find a maximum matching? Idea: add edges until we can’t anymore, allowing people to push each other out. Matching augmenting path = path between exposed vertices Theorem. Matching is maximum iff no augmenting paths. Matching matching = a set of edges that share no vertices. vertex cover = a set of vertices such that each edge is incident to at least one vertex in the set. Matching Theorem. Maximum matching equals minimum vertex cover. Matching Theorem. Maximum matching equals minimum vertex cover (bipartite graphs). Proof. Matching = M, cover = C. 1. |M| ≤ |C|. Matching Theorem. Maximum matching equals minimum vertex cover (bipartite graphs). Proof. Matching = M, cover = C. 2. |max M| ≥ |min C| (constructive). Matching Theorem. Maximum matching equals minimum vertex cover (bipartite graphs). Proof. Matching = M, cover = C. 2. |max M| ≥ |min C| (constructive). augmenting path = path between exposed vertices Matching Theorem. Maximum matching equals minimum vertex cover (bipartite graphs). Proof. Matching = M, cover = C. 2. |max M| ≥ |min C| (constructive). Key. vertices reachable from left-side exposed vertices. proposed vertex cover. Matching Theorem. Maximum matching equals minimum vertex cover. Question. When can we match everyone? Perfect Matching Question. When can we match everyone? Defn. A matching is perfect if every vertex is matched. Hall’s Marriage Theorem Boys Girls Defn. A matching is perfect if every vertex is matched. Thm. A perfect matching exists if and only if every set of girls likes at least as large a set of boys. Hall’s Marriage Theorem Boys Boys in Cover Girls Girls not in Cover Condition. Every set of girls likes at least as large a set of boys. Prf. |Cover| = |Boys in Cover| + |Girls in Cover| ≥ |Girls not in Cover| + |Girls in Cover| = |Girls| and Girls is a cover, so |min Cover| ≤ |Girls|. Matching in Random Graphs Agents Items Theorem. If each agent likes at least 2log n items, then with good probability there is a way to assign everyone an item they like. Matching in Random Graphs Theorem. If each agent likes at least 2ln(n) items, then with good probability there is a way to assign everyone an item they like. Intuition. Deferred randomness. 1) Pr[ unique choice in market of size k ] = (1 – 1/k)k-1 ≥ 1/3 2) Constant fraction of market clears in each step. 3) Entire market clears in about log n steps. Matching in Random Graphs Theorem. If each agent likes k < ½ ln(n) items, then with good probability someone is unassigned. Intuition. Some item is liked by nobody. E[ # unliked items] for k < ½ ln(n). = n ∙ Pr[ item is unliked ] = n ∙ (1 – 1/n)nk = n ∙ e-k > n ∙ n-½ >1 Weighted Matching Agents $4 Items $6 $8 Questions. 1) What’s the most value we can create? 2) How can we find this allocation? Weighted Matching Agents $4 Items Agents $6 $8 WLOG, assume complete bipartite graph. Look for max-weight matching . Items Primal-Dual Approach L 3 3 “budgets” y(.) “value” or “weight” w(.) 2 3 1 2 3 3 2 3 1 2 1 R 0 0 “prices” y(.) 0 0 “dual” variable y maps vertices to numbers such that for every edge e = (u,v), w(e) ≤ y(u) + y(v) (y non-negative). Primal-Dual Approach L “weight” w(.) 3 3 2 3 2 “budgets” y(.) R 0 1 0 “prices” y(.) 3 3 2 3 1 2 1 0 0 w(e) ≤ y(u) + y(v) implies ∑e in M w(e) ≤ ∑e in LUR y(v) Primal-Dual Approach L “weight” w(.) 3 3 2 3 2 “budgets” y(.) R 0 1 0 “prices” y(.) 3 3 2 3 1 2 1 0 0 Feasible Dual: for every M, y(.), ∑e in M w(e) ≤ ∑e in LUR y(v) Certificate of Optimality: find M, y(.) s.t. this holds with equality Hungarian Algorithm Algorithm maintains invariants 1) Feasibility of dual: w(e) ≤ y(u) + y(v) 2) Tightness: if e=(u,v) is in M, then w(e) = y(u) + y(v) Algorithm: Initialize y(v) = max weight for v in L; y(v) for v in R = 0; M = {.}. Repeat: 1) Augment matching: if there’s an augmenting path in subgraph of tight edges, use it to augment matching M. 2) Dual adjustment: if M is not perfect, adjust dual variable y(.) to make more edges tight. Until M is maximum or duals reach zero. Augmentation Step new matching edges L 4 5 3 R 6 5 4 3 5 3 2 1 matching edge 2 0 Find augmenting paths in subgraph of tight edges. Dual Adjustment Step L 4 3 5 3 R 6 5 4 3 5 3 2 1 2 0 matching edges tight edges Update dual variables to make more tight edges: 1) Orient matching edges right-to-left, tight edges left-to-right. 2) Find set Z of vertices reachable from exposed vertices of L. 3) Decrease dual of v in L ∩ Z; increase dual of v in R ∩ Z until an edge goes tight. Dual Adjustment Step L R 1 2 1 2 3 1 0 2 3 3 2 2 1 2 1 0 0 matching edges tight edges Dual Adjustment Step L R 0 1 1 2 2 3 1 2 1 0 1 2 3 2 3 2 2 1 2 1 0 0 matching edges tight edges Dual Adjustment Step L R 0 1 2 3 2 1 2 1 3 2 2 2 2 1 0 1 0 matching edges tight edges Correctness Algorithm maintains invariants 1) Tight: w(e) = y(u) + y(v), for e in M matching edges can’t cross in or out of red set. 2) Dual feasibility: w(e) ≤ y(u) + y(v) edges that cross from inside red set to outside it cannot be tight. matching edges tight edges reachable from exposed vertices L R -Δ +Δ Optimality Uncovered vertices all have zero duals at end of algorithm: 1) Once a vertex is covered, it remains so throughout algorithm. 2) So uncovered left-vertices have duals that decrease at same rate and reach zero simultaneously 3) And uncovered right-vertices have zero duals initially, never change. Thus, by tightness invariant, weight of matching equals dual value and so it must be optimal. L R -Δ +Δ Example L R 3 0 2 3 1 3 0 2 3 3 0 2 2 1 3 1 0 matching edges tight edges Example L R 3 0 2 3 1 3 0 2 3 3 0 2 2 1 3 1 0 matching edges tight edges Example L R 3 0 2 3 1 3 0 2 3 3 0 2 2 1 3 1 0 matching edges tight edges Example L R 0 2 2 3 3 1 3 0 2 3 3 0 2 2 1 2 3 1 0 matching edges tight edges Example L R 0 2 2 3 3 1 3 0 2 3 3 0 2 2 1 2 3 1 0 matching edges tight edges Example L R 0 2 2 3 3 1 3 0 2 3 3 0 2 2 1 2 3 1 0 matching edges tight edges Example L R 2 1 2 3 0 1 3 1 2 3 0 2 3 3 0 2 2 1 2 3 1 0 matching edges tight edges Example L R 2 1 2 3 0 1 3 1 2 3 0 2 3 3 0 2 2 1 2 3 1 0 matching edges tight edges Example L R 2 0 1 2 3 0 1 2 3 1 1 2 3 0 1 2 3 2 3 0 2 2 1 2 3 1 0 matching edges tight edges Example L R 2 0 1 2 3 0 1 2 3 1 1 2 3 0 1 2 3 2 3 0 2 2 1 2 3 1 0 matching edges tight edges Example L R 2 -1 0 1 2 3 0 1 2 3 3 1 0 1 2 3 0 1 2 2 3 1 2 3 0 1 2 2 1 1 2 3 1 0 matching edges tight edges Example L R 2 -1 0 1 2 3 0 1 2 3 3 1 0 1 2 3 0 1 2 2 3 1 2 3 0 1 2 2 1 1 2 3 1 0 matching edges tight edges Example L R 2 -1 0 1 2 3 0 1 2 3 3 1 0 1 2 3 0 1 2 2 3 1 2 3 0 1 2 2 1 1 2 3 1 0 matching edges tight edges