Bipartite Matchings and Stable Marriage

Similar documents
Ma/CS 6b Class 3: Stable Matchings

Ma/CS 6b Class 3: Stable Matchings

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

1. REPRESENTATIVE PROBLEMS

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

Analysis of Algorithms Fall Some Representative Problems Stable Matching

Input. A set of men M, and a set of women W.

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

1. REPRESENTATIVE PROBLEMS

CS320 Algorithms: Theory and Practice. Course Introduction

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

Stable Marriage with Ties and Bounded Length Preference Lists

Subramanian s stable matching algorithm

CS 6901 (Applied Algorithms) Lecture 2

COMP251: Bipartite graphs

COMP251: Bipartite graphs

1. REPRESENTATIVE PROBLEMS

Efficient Algorithms for Bipartite Matching Problems with Preferences

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

Dynamic Matching under Preferences

Algorithm Design and Analysis

Popular Matchings with Lower Quotas

Lecture 2: Just married

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

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

Algorithmics of Two-Sided Matching Problems

Math 301: Matchings in Graphs

1 Matchings in Non-Bipartite Graphs

CS 598RM: Algorithmic Game Theory, Spring Practice Exam Solutions

Algorithm Design and Analysis

Weights in stable marriage problems increase manipulation opportunities

Lecture 5: The Principle of Deferred Decisions. Chernoff Bounds

Matching Residents to Hospitals

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

Omega notation. Transitivity etc.

Matching Theory and the Allocation of Kidney Transplantations

The Man-Exchange Stable Marriage Problem

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

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

Breadth-First Search of Graphs

Agenda. Soviet Rail Network, We ve done Greedy Method Divide and Conquer Dynamic Programming

Algorithm Design and Analysis

Game Theory: Lecture #5

An Efficient Algorithm for Batch Stability Testing

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

Cheating to Get Better Roommates in a Random Stable Matching

SEQUENTIAL ENTRY IN ONE-TO-ONE MATCHING MARKETS

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

Algorithm Design and Analysis

1 Definitions and Things You Know

Bipartite Matchings. Andreas Klappenecker

Socially stable matchings in the Hospitals/Residents problem

Popularity at minimum cost

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

Stable Matching Problems with Exchange Restrictions

Deposited on: 30 September 2010

Faster Algorithms For Stable Allocation Problems

The Generalized Stable Allocation Problem

COOPERATIVE GAME THEORY: CORE AND SHAPLEY VALUE

Two-Sided Matching. Terence Johnson. December 1, University of Notre Dame. Terence Johnson (ND) Two-Sided Matching December 1, / 47

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

Applying Predicate Detection to the Constrained Optimization Problems

APPROXIMATION ALGORITHMS FOR THE STABLE MATCHING PROBLEM

Two-sided Matching Theory

Stable Matching Beyond Bipartite Graphs

8.5 Sequencing Problems

Soviet Rail Network, 1955

PROBLEMS OF MARRIAGE Eugene Mukhin

CSC 373: Algorithm Design and Analysis Lecture 12

1 Computational Problems

7.5 Bipartite Matching

Matching. Terence Johnson. April 17, University of Notre Dame. Terence Johnson (ND) Matching April 17, / 41

Glasgow eprints Service

Algorithms and Theory of Computation. Lecture 11: Network Flow

Two-Sided Matching. Terence Johnson. September 1, University of Notre Dame. Terence Johnson (ND) Two-Sided Matching September 1, / 37

Combinatorial Optimization

Problem set 1. (c) Is the Ford-Fulkerson algorithm guaranteed to produce an acyclic maximum flow?

Popular Matchings with Multiple Partners

Algorithms for Pareto Stable Assignment

Notes for Lecture Notes 2

Maximum flow problem

arxiv: v2 [cs.gt] 25 Jul 2014

Running Time. Assumption. All capacities are integers between 1 and C.

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

Algorithm Design and Analysis

Improving Man-Optimal Stable Matchings by Minimum Change of Preference Lists

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

CS 138b Computer Algorithm Homework #14. Ling Li, February 23, Construct the level graph

CS711008Z Algorithm Design and Analysis

directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time

Maintaining Near-Popular Matchings

Glasgow eprints Service

A General Two-Sided Matching Market with Discrete Concave Utility Functions

Max Flow: Algorithms and Applications

