Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Blah blah blah. Zoes shark Thanks to the conference artist Phoebe."— Presentation transcript:

1 Blah blah blah

2 Zoes shark

3 Thanks to the conference artist Phoebe

4 A Constraint Programming Approach to The Stable Marriage Problem

5

6 What is the Stable Marriage Problem? (SM) We have n men 12341234 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 12341234 and each woman ranks the men MenWomen Each man has to marry a woman. Bigamy is not allowed. Marriages must be stable done

7 No Bigamy? There is a bijection from men to women man m i marries woman w j woman w j marries man m i No, not bigamy … bijection

8 Stable?An example 12341234 : 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 12341234 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 man 3 marries woman 1

9 There are algorithms for this The Gale Shapely algorithm, O(n 2 ) problem has n variables, each with n partners and is of size O(n 2 ) The complexity of the algorithm is linear in the size of the input

10 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)) // ms most preferred partner 2.3 if isMarried(w) // unconditional remarriage! 2.3.1 L := add(L,partner(w)) // ws 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 youve seen it

11 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

12 An example of the male-oriented extended Gale-Shapely algorithm Male-oriented EGS

13 Men 1: 3 1 2 4 2: 2 1 4 3 3: 1 3 2 4 4: 4 3 1 2 Women 1: 2 3 4 1 2: 3 2 1 4 3: 1 3 4 2 4: 4 1 2 3 Free: 1,2,3,4 m = 1 (first free man) w = 3 (man 1s first choice) engaged(m,w) delete pairs :,, Men 1: 3 1 2 4 2: 2 1 4 3 3: 1 3 2 4 4: 4 3 1 2 Women 1: 2 3 4 1 2: 3 2 1 4 3: 1 3 4 2 4: 4 1 2 3 Men 1: 3 1 2 4 2: 2 1 4 3 3: 1 3 2 4 4: 4 3 1 2 Women 1: 2 3 4 1 2: 3 2 1 4 3: 1 3 4 2 4: 4 1 2 3 Men 1: 3 1 2 4 2: 2 1 4 3: 1 2 4 4: 4 1 2 Women 1: 2 3 4 1 2: 3 2 1 4 3: 1 4: 4 1 2 3

14 Free: 2,3,4 m = 2 (first free man) w = 2 (man 2s first choice) engaged(m,w) delete pairs :, Men 1: 3 1 2 4 2: 2 1 4 3: 1 2 4 4: 4 1 2 Women 1: 2 3 4 1 2: 3 2 1 4 3: 1 4: 4 1 2 3 Men 1: 3 1 2 4 2: 2 1 4 3: 1 2 4 4: 4 1 2 Women 1: 2 3 4 1 2: 3 2 1 4 3: 1 4: 4 1 2 3 Men 1: 3 1 2 4 2: 2 1 4 3: 1 2 4 4: 4 1 2 Women 1: 2 3 4 1 2: 3 2 1 4 3: 1 4: 4 1 2 3 Men 1: 3 1 4 2: 2 1 4 3: 1 2 4 4: 4 1 Women 1: 2 3 4 1 2: 3 2 3: 1 4: 4 1 2 3

15 Free: 3,4 m = 3 (first free man) w = 1 (man 3s first choice) engaged(m,w) delete pairs :, Men 1: 3 1 4 2: 2 1 4 3: 1 2 4 4: 4 1 Women 1: 2 3 4 1 2: 3 2 3: 1 4: 4 1 2 3 Men 1: 3 1 4 2: 2 1 4 3: 1 2 4 4: 4 1 Women 1: 2 3 4 1 2: 3 2 3: 1 4: 4 1 2 3 Men 1: 3 1 4 2: 2 1 4 3: 1 2 4 4: 4 1 Women 1: 2 3 4 1 2: 3 2 3: 1 4: 4 1 2 3 Men 1: 3 1 4 2: 2 1 4 3: 1 2 4 4: 4 1 Women 1: 2 3 4 1 2: 3 2 3: 1 4: 4 1 2 3 Men 1: 3 4 2: 2 1 4 3: 1 2 4 4: 4 Women 1: 2 3 2: 3 2 3: 1 4: 4 1 2 3

16 Free: 4 m = 4 (first free man) w = 4 (man 4s first choice) engaged(m,w) delete pairs :,, Men 1: 3 4 2: 2 1 4 3: 1 2 4 4: 4 Women 1: 2 3 2: 3 2 3: 1 4: 4 1 2 3 Men 1: 3 4 2: 2 1 4 3: 1 2 4 4: 4 Women 1: 2 3 2: 3 2 3: 1 4: 4 1 2 3 Men 1: 3 4 2: 2 1 4 3: 1 2 4 4: 4 Women 1: 2 3 2: 3 2 3: 1 4: 4 1 2 3 Men 1: 3 2: 2 1 3: 1 2 4: 4 Women 1: 2 3 2: 3 2 3: 1 4: 4

17 Free: Men 1: 3 1 2 4 2: 2 1 4 3 3: 1 3 2 4 4: 4 3 1 2 Women 1: 2 3 4 1 2: 3 2 1 4 3: 1 3 4 2 4: 4 1 2 3 before after Male-oriented EGS Men 1: 3 2: 2 1 3: 1 2 4: 4 Women 1: 2 3 2: 3 2 3: 1 4: 4 done

