Specialised N-ary Constraint for the Stable Marriage Problem

35
Specialised N-ary Constraint for the Stable Marriage Problem By Chris Unsworth and Patrick Prosser

description

Specialised N-ary Constraint for the Stable Marriage Problem. By Chris Unsworth and Patrick Prosser. Contents. The Stable Marriage Problem The Algorithm Previous Constraint Models Specialised N-ary Constraint Computational Comparison Conclusion Applause. Contents. - PowerPoint PPT Presentation

Transcript of Specialised N-ary Constraint for the Stable Marriage Problem

Page 1: Specialised N-ary Constraint for the Stable Marriage Problem

Specialised N-ary Constraint for the Stable Marriage ProblemBy Chris Unsworth and Patrick Prosser

Page 2: Specialised N-ary Constraint for the Stable Marriage Problem

Contents

The Stable Marriage Problem The Algorithm Previous Constraint Models Specialised N-ary Constraint Computational Comparison Conclusion Applause

Page 3: Specialised N-ary Constraint for the Stable Marriage Problem

Contents

The Stable Marriage Problem The Algorithm Previous Constraint Models Specialised N-ary Constraint Computational Comparison Conclusion Applause

Page 4: Specialised N-ary Constraint for the Stable Marriage Problem

The Stable Marriage Problem

Men Women

BobIanJon

: Ian Jon Bob: Jon Ian Bob : Bob Jon Ian

: Sue Jan Liz: Liz Jan Sue: Jan Sue Liz

JanLizSue

We have n menand n women

Each man ranks the n womenAnd each woman ranks the n men

Objective :To find a matching of men to womenSuch that the matching is Stable

Page 5: Specialised N-ary Constraint for the Stable Marriage Problem

The Stable Marriage Problem

Men Women

BobIanJon

: Ian Jon Bob: Jon Ian Bob : Bob Jon Ian

: Sue Jan Liz: Liz Jan Sue: Jan Sue Liz

JanLizSue

A MatchingBut not a stable one

Bob and Sue would rather be matched to eachother than to there assigned partners

In this matching Bob and Sue are a Blocking pairA matching is only stable iff it contains no Blocking pairs

Page 6: Specialised N-ary Constraint for the Stable Marriage Problem

The Stable Marriage Problem

Men Women

BobIanJon

: Ian Jon Bob: Jon Ian Bob : Bob Jon Ian

: Sue Jan Liz: Liz Jan Sue: Jan Sue Liz

JanLizSue

A Stable MatchingAnd another Stable Match

Page 7: Specialised N-ary Constraint for the Stable Marriage Problem

Contents

The Stable Marriage Problem The Algorithm Previous Constraint Models Specialised N-ary Constraint Computational Comparison Conclusion Applause

Page 8: Specialised N-ary Constraint for the Stable Marriage Problem

The Extended Gale Shapley Algorithm Cycles through a list of free men

until there are no free men remaining The man proposes to his most preferred

woman If the woman was engaged then the

engagement is broken and her previous fiancé will be added to the free list

The man and woman become engaged All men the woman likes less than her

new fiancé will be removed from her preference list, and she will also be removed from theirs

Page 9: Specialised N-ary Constraint for the Stable Marriage Problem

assign each person to be freeWHILE (some man m is free)DO BEGIN

w := first woman on m's listIF (some man p is engaged to w)THEN assign p to be freeassign m and w to be engaged to

each otherFOR (each successor p of m on w's

list)DO BEGIN

delete p from w's listdelete w from p's list

ENDEND

The Extended Gale Shapley Algorithm

Page 10: Specialised N-ary Constraint for the Stable Marriage Problem

The Extended Gale Shapley Algorithm The reduced preference lists are

the MGS-Lists The female version yields the

WGS-Lists The intersection of these lists are

known as the GS-Lists Contains all possible stable

matchings If all men are match to there best

match in the GS-Lists that matching will be the man optimal matching

Likewise with the women

Page 11: Specialised N-ary Constraint for the Stable Marriage Problem

Contents

