0% found this document useful (0 votes)
73 views31 pages

Atching: Stable Matching Problem Gale-Shapley Algorithm Hospital Optimality Context

The Gale-Shapley algorithm finds a stable matching between hospitals and students. [1] It works by having the hospitals sequentially propose to their most preferred students not yet proposed to. [2] If a student is currently unmatched or prefers the new hospital to their current match, they accept; otherwise they reject the proposal. [3] The algorithm terminates when all hospitals have proposed or been rejected, resulting in a stable matching.

Uploaded by

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

Atching: Stable Matching Problem Gale-Shapley Algorithm Hospital Optimality Context

The Gale-Shapley algorithm finds a stable matching between hospitals and students. [1] It works by having the hospitals sequentially propose to their most preferred students not yet proposed to. [2] If a student is currently unmatched or prefers the new hospital to their current match, they accept; otherwise they reject the proposal. [3] The algorithm terminates when all hospitals have proposed or been rejected, resulting in a stable matching.

Uploaded by

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

1.

S TABLE M ATCHING
‣ stable matching problem
‣ Gale–Shapley algorithm
‣ hospital optimality
‣ context
1. S TABLE M
ATCHING
‣ stable matching problem
‣ Gale–Shapley algorithm
‣ hospital optimality
‣ context

SECTION
1.1
Matching med-school students to hospitals

Goal. Given a set of preferences among hospitals and med-school


students, design a self-reinforcing admissions process.

Unstable pair. Hospital h and student s form an unstable pair if


both: h prefers s to one of its admitted students.
s prefers h to assigned
hospital.
Stable assignment. Assignment with no unstable
pairs.
Natural and desirable
condition.
Individual self-interest prevents any hospital–student side
deal.

3
Stable matching problem: input

Input. A set of n hospitals H and a set of n students


S.
Each hospital h ∈ H ranks one student per hospital (for
students. Each student s ∈ S ranks now)

hospitals.

favorite least favorite least


favorite favorite

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

Atlanta Xavier Yolanda Zeu Xavier Boston Atlanta Chicag


s o
Boston Yolanda Xavier Zeu Yolanda Atlanta Boston Chicag
s o
Chicago Xavie Yolanda Zeu Zeus Atlant Bosto Chicag
r s a n o
hospitals’ preference students’ preference
lists lists 4
Perfect matching

Def. A matching M is a set of ordered pairs h–s with h ∈ H and s ∈ S


s.t. Each hospital h ∈ H appears in at most one pair of M.
Each student s ∈ S appears in at most one pair of
M.
Def. A matching M is perfect if | M | = | H | = | S | =
n.

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

Atlanta Xavier Yolanda Zeus Xavier Boston Atlanta Chicago

Boston Yolanda Xavier Zeu Yolanda Atlanta Boston Chicag


s o
Chicago Xavier Yolanda Zeu Zeus Atlanta Bosto Chicag
s n o
a perfect matching M = { A–Z, B-Y,
C -X } 5
Unstable pair

Def. Given a perfect matching M, hospital h and student s form


an unstable pair if both:
h prefers s to matched
student.
s prefers h to matched
hospital.
Key point. An unstable pair h–s could each improve by joint
action.

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

Atlanta Xavier Yolanda Zeus Xavier Boston Atlanta Chicago

Boston Yolanda Xavier Zeu Yolanda Atlanta Boston Chicag


s o
Chicago Xavier Yolanda Zeu Zeus Atlanta Bosto Chicag
s n o
A -Y is an unstable pair for matching M = { A–Z, B-Y,
C -X } 6
Stable matching: quiz 1

Which pair is unstable in the matching { A–X, B–Z,


C–Y } ?
A A–Y.
.
B B–
. X.
C B–
. Z.
D None of the
. above.

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

Atlanta Xavier Yolanda Zeu Xavier Boston Atlanta Chicag


s o
Boston Yolanda Xavier Zeus Yolanda Atlanta Boston Chicago

Chicago Xavie Yolanda Zeu Zeus Atlant Boston Chicag


r s a o

7
Stable matching problem

Def. A stable matching is a perfect matching with no unstable


pairs.

Stable matching problem. Given the preference lists of n hospitals


and n students, find a stable matching (if one exists).

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

