Algorithm Design and Analysis

Similar documents
Algorithm Design and Analysis

Analysis of Algorithms Fall Some Representative Problems Stable Matching

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

1. REPRESENTATIVE PROBLEMS

1. REPRESENTATIVE PROBLEMS

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

Matching Residents to Hospitals

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

CS320 Algorithms: Theory and Practice. Course Introduction

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

1. REPRESENTATIVE PROBLEMS

CS 6901 (Applied Algorithms) Lecture 2

CSE 417, Winter Introduc6on, Examples, and Analysis. Ben Birnbaum Widad Machmouchi

Omega notation. Transitivity etc.

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

COMP251: Bipartite graphs

Game Theory: Lecture #5

COMP251: Bipartite graphs

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

Ma/CS 6b Class 3: Stable Matchings

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

cs.washington.edu/417

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

Subramanian s stable matching algorithm

CS711008Z Algorithm Design and Analysis

Ma/CS 6b Class 3: Stable Matchings

Bipartite Matchings and Stable Marriage

Review Asympto&c Bounds

Matching Theory and the Allocation of Kidney Transplantations

Lecture 5: The Principle of Deferred Decisions. Chernoff Bounds

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

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

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

Algorithms: COMP3121/3821/9101/9801

PROBLEMS OF MARRIAGE Eugene Mukhin

Matching Problems. Roberto Lucchetti. Politecnico di Milano

Matching and Stable Matching

Assignment 3 Logic and Reasoning KEY

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

Strategic Behavior and Manipulation in Gender- Neutral Matching Algorithms

CPSC 320 Sample Solution, Reductions and Resident Matching: A Residentectomy

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

Lecture 2: Just married

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

Matching Problems. Roberto Lucchetti. Politecnico di Milano

CPSC 320 Sample Final Examination December 2013

Stable Marriage with Ties and Bounded Length Preference Lists

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

Copyright 2000, Kevin Wayne 1

1 Definitions and Things You Know

Cheating to Get Better Roommates in a Random Stable Matching

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:

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

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

Math 301: Matchings in Graphs

Math 391: Midterm 1.0 Spring 2016

Glasgow eprints Service

CPSC 320 Sample Solution, The Stable Marriage Problem

Distributed Stable Matching with Similar Preference Lists

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

Dynamic Matching under Preferences

COOPERATIVE GAME THEORY: CORE AND SHAPLEY VALUE

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

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Homework 3. This homework is due September 22, 2014, at 12:00 noon.

CPSC W1: Midterm #1 Sample Solution

Algorithm Design and Analysis

Sisterhood in the Gale-Shapley Matching Algorithm

Local Search Approaches in Stable Matching Problems

Algorithmics of Two-Sided Matching Problems

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

SEQUENTIAL ENTRY IN ONE-TO-ONE MATCHING MARKETS

CS/SE 2C03. Sample solutions to the assignment 1.

An Efficient Algorithm for Batch Stability Testing

Incentives in Large Random Two-Sided Markets

APPROXIMATION ALGORITHMS FOR THE STABLE MATCHING PROBLEM

Stable Matching Problems with Exchange Restrictions

Market Design: Lecture 1 NICOLE IMMORLICA, NORTHWESTERN UNIVERSITY

THREE ESSAYS ON GAME THEORY. Demet Yilmazkuday. Dissertation. Submitted to the Faculty of the. Graduate School of Vanderbilt University

Modelling and Solving the Stable Marriage Problem Using Constraint Programming

Complexity. CS 320, Fall Dr. Geri Georg, Instructor Some materials adapted from Prof. Wim Bohm.

Stable Matching Beyond Bipartite Graphs

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

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

Algorithms and Data Structures (COMP 251) Midterm Solutions

Batch Testing, Adaptive Algorithms, and Heuristic Applications for Stable Marriage Problems

arxiv: v1 [cs.ds] 8 Apr 2019

Lecture 5: Loop Invariants and Insertion-sort

Computational Thinking

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

Greedy Homework Problems

Dynamic Matching with a Fall-back Option

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Midterm 1

Stable Matching with Uncertain Pairwise Preferences

Deposited on: 30 September 2010

Two Algorithms for the Student-Project Allocation Problem

U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 2 Luca Trevisan August 29, 2017

The Man-Exchange Stable Marriage Problem

The Deferred Acceptance Algorithm. A thesis presented for a Bachelor degree in Economics and Business

Two-sided Matching Theory

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

Transcription:

Algorithm Design and Analysis LECTURE 2 Analysis of Stable Matching Asymptotic Notation Adam Smith

Stable Matching Problem Goal: Given n men and n women, find a "suitable" matching. Participants rate members of opposite sex. Each man lists women in order of preference from best to worst. Each woman lists men in order of preference from best to worst. favorite least favorite favorite least favorite 1 st 2 nd 3 rd Xavier Amy Bertha Clare Yancey Bertha Amy Clare Zeus Amy Bertha Clare 1 st 2 nd 3 rd Amy Yancey Xavier Zeus Bertha Xavier Yancey Zeus Clare Xavier Yancey Zeus Men s Preference Profile Women s Preference Profile

