0% found this document useful (0 votes)
147 views8 pages

Some Representative Problems: 1.1 A First Problem: Stable Matching

Uploaded by

Rajendra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views8 pages

Some Representative Problems: 1.1 A First Problem: Stable Matching

Uploaded by

Rajendra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1.

1 A First Problem: Stable Matching


Chapter 1

Introduction:
Some Representative
Problems

Slides by Kevin Wayne.


Copyright © 2005 Pearson-Addison Wesley.
All rights reserved.

Matching Residents to Hospitals Stable Matching Problem

Goal. Given a set of preferences among hospitals and medical school Goal. Given n men and n women, find a "suitable" matching.
students, design a self-reinforcing admissions process. !Participants rate members of opposite sex.
!Each man lists women in order of preference from best to worst.
Unstable pair: applicant x and hospital y are unstable if: !Each woman lists men in order of preference from best to worst.
! x prefers y to its assigned hospital.
! y prefers x to one of its admitted students.
favorite least favorite favorite least favorite
Stable assignment. Assignment with no unstable pairs.
! Natural and desirable condition. 1st 2nd 3rd 1st 2nd 3rd
Individual self-interest will prevent any applicant/hospital deal
Xavier Amy Bertha Clare Amy Yancey Xavier Zeus
!

from being made.


Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus

Zeus Amy Bertha Clare Clare Xavier Yancey Zeus


Men’s Preference Profile Women’s Preference Profile

3 4
Stable Matching Problem Stable Matching Problem

Perfect matching: everyone is matched monogamously. Q. Is assignment X-C, Y-B, Z-A stable?
!Each man gets exactly one woman.
!Each woman gets exactly one man.

Stability: no incentive for some pair of participants to undermine


assignment by joint action.
!In matching M, an unmatched pair m-w is unstable if man m and favorite least favorite favorite least favorite
woman w prefer each other to current partners.
!Unstable pair m-w could each improve by eloping. 1st 2nd 3rd 1st 2nd 3rd

Xavier Amy Bertha Clare Amy Yancey Xavier Zeus


Stable matching: perfect matching with no unstable pairs.
Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus

Stable matching problem. Given the preference lists of n men and n Zeus Amy Bertha Clare Clare Xavier Yancey Zeus
women, find a stable matching if one exists. Men’s Preference Profile Women’s Preference Profile

5 6

Stable Matching Problem Stable Matching Problem

Q. Is assignment X-C, Y-B, Z-A stable? Q. Is assignment X-A, Y-B, Z-C stable?
A. No. Bertha and Xavier will hook up. A. Yes.

favorite least favorite favorite least favorite favorite least favorite favorite least favorite

1st 2nd 3rd 1st 2nd 3rd 1st 2nd 3rd 1st 2nd 3rd

Xavier Amy Bertha Clare Amy Yancey Xavier Zeus Xavier Amy Bertha Clare Amy Yancey Xavier Zeus

Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus Yancey Bertha Amy Clare Bertha Xavier Yancey Zeus

Zeus Amy Bertha Clare Clare Xavier Yancey Zeus Zeus Amy Bertha Clare Clare Xavier Yancey Zeus
Men’s Preference Profile Women’s Preference Profile Men’s Preference Profile Women’s Preference Profile

7 8
Stable Roommate Problem Propose-And-Reject Algorithm

Q. Do stable matchings always exist? Propose-and-reject algorithm. [Gale-Shapley 1962] Intuitive method
A. Not obvious a priori. that guarantees to find a stable matching.
is core of market nonempty?

Stable roommate problem.


