Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

42
Blah blah blah

Transcript of Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Page 1: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Blah blah blah

Page 2: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Zoe’s shark

Page 3: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Thanks to the conference artist Phoebe

Page 4: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

A Constraint Programming Approach toThe Stable Marriage Problem

Page 5: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.
Page 6: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

What is the Stable Marriage Problem? (SM)

We have n men

1234

and n women

: 2 3 4 1: 3 2 1 4: 1 3 4 2: 4 1 2 3

Each man ranks the n women

: 3 1 2 4 : 2 1 4 3: 1 3 2 4: 4 3 1 2

1234

and each woman ranks the men

Men Women

Each man has to marry a woman.

Bigamy is not allowed.

Marriages must be stable

done

Page 7: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

No Bigamy?

There is a bijection from men to women• man mi marries woman wj woman wj marries man mi

No, not bigamy … bijection

Page 8: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Stable? An example

1234

: 2 3 4 1: 3 2 1 4: 1 3 4 2: 4 1 2 3

: 3 1 2 4 : 2 1 4 3: 1 3 2 4: 4 3 1 2

1234

man 2 prefers woman 1 to woman 4 woman 1 prefers man 2 to man 3

man 2 and woman 1 will elope

man 2 marries woman 4 <2,4>man 3 marries woman 1 <3,1>

Page 9: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

There are algorithms for this

The Gale Shapely algorithm, O(n2)

problem has n variables, each with n partnersand is of size O(n2)

The complexity of the algorithm is linear in the size of the input

Page 10: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

The Extended Gale Shapley Algorithm (man optimal)

1 L := list of free men

2. While L 2.1 m := selectAndRemoveFrom(L) // note, m is removed from L

2.2 w := first(preferenceList(m)) // m’s most preferred partner

2.3 if isMarried(w) // unconditional remarriage!

2.3.1 L := add(L,partner(w)) // w’s partner is free … again!

2.3.2 delete(preferenceList(w),partner(w))

2.3.3 delete(preferenceList(partner(w)),w)

2.4 marry(m,w) // m and w get married. 2.5 for each m’ in preferenceList(w)

2.5.1 if w prefers m to m’ // remove unacceptable pairs

2.5.1.1 delete(preferenceList(w),m’)

2.5.1.2 delete(preferenceList(m’),w)

Now you’ve seen it

Page 11: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

The Extended Gale Shapley Algorithm (man optimal)

“… reduces the preference lists by eliminating pairs that can readily be identified as not belonging to any stable matching” Gusfield and Irving, 1989

Page 12: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

An example of the male-oriented extendedGale-Shapely algorithm

Male-oriented EGS

Page 13: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Men1: 3 1 2 42: 2 1 4 33: 1 3 2 44: 4 3 1 2

Women1: 2 3 4 12: 3 2 1 4 3: 1 3 4 24: 4 1 2 3

Free: 1,2,3,4m = 1 (first free man)

w = 3 (man 1’s first choice)

engaged(m,w)

delete pairs : <3,3>,<4,3>,<2,3>

Men1: 3 1 2 42: 2 1 4 33: 1 3 2 44: 4 3 1 2

Women1: 2 3 4 12: 3 2 1 4 3: 1 3 4 24: 4 1 2 3

Men1: 3 1 2 42: 2 1 4 33: 1 3 2 44: 4 3 1 2

Women1: 2 3 4 12: 3 2 1 4 3: 1 3 4 24: 4 1 2 3

Men1: 3 1 2 42: 2 1 4 3: 1 2 44: 4 1 2

Women1: 2 3 4 12: 3 2 1 4 3: 1 4: 4 1 2 3

Page 14: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Free: 2,3,4m = 2 (first free man)

w = 2 (man 2’s first choice)

engaged(m,w)

delete pairs : <1,2>,<4,2>

Men1: 3 1 2 42: 2 1 4 3: 1 2 44: 4 1 2