The Stable Marriage Problem The Algorithm Previous Constraint Models Specialised N-ary Constraint Computational Comparison Conclusion Applause

Page 12: Specialised N-ary Constraint for the Stable Marriage Problem

Previous Constraint Models Two Constraint encodings

presented by Ian Gent, Robert Irving, David Manlove, Patrick Prosser and Barbara Smith in CP01

Page 13: Specialised N-ary Constraint for the Stable Marriage Problem

Forbidden tuples model (CP01) 2n variables, one for each man

and woman each with a domain (1 .. N)

n2 table constraints One for each potential couple Set of pairs of values the

constrained variables cannot simultaneously take

Potentially O(n2) pairs per constraint

Page 14: Specialised N-ary Constraint for the Stable Marriage Problem

Forbidden tuples model (CP01) When made arc consistent

the variable domains are equivalent to the GS-Lists

All stable matchings can be found in a failure free enumeration

Space complexity O(n4) Time complexity O(n4)

Page 15: Specialised N-ary Constraint for the Stable Marriage Problem

Boolean Encoding (CP01)

2n2 variables with 0/1 domains m[i,j] = 1 means m[i] is married

to a partner no better than j. m[i,j] = 0 means m[i] is married

to a partner better than j O(n2) constraints, mostly

implication

Page 16: Specialised N-ary Constraint for the Stable Marriage Problem

Boolean Encoding (CP01)

When made arc consistent the variable domains equal the bounds of the GS-lists

All stable matchings can be found in a failure free enumeration

Space complexity O(n2) Time complexity O(n2)

Page 17: Specialised N-ary Constraint for the Stable Marriage Problem

Contents

The Stable Marriage Problem The Algorithm Previous Constraint Models Specialised N-ary Constraint Computational Comparison Conclusion Applause

Page 18: Specialised N-ary Constraint for the Stable Marriage Problem

Justification A Linear time algorithm already exists for this

problem (linear to the size of input i.e. O(n2)) Optimal Constraint models have been

published So why do we need a specialised constraint

for this problem? Performance gap between Constraint models

and algorithm Inflexibility of the algorithm The Aim of the Specialised Constraint Is then

to reduce the performance gap whilst retaining the flexibility of the constraint models

Page 19: Specialised N-ary Constraint for the Stable Marriage Problem

Specialised N-ary Constraint 2n variables, one for each man

and woman each with a domain (1 .. N)

Domain values represent preferences e.g. if the man variable m[1] were

assigned the value 3 then man 1 would be assigned to his third choice woman

1 Specialised n-ary Constraint

Page 20: Specialised N-ary Constraint for the Stable Marriage Problem

Specialised N-ary Constraint 5 methods associated with a

constraint Initialisation of constraints Lower bound of a variable increases Upper bound of a variable decreases Interior value removal Variable instantiation

Assume constraint is processed in an AC5-like environment when a variable loses a value,

process the constraints incident on that variable

Page 21: Specialised N-ary Constraint for the Stable Marriage Problem

Specialised N-ary Constraint Constraint requirements

Access to all variable domains x[i] = variable for man i y[j] = variable for woman j

The inverse preference lists mpw[i] = man i’s inverse preference

list mpw[i][j] = man i’s inverse preference

for woman j mpw[i][j] = k iff mpl[i][k] = j

wpm[j] = woman j’s inverse preference list

Page 22: Specialised N-ary Constraint for the Stable Marriage Problem

Lower bound increases

Man mi’s lower bound increases The Lower bound method is called Get man mi’s new lower bound Find woman wj that a corresponds to Remove all men from woman wj‘s

domain she likes less than mi

LowerBound(i)

a = getMin(x[i])

j = mpw[i][a]

setMax(y[j],wpm[j][j])

Page 23: Specialised N-ary Constraint for the Stable Marriage Problem

Upper bound decreases

Woman wj’s upper bound is reduced The upper bound method is called Loop for each value k removed form

the tail of woman wj’s domain

Find man mi that k represents

Remove woman wj from mi’s domain

