/
The Stable Marriage Problem The Stable Marriage Problem

The Stable Marriage Problem - PowerPoint Presentation

ripplas
ripplas . @ripplas
Follow
345 views
Uploaded On 2020-06-23

The Stable Marriage Problem - PPT Presentation

Algorithms and Networks 20172018 Johan M M van Rooij Hans L Bodlaender A prize winning algorithm Lloyd Shapley Nobel Prize Winner 2012 in economics Obtained the prize for a number of contributions one being the GaleShapley algorithm discussed today ID: 783924

list stable matching person stable list person matching algorithm roommates preference phase partner arie proposal carl bert problem assignment

Share:

Link:

Embed:

Download Presentation from below link

Download The PPT/PDF document "The Stable Marriage Problem" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

The Stable Marriage Problem

Algorithms

and Networks 2017/2018

Johan M. M. van Rooij

Hans L.

Bodlaender

Slide2

A prize winning algorithm

Lloyd Shapley, Nobel Prize Winner 2012 in economics.

Obtained the prize for a number of contributions, one being the Gale-Shapley algorithm, discussed today.

Photo Bengt Nyman

http://en.wikipedia.org/wiki/File:Lloyd_Shapley_2_2012.jpg

Slide3

The stable marriage problem

There are

n

men and

n women all unmarried. Each has a preference list on the persons of the opposite sex.

Does there exist and can we find a

stable marriage

(stable matching)

: a matching between men and women, such that there is no man and woman who both prefer each other above their partner in the matching?

Origin

: assignment of medical students to hospitals (for internships).

Students list hospitals in order of preference.

Hospitals list students in order of preference.

Slide4

Example

Arie

: Ann Cindy Betty

Bert

: Betty Ann CindyCarl: Betty Ann CindyAnn

: Bert Carl

Arie

Betty

: Carl Bert Arie Cindy: Bert Carl Arie

Stable matching:

(

Arie

, Cindy), (Bert, Ann), (Carl,

Betty

).

Matching (

Arie

, Cindy), (Bert, Betty), (Carl, Ann) is not stable.

Carl and Betty prefer each other above given partner: they form a

Blocking pair

.

Slide5

Contents of this lecture

Stable marriage problem.

Gale-Shapley algorithm.

Man-optimal and woman-optimal stable marriages.

Stable roommates problem.Introduction.Next week: An algorithm for the stable roommates problem.

Slide6

Stable marriage problem

Stable Marriage & Roommates - Algorithms and Networks

Slide7

Problem: greedy algorithm

does not need to terminate

Greedy or ‘Soap-Series’ Algorithm:

While

there is a blocking pairDo Switch the blocking pair

Greedy “local search” approach does not need to terminate:

Can go on for ever!

So, we need something else…

Slide8

Result

Gale-Shapley algorithm

: always finds a stable matching.

Input

: list of men, women, and their preference list.Output: stable matching.

Slide9

The algorithm

Fix some ordering on the men.

Repeat until everyone is matched.

Let Y be the first unmatched man in the ordering.

Now Y will ‘propose’ to the women X highest on Y’s preference list to whom he has not proposed before.

If X has no partner, or feels that she is better off with Y than with her current partner, she accepts and X and Y become matched. This possibly turns a man Z to be unmatched.

Otherwise X turns down Y and Y will continue proposing to the next woman on his list.

Questions:

Does this terminate? How fast?

Does this give a stable matching?

Slide10

A demonstration on the blackboard

Example:

Arie

: Ann Cindy Betty

Bert: Betty Ann Cindy

Carl

: Betty Ann Cindy

Ann

: Bert Carl

Arie Betty: Carl Bert Arie Cindy

: Bert Carl

Arie

Gale-Shapley Algorithm:

Repeat until everyone is matched:

Let Y be the first unmatched man.

Y will ‘propose’ to the women X highest on Y’s preference list to whom he has not proposed before.

If X has no partner, or feels that she is better off with Y than with her current partner, she accepts and X and Y become matched (possibly leaving man Z).

Otherwise X turns down Y and Y will continue proposing to next woman on his list.

