Title: Specialised Binary Constraint for the Stable Marriage Problem
1Specialised Binary Constraint for the Stable
Marriage Problem
- By Chris Unsworth and Patrick Prosser
2Contents
- The Stable Marriage Problem
- The Algorithm
- Previous Constraint Models
- Specialised Binary Constraint
- Computational Comparison
- Conclusion
- Applause
3Contents
- The Stable Marriage Problem
- The Algorithm
- Previous Constraint Models
- Specialised Binary Constraint
- Computational Comparison
- Conclusion
- Applause
4The Stable Marriage Problem
We have n men
and n women
Each man ranks the n women
And each woman ranks the n men
Men
Women
Ian Jon Bob Jon Ian Bob Bob Jon Ian
Jan Liz Sue
Bob Ian Jon
Sue Jan Liz Liz Jan Sue Jan Sue Liz
Objective To find a matching of men to women
Such that the matching is Stable
5The Stable Marriage Problem
A Matching
But not a stable one ?
Bob and Sue would rather be matched to each other
than to their assigned partners
Men
Women
Ian Jon Bob Jon Ian Bob Bob Jon Ian
Jan Liz Sue
Bob Ian Jon
Sue Jan Liz Liz Jan Sue Jan Sue Liz
In this matching Bob and Sue are a Blocking pair
A matching is only stable iff it contains no
Blocking pairs
6The Stable Marriage Problem
A Stable Matching
And another Stable Match
Men
Women
Ian Jon Bob Jon Ian Bob Bob Jon Ian
Jan Liz Sue
Bob Ian Jon
Sue Jan Liz Liz Jan Sue Jan Sue Liz
7Contents
- The Stable Marriage Problem
- The Algorithm
- Previous Constraint Models
- Specialised Binary Constraint
- Computational Comparison
- Conclusion
- Applause
8The 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
9The Extended Gale Shapley Algorithm
assign each person to be free WHILE (some man m
is free) DO BEGIN w first woman on m's
list IF (some man p is engaged to w) THEN
assign p to be free assign m and w to be engaged
to each other FOR (each successor p of m on w's
list) DO BEGIN delete p from w's list delete
w from p's list END END
10The 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
11Contents
- The Stable Marriage Problem
- The Algorithm
- Previous Constraint Models
- Specialised Binary Constraint
- Computational Comparison
- Conclusion
- Applause
12Previous Constraint Models
- Two Constraint encodings presented by Ian Gent,
Robert Irving, David Manlove, Patrick Prosser and
Barbara Smith in CP01
13Forbidden 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
14Forbidden 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)
15Boolean Encoding (CP01)
- 2n2 variables with 0/1 domains
- mi,j 1 means mi is married to a partner no
better than j. - mi,j 0 means mi is married to a partner
better than j - O(n2) constraints, mostly implication
16Boolean 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)
17Contents
- The Stable Marriage Problem
- The Algorithm
- Previous Constraint Models
- Specialised Binary Constraint
- Computational Comparison
- Conclusion
- Applause
18Justification
- 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
19Specialised Binary 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 m1 were assigned the
value 3 then man 1 would be assigned to his third
choice woman - n2 Specialised Binary Constraints
- One for each potential couple
20Specialised Binary Constraint
- 5 methods associated with a constraint
- Initialisation of constraints
- Lower bound of a variable increases
- Upper bound of a variable increases
- Interior value removal
- Variable instantiation
- Assume constraint is processed in an AC5-like
environment - when a variable loses a value, process the
constraints (n of these) incident on that
variable
21Specialised Binary Constraint
mi
wj
- Constraint between mi and wj
- Access to mis domain
- Access to wjs domain
- Position of wj in mis preference list
- Position of mi in wjs preference list
22Lower bound increases
mi
wj
- Man mis lower bound increases
- The Lower bound method is called
- Man mis new favourite is wj
- Woman wj will then reject all men she likes less
than mi - Woman wjs upper bound is reduced
23Upper bound decreases
wj
mi
- Woman wjs upper bound is reduced
- The upper bound method is called
- Man mi is no longer in wjs domain
- Woman wj is removed from mis domain
24Initialisation, 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
25An Inefficiency
- Revision of O(n) constraints when only one of
these will have an effect - Space complexity O(n2)
- Time complexity O(n3)
- Due to redundant calls above
- See paper for complexity argument
26Contents
- The Stable Marriage Problem
- The Algorithm
- Previous Constraint Models
- Specialised Binary Constraint
- Computational Comparison
- Conclusion
- Applause
27Computational Comparison
- Compare forbidden tuples (FT), Boolean (Bool),
and the specialised binary constraint (SM2) on
random SMP - Time to make arc-consistent
- Time to find all solutions
- All times include model creation time
28Computational Comparison
Time in seconds to produce the GS-Lists
Time in seconds to find all solutions
29Computational Comparison
- Why is suboptimal model dominating?
- SM2 is more space efficient
- Bool has 2n 6n2 constraints
- SM2 has n2 constraints
- Bool has 2n2 variables
- SM2 has 2n variables
30Demonstration 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 m1s preference for his
assigned partner - This has been proven to be NP-hard
31Demonstration 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,
nn) solver.add(solver.eq(optVar, solver.abs(
solver.diff(solver.sum(menVars),
solver.sum(womenVars))))) solver.add(solver.mini
mize(optVar))
32Demonstration of Versatility
Time in seconds to find sex-equal optimal
solution
Time in seconds to find all solutions
33Conclusion
- A new specialised binary constraint for SM
- Outperforms optimal constraint model
- Because compact and simple
- Versatile
- 1st computational study of SESMP (we think)
- Room for improvement
- Avoid redundant revisions (see The Fifth Workshop
on Modelling and Solving Problems with
Constraints at IJCAI05)
34Applause Questions