Atlanta Xavier Yolanda Zeu Xavier Boston Atlanta Chicag


s o
Boston Yolanda Xavier Zeu Yolanda Atlanta Boston Chicag
s o
Chicago Xavie Yolanda Zeus Zeus Atlant Bosto Chicago
r a n
a stable matching M = { A–X, B–Y,
C–Z } 9
Stable roommate problem

Q. Do stable matchings always


exist? A. Not obvious a priori.

Stable roommate
problem.
2 n people; each person ranks others from 1 to 2 n –
1. Assign roommate pairs so that no unstable pairs.

1st 2nd 3rd


no perfect matching is
A B C D stable
A–B, C–D ⇒ B–C
B C A D unstable
A–C, B–D ⇒ A–B
C A B D unstable
A–D, B–C ⇒ A–C
D A B C unstable

Observation. Stable matchings need not


exist.
10
1. S TABLE M
ATCHING
‣ stable matching problem
‣ Gale–Shapley algorithm
‣ hospital optimality
‣ context

SECTION
1.1
Gale–Shapley deferred acceptance algorithm

An intuitive method that guarantees to find a stable


matching.

GALE–SHAPLEY (preference lists for hospitals and students)


________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ INI
TIALIZE M to empty matching.
WHILE (some hospital h is unmatched and hasn’t proposed to every student)
s ← first student on h’s list to whom h has not yet proposed.
IF (s is unmatched)
Add h–s to matching M.
ELSE IF (s prefers h to current partner hʹ)
Replace hʹ–s with h–s in matching M.
ELSE

s rejects h.

RETURN stable matching M.


________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

12
Proof of correctness: termination

Observation 1. Hospitals propose to students in decreasing order


of preference.

Observation 2. Once a student is matched, the student never


becomes unmatched; only “trades up.”

Claim. Algorithm terminates after at most 2n iterations of WHILE


loop.
Pf. Each time through the WHILE loop, a hospital proposes to a new
student. Thus, there are 2at most n possible proposals. ▪

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

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

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

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

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

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

n(n-1) + 1
proposals
13
Proof of correctness: perfect matching

Claim. Gale–Shapley outputs a


matching.
Pf.
Hospital proposes only if unmatched. ⇒ matched to ≤ 1
student
Student keeps only best ⇒ matched to ≤ 1
hospital. hospital
Claim. In Gale–Shapley matching, all hospitals get
matched.
Pf. [by
contradiction]
Suppose, for sake of contradiction, that some hospital h ∈ H
is unmatched upon termination of Gale–Shapley algorithm.
Then some student, say s ∈ S, is unmatched upon
termination. By Observation 2, s was never proposed to.

But, h proposes to every student, since h ends up unmatched.

※ Claim. In Gale–Shapley matching, all students get matched.


Pf. [by
counting]
By previous claim, all n hospitals get
matched.
Thus, all n students get matched. 14
Proof of correctness: stability

Claim. In Gale–Shapley matching M*, there are no unstable


pairs. Pf. Consider any pair h–s that is not in M*.

Case 1: h never proposed to


hospitals propose in
s.
⇒ h prefers its Gale–Shapley partner sʹ to decreasing
order
of
s. ⇒ h–s is not unstable. preference

Case 2: h proposed to
s.
⇒ s rejected h (either right away or
later) ⇒ s prefers Gale–Shapley partner
h–
⇒ to
hʹ h–sh.is not unstable. sʹ
students only trade
up hʹ –
s

In either case, the pair h–s is not unstable.

Gale–Shapley matching
M*

15
Summary

Stable matching problem. Given n hospitals and n students, and


their preference lists, find a stable matching if one exists.

Theorem. [Gale–Shapley 1962] The Gale–Shapley algorithm


guarantees to find a stable matching for any problem instance.

16
Stable matching: quiz 2

Do all executions of Gale–Shapley lead to the same stable


matching?
A No, because the algorithm is
. nondeterministic.
B
. No, because an instance can have several stable
C matchings. Yes, because each instance has a unique
.
stable matching.
D Yes, even though an instance can have several stable
. matchings and the algorithm is nondeterministic.

17
1. S TABLE M
ATCHING
‣ stable matching problem
‣ Gale–Shapley algorithm
‣ hospital optimality
‣ context

