Subramanian s stable matching algorithm

Similar documents
Bipartite Matchings and Stable Marriage

Matchings in Graphs. Definition 3 A matching N in G is said to be stable if it does not contain a blocking pair.

CS 6901 (Applied Algorithms) Lecture 2

Omega notation. Transitivity etc.

Ma/CS 6b Class 3: Stable Matchings

Ma/CS 6b Class 3: Stable Matchings

Analysis of Algorithms Fall Some Representative Problems Stable Matching

Algorithm Design and Analysis

1. REPRESENTATIVE PROBLEMS

The Complexity of the Comparator Circuit Value Problem

Consider a complete bipartite graph with sets A and B, each with n vertices.

CSC2556. Lecture 5. Matching - Stable Matching - Kidney Exchange [Slides : Ariel D. Procaccia]

Stable Matching Existence, Computation, Convergence Correlated Preferences. Stable Matching. Algorithmic Game Theory.

1. REPRESENTATIVE PROBLEMS

A Formal Theory for the Complexity Class Associated with Stable Marriage Problem

Matching Theory and the Allocation of Kidney Transplantations

The Complexity and Proof Complexity of the Comparator Circuit Value Problem

Midterm 1. Your Exam Room: Name of Person Sitting on Your Left: Name of Person Sitting on Your Right: Name of Person Sitting in Front of You:

Advanced Algorithms. Lecture Notes for April 5, 2016 Dynamic programming, continued (HMMs); Iterative improvement Bernard Moret

PROBLEMS OF MARRIAGE Eugene Mukhin

Algorithm Design and Analysis

Math 301: Matchings in Graphs

Glasgow eprints Service

Dynamic Matching under Preferences

Lecture 2: Just married

Game Theory: Lecture #5

A (ln 4)-Approximation Algorithm for Maximum Stable Matching with One-Sided Ties and Incomplete Lists

Stable Marriage with Ties and Bounded Length Preference Lists

COMP251: Bipartite graphs

COMP251: Bipartite graphs

1 Definitions and Things You Know

Algorithms. [Knuth, TAOCP] An algorithm is a finite, definite, effective procedure, with some input and some output.

Stable Matching Problems with Exchange Restrictions

Modelling and Solving the Stable Marriage Problem Using Constraint Programming

Approximation and Randomized Algorithms (ARA) Lecture 1, September 3, 2012

An improved approximation algorithm for the stable marriage problem with one-sided ties

The Man-Exchange Stable Marriage Problem

CS320 Algorithms: Theory and Practice. Course Introduction

Sums of Squares. Bianca Homberg and Minna Liu

A Formal Theory for the Complexity Class Associated with the Stable Marriage Problem

The key is that there are two disjoint populations, and everyone in the market is on either one side or the other

CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010

STABLE MARRIAGE PROBLEM WITH TIES AND INCOMPLETE BOUNDED LENGTH PREFERENCE LIST UNDER SOCIAL STABILITY

Sisterhood in the Gale-Shapley Matching Algorithm

SEQUENTIAL ENTRY IN ONE-TO-ONE MATCHING MARKETS

Assignment 3 Logic and Reasoning KEY

Cheating to Get Better Roommates in a Random Stable Matching

Matching Theory. Mihai Manea. Based on slides by Fuhito Kojima. MIT

Stable matching. Carlos Hurtado. July 5th, Department of Economics University of Illinois at Urbana-Champaign

1. REPRESENTATIVE PROBLEMS

Matching Problems. Roberto Lucchetti. Politecnico di Milano

Lecture 5: The Principle of Deferred Decisions. Chernoff Bounds

1. STABLE MATCHING. stable matching problem Gale Shapley algorithm hospital optimality context

A PARALLEL ALGORITHM TO SOLVE THE STABLE MARRIAGE PROBLEM. S. S. TSENG and R. C. T. LEE

An Efficient Algorithm for Batch Stability Testing

Matching Problems. Roberto Lucchetti. Politecnico di Milano

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

Stable Matching Beyond Bipartite Graphs

Course : Algebraic Combinatorics

APPROXIMATION ALGORITHMS FOR THE STABLE MATCHING PROBLEM

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Midterm 1

Lecture notes for Analysis of Algorithms : Markov decision processes

Strategic Behavior and Manipulation in Gender- Neutral Matching Algorithms

Stability and the Core of Probabilistic Marriage Problems

The Generalized Median Stable Matchings: finding them is not that easy

Greedy Homework Problems

CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions

The domination game played on unions of graphs

Published: Social Choice and Welfare, 33(1), June 2009, pp doi: /s SEQUENTIAL ENTRY IN MANY-TO-ONE MATCHING MARKETS