! 2n people; each person ranks others from 1 to 2n-1. Initialize each person to be free.
! Assign roommate pairs so that no unstable pairs. while (some man is free and hasn't proposed to every woman) {
Choose such a man m
1st 2nd 3rd w = 1st woman on m's list to whom m has not yet proposed
Adam B C D if (w is free)
A-B, C-D ! B-C unstable assign m and w to be engaged
Bob C A D A-C, B-D ! A-B unstable else if (w prefers m to her fiancé m')
Chris A B D A-D, B-C ! A-C unstable assign m and w to be engaged, and m' to be free
Doofus A B C else
w rejects m
}
Observation. Stable matchings do not always exist for stable
roommate problem.

9 10

Proof of Correctness: Termination Proof of Correctness: Perfection

Observation 1. Men propose to women in decreasing order of preference. Claim. All men and women get matched.
Pf. (by contradiction)
Observation 2. Once a woman is matched, she never becomes unmatched; ! Suppose, for sake of contradiction, that Zeus is not matched upon
she only "trades up." termination of algorithm.
! Then some woman, say Amy, is not matched upon termination.
Claim. Algorithm terminates after at most n2 iterations of while loop. ! By Observation 2, Amy was never proposed to.
Pf. Each time through the while loop a man proposes to a new woman. ! But, Zeus proposes to everyone, since he ends up unmatched. !
There are only n2 possible proposals. !

1 st 2nd 3rd 4th 5th 1 st 2nd 3rd 4th 5th

Vi ctor A B C D E Amy W X Y Z V

Wyatt B C D A E Bertha X Y Z V W

Xavi er C D A B E Clare Y Z V W X

Yancey D A B C E Di ane Z V W X Y

Zeus A B C D E Eri ka V W X Y Z

n(n-1) + 1 proposals required

11 12
Proof of Correctness: Stability Summary

Claim. No unstable pairs. Stable matching problem. Given n men and n women, and their
Pf. (by contradiction) preferences, find a stable matching if one exists.
! Suppose A-Z is an unstable pair: each prefers each other to
partner in Gale-Shapley matching S*. Gale-Shapley algorithm. Guarantees to find a stable matching for any
men propose in decreasing
problem instance.
S*
! Case 1: Z never proposed to A. order of preference

! Z prefers his GS partner to A. Amy-Yancey Q. How to implement GS algorithm efficiently?


! A-Z is stable. Bertha-Zeus
... Q. If there are multiple stable matchings, which one does GS find?
! Case 2: Z proposed to A.
! A rejected Z (right away or later)
! A prefers her GS partner to Z. women only trade up

! A-Z is stable.

! In either case A-Z is stable, a contradiction. !

13 14

Efficient Implementation Efficient Implementation

Efficient implementation. We describe O(n2) time implementation. Women rejecting/accepting.


!Does woman w prefer man m to man m'?
Representing men and women. !For each woman, create inverse of preference list of men.
! Assume men are named 1, …, n. !Constant time access for each query after O(n) preprocessing.
! Assume women are named 1', …, n'.

Engagements. Amy 1st 2nd 3rd 4th 5th 6th 7th 8th

! Maintain a list of free men, e.g., in a queue. Pref 8 3 7 1 4 5 6 2

! Maintain two arrays wife[m], and husband[w].


– set entry to 0 if unmatched Amy 1 2 3 4 5 6 7 8
– if m matched to w then wife[m]=w and husband[w]=m Inverse 4th 8th 2nd 5th 6th 7th 3rd 1st

Men proposing. Amy prefers man 3 to 6


since inverse[3] < inverse[6]
!For each man, maintain a list of women, ordered by preference. for i = 1 to n
2 7
!Maintain an array count[m] that counts the number of proposals inverse[pref[i]] = i
made by man m.

15 16
Understanding the Solution Understanding the Solution

Q. For a given problem instance, there may be several stable Q. For a given problem instance, there may be several stable
matchings. Do all executions of Gale-Shapley yield the same stable matchings. Do all executions of Gale-Shapley yield the same stable
matching? If so, which one? matching? If so, which one?

Def. Man m is a valid partner of woman w if there exists some stable


An instance with two stable matchings. matching in which they are matched.
! A-X, B-Y, C-Z.
! A-Y, B-X, C-Z. Man-optimal assignment. Each man receives best valid partner.

Claim. All executions of GS yield man-optimal assignment, which is a


1st 2nd 3rd 1st 2nd 3rd
stable matching!
Xavier A B C Amy Y X Z
! No reason a priori to believe that man-optimal assignment is
Yancey B A C Bertha X Y Z
perfect, let alone stable.
Zeus A B C Clare X Y Z ! Simultaneously best for each and every man.

17 18

Man Optimality Stable Matching Summary

Claim. GS matching S* is man-optimal. Stable matching problem. Given preference profiles of n men and n
Pf. (by contradiction) women, find a stable matching.
! Suppose some man is paired with someone other than best partner.
no man and woman prefer to be with
Men propose in decreasing order of preference ! some man is each other than assigned partner

rejected by valid partner.


S
! Let Y be first such man, and let A be first valid Gale-Shapley algorithm. Finds a stable matching in O(n2) time.
Amy-Yancey
woman that rejects him.
! Let S be a stable matching where A and Y are matched. Bertha-Zeus Man-optimality. In version of GS where men propose, each man
! When Y is rejected, A forms (or reaffirms) ... receives best valid partner.
engagement with a man, say Z, whom she prefers to Y. w is a valid partner of m if there exist some
! Let B be Z's partner in S. stable matching where m and w are paired

! Z not rejected by any valid partner at the point when Y is rejected


by A. Thus, Z prefers A to B.
since this is first rejection
! But A prefers Z to Y. by a valid partner
Q. Does man-optimality come at the expense of the women?
! Thus A-Z is unstable in S. !

19 20
Woman Pessimality Extensions: Matching Residents to Hospitals

Woman-pessimal assignment. Each woman receives worst valid partner. Ex: Men " hospitals, Women " med school residents.

Claim. GS finds woman-pessimal stable matching S*. Variant 1. Some participants declare others as unacceptable.

resident A unwilling to
Pf. Variant 2. Unequal number of men and women. work in Cleveland
! Suppose A-Z matched in S*, but Z is not worst valid partner for A.
! There exists stable matching S in which A is paired with a man, say Variant 3. Limited polygamy.
Y, whom she likes less than Z.
S hospital X wants to hire 3 residents
! Let B be Z's partner in S.
! Z prefers A to B. man-optimality Amy-Yancey
! Thus, A-Z is an unstable in S. ! Bertha-Zeus Def. Matching S unstable if there is a hospital h and resident r such that:
...
!h and r are acceptable to each other; and
!either r is unmatched, or r prefers h to her assigned hospital; and
!either h does not have all its places filled, or h prefers r to at least one
of its assigned residents.

21 22

Application: Matching Residents to Hospitals Lessons Learned

NRMP. (National Resident Matching Program) Powerful ideas learned in course.


!Original use just after WWII. predates computer usage Isolate underlying structure of problem.
!

!Ides of March, 23,000+ residents. Create useful and efficient algorithms.


!

Rural hospital dilemma. Potentially deep social ramifications. [legal disclaimer]


! Certain hospitals (mainly in rural areas) were unpopular and
declared unacceptable by many residents.
! Rural hospitals were under-subscribed in NRMP matching.
! How can we find stable matching that benefits "rural hospitals"?

Rural Hospital Theorem. Rural hospitals get exactly same residents in


every stable matching!

23 24
Interval Scheduling

1.2 Five Representative Problems Input. Set of jobs with start times and finish times.
Goal. Find maximum cardinality subset of mutually compatible jobs.

jobs don't overlap

h Time
0 1 2 3 4 5 6 7 8 9 10 11

26

Weighted Interval Scheduling Bipartite Matching

Input. Set of jobs with start times, finish times, and weights. Input. Bipartite graph.
Goal. Find maximum weight subset of mutually compatible jobs. Goal. Find maximum cardinality matching.

A 1

23
B 2
12

20
C 3
26

13 D 4

20
E 5
11

16 Time
0 1 2 3 4 5 6 7 8 9 10 11

27 28
Independent Set Competitive Facility Location

Input. Graph. Input. Graph with weight on each each node.


Goal. Find maximum cardinality independent set. Game. Two competing players alternate in selecting nodes. Not
allowed to select a node if any of its neighbors have been selected.
subset of nodes such that no two
joined by an edge

Goal. Select a maximum weight subset of nodes.

1 2

4 5 10 1 5 15 5 1 5 1 15 10
3

6 7 Second player can guarantee 20, but not 25.

29 30

Five Representative Problems

Variations on a theme: independent set.

Interval scheduling: n log n greedy algorithm.


Weighted interval scheduling: n log n dynamic programming algorithm.
Bipartite matching: nk max-flow based algorithm.
Independent set: NP-complete.
Competitive facility location: PSPACE-complete.

31

You might also like