Slide11

Termination and number of steps

Observations:

Once a woman is matched, she stays matched. Her partner can change though.

If her partner changes, she will always get a more preferable partner.

The women to whom a man proposes will get worse (in his opinion) during the execution of algorithm.

If a man becomes free again, then there is a woman to whom he has not yet proposed.

There must be a free woman due to a counting argument, and he cannot have proposed to her by the first observation.

The computed set is a matching.

The algorithm uses at most

n

2

steps/proposals.

Each man proposes to each women at most once.

Proof: the matching is stable.

Slide12

The matching is stable

Suppose the computed matching is not stable.

There exist a blocking pair: (X,Y), (X’,Y’) where:

Y prefers X’ over X

X’ prefers Y over Y’.Ys last proposal was to X (by definition of the algorithm).Did Y propose to X’ during the execution of the algorithm?

No? Then Y does not prefer X’ over X – contradiction.

Yes? Then X’ rejected Y in favour of man Y’’.

Y’’

Y’! Otherwise, contradiction with that X’ prefers Y over Y’.Since X’ ends up with Y’, we know that she prefers Y’ over Y’’.But wait: X’ prefers Y over Y’ and Y’ over Y’’, thus Y over Y’’.Contradiction: she rejected Y in favour of Y’’.

Slide13

More than one stable matching?

Conclusion:

A stable matching always exists and can be found in polynomial time.

How well are the men/women off in the stable matching produced by the Gale-Shapley algorithm?

What if the woman would propose?

Are there alternative stable matchings?

Example

:

(preference lists)

Arie

: Ann Betty

Bert

: Betty Ann

Ann

: Bert

Arie

Betty

:

Arie

Bert

Slide14

Man-optimal stable

matchings

Theorem

:

All executions of the Gale-Shapley algorithm result in the set S = { (Y, best partner of Y in any stable matching) }.

Corollaries:

S is a stable matching (not clear from the definition).

The algorithm produces a Man-optimal stable matching.

The algorithm produces the worst stable matching from the perspective of the women.

Slide15

Proof of Corollary

3

Theorem

:

All executions of the Gale-Shapley algorithm result in the set S = { (Y, best partner of Y in any stable matching) }.

Corollary:

The algorithm produces the worst stable matching from the perspective of the women.

Suppose that in S woman X is matched to Y while Y is not her worst possible stable partner.

Then there is a stable matching S’ in which she is matched to Y’ that is worse than Y (let Y have partner X’ in S’).

Since X is the best stable partner of Y (in S) and X’ is a stable partner of Y (in S’), we know that Y prefers X to X’.

Contradiction: S’ is not stable, blocking pair (X,Y).

Slide16

Proof of Theorem

Theorem

:

All executions of the Gale-Shapley algorithm result in the set S = { (Y, best partner of Y in any stable matching) }.

Suppose it is not true, then some man Y is rejected by a stable partner X during the execution of the algorithm.

Consider the first time this happens: X rejects Y in favour of Y’.

Because men propose in order of preference, and this is the first such rejection, X is Ys best stable partner.

Since X is a stable partner for Y, there is a stable matching S’ where X and Y are matched. Here Y’ is matched to X’

X.Since we consider the first rejection of a stable partner, Y’ has not been rejected yet by a stable partner: thus, Y’ prefers X over X’.Then S’ is not stable: X prefers Y’ over Y, Y’ prefers X over X’.

Contradiction.

Slide17

Stable marriage: conclusions

A stable matching always exists and can be found in O(n

2

) time using the Gale-Shapley algorithm.

The Gale-Shapley algorithm produces a stable matching where:All men have their best possible stable partner.All woman have their worst possible stable partner.

Slide18

Stable ROOMMATES problem

Stable Marriage & Roommates - Algorithms and Networks

Slide19

Stable roommates

Given:

A set of people that must share two-person rooms.

Each person has a preference list with all possible roommates.

Question:Does there exist (and can we find) a

stable matching

: an assignment of roommates, such that there are no two people who both prefer each other above their current roommate.

Slide20

Not always a stable matching for the stable roommates problem