What Matchings Can be Stable? Refutability in Matching Theory

Two Algorithms for the Student-Project Allocation Problem

Weights in Stable Marriage Problems Increase Manipulation Opportunities

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

Flows and Cuts. 1 Concepts. CS 787: Advanced Algorithms. Instructor: Dieter van Melkebeek

Competition and Resource Sensitivity in Marriage and Roommate Markets

Transcription:

Bipartite Matchings and Stable Marriage Meghana Nasre Department of Computer Science and Engineering Indian Institute of Technology, Madras Faculty Development Program SSN College of Engineering, Chennai December 12, 2014

Why matchings? Several real world applications involve assigning: jobs to machines. students to projects. jobs to applicants. roommate to another.

Outline of Talk Quick introduction to graphs. Matchings in graphs. Bipartite matching algorithm. Stable matchings.

Introduction to graphs

G = (V, E). Representation and search techniques v1 v2 v6 v3 v5 How large can m be? v4 n = V = 6, m = E = 8.

G = (V, E). Representation and search techniques v1 v2 v6 v3 v5 How large can m be? Representation: v4 n = V = 6, m = E = 8. Adjacency Lists O(m + n) space. Adjacency Matrix O(n 2 ) space.

G = (V, E). Representation and search techniques v1 v2 v6 v3 v5 How large can m be? Representation: v4 n = V = 6, m = E = 8. Adjacency Lists O(m + n) space. Adjacency Matrix O(n 2 ) space. Search methods: Breadth First Search. Depth First Search.

Matching in a graph

Matching in a graph A matching M is a set of vertex disjoint edges. v1 v2 v6 v3 v5 v4

Matching in a graph A matching M is a set of vertex disjoint edges. v1 v2 v6 v3 v5 v4

Matching in a graph A matching M is a set of vertex disjoint edges. v1 v2 v6 v3 v5 v4 Goal: compute a maximum sized matching. Question: is the above matching maximum sized?

Matching in a graph A matching M is a set of vertex disjoint edges. v1 v2 v1 v2 v6 v6 v3 v5 v3 v5 v4 v4

Matching in a graph A matching M is a set of vertex disjoint edges. v1 v2 v1 v2 v6 v6 v3 v5 v3 v5 v4 Maximal: No more edges can be added to the matching. v4

Matching in a graph A matching M is a set of vertex disjoint edges. v1 v2 v1 v2 v6 v6 v3 v5 v3 v5 v4 Maximal: No more edges can be added to the matching. Size may not be largest possible. Maximum: Has size as large as possible. Note that every maximum matching is maximal. v4

Alternating paths A path having alternate matched and unmatched edges. v1 v2 v6 v3 v5 v4

Alternating paths A path having alternate matched and unmatched edges. v1 v2 v6 v3 v5 v4 Is there any other alternating path?

Alternating paths A path having alternate matched and unmatched edges. v1 v2 v6 v3 v5 v4 Is there any other alternating path? Which paths are not alternating?

Augmenting paths An alternating path starting and ending in free edges. v1 v2 v6 v3 v5 v4

Augmenting paths An alternating path starting and ending in free edges. v1 v2 v6 v3 v5 v4 How are augmenting paths useful? Properties of augmenting paths.

Using augmenting paths Berge s Theorem If aug. path P is present size of matching can be increased.

Using augmenting paths Berge s Theorem If aug. path P is present size of matching can be increased. M = M P. v1 v2 v1 v2 v6 augment M with P v6 v3 P v5 v3 P v5 v4 M M v4

Using augmenting paths Berge s Theorem If no aug. path w.r.t. M M is maximum. Proof (by contradiction) Suppose M does not admit any aug. path and still it is not maximum. Some other matching M is maximum.

Using augmenting paths Berge s Theorem If no aug. path w.r.t. M M is maximum. Proof (by contradiction) Suppose M does not admit any aug. path and still it is not maximum. Some other matching M is maximum. Consider M M. Construct an aug. path w.r.t. M.

Maximum matching algorithm Given G = (V, E), compute a maximum sized matching.

Maximum matching algorithm Given G = (V, E), compute a maximum sized matching. Iterative Improvement Initialize M to be empty. while there exists an aug. path P w.r.t. M M = M P. return M.