SECTION
1.1
Understanding the solution

For a given problem instance, there may be several stable


matchings.

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

A X Y Z X B A C

B Y X Z Y A B C

C X Y Z Z A B C

an instance with two stable matchings: S = { A-X, B-Y, C - Z } and S′ = { A-Y,


B-X, C - Z } 19
Understanding the solution

Def. Student s is a valid partner for hospital h if there exists any


stable matching in which h and s are matched.

Ex.
Both X and Y are valid partners for
A. Both X and Y are valid partners
for B. Z is the only valid partner for
C.

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

A X Y Z X B A C

B Y X Z Y A B C

C X Y Z Z A B C

an instance with two stable matchings: S = { A-X, B-Y, C - Z } and S′ = { A-Y,


B-X, C - Z } 20
Stable matching: quiz 3

Who is the best valid partner for W in the following


instance?

A 6 stable matchings
. { A–W, B–X, C–Y, D–
B
Z } { A–X, B–W, C–Y,
.
D–Z } { A–X, B–Y, C–
C
. W, D–Z } { A–Z, B–

D W, C–Y, D–X } { A–Z,


. B–Y, C–W, D–X } { A–
Y, B–Z, C–W, D–X }

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

A Y Z X W W D A B C

B Z Y W X X C B A D

C W Y X Z Y C B A D

D X Z W Y Z D A B C
21
Understanding the solution

Def. Student s is a valid partner for hospital h if there exists any


stable matching in which h and s are matched.

Hospital-optimal assignment. Each hospital receives best valid


partner. Is it a perfect matching?
Is it
stable?

Claim. All executions of Gale–Shapley yield hospital-optimal


assignment. Corollary. Hospital-optimal assignment is a stable
matching!

23
Hospital optimality

Claim. Gale–Shapley matching M* is hospital-


optimal.
Pf. [by
contradiction]
Suppose a hospital is matched with student other than best valid
partner. Hospitals propose in decreasing order of preference.
⇒ some hospital is rejected by a valid partner during Gale–
Shapley Let h be first such hospital, and let s be the first valid
h–
partner that rejects s
h. hʹ – sʹ
Let M be a stable matching where h and s are
matched. ⋮
When s rejects h in Gale–Shapley, s forms (or re-
affirms)
commitment to a hospital, say
hʹ.
⇒ s prefers hʹ to h.
stable matching
M
Let sʹ be partner of hʹ in
M.
hʹ had not been rejected by any valid partner
because this is the first
(including sʹ) at the point when h is rejected by rejection by a valid
s. partner
Thus, hʹ had not yet proposed to sʹ when hʹ proposed to
s. ⇒ hʹ prefers s to sʹ.
Thus, hʹ–s is unstable in M, a contradiction. 24
Student pessimality

Q. Does hospital-optimality come at the expense of the


students? A. Yes.

Student-pessimal assignment. Each student receives worst valid


partner.
Claim. Gale–Shapley finds student-pessimal stable matching
M*.
Pf. [by
contradiction]
Suppose h–s matched in M* but h is not the worst valid partner for
s. There exists stable matching M in which s is paired with a
hospital, say hʹ, whom s prefers less than h.
⇒ s prefers h to hʹ. hʹ –
Let sʹ be the partner of h in s
h – sʹ
M.
By hospital-optimality, s is the best valid partner for ⋮
h.
⇒ h prefers s to sʹ.
Thus, h–s is an unstable pair in M, a contradiction.
stable matching
▪ M

25
Stable matching: quiz 4

Suppose each agent knows the preference lists of every


other agent before the hospital propose-and-reject
algorithm is executed. Which is true?

A No hospital can improve by falsifying its preference


. list.
B
. No student can improve by falsifying their preference
C list. Both A and B.
.
D Neither A nor
. B.

26
1. S TABLE M
ATCHING
‣ stable matching problem
‣ Gale–Shapley algorithm
‣ hospital optimality
‣ context

SECTION
1.1
Extensions

Extension 1. Some agents declare others as


med-school
unacceptable. Extension 2. Some hospitals have more student
unwilling to work
than one position. Extension 3. Unequal number of in
Cleveland
positions and students.
≥ 43K med-school
students;
only 31K positions