CPSC 320 Sample Final Examination December 2013

Algorithms: COMP3121/3821/9101/9801

Deposited on: 30 September 2010

HAMBURGER BEITRÄGE ZUR MATHEMATIK

The Blocking Lemma and Strategy-Proofness in Many-to-Many Matchings

Direct Proof and Counterexample I:Introduction

Lecture 23 : Nondeterministic Finite Automata DRAFT Connection between Regular Expressions and Finite Automata

Petty Envy When Assigning Objects

Direct Proof and Counterexample I:Introduction. Copyright Cengage Learning. All rights reserved.

A Lower Bound for Boolean Satisfiability on Turing Machines

Research Article Instability in Stable Marriage Problem: Matching Unequally Numbered Men and Women

Creating new worlds inside the computer. COS 116: 2/10/2011 Sanjeev Arora

On the Computational Hardness of Graph Coloring

Marriage Matching: A Conjecture of Donald Knuth

CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal?

We set up the basic model of two-sided, one-to-one matching

Distributed Stable Matching with Similar Preference Lists

Lecture 2. 1 More N P-Compete Languages. Notes on Complexity Theory: Fall 2005 Last updated: September, Jonathan Katz

Part V. Matchings. Matching. 19 Augmenting Paths for Matchings. 18 Bipartite Matching via Flows

Lecture 20: PSPACE. November 15, 2016 CS 1010 Theory of Computation

Two Sided Matching: An Algorithm with both sides making proposals

Two Algorithms for the Student-Project Allocation Problem

Notes for Recitation 7

CSC 5170: Theory of Computational Complexity Lecture 9 The Chinese University of Hong Kong 15 March 2010

1.1 First Problem: Stable Matching. Six medical students and four hospitals. Student Preferences. s6 h3 h1 h4 h2. Stable Matching Problem

What do you do when you can t use money to solve your problems?

198:538 Complexity of Computation Lecture 16 Rutgers University, Spring March 2007

Chapter 7 Matchings and r-factors

Algorithms and Data Structures (COMP 251) Midterm Solutions

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CS711008Z Algorithm Design and Analysis

Transcription:

Subramanian s stable matching algorithm Yuval Filmus November 2011 Abstract Gale and Shapley introduced the well-known stable matching problem in 1962, giving an algorithm for the problem. Subramanian later showed that the problem can be solved by comparator circuits. Lê, Cook and Ye simplified his construction. We present an algorithm interpolating (in some sense) between the two. Our algorithm is a symmetrized lazy version of Gale-Shapley, while Subramanian s algorithm in turn can be viewed as a lazy version of our algorithm. Subramanian s algorithm employs three-valued logic, a device which arises more naturally in the setting of our algorithm. 1 Stable matching problem An instance of the stable matching problem consists of a set M of n men and a set W of n women. In addition, each person p M W has an order of preference over persons of the opposite sex: p: π 1 (p) π 2 (p) π n (p). Person p prefers π 1 (p) the most, and π n (p) the least. If i > j then p prefers π i (p) over π j (p), in symbols π i (p) p π j (p). The person most preferred by p among a list P is denoted max p P. The one least preferred is min p P. Beware that in terms of indices π i (p), max p P is the person with lowest index! A matching S is a list of pairs (m, w) M W such that each man is matched with exactly one woman. We will denote the match of a person p by S(p). A pair (m, w) / S is unstable if w m S(m) and m w S(w). In words, an unmatched pair (m, w) is unstable if both parties prefer the other person over their current partner. A matching is stable if there is no unstable pair. Gale and Shapley [1] have shown that a stable matching always exists, by giving an algorithm computing it. Their algorithm constructs a stable matching S with the additional property that for each man m, S(m) m T (m) for any stable matching T. In words, in S every man is matched with the best woman he could ever get in a stable matching. This matching is called the man-optimal stable matching. The same algorithm also shows the existence of the womanoptimal stable matching. 1