18 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 EGS The intersection of the man and woman lists gives us GS-lists

19 A Constraint Encoding (a 1 st stab) 12341234 : 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 12341234 2n variables, each with a domain (1.. n) n 2 channeling constraints v i = j v j = i n 2 stability constraints 2 allDiffs (one for men, one for women) done

20 Whats a stability constraint? 12341234 : 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 12341234 n 2 stability constraints An example, between man m 4 and woman w 3 (1) locate position of w 3 in m 4 s preference list (2) locate position of m 4 in w 3 s preference list (3) compute the Cartesian product beyond these points {(1,2),(2,2)} these are nogoods done

21 Arc consistency does not compute the GS-lists We require search Encoding is O(n 4 ) allDiffs are redundant No good news then?

22 Hey! It was a 1 st stab!

23 Combining the Constraints The channeling constraints guarantee a bijection 12341234 : 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 12341234 m 4 = 3 w 3 = 4 Nogoods: m 4 marries w 3 and w 3 marries some one else! {(3,1),(3,3),(3,2)} Nogoods: w 3 marries m 4 and m 4 marries some one else! {(4,4),(1,4),(2,4)}

24 Combining the Constraints 12341234 : 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 12341234 (m 4 = 3 w 3 = 4) stable(m 4,w 3 ) 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

25 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(n 4 ) So, some good news then? Combining the Constraints

26 The constraint has structure 12341234 : 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 12341234 Combined nogoods: {(3,1),(3,3),(3,2),(4,4),(1,4),(2,4),(1,2),(2,2)} m4m4 w3w3 m4m4 w3w3 Arrange in preference order Cant see it?

27 The constraint has structure 12341234 : 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 12341234 Combined nogoods: {(3,1),(3,3),(3,2),(4,4),(1,4),(2,4),(1,2),(2,2)} m4m4 w3w3 I is illegal, bigamy B is blocking, unstable A is allowed More generally

28 Revision of constraints Revising only certain shapes of constraints has an effect w k is top of m i s listm i is top of w k s list mimi wkwk mimi wkwk Done Revise(i,k)

29 Nice, interesting, … but still O(n 4 )

30 An O(n 2 ) encoding (a 1 st stab) The intuition, part 1a Man to woman: I love you. Marry me. Please say yes! Woman to man: thats the best offer Ive 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! Ive married someone better than you. Beat it! Man to man: Och well. Theres always someone else. In a mans world

31 An O(n 2 ) encoding (a 1 st stab) The intuition, part 1.1b Assume man m i has proposed to his j th choice, woman w k assume w k is engaged to someone she prefers to m i m i should then propose to his j+1 th choice The intuition, part 1.1a Assume man m i has proposed to his j th choice, woman w k assume w k is not engaged to someone she prefers to m i w k should reject any proposals from men less preferred than m i The following description is male-oriented and has a symmetric female orientation

32 An O(n 2 ) encoding (a 1 st stab) w k,h = 0 w k has accepted a proposal from better than her h th choice w k,h = 0 w k,h+1 = 0 If w k has accepted a proposal from her h th choice or better then w k has accepted a proposal from her h+1 th choice or better m i,j = 1 m i has proposed to his j th choice or worse

33 An O(n 2 ) encoding (a 1 st stab) m 3 proposes to 2 nd choice w 6 has been proposed to by better than her 5 th

34 An O(n 2 ) encoding, the stability constraints Suppose man m i has a partner no better than j th choice, i.e. m i,j = 1 and j th choice is woman w k preference person Man m 3 proposed to his 2 nd choice, w 6 Suppose woman w k has a partner better than h th choice, i.e. w k,h = 0 and h th choice is man m i preference person Woman w 6 has a partner better than her 7 th choice, m 3 Therefore m i is rejected by w k, and m i has a partner no better than his j+1 th choice, i.e. m i,j+1 = 1

35 m i is rejected by w k, and m i has a partner no better than his j+1 th choice, i.e. m i,j+1 = 1 w k is m i s jth choice m i is w k s h th choice the constraint is An O(n 2 ) encoding, the stability constraints This increments the pointer to the head of m i s preference list

36 Otherwise m i becomes engaged to w k, and w k now has a partner better than her h+1 th choice, i.e. w k,h+1 = 0 w k is m i s jth choice m i is w k s h th choice This deletes the tail of w k s preference list An O(n 2 ) encoding, the stability constraints

37 An O(n 2 ) encoding Obviously, symmetrically we have the female orientation

38 An O(n 2 ) encoding On the completion of (male-oriented) propagation the preference list for m i the maximum value of j such that m ij = 1 gives the head of the list the preference list for w i minimum value of j such that w i,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 = (6,5,3) = (5,6)

39 An O(n 2 ) encoding … the complexity 2n 2 variables domains are {0,1} 6n(n-1) constraints arc consistency complexity is O(ed r ) 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(n 2 ) This is same complexity as the GS algorithm, and is linear in the size of the input. It is optimal

40 A 2 nd 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

41 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(n 4 ) space 0/1 encoding gives us XGS-lists and failure free enumeration for SMI O(n 2 ), 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.

42 Questions?


Download ppt "Blah blah blah. Zoes shark Thanks to the conference artist Phoebe."

Similar presentations


Ads by Google