Consider the following instance:

Arie

: Carl Bert Dirk

Bert:

Arie

Carl Dirk

Carl

: Bert

Arie DirkDirk: can be anythingEach matching is unstable e.g., (

Arie,Bert

)(

Carl,Dirk

) has {

Carl,Arie

} as blocking pair.

Slide21

The Stable Roommates Problem

Algorithms

and

Networks 2017/2018

Johan M. M. van RooijHans L. Bodlaender

Slide22

Contents of this lecture

Last week: Stable marriage problem.

Gale-Shapley algorithm.

Man-optimal and woman-optimal stable marriages.

Introduction to stable roommates problem.This week: An algorithm for the stable roommates problem.

Slide23

Stable roommates

Given:

A set of people that must share two-person rooms.

Each person has a preference list with all possible roommates.

Question:

Does there exist (and can we find) a

stable matching

: an assignment of roommates, such that there are no two people who both prefer each other above their current roommate.

Last week, we have seen that such a stable roommates assignment does not need to exists.

Slide24

Stable roommates

Given:

A set of people that must share two-person rooms.

Each person has a preference list with all possible roommates.

Question:

Does there exist (and can we find) a

stable matching

: an assignment of roommates, such that there are no two people who both prefer each other above their current roommate.

Slide25

Not always a stable matching for the stable roommates problem

Consider the following instance:

Arie

: Carl Bert Dirk

Bert:

Arie

Carl Dirk

Carl

: Bert

Arie DirkDirk: can be anythingEach matching is unstable e.g., (

Arie,Bert

)(

Carl,Dirk

) has {

Carl,Arie

} as blocking pair.

Slide26

Not always a stable matching for the stable roommates problem

Consider the following instance:

Arie

: Carl Bert Dirk

Bert:

Arie

Carl Dirk

Carl

: Bert

Arie DirkDirk: can be anythingEach matching is unstable e.g., (

Arie,Bert

)(

Carl,Dirk

) has {

Carl,Arie

} as blocking pair.

This problem appears a bit more complicated than the stable marriage problem.

Slide27

Testing stable roommates

In the next slides, we give an algorithm to find a stable roommates assignment or decide that no such assignment exists.

The algorithm will filter preference lists, removing options that will never lead to stable assignments.

Some form of constraint propagation.

Algorithm outline:

Phase 1

: proposing and filtering.

Phase 2

: removing all-or-nothing cycles.

Phase 3: find empty preference lists, or output solution.

Slide28

Phase 1: proposing

Proposing phase

: people propose to others to be roommates.

During the algorithm each person:

Has at most one outstanding proposal.Keeps the best proposal he has received so far and rejects others.

Algorithm:

Apply the following for each person once:

proposer := current person.

proposer proposes to his best choice by whom he is not (yet) rejected.

if rejected by this person: goto 2.

if accepted by someone without a proposal: done for this person.

else proposer := person who just got rejected,

goto

2.

Slide29

Phase 1: example on the blackboard

Example:

1:

4, 6, 2, 5, 3.

2: 6, 3, 5, 1, 4.

3:

4, 5, 1, 6, 2.

4:

2, 6, 5, 1, 3.5: 4, 2, 3, 6, 1.6:

5, 1, 4, 2, 3.

Algorithm:

Apply the following for each

person once:

proposer := current person.

proposer proposes to his best choice by whom he is not (yet) rejected.

if rejected,

goto

2.

if accepted by someone without a proposal: done for this person.

else proposer := person who just got rejected,

goto

2.

Slide30

A lemma on rejections

Lemma:

If y rejects x in phase 1 of the algorithm, then x and y cannot be partners in a stable matching.

Slide31

A lemma on rejections

Lemma:

If y rejects x in phase 1 of the algorithm, then x and y cannot be partners in a stable matching.

Suppose that y rejects x in favour of z while x and y are roommates in some stable matching S.

W.l.o.g. assume that this is the first such rejection while running the algorithm. We consider both types of rejection

(z proposing to y or x proposing to y) and note that z must have proposed to y in both cases (now or earlier respectively).