Maximum matching algorithm Given G = (V, E), compute a maximum sized matching. Iterative Improvement Initialize M to be empty. while there exists an aug. path P w.r.t. M M = M P. return M. Two questions that need to be always asked: 1. Correctness? 2. Complexity/ Running time?

Maximum matching algorithm Given G = (V, E), compute a maximum sized matching. Iterative Improvement Initialize M to be empty. while there exists an aug. path P w.r.t. M M = M P. return M. Two questions that need to be always asked: 1. Correctness? 2. Complexity/ Running time? How to efficiently compute an augmenting path?

Bipartite matching algorithm

Bipartite graphs G = (A B, E). A B Equivalent statements Vertices can be partitioned into 2 disjoint sets. G is bipartite iff G does not have any odd cycle. Graph is 2 colorable iff it is bipartite.

Finding aug. path in bipartite graphs a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 A B

Finding aug. path in bipartite graphs a1 a2 a3 b1 b2 b3 Aug. paths w.r.t. M: a 1, b 2. a 5, b 5. a4 b4 a5 b5 A B

Finding aug. path in bipartite graphs a1 a2 a3 a4 b1 b2 b3 b4 Aug. paths w.r.t. M: a 1, b 2. a 5, b 5. a 4, b 3, a 2, b 4. a5 b5 A B

Finding aug. path in bipartite graphs a1 a2 a3 a4 a5 A B b1 b2 b3 b4 b5 Aug. paths w.r.t. M: a 1, b 2. a 5, b 5. a 4, b 3, a 2, b 4. Finding aug. paths reachability in a modified graph.

Finding aug. path in bipartite graphs a1 b1 a1 b1 a2 b2 a2 b2 a3 b3 s a3 b3 t a4 b4 a4 b4 a5 b5 a5 b5 A B A B

Finding aug. path in bipartite graphs a1 b1 a1 b1 a2 b2 a2 b2 a3 b3 s a3 b3 t a4 b4 a4 b4 a5 b5 a5 b5 A B A B Add dummy nodes s and t. Add edges from s to unmatched vertices in A. Add edges from unmatched vertices in B to t. Matched edges: B A. Unmatched edges: A B.

Finding aug. path in bipartite graphs a1 b1 a1 b1 a2 b2 a2 b2 a3 b3 s a3 b3 t a4 b4 a4 b4 a5 b5 a5 b5 A B A B Aug. path in G w.r.t. M is a simple directed s to t path in G.

Maximum matching in bipartite graph Given G = (V, E), compute a maximum sized matching. Iterative Improvement Initialize M to be empty. while there exists an aug. path P w.r.t. M M = M P. return M. Running time?

Maximum matching in bipartite graph Given G = (V, E), compute a maximum sized matching. Iterative Improvement Initialize M to be empty. while there exists an aug. path P w.r.t. M M = M P. return M. Running time? 1. How many iterations?

Maximum matching in bipartite graph Given G = (V, E), compute a maximum sized matching. Iterative Improvement Initialize M to be empty. while there exists an aug. path P w.r.t. M M = M P. return M. Running time? 1. How many iterations? at most n/2.

Maximum matching in bipartite graph Given G = (V, E), compute a maximum sized matching. Iterative Improvement Initialize M to be empty. while there exists an aug. path P w.r.t. M M = M P. return M. Running time? 1. How many iterations? at most n/2. 2. How long does each iteration take?

Maximum matching in bipartite graph Given G = (V, E), compute a maximum sized matching. Iterative Improvement Initialize M to be empty. while there exists an aug. path P w.r.t. M M = M P. return M. Running time? 1. How many iterations? at most n/2. 2. How long does each iteration take? at most O(m + n).

Maximum matching in bipartite graph Given G = (V, E), compute a maximum sized matching. Iterative Improvement Initialize M to be empty. while there exists an aug. path P w.r.t. M M = M P. return M. Running time? 1. How many iterations? at most n/2. 2. How long does each iteration take? at most O(m + n). 3. Total running time: O(mn).

Efficient algorithms The best known for both bipartite and general graphs is O( nm) time algorithms. Algorithms on general graphs are significantly involved.

Efficient algorithms The best known for both bipartite and general graphs is O( nm) time algorithms. Algorithms on general graphs are significantly involved. Edmond s Blossom Shrinking algorithm. (Also the paper where the notion of polynomial time being efficient was formalized). Weighted matchings can also be done in polynomial time. Beautiful theory of Linear Programming Duality involved.