upperBound(j)

for (k = value removed from the tail of j[j])

i = wpm[j][k]

remVal(x[i],mpw[i][j])

Page 24: Specialised N-ary Constraint for the Stable Marriage Problem

Initialisation, Interior Removal, Instantiation Initialisation simply calls the lower

bound method The Interior Removal and Instantiation

methods are required for search and side constraints

Read paper for more detail

Page 25: Specialised N-ary Constraint for the Stable Marriage Problem

Complexity

Space complexity O(n2) Time complexity O(n2) See paper for complexity

argument

Page 26: Specialised N-ary Constraint for the Stable Marriage Problem

Contents

The Stable Marriage Problem The Algorithm Previous Constraint Models Specialised N-ary Constraint Computational Comparison Conclusion Applause

Page 27: Specialised N-ary Constraint for the Stable Marriage Problem

Computational Comparison Compare forbidden tuples (FT),

Boolean (Bool) and the specialised N-ary constraint (SMN) on random SMP

Time to make arc-consistent Time to find all solutions All times include model creation time

Page 28: Specialised N-ary Constraint for the Stable Marriage Problem

Computational Comparison

Size n

model 45 100 200 400 600 800 1000

FT 8.95 - - - - - -

Bool 0.25 1.2 4.4 - - - -

SMN 0.01 0.02 0.06 0.21 0.51 0.95 2.11

Size n

model 45 100 200 400 600 800 1000

FT 9.32 - - - - - -

Bool 0.36 2.02 6.73 - - - -

SMN 0.02 0.03 0.07 0.24 0.73 1.56 3.35

Time in seconds to produce the GS-Lists

Time in seconds to find all solutions

Page 29: Specialised N-ary Constraint for the Stable Marriage Problem

Computational Comparison

Size n

problem

1000 1200 1400 1600 1800 2000

AC 2.11 3.12 5.93 8.71 11.59 20.19

All 3.35 5.09 8.8 12.92 18.96 26.81Time in seconds to produce the GS-Lists and find

all solutions with the SMN constraint

Page 30: Specialised N-ary Constraint for the Stable Marriage Problem

Computational Comparison Why is SMN dominating Bool?

SMN is more space efficient Bool has 2n + 6n2 constraints SMN has 1 constraint of size O(n2) Bool has 2n2 variables SMN has 2n variables

Bool runs out of memory constructing the variable for n = 1300

SMN constructs the variables for n = 1300 in 0.25 seconds

Page 31: Specialised N-ary Constraint for the Stable Marriage Problem

Demonstration of Versatility The sex equal stable marriage

problem Find the matching that is equally good for

all Minimise the absolute difference between

the sums of the preferences of the male and female assignment

Minimise( )

Where P(m1) gives m1’s preference for his assigned partner

This has been proven to be NP-hard

|)()(| j

ji

i wPmP

Page 32: Specialised N-ary Constraint for the Stable Marriage Problem

Demonstration of Versatility Implementation

2 summation constraints 1 over the male variable the other over the

female 1 variable to hold the value of the

absolute difference between the 2 summation constraints

1 minimising objective constraint Code needed :final IlcIntVar optVar = solver.intVar(0, n*n);

solver.add(solver.eq(optVar, solver.abs( solver.diff(solver.sum(menVars), solver.sum(womenVars)))));

solver.add(solver.minimize(optVar));

Page 33: Specialised N-ary Constraint for the Stable Marriage Problem

Demonstration of Versatility

Time in seconds to find sex-equal optimal solution

Size n

problem 1000 1200 1400 1600 1800 2000

SE 3.65 5.02 8.73 14.44 17.59 22.44

All 3.35 5.09 8.8 12.92 18.96 26.81

Page 34: Specialised N-ary Constraint for the Stable Marriage Problem

Conclusion

A new specialised N-ary constraint for SM

Outperforms optimal constraint model Because compact and simple

Versatile 1st computational study of SESMP

(we think)

Page 35: Specialised N-ary Constraint for the Stable Marriage Problem

Applause & Questions

Thank you