Women1: 2 3 4 12: 3 2 1 4 3: 1 4: 4 1 2 3

Men1: 3 1 2 42: 2 1 4 3: 1 2 44: 4 1 2

Women1: 2 3 4 12: 3 2 1 4 3: 1 4: 4 1 2 3

Men1: 3 1 2 42: 2 1 4 3: 1 2 44: 4 1 2

Women1: 2 3 4 12: 3 2 1 4 3: 1 4: 4 1 2 3

Men1: 3 1 42: 2 1 4 3: 1 2 44: 4 1

Women1: 2 3 4 12: 3 2

3: 1 4: 4 1 2 3

Page 15: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Free: 3,4m = 3 (first free man)

w = 1 (man 3’s first choice)

engaged(m,w)

delete pairs : <4,1>,<1,1>

Men1: 3 1 42: 2 1 4 3: 1 2 44: 4 1

Women1: 2 3 4 12: 3 2

3: 1 4: 4 1 2 3

Men1: 3 1 42: 2 1 4 3: 1 2 44: 4 1

Women1: 2 3 4 12: 3 2

3: 1 4: 4 1 2 3

Men1: 3 1 42: 2 1 4 3: 1 2 44: 4 1

Women1: 2 3 4 12: 3 2

3: 1 4: 4 1 2 3

Men1: 3 1 42: 2 1 4 3: 1 2 44: 4 1

Women1: 2 3 4 12: 3 2

3: 1 4: 4 1 2 3

Men1: 3 42: 2 1 4 3: 1 2 44: 4

Women1: 2 3 2: 3 2

3: 1 4: 4 1 2 3

Page 16: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Free: 4m = 4 (first free man)

w = 4 (man 4’s first choice)

engaged(m,w)

delete pairs : <1,4>,<2,4>,<3,4>

Men1: 3 42: 2 1 4 3: 1 2 44: 4

Women1: 2 3 2: 3 2

3: 1 4: 4 1 2 3

Men1: 3 42: 2 1 4 3: 1 2 44: 4

Women1: 2 3 2: 3 2

3: 1 4: 4 1 2 3

Men1: 3 42: 2 1 4 3: 1 2 44: 4

Women1: 2 3 2: 3 2

3: 1 4: 4 1 2 3

Men1: 3 2: 2 1 3: 1 2 4: 4

Women1: 2 3 2: 3 2

3: 1 4: 4

Page 17: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Free:

Men1: 3 1 2 42: 2 1 4 33: 1 3 2 44: 4 3 1 2

Women1: 2 3 4 12: 3 2 1 43: 1 3 4 24: 4 1 2 3

before

after

Male-oriented EGS

Men1: 3 2: 2 1 3: 1 2 4: 4

Women1: 2 3 2: 3 2

3: 1 4: 4

done

Page 18: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

The Extended Gale Shapley Algorithm (man optimal)

On completion we have man optimal GS-lists

• if men marry their 1st partners we get• man optimal stable marriages• female pessimal stable marriages

We can also apply female oriented EGSThe intersection of the man and woman listsgives us GS-lists

Page 19: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

A Constraint Encoding (a 1st stab)

1234

: 2 3 4 1: 3 2 1 4: 1 3 4 2: 4 1 2 3

: 3 1 2 4 : 2 1 4 3: 1 3 2 4: 4 3 1 2

1234

2n variables, each with a domain (1 .. n)n2 channeling constraints

• vi = j vj = i

n2 stability constraints2 allDiff’s (one for men, one for women)

done

Page 20: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

What’s a stability constraint?

1234

: 2 3 4 1: 3 2 1 4: 1 3 4 2: 4 1 2 3

: 3 1 2 4 : 2 1 4 3: 1 3 2 4: 4 3 1 2

1234

n2 stability constraints

An example, between man m4 and

woman w3

(1) locate position of w3 in m4’s preference list

(2) locate position of m4 in w3’s preference list

(3) compute the Cartesian product beyond these points• {(1,2),(2,2)}• these are nogoods