Stable matching problem

A bit of history.. Introduced by Gale and Shapley in 1962 while studying college admissions. Bipartite matching problem with preferences. Arises in several places like TA-allocation, project allocation. Classical setting: marriage between n men and n women.

Setting Input: m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is optimal.

Setting Input: m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is optimal. m1 w1 m2 w2 m3 w3 Question: Is this a good matching?

Setting Input: m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is optimal. m1 w1 m2 w2 m3 w3 Question: Is this a good matching? pair (m 2, w 2 ) is bad!

Setting Input: m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is stable.

Setting Input: m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is stable. m1 w1 m1 w1 m2 w2 m2 w2 m3 w3 m3 w3 unstable. stable.

Setting Input: m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is stable. m1 w1 m1 w1 m2 w2 m2 w2 m3 w3 m3 w3 unstable. stable. unstable pair: A pair (m, w) not matched to each other, both of which prefer each other to their current partners in M.

Stable marriage problem Input: m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is stable. Does a stable marriage exist in any instance?

Stable marriage problem Input: m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is stable. Does a stable marriage exist in any instance? Is stable marriage unique?

Stable marriage problem Input: m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is stable. Does a stable marriage exist in any instance? Is stable marriage unique? Can it be computed efficiently?

Stable marriage problem Remarkable result of Gale and Shapley m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is stable. Does a stable marriage exist in any instance?

Stable marriage problem Remarkable result of Gale and Shapley m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is stable. Does a stable marriage exist in any instance? Yes, always! Is stable marriage unique?

Stable marriage problem Remarkable result of Gale and Shapley m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is stable. Does a stable marriage exist in any instance? Yes, always! Is stable marriage unique? No, there is a range of stable matchings; can be unique in some cases. Can it be computed efficiently?

Stable marriage problem Remarkable result of Gale and Shapley m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 Goal: To compute a matching that is stable. Does a stable marriage exist in any instance? Yes, always! Is stable marriage unique? No, there is a range of stable matchings; can be unique in some cases. Can it be computed efficiently? Yes, in O(n 2 ) time.

Stable marriage algorithm m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 set all men and women as unengaged. while there exists an unengaged man m 1. m proposes to the most preferred woman w to whom he has not yet proposed. 2. w accepts if either she is unengaged or she is engaged to m and w prefers m to m.

Stable marriage algorithm m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 set all men and women as unengaged. while there exists an unengaged man m 1. m proposes to the most preferred woman w to whom he has not yet proposed. 2. w accepts if either she is unengaged or she is engaged to m and w prefers m to m. Questions: Does the algorithm even terminate?

Stable marriage algorithm m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 set all men and women as unengaged. while there exists an unengaged man m 1. m proposes to the most preferred woman w to whom he has not yet proposed. 2. w accepts if either she is unengaged or she is engaged to m and w prefers m to m. Questions: Does the algorithm even terminate? Why does it output a stable marriage?

Stable marriage algorithm m 1 : w 1, w 2, w 3 m 2 : w 2, w 3, w 1 m 3 : w 3, w 1, w 2 w 1 : m 3, m 2, m 1 w 2 : m 2, m 1, m 3 w 3 : m 1, m 3, m 2 set all men and women as unengaged. while there exists an unengaged man m 1. m proposes to the most preferred woman w to whom he has not yet proposed. 2. w accepts if either she is unengaged or she is engaged to m and w prefers m to m. Questions: Does the algorithm even terminate? Why does it output a stable marriage? How does the ordering of men in the while loop matter?

Stable marriage algorithm A surprisingly simple algorithm that is guaranteed to produce a stable matching. A rich structure underlying the problem.

Stable marriage algorithm A surprisingly simple algorithm that is guaranteed to produce a stable matching. A rich structure underlying the problem. Has been dealt in two books one by Irving and Gusfield and a recent one by Manlove. National Residency Matching program one of the most important applications amongst several others. Pioneering work by Roth and Shapley won the 2012 Nobel prize for Economics.

Summary Matchings, definitions, augmenting/alternating paths. A template for finding matchings by iterative improvement. An efficient algorithm in the bipartite case. Stable marriage algorithm and properties.

Thank You!