2 Gale-Shapley algorithm The Gale-Shapley algorithm proceeds in rounds. In the first round, each man proposes to his top woman, and each woman selects her most preferred suitor. In each subsequent round, each rejected man proposes to his next choice, and each woman selects her most preferred suitor (including her choice from the previous round). The situation eventually stabilizes, and the woman s choices are finalized. They form the man-optimal stable matching. We can keep track of the workings of the algorithm using a bipartite graph, which lists for each person their potential spouses. Algorithm 1 follows this viewpoint. Algorithm 1 Gale-Shapley G M W repeat top(m) max m w : (m, w) G} for all m M best(w) max w m : top(m) = w} for all w W (max w = ) G (m, w) : m w best(w)} (m w for all m M) until best(w) is defined for all w W return (best(w), w) : w W } It is straightforward to prove by induction that top(m) can only decrease, best(w) can only increase, and the graph G keeps shedding edges. Moreover, induction shows that each stable matching is a subgraph of G: indeed, if m w best(w) then, in any matching where m is matched to w, (best(w), w) is an unstable pair. At the end, each woman w is matched to a man m such that top(m) = w. It follows that the matching is the man-optimal stable matching. Why does the algorithm terminate? Say that a man m and a woman w are engaged if m = best(w) (and so w = top(m)). Suppose that at some iteration, the women in W f are unengaged. Engaged couples come in pairs, so some man m is unengaged. Either top(m) W f, in which case top(m) will become engaged in the next round, or top(m) is engaged to some m. In the latter case, the two men will compete in the next round, resulting in an update of the graph. So G keeps reducing until all women get engaged. At the end of the algorithm, it is clear that if m = best(w) then m is the only man with that property, and so m = min w m : (m, w) G}. So not only is the resulting stable matching man-optimal, but also woman-pessimal. 3 Interval algorithm The Gale-Shapley algorithm has one disadvantage: it finds only the man-optimal stable matching. Algorithm 2 finds both the man-optimal and the womanoptimal stable matchings at the same time. Considering Algorithm 2, if we change the quantification of p, q to p M and q Q, then we get an algorithm very similar to Gale-Shapley. The undirected 2

Algorithm 2 Interval algorithm I 0 (m) W for all m M I 0 (w) M for all w W t 0 repeat top t (p) = max p I t (p) for all p M W best t (q) = max q p : q = top t (p)} for all q M W I t+1 (q) p I t (q) : p q best t (q)} for all q M W I t+1 (p) I t+1 (p) \ top t (p) for all p M W such that p / I t (top t (p)) t t + 1 until I t = I t 1 return (m, max m I t (m)) : m M}, (max w I t (w), w) : w W } graph G is replaced by a directed graph represented by sets of neighbors I(p). When a woman removes a man from her neighborhood, he is not immediately informed of the fact; he will eventually find out, when she becomes his top choice. The stopping condition is also different, but the proof shows that when the situation stabilizes, all women are engaged. In contrast to Gale-Shapley, Algorithm 2 is symmetric in both parties. The analysis in the previous paragraph should convince the reader that it returns both the man-optimal and the woman-optimal stable matchings. The rules updating I t (p) ensure that these always remain intervals within p s preference order, hence the name Interval algorithm. 4 Three-valued logic There is a curious connection between Algorithm 2 and three-valued logic. In three-valued logic, apart from the usual definite boolean values 0, 1 (which we think of as singletons 0},1}), we have a further indefinite value = 0, 1}. The boolean operators,, are generalized in the natural way: x = b : b x}, x y = b c : b x, c y}, x y = b c : b x, c y}. So we have =, 0 =, 1 = 1, =, and so on. Our aim is to reformulate Algorithm 2 using three-valued logic. The sets I t (p) will be replaced by two matrices M t (m, w), W t (m, w), defined according to the following rules (m M, w W ): 1 w m max m I t (m) M t (m, w) = max m I t (m) m w m min m I t (m) 0 min m I t (m) m w 0 m w max w I t (w) W t (w, m) = max w I t (w) w m w min w I t (w) 1 min w I t (w) w m 3