done

Page 21: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Arc consistency does not compute the GS-lists

We require search

Encoding is O(n4)

allDiff’s are redundant

No good news then?

Page 22: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Hey! It was a 1st stab!

Page 23: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Combining the Constraints

The channeling constraints guarantee a bijection

1234

: 2 3 4 1: 3 2 1 4: 1 3 4 2: 4 1 2 3

: 3 1 2 4 : 2 1 4 3: 1 3 2 4: 4 3 1 2

1234

m4 = 3 w3 = 4

Nogoods: m4 marries w3 and w3 marries some one else! {(3,1),(3,3),(3,2)}

Nogoods: w3 marries m4 and m4 marries some one else! {(4,4),(1,4),(2,4)}

Page 24: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Combining the Constraints

1234

: 2 3 4 1: 3 2 1 4: 1 3 4 2: 4 1 2 3

: 3 1 2 4 : 2 1 4 3: 1 3 2 4: 4 3 1 2

1234

(m4 = 3 w3 = 4) stable(m4,w3)

Combined nogoods: {(3,1),(3,3),(3,2),(4,4),(1,4),(2,4),(1,2),(2,2)}

Do this for all man/woman pairs

Page 25: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

• Arc consistency now computes the GS-lists• we have a proof

• We have failure free enumeration• with a value ordering heuristic• we have a proof

• The encoding trivially extends to SMTI • (an NP-complete problem)

• The encoding is O(n4)

So, some good news then?

Combining the Constraints

Page 26: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

The constraint has structure

1234

: 2 3 4 1: 3 2 1 4: 1 3 4 2: 4 1 2 3

: 3 1 2 4 : 2 1 4 3: 1 3 2 4: 4 3 1 2

1234

Combined nogoods: {(3,1),(3,3),(3,2),(4,4),(1,4),(2,4),(1,2),(2,2)}

04

0003

002

001

4321

m4

w3

001

002

0003

04

2431

m4

w3

Arrange in preference order

Can’t see it?

Page 27: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

The constraint has structure

1234

: 2 3 4 1: 3 2 1 4: 1 3 4 2: 4 1 2 3

: 3 1 2 4 : 2 1 4 3: 1 3 2 4: 4 3 1 2

1234

Combined nogoods: {(3,1),(3,3),(3,2),(4,4),(1,4),(2,4),(1,2),(2,2)}

BI

BI

IAII

I

1

2

3

4

2431

m4

w3

• I is illegal, bigamy• B is blocking, unstable• A is allowed

BBBBI

BBBBI

BBBBI

BBBBI

BBBBI

BBBBI

IIIIAIIIII

I

I

I

More generally

Page 28: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Revision of constraints

Revising only certain shapes of constraints has an effect

wk is top of mi’s list mi is top of wk’s list

BBBBI

BBBBI

BBBBI

BBBBI

BBBBI

BBBBI

IIIIAII

mi

wk

BBBBBBI

BBBBBBI

BBBBBBI

BBBBBBI

IIIIIIA

I

I

mi

wk

Done

Revise(i,k)Revise(i,k)

Page 29: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Nice, interesting, … but still O(n4)

Page 30: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

An O(n2) encoding (a 1st stab)

The intuition, part 1a

Man to woman: I love you. Marry me. Please say yes!

Woman to man: that’s the best offer I’ve had. Okay. (and by the way, all you other guys, beat it!)

The intuition, part 1b

Man to woman: I love you. Marry me. Please say yes!

Woman to man: Who do you think you are! I’ve married someone better than you. Beat it!

Man to man: Och well. There’s always someone else.

In a man’s world

Page 31: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

An O(n2) encoding (a 1st stab)

The intuition, part 1.1b• Assume man mi has proposed to his jth choice, woman wk

• assume wk is engaged to someone she prefers to mi

• mi should then propose to his j+1th choice