Stable Matching Problem Unstable pair: man m and woman w are unstable if m prefers w to his assigned match, and w prefers m to her assigned match Stable assignment: no unstable pairs. favorite least favorite favorite least favorite 1 st 2 nd 3 rd Xavier Amy Bertha Clare Yancey Bertha Amy Clare Zeus Amy Bertha Clare 1 st 2 nd 3 rd Amy Yancey Xavier Zeus Bertha Xavier Yancey Zeus Clare Xavier Yancey Zeus Men s Preference Profile Women s Preference Profile

Review Questions In terms of n, what is the length of the input to the Stable Matching problem, i.e., the number of entries in the tables? (Answer: 2n 2 list entries, or 2n 2 log n bits)

Review Question Brute force algorithm: an algorithm that checks every possible solution. In terms of n, what is the running time for the brute force algorithm for Stable Matching Problem? (Assume your algorithm goes over all possible perfect matchings.) (Answer: n! (time to check if a matching is stable) = Θ(n! n 2 ) )

Propose-and-Reject Algorithm Propose-and-reject algorithm. [Gale-Shapley 1962] Initialize each person to be free. while (some man is free and hasn't proposed to every woman) { Choose such a man m w = 1 st woman on m's list to whom m has not yet proposed if (w is free) assign m and w to be engaged else if (w prefers m to her fiancé m') assign m and w to be engaged, and m' to be free else w rejects m }

Proof of Correctness: Termination Claim. Algorithm terminates after at most n 2 iterations of while loop. Pf. Each time through the loop a man proposes to a new woman. There are only n 2 possible proposals. 1 st 2 nd 3 rd 4 th 5 th 1 st 2 nd 3 rd 4 th 5 th Victor A B C D E Amy W X Y Z V Wyatt B C D A E Bertha X Y Z V W Xavier C D A B E Clare Y Z V W X Yancey D A B C E Diane Z V W X Y Zeus A B C D E Erika V W X Y Z An instance where n(n-1) + 1 proposals required

Propose-and-Reject Algorithm Observation 1. Men propose to women in decreasing order of preference. Observation 2. Once a woman is matched, she never becomes unmatched; she only "trades up."

Proof of Correctness: Perfection Claim. All men and women get matched. Proof: (by contradiction) Suppose, for sake of contradiction, some guy, say Zeus, is not matched upon termination of algorithm. Then some woman, say Amy, is not matched upon termination. By Observation 2, Amy was never proposed to. But Zeus proposes to everyone, since he ends up unmatched.

Proof of Correctness: Stability Claim. No unstable pairs. Proof: (by contradiction) Suppose A-Z is an unstable pair: they prefer each other to their partners in Gale-Shapley matching S*. Case 1: Z never proposed to A. Z prefers his GS partner to A. A-Z is stable. Case 2: Z proposed to A. A rejected Z (right away or later) A prefers her GS partner to Z. A-Z is stable. men propose in decreasing order of preference women only trade up In either case A-Z is stable, a contradiction.

Efficient Implementation We describe O(n 2 ) time implementation. Assume men have IDs 1,, n, and so do women. Engagements data structures: a list of free men, e.g., a queue. two arrays wife[m], and husband[w]. set entry to 0 if unmatched if m matched to w then wife[m]=w and husband[w]=m Men proposing data structures: an array men-pref[m,i]= i th women on m th list an array count[m] = how many proposals m made.

Efficient Implementation Women rejecting/accepting data structures Does woman w prefer man m to man m'? For each woman, create inverse of preference list of men. Constant time queries after O(n) preprocessing per woman. Amy Pref 1 st 8 2 nd 3 rd 3 7 4 th 5 th 6 th 7 th 8 th 1 4 5 6 2 Amy 1 2 3 4 5 6 7 8 Inverse 4 th 8 th 2 nd 5 th 6 th 7 th 3 rd 1 st for i = 1 to n inverse[pref[i]] = i Amy prefers man 3 to 6 since inverse[3] < inverse[6] 2 7

Summary Stable matching problem. Given n men and n women, and their preferences, find a stable matching if one exists. Gale-Shapley algorithm. Guarantees to find a stable matching for every problem instance. (Also proves that stable matching always exists) Time and space complexity: O(n 2 ), linear in the input size.

Brief Syllabus Reminders Worst-case analysis Asymptotic notation Basic Data Structures Design Paradigms Greedy algorithms, Divide and conquer, Dynamic programming, Network flow and linear programming Analyzing algorithms in other models Parallel algorithms, Memory hierarchies (?) P, NP and NP-completeness

Measuring Running Time Focus on scalability: parameterize the running time by some measure of size (e.g. n = number of men and women) Kinds of analysis Worst-case Average-case (requires knowing the distribution) Best-case (how meaningful?) Exact times depend on computer; instead measure asymptotic growth