Since the intervals I t (p) always shrink during the course of Algorithm 2, once a value in M or W becomes definite, it never changes. When does a value become definite? Suppose that M t (m, π i (m)) =. The value can change to 1 only if w π i 1 (m) = max m I t (m) is chopped. That, in turn, happens if m / I t (w). In fact, we must have m w min w I t (w), for otherwise (m, w) would be an unstable pair in any stable matching produced by the algorithm. So M t (m, w) = W t (w, m) = 1. Our reasoning makes it clear that this condition is not only necessary but also sufficient. Consider the other case: given that M t (m, π i (m)) =, when does it change to 0? That happens when w best t (m) m π i (m). Since m = top t (w), we see that W t (w, m) = 0. So if M t+1 (m, π i (m)) = 0, we must have W t (w, m) = 0 for some w m π i (m). Conversely, suppose that W t (w, m) = 0 for some w m π i (m). If m w top t (w) then m = top s (w) at some earlier point in time s < t. At that point, best s (m) m w m π i (m), and so π i (m) / I s+1 (m), contradicting our assumption M t (m, π i (m)) =. Hence m = top t (w) after all, and so M t+1 (m, π i (m)) = 0. We have completed the proof of the following lemma. Lemma 1. Suppose M t (m, π i+1 (m)) =. Then M t+1 (m, π i+1 (m)) = 1 if and only if M t (m, π i (m)) = W t (π i (m), m) = 1, and M t+1 (m, π i+1 (m)) = 0 if and only if W t (π j (m), m) = 0 for some j i. Combining the two conditions together, we obtain a recurrence relation for the array M. Lemma 2. For all t, M t (m, π 1 (m)) = 1. At the beginning of the algorithm, M 0 (m, w) = for w π 1 (m), and in general M t+1 (m, π i+1 (m)) = M t (m, π i (m)) j i W t (π j (m), m). Proof. The first step is to relate Lemma 1 to the recurrence equation. We do this by (implicit) induction on t. Suppose that M t (m, π i+1 (m)) =, and let R = M t (m, π i (m)) j i W t (π j (m), m). If R = 1, then the lemma implies that M t+1 (m, π i+1 (m)) = 1. Conversely, if M t+1 (m, π i+1 (m)) = 1 then the lemma implies that M t (m, π i (m)) = W t (π i (m), m) = 1. If i > 1, then the recurrence equation for M t (m, π i (m)) shows that W t 1 (π j (m), m) = 1 for j i 1. As mentioned above, once a value of W becomes definite it remains constant, and so R = 1. If M t+1 (m, π i+1 (m)) = 0, then the lemma shows that R = 0. Conversely, if R = 0, then either M t (m, π i (m)) = 0, or W t (π j (m), m) = 0 for some j i. In 4

the first case, the definition of M directly implies that M t+1 (m, π i+1 (m)) = 0. In the latter case, we reach the same conclusion by way of the lemma. Summarizing, the recurrence equation holds in case M t (m, π i+1 (m)) =. If M t (m, π i+1 (m)) is boolean, then either all values in R are equal to 1, or at least one of them is equal to 0. Since boolean values in the arrays remain constant, the correctness of the recurrence equation for t + 1 follows directly from its correctness for t. The lemma allows us to reformulate Algorithm 2 as a three-valued logic algorithm, Algorithm 3. Algorithm 3 Interval algorithm, three-valued logic formulation 1 w = π 1 (m) M 0 (m, w) = otherwise 0 m = π 1 (w) W 0 (w, m) = otherwise t 0 repeat M t+1 (m, π i (m)) = 1 i = 1 M t (m, π i 1 (m)) j i 1 W t(π j (m), m) otherwise 0 i = 1 W t+1 (w, π i (w)) = W t (w, π i 1 (w)) j i 1 M t(π j (w), w) otherwise t t + 1 until M t = M t 1 and W t = W t 1 S M (m, w) : M t (m, w) = 1 and W t (w, m) 0, }} S W (m, w) : W t (w, m) = 0 and M t (m, w) 1, }} return S M, S W The lemma shows that at the end of Algorithm 3, M t and W t correspond to I t at the end of Algorithm 2. The latter algorithm returns the man-optimal stable matching T M = (m, max I t(m)) : m M} = (min I t(w), w) : w W }. m w The definitions of M t, W t makes it plain that S M T M. Conversely, suppose that M t (m, w) = 1 and W t (w, m) 0, }. In terms of intervals, w m max m I t (m) and m w min w I t (w). So w = max m I t (m) and m = min w I t (w), for otherwise (m, w) would be an unstable pair in T M. We conclude that S M = T M is the man-optimal stable matching. 5 Subramanian s algorithm Subramanian s paper [3] is concerned with comparator circuits. These can be thought of as programs in a language with boolean variables and a single in- 5