Def. Matching M is unstable if there is a hospital h and student s such


that: h and s are acceptable to each other; and
Either s is unmatched, or s prefers h to assigned hospital;
and
Either h does not have all its places filled, or h prefers s to at
least one of its assigned students.

Theorem. There exists a stable


matching.
Pf. Straightforward generalization of Gale–Shapley
algorithm.

29
Historical context

National resident matching program


(NRMP).
Centralized clearinghouse to match med-school students to
hospitals. Began in 1952 to fix unraveling of offer dates.
hospitals began
Originally used the “Boston Pool” making
offers earlier and
earlier, up to 2 years in
algorithm. Algorithm overhauled in 1998. advance
- med-school student
optimal
- deals with various side
constraints
(e.g., allow couples to match
stable matching no
longer
guaranteed to
together) exist

The Redesign of the Matching Market for American Physicians:


Some Engineering Aspects of Economic Design

By ALVIN E. ROTH AND ELLIOTT PERANSON*

We report on the design of the new clearinghouse adopted by the National Resident
Matching Program, which annually fills approximately 20,000 jobs for new physi-
cians. Because the market has complementarities between applicants and between
positions, the theory of simple matching markets does not apply directly. However,
computational experiments show the theory provides good approximations. Fur-
thermore, the set of stable matchings, and the opportunities for strategic manipu-
lation, are surprisingly small. A new kind of “core convergence” result explains
this; that each applicant interviews only a small fraction of available positions is
important. We also describe engineering aspects of the design process. (JEL C78,
B41, J44)

The entry-level labor market for new physi- employment, rather than waiting to participate
cians in the United States is organized via a in the larger market. (By the 1940’s, contracts 30
centralized clearinghouse called the National were typically being signed two years in ad-
2012 Nobel Prize in Economics

Lloyd Shapley. Stable matching theory and Gale–Shapley


algorithm.

original
applications:
college admissions
and
opposite-sex
marriage

Alvin Roth. Applied Gale–Shapley to matching med-school students


with hospitals, students with schools, and organ donors with patients.

Lloyd Alvin
31
Shapley Roth
New York City high school match

8th grader. Ranks top-5 high


schools.
High school. Ranks students (and
limit).
Goal. Match 90K students to 500 high school
programs.

32
Questbridge national college match

Low-income student. Ranks


colleges.
College. Ranks students willing to admit (and
limit). Goal. Match students to colleges.

33
A modern application

Content delivery networks. Distribute much of world’s content on

web. User. Preferences based on latency and packet loss.


Web server. Preferences based on costs of bandwidth and co-
location. Goal. Assign billions of users to servers, every 10
seconds.

Algorithmic Nuggets in Content Delivery

Bruce M. Maggs Ramesh K. Sitaraman


Duke and Akamai UMass, Amherst and Akamai
[email protected] [email protected]
This article is an editorial note submitted to CCR. I t has NOT been peer reviewed.

The authors take full responsibility for this article’s technical content. Comments can be posted through CCR Online.

ABSTRACT Edge%Server%
This paper “peeks under the covers” at the subsystems Overlay%
that
provide the basic functionality of a leading content deliv- Rou4ng%
ery network. Based on our experiences in building one of Client%
the largest distributed systems in the world, we illustrate
how sophisticated algorithmic research has been adapted to
balance the load between and within server clusters, man-
age the caches on servers, select paths through an
overlay
routing network, and elect leaders in various contexts. In
each instance, we first explain the theory underlying the Origin%
algorithms, then introduce practical considerations not cap-
tured by the theoretical models, and finally describe what is Content%
implemented in practice. Through these examples, we high- Authorita4ve%Name%Server%
DNS% %(Global%and%Local%Load%
light the role of algorithmic research in the design of com-
Balancing)%
plex networked systems. The paper also illustrates the close
synergy that exists between research and industry where
research ideas cross over into products and product require-
ments drive future research.
Figure 1: A C D N serves content in response to a
1. INTRODUCTION client’s request.
The top-three objectives for the designers and operators
of a content delivery network (CDN) are high reliability, 34
fast and consistent performance, and low operating cost. CDN’s authoritative name server. The authoritative name
While many techniques must be employed to achieve these server examines the network address of the resolving name

You might also like