The intuition, part 1.1a• Assume man mi has proposed to his jth choice, woman wk

• assume wk is not engaged to someone she prefers to mi

• wk should reject any proposals from men less preferred than mi

The following description is male-orientedand has a symmetric female orientation

Page 32: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

An O(n2) encoding (a 1st stab)}1,0{ }1,0{ ,, jiji wm

wk,h = 0 wk has accepted a proposal from better than her hth choice

wk,h = 0 wk,h+1 = 0

If wk has accepted a proposal from her hth choice or better

then wk has accepted a proposal from her h+1th choice or better

mi,j = 1 mi has proposed to his jth choice or worse

1 :Initially 1, im

Page 33: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

An O(n2) encoding (a 1st stab)

1/01/01/01/01/01/01/011

98765432112,3 m

m3 proposes to 2nd choice

w6 has been proposed to by better than her 5th

000001/01/01/01/0

98765432105,6 w

Page 34: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

An O(n2) encoding, the stability constraints

758194263

1/01/01/01/01/01/01/011

987654321

Suppose man mi has a partner no better than jth choice, i.e. mi,j = 1 and jth choice is woman wk

3mpreference

person

6,2,3 kji Man m3 proposed to his 2nd choice, w6

Suppose woman wk has a partner better than hth choice, i.e. wk,h = 0 and hth choice is man mi

253917684

000001/01/01/01/0

987654321

6wpreference

person

3,7,6 ihk Woman w6 has a partner better than her 7th choice, m3

Therefore mi is rejected by wk, and mi has a partner no better than his j+1th choice, i.e. mi,j+1 = 1

Page 35: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

mi is rejected by wk, and mi has a partner no better than his j+1th choice, i.e. mi,j+1 = 1

• wk is mi’s jth choice• mi is wk’s hth choice

the constraint is101 1,,, jihkji mwm

An O(n2) encoding, the stability constraints

This increments the pointer to the head of mi’s preference list

Page 36: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Otherwise mi becomes engaged to wk, and wk now has a partner better than her h+1th choice, i.e. wk,h+1 = 0

• wk is mi’s jth choice• mi is wk’s hth choice

01 1,, hkji wm

This deletes the tail of wk’s preference list

An O(n2) encoding, the stability constraints

Page 37: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

An O(n2) encoding

Obviously, symmetrically we have the female orientation

Page 38: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

An O(n2) encoding

On the completion of (male-oriented) propagation

• the preference list for mi

• the maximum value of j such that mij = 1 gives the head of the list

• the preference list for wi

• minimum value of j such that wi,j+1 = 0 gives the tail of the list

• when we do male and female propagation• we get the XGS-list, a superset of the GS-list

124356

0001/01/01

654321

= (6,5,3)

654132

1/011111

654321

= (5,6)

Page 39: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

An O(n2) encoding … the complexity

• 2n2 variables • domains are {0,1}• 6n(n-1) constraints• arc consistency complexity is O(edr)

• where e is number of constraints• d is domain size• r is arity of constraints

• for our encoding e = 6n(n-1), d = 2, r 3 O(n2)

This is same complexity as the GS algorithm, and is linear in the size of the input. It is optimal

Page 40: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

A 2nd stab at the 0/1 encoding

• Generalises to incomplete list (SMI)• we prove that the AC on the 0/1 model gives XGS-lists• we prove that we get failure free enumeration

Page 41: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Conclusions

• A naïve encoding as a csp

• However, combining the constraints

• AC gives us GS-lists and failure free enumeration

• easily extend to SMTI

• O(n4) space

• 0/1 encoding

• gives us XGS-lists and failure free enumeration for SMI

• O(n2), optimal!

• Non-trivial

• SM constraint may be part of a bigger problem

• something like allDiff

• Question

•“If there is a special algorithm, such as GS, is it worth encoding as a csp?”

• In this case “Yes.”

Page 42: Blah blah blah. Zoes shark Thanks to the conference artist Phoebe.

Questions?