struction, known as comparison: (x, y) (x y, x y). For the sake of computation, we are additionally allowed to initialize some of the variables by constants. Lê, Cook and Ye [2] show that if we enlarge the language by allowing threevalued variables and by adding a negation instruction x x, then the resulting program can be simulated by a comparator circuit; this includes a final step in which each is replaced by a predetermined value. For more information on comparator circuits, consult their paper. Comparator circuits simulate boolean formulas, but they are conjectured not to simulate general circuits. The problem is with gates whose fan-out is larger than 1: once a variable is compared against another variable, its original value is irretrievably lost. Subramanian s goal was to come up with a comparator circuit for the stable matching problem. Algorithm 3 cannot be used for this purpose as it stands, since a value W t (π j (m), m) is compared against M t (m, π i (m)) for all i j. The main result of Subramanian s paper is a comparator circuit algorithm for stable matching. He presents his algorithm in terms of X-networks; our presentation follows the one by Lê et al. Looking at Lemma 1, we see that we only need to consider several values of W t (, m) when checking whether an entry M t+1 (m, π i (m)) changes to zero. What if we only looked at W t (π i (m), m)? A zero in W t (π j (m), m) for j < i will change M t+1 (m, π j+1 (m)) to zero, and the zero will propagate in i j steps to M(m, π i+1 (m)). This prompts Algorithm 4, which is realizable as a comparator circuit. In order to convince ourselves that Algorithm 4 is valid, we show that, in some sense, Algorithms 3 and 4 simulate each other. Since we will be considering both algorithms at the same time, it will be convenient to use M I, W I for Algorithm 3 and M S, W S for Algorithm 4. Lemma 3. If M I (m, w) = b 0, 1} at the end of Algorithm 3, then M S (m, w) = b at the end of Algorithm 4. The same is true for W. Proof. The proof is by induction on the time t in which an entry becomes definite in Algorithm 3. We only consider M, the proof for W being dual. The lemma is trivial for entries which become definite during the initialization phase. Suppose an entry M I t+1(m, π i+1 (m)) = b becomes definite at time t + 1. If b = 1 then M I t (m, π i (m)) = W I t (π i (m), m) = 1, and so the induction hypothesis implies that at some time s, M S s (m, π i (m)) = W S s (π i (m), m) = 1. At the following step, M S s+1(m, π i+1 (m)) = 1. If b = 0, then either M I t (m, π i (m)) = 0, or W I t (π j (m), m) = 0 for some j i. In the first case, argue as before. In the second, the induction hypothesis implies that at some time s, W S s (π j (m), m) = 0. At the following step, M S s+1(m, π j+1 (m)) = 0, and i j steps later, M S s+1+i j (m, π i+1(m)) = 0. 6

Algorithm 4 Subramanian s algorithm 1 w = π 1 (m) M 0 (m, w) = otherwise 0 m = π 1 (w) W 0 (w, m) = otherwise t 0 repeat M t+1 (m, π i (m)) = 1 i = 1 M t (m, π i 1 (m)) W t (π i 1 (m), m) otherwise 0 i = 1 W t+1 (w, π i (w)) = W t (w, π i 1 (w)) M t (π i 1 (w), w) otherwise t t + 1 until M t = M t 1 and W t = W t 1 S M (m, w) : M t (m, w) = 1 and W t (w, m) 0, }} S W (m, w) : W t (w, m) = 0 and M t (m, w) 1, }} return S M, S W Lemma 4. If M S (m, w) = b 0, 1} at the end of Algorithm 4, then M I (m, w) = b at the end of Algorithm 3. The same is true for W. Proof. The proof is by induction on the time t in which an entry becomes definite in Algorithm 4. We only consider M, the proof for W being dual. The lemma is trivial for entries which become definite during the initialization phase. Suppose an entry M S t+1(m, π i+1 (m)) = b becomes definite at time t + 1. If b = 0 then either M S t (m, π i (m)) = 0 or W S t (π i (m), m) = 0. In both cases, the induction hypothesis implies that the same is true at some time s for M I s(m, π i (m)) or W I s(π i (m), m), and so M I s+1(m, π i+1 (m)) = 0. If b = 1, then M S t (m, π i (m)) = W S t (π i (m), m) = 1. The induction hypothesis implies that at some time s, M I s(m, π i (m)) = W I s(π i (m), m) = 1. The recurrence equation for M I s(m, π i (m)) in Algorithm 3 implies that W I s(π j (m), m) = W I s 1(π j (m), m) = 1 for all j < i, and so M I s+1(m, π i+1 (m)) = 1. The two lemmas together imply that at the end of both algorithms, M I = M S and W I = W S. So Subramanian s algorithm correctly computes the manoptimal and woman-optimal stable matchings. Each value of M t, W t is used twice in the computation of M t+1, W t+1, once as an input to an gate and once as an input to an gate. In both cases, it is compared against the same value: indeed M t (m, w) is always compared against W t (w, m). This shows that the algorithm can be implemented as a comparator circuit, if we replace the repeat-until loop with 2n 2 fixed iterations. 7

References [1] David Gale and Lloyd S. Shapley. College admissions and the stability of marriage. The American Mathematical Monthly, 69(1):9 15, 1962. [2] Dai Tri Man Lê, Stephen Cook, and Yuli Ye. A formal theory for the complexity class associated with the stable marriage problem. In Computer Science Logic (CSL 11), 2011. [3] Ashok Subramanian. A new approach to stable matching problems. SIAM Journal of Computing, 23:671 701, August 1994. 8