Let z be matched to w in S. Since S is stable, and y prefers z to x, z must prefer w over y.

But then, z has proposed to w earlier than he did to y, and hence has been rejected by w earlier, contradicting that this is the first rejection by a stable roommate.

Slide32

Best or worst stable roommates

Lemma:

If y rejects x in phase 1 of the algorithm, then x and y cannot be partners in a stable matching.

Corollaries:

If, in phase 1 of the algorithm, x proposes to y:

x cannot have a better stable roommate than y.

y cannot have a worse stable roommate than x.

Slide33

Best or worst stable roommates

Lemma:

If y rejects x in phase 1 of the algorithm, then x and y cannot be partners in a stable matching.

Corollaries:

If, in phase 1 of the algorithm, x proposes to y:

x cannot have a better stable roommate than y.

y cannot have a worse stable roommate than x.

(1.) follows directly by the lemma. For (2.):

Let S be a stable assignment, where y is matched to z while y prefers x over z, and where x is matched to any person w.

y prefers x to z, and by (1.) x prefers y to w: contradiction to S being stable.

Slide34

Filtering for phase 1

Phase 1 finishes with either:

Some person being rejected by all others.

There is no stable matching (by the previous lemma).

Everyone holds a proposal from someone and has a made a proposal to someone that has not been rejected.

In the second case we can delete entries from the preference lists that never lead to a stable assignment.

If y holds a proposal from x then we remove from

y’s

preference list:

All those who rejected y.All those to whom y prefers x (x was worst possible matching).All those who hold a proposal from a person whom they prefer to y.

Slide35

Filtering for phase 1

If y holds a proposal from x then we remove from

y’s

preference list:

All those who rejected y.All those to whom y prefers x (x was worst possible matching).All those who hold a proposal from a person whom they prefer to y.The example

1: 4

,

6

,

2, 5, 3. Proposals held in bold black.

2:

6

, 3, 5,

1

,

4

. Rejected in phase 1 in

red

.

3: 4

, 5,

1

,

6

,

2

. Worse than proposal in

purple

.

4:

2,

6

,

5

,

1

,

3

. Eliminated because the other holds

5:

4, 2,

3

,

6

,

1

. a better proposal in

green

.

6:

5

,

1

,

4

,

2

,

3

.

Slide36

The result of phase 1 filtering

If y holds a proposal from x then we remove from

y’s

preference list:

All those who rejected y.All those to whom y prefers x (x was worst possible matching).All those who hold a proposal from a person whom they prefer to y.The example The filtered example

1: 4

,

6

,

2, 5, 3. 1: 6.

2:

6

, 3, 5,

1

,

4

.

2:

3, 5,

4

.

3: 4

, 5,

1

,

6

,

2

.

3:

5,

2

.

4:

2,

6

,

5

,

1

,

3

.

4:

2,

5

.

5:

4, 2,

3

,

6

,

1

.

5:

4, 2,

3

.

6:

5

,

1

,

4

,

2

,

3

.

6:

1

.

Slide37

Properties after filtering

Proposals after filtering:

Everyone holds a proposal, and the proposal is from the last person on his list.

Everyone is first on someone’s list, namely the person where he holds a proposal from.

Other properties after filtering:x appears on y’s list, if and only if, y appears on

x’s

list.

x is first on

y’s

list, if and only if, y appears last on x’s list.if x has only y on his list, then y has only x on his list and they must be together in a stable roommates assignment if such an assignment exists.Now we are ready for phase 2.

Slide38

Definition: all-or-nothing cycle

Definition:

An

all-or-nothing cycle

is a sequence of persons a1,a

2

,...,

a

r

such that:The second person in ai’s current preference list is the first person in a

i+1

’s

preference list, and we will call this person b

i+1

, the best match for a

i+1

. (all indices modulo r)

a

1

:

b

1

,

b

2

, ...

a

2

:

b

2

,

b

3

, ...

a

i

is the

i

-the person on the cycle.

a

3

:

b

3

, b

4

, ...

b

i

is

a

i

’s

best remaining roommate.

a

4

:

b

4

, b

5

, ...

b

i+1

is second on

a

i

’s

list.

....

(modulo r)

Slide39

Definition: all-or-nothing cycle

Definition:

An

all-or-nothing cycle

is a sequence of persons a1,a

2

,...,

a

r

such that:The second person in ai’s current preference list is the first person in a

i+1

’s

preference list, and we will call this person b

i+1

, the best match for a

i+1

. (all indices modulo r)

The example after phase 1

1:

6

.

All-or-nothing

cycle

: 3, 4.

2:

3, 5,

4

.

a

1

=

3

.

3:

5,

2

.

b

2

= 2.

a

1

:

b

1

,

b

2

, ...

4:

2,

5

.

a

2

=

4

.

a

2

:

b

2

,

b

1

, ...

5:

4, 2,

3

.

b

1

= 5.

6:

1

.

Slide40

First lemma on all-or-nothing cycles

Lemma:

(this is why we call it an all-or-nothing cycle)

Let a

1,a2,...,ar be an all-or-nothing cycle relative to a set of filtered preference lists, and let

b

i

be the first person on

a

i’s preference list. In any stable assignment:either ai

and

b

i

are roommates for all

i

,

or

a

i

and

b

i

are roommates for no value of

i

.

Slide41

First lemma on all-or-nothing cycles

Lemma:

(this is why we call it an all-or-nothing cycle)

Let a

1,a2,...,ar

be an all-or-nothing cycle relative to a set of filtered preference lists, and let

b

i

be the first person on

ai’s preference list. In any stable assignment:either ai

and

b

i

are roommates for all

i

,

or

a

i

and

b

i

are roommates for no value of

i

.

Suppose that for some

i

,

a

i

and

b

i

are partners in a stable matching S that is part of the filtered preference lists.

Since

b

i

is first on

a

i

’s

filtered list,

a

i

is last on

b

i

’s

filtered list.

Since

b

i

is second on

a

i-1

’s

list,

a

i-1

is present on

b

i

’s

filtered list.

So, for S to be stable,

a

i-1

must be matched to the only person he prefers to

b

i

, namely

b

i-1

.

By induction and taking

i

modulo r, the result follows.

Slide42

Second lemma on all-or-nothing cycles

Lemma:

Let a

1

,a2,...,ar be an all-or-nothing cycle relative to a set of filtered preference lists, and let b

i

be the first person on

a

i

’s preference list. If there is a stable assignment S in which (all) ai and bi are partners, then there is another one in which they are not.

We may assume all

a

i

to be different from all

b

i

: no

a

j

=

b

k

.

If so, then not all

a

i

can have their best partner

b

i

, as

a

j

=

b

k

has its worst remaining partner as

a

k

has his best (and

a

j

has more than one option because it is on the all-or-nothing cycle).

Claim

: Let S’ be the matching where

a

i

is partnered to

b

i+1

(his second best choice), and any person that is not any

a

i

or

b

i

is partnered as in S. We claim that S’ is stable.

Lemma follows if we prove this claim.

Slide43

Proof of the claim

Claim

:

Let S’ be the matching where

ai is partnered to bi+1 (his second best choice), and any person that is not any a

i

or b

i

is partnered as in S. We claim that S’ is stable.

Each bi gets a better partner in S’ than in S, where he gets his worst possible remaining partner, so any instability must involve some ai (otherwise S not stable).

Let

a

i

prefer x to

b

i+1

. Then:

Either x =

b

i

(

a

i

’s

partner in S), then clearly

b

i

prefers

a

i-1

to

a

i

.

Or, x is no longer on

a

i

’s

reduced preference list. In this case, x currently holds a better proposal than

a

i

, otherwise x would still be on

a

i

’s

list. And because

x’s

current proposal is his worst remaining option, he clearly prefers his partner in S’ to

a

i

.

Slide44

Filtering for phase 2

Given an all-or-nothing cycle a

1

,a

2,...,ar relative to a set of filtered preference lists, we filter the preference lists by:Letting each

b

i

reject the current proposal from

a

i.Let each ai consequently propose to bi+1

.

Removing all items further back on

b

i+1

’s

list than

a

i

(these are now worse than

b

i+1

’s

current proposal.

The example with one phase-2 filtering step

1:

6

.

1:

6

.

2:

3, 5,

4

. a

1

= 3.

2:

3

.

3:

5,

2

. b

2

= 2.

3:

2

.

Stable assignment:

4:

2,

5

. a

2

= 4.

4:

5

. (1,6), (2,3), (4,5).

5:

4, 2,

3

. b

1

= 5.

5:

4

.

6:

1

.

6:

1

.

Slide45

Phase 2 filtering maintains the properties

Proposals after filtering:

Everyone holds a proposal, and the proposal is from the last person on his list.

Everyone is first on someone’s list, namely the person where he holds a proposal from.

Other properties after filtering:x appears on y’s list, if and only if, y appears on

x’s

list.

x is first on

y’s

list, if and only if, y appears last on x’s list.if x has only y on his list, then y has only x on his list and they must be together in a stable roommates assignment if such an assignment exists.

Slide46

Finding an all-or-nothing cycle

An

all-or-nothing cycle

is a sequence of persons a

1,a2,...,ar such that:

The second person in

a

i

’s

current preference list is the first person in ai+1’s preference list, and we will call this person bi+1, the best match for ai+1. (all indices modulo r)Property of filtered instances:Everyone is first on someone’s list:

the person where he holds a proposal from.

Let

p

1

be any person who’s current preference list contains more than one person.

Let

q

i+1

:= the second person on

p

i

’s

filtered list.

Let

p

i+1

:= the last person on

q

i+1

’s

filtered list (

q

i+1

first on

p

i+1

).

Repeat until this cycles, then

a

i

=

p

s

+i-1

, where

p

s

is the first

p

i

to be repeated in the sequence.

a

1

:

b

1

,

b

2

, ...

a

2

:

b

2

,

b

1

, ...

Slide47

Phase 3: find empty lists or output solution

After phase 1, apply phase 2 filtering exhaustively.

If at some point a reduced preference list is empty, then there is no stable roommates assignment.

Filtering keeps at least one stable roommates assignment.

If a reduced set of preference lists has exactly one person on each list, then the lists specify a stable assignment.Identical to ‘proof of the claim’. If some y prefers person x over his current partner, then by filtering x must prefer the last person on his list over y.

Slide48

Example where phase 2 results in an empty list

Example

Example

after phase 1 filtering

1: 2, 6, 4, 3, 5. 1: 2,

3

.

2:

3, 5, 1, 6, 4. 2: 3, 1.3:

1, 6, 2, 5, 4.

3:

1,

2

.

4:

5, 2, 3, 6, 1.

4:

5,

6

.

5:

6, 1, 3, 4, 2.

5:

6,

4

.

6:

4, 2, 5, 1, 3.

6:

4,

5

.

All-or-nothing cycle: 1, 2, 3

a

1

= 1,

b

2

= 3.

a

2

= 2,

b

3

= 1.

a

3

= 3,

b

1

= 2.

If the

b

i

reject their current proposal, lists become empty.

Slide49

Stable Roommates Problem

We have shown a three phase algorithm for the stable roommates problem.

The algorithm filters preference list, removing options that will never lead to stable assignments.

Some form of constraint propagation.

Three phases:Phase 1: proposing and filtering.

Phase 2

: removing all-or-nothing cycles.

Phase 3

: find empty preference lists, or output solution.

Slide50

SOME FINAL COMMENTS

Stable Marriage & Roommates - Algorithms and Networks

Slide51

Final comments

Stable marriage problem

Stable matching always exists.

Man-optimal (or woman-optimal) matchings can be found using the Gale-Shapley algorithm.

Stable roommates problem.

Stable matchings do not always exists.

Testing whether one exists, and finding one can be done using the given three-phase algorithm.

Much further work has been done, e.g.:

Random / fair stable matchings.

Many variants of stable matching are also solvable (indifferences, groups, forbidden pairs, …).

What happens if some participants lie about their preferences?

Stable roommates with indifferences: NP-complete.