Title: Algorithms%20for%20Student-Project%20Allocation
1Algorithms for Student-Project Allocation
- David Manlove
- University of GlasgowDepartment of Computing
Science - Joint work with David Abraham and Rob Irving
Supported by EPSRC grant GR/R84597/01,Nuffield
Foundation award NUF-NAL-02, and RSE / SEETLLD
Personal Research Fellowship
2Background
- Students may undertake project work during degree
course - Set of students, projects and lecturers
- Typically a wide range of projects exceeding
number of students - Students may rank projects in preference order
- Lecturers may rank students in preference order
- Projects / lecturers may have capacities
3Efficient algorithms
- Growing interest in automating the allocation
process - Efficient algorithms are important
- Can identify a family of matching problems
- Range of optimisation criteria possible
- Cases considered
Preferences Preferences Capacities Capacities
Case Students Lecturers Projects Lecturers
1 ? ? ? ?
2 ? ? ? ?
3 ? ? ? ?
4 ? ? ? ?
4Case 1 formal definition
- No explicit preferences project capacities only
- Set of students Ss1, s2, , sn
- Set of projects Pp1, p2, , pm
- Set of lecturers Ll1, l2, , lq
- Each lecturer lk offers a set of projects Pk ? P
- assume that P1, P2, , Pq partitions P
- Each project pj has a capacity cj
- Each student si finds acceptable a set of
projects Ai ? P
5Definition of a matching
- An assignment M is a subset of SP
- If (si, pj)?M , where lk offers pj , we say that
- si is assigned to pj
- si is assigned to lk
- pj is assigned si
- lk is assigned si
- A matching M is an assignment such that
- if si is assigned to pj in M then si finds pj
acceptable - si is assigned to at most one project in M
- pj is assigned at most cj students in M
6Case 1 example
- Set of students, projects and lecturers
- Ss1, s2, s3, s4, s5, Pp1, p2, p3, p4, p5,
Ll1, l2, l3 - Lecturers offer projects as follows
- P1p1, p2, P2p3, P3p4, p5
- Project capacities
- c1 c2 c4 c5 1, c3 2
- Students find projects acceptable as follows
- A1p1, p3
- A2p1 , p4
- A3p2, p4
- A4p1, p2, p4
- A5p2, p4
7Corresponding bipartite graph
s1
p1
1
s2
p2
1
s3
p3
2
s4
p4
1
p5
s5
1
8A matching
s1
p1
1
s2
p2
1
s3
p3
2
s4
p4
1
p5
s5
1
- A set of edges M is a matching in G if
- each student si is incident to at most one edge
of M - each project pj is incident to at most cj edges
of M
9A maximum matching
s1
p1
1
s2
p2
1
s3
p3
2
s4
p4
1
p5
s5
1
Degree-constrained subgraph problem A maximum
matching may be found in time O where L is the
number of edges (Gabow, 1983)
10Case 2 student preferences
- Assume that each student si has a
strictly-ordered ranking list Ri over Ai - Project capacities only
- Let r denote the maximum length of any students
preference list - Define the signature of a matching M to be an
r-tuple ?x1, x2, , xr? where xi denotes
the number of students assigned in M to their
ith-choice project - A matching M is greedy if M has maximum signature
(with respect to lexicographic order) - i.e. the maximum number of students obtain their
first-choice project, and subject to this
condition, the maximum number of students obtain
their second-choice project, etc.
11Case 2 example
- Set of students, projects and lecturers
- Ss1, s2, s3, Pp1, p2, p3, Ll1
- Project capacities are all 1
- Student preference lists
- s1 p1
- s2 p2 p1 p3
- s3 p2 p3
- Matching M1(s1, p1) (s2, p3) (s3, p2),
signature ?2, 0, 1? - Matching M2(s1, p1) (s2, p2) (s3, p3),
signature ?2, 1, 0? - M2 is greedy
12Case 2 example
- Set of students, projects and lecturers
- Ss1, s2, s3, Pp1, p2, p3, Ll1
- Project capacities are all 1
- Student preference lists
- s1 p1
- s2 p2 p1 p3
- s3 p2 p3
- Matching M1(s1, p1), (s2, p3), (s3, p2),
signature ?2, 0, 1? - Matching M2(s1, p1) (s2, p2) (s3, p3),
signature ?2, 1, 0? - M2 is greedy
13Case 2 example
- Set of students, projects and lecturers
- Ss1, s2, s3, Pp1, p2, p3, Ll1
- Project capacities are all 1
- Student preference lists
- s1 p1
- s2 p2 p1 p3
- s3 p2 p3
- Matching M1(s1, p1), (s2, p3), (s3, p2),
signature ?2, 0, 1? - Matching M2(s1, p1), (s2, p2), (s3, p3),
signature ?2, 1, 0? - M2 is greedy
14Finding a greedy matching
- Traditional method transform to instance of
assignment problem - Create weighted bipartite graph G(V, E) with
VS?P and E(si, pj) pj?Ai - For any student si and project pj ?Ai, define
ranki(pj)k, where pj is the kth-choice project
of si - Weight of edge (si, pj) is nr-k where kranki(pj)
- Compute a maximum weight matching in G
- Complexity of algorithm O(rn(Lnlog n))
(Fredman and Tarjan, 1987) - Two problems
- Arithmetic operations involving edge weights O(r)
- Possible implementation difficulties
15A direct algorithm
- Combinatorial algorithm O(min(nR, R?n)m) where
R is the largest rank used in a greedy matching
(Irving, Kavitha, Mehlhorn, Michail and
Paluch, Rank-Maximal Matchings, Proc. SODA
2004) - Algorithm can be generalised to deal with
arbitrary project capacities
16Greedy matchings vs maximum matchings
- Greedy matchings need not be maximum matchings
- E.g. set of students, projects and lecturers
- Ss1, s2, s3, Pp1, p2, p3, Ll1
- Project capacities are all 1
- Student preference lists
- s1 p1 p3
- s2 p2
- s3 p2 p1
17Greedy matchings vs maximum matchings
- Greedy matchings need not be maximum matchings
- E.g. set of students, projects and lecturers
- Ss1, s2, s3, Pp1, p2, p3, Ll1
- Project capacities are all 1
- Student preference lists
- s1 p1 p3
- s2 p2
- s3 p2 p1
- Two greedy matchings
- M1(s1, p1), (s2, p2), signature ?2, 0?
- M2(s1, p1), (s3, p2), signature ?2, 0?
18Greedy matchings vs maximum matchings
- Greedy matchings need not be maximum matchings
- E.g. set of students, projects and lecturers
- Ss1, s2, s3, Pp1, p2, p3, Ll1
- Project capacities are all 1
- Student preference lists
- s1 p1 p3
- s2 p2
- s3 p2 p1
- Two greedy matchings
- M1(s1, p1), (s2, p2), signature ?2, 0?
- M2(s1, p1), (s3, p2), signature ?2, 0?
- Maximum matching
- M3(s1, p3), (s2, p2), (s3, p1), signature ?1,
2?
19Greedy maximum matchings and rank-minimum
matchings
- Define a greedy maximum matching to be a matching
with maximum signature, taken over all maximum
(cardinality) matchings - The existence of a direct (combinatorial)
algorithm for finding a greedy maximum matching
remains open - Greedy matchings could leave some people very
badly off - Alternative notion of optimality define the cost
of a matching M to be - cost(M)?ranki(pj) (si, pj)?M
- Define a rank-minimum matching to be a matching
with minimum cost, taken over all maximum
matchings
20Greedy matchings vsrank-minimum matchings
- E.g. set of students, projects and lecturers
- Ss1, s2, s3,, s4, s5, Pp1, p2, p3, p4, p5,
Ll1 - Project capacities are all 1
- Student preference lists
- s1 p1
- s2 p2 p5
- s3 p3
- s4 p4
- s5 p1 p2 p3 p4 p5
- Greedy matching
- M1(s1, p1), (s2, p2), (s3, p3), (s4, p4), (s5,
p5), signature ?4, 0, 0, 0, 1?,
cost 9 - Rank-minimum matching
- M2(s1, p1), (s2, p5), (s3, p3), (s4, p4), (s5,
p2), signature ?3, 2, 0, 0, 0?,
cost 7
21Greedy matchings vsrank-minimum matchings
- E.g. set of students, projects and lecturers
- Ss1, s2, s3,, s4, s5, Pp1, p2, p3, p4, p5,
Ll1 - Project capacities are all 1
- Student preference lists
- s1 p1
- s2 p2 p5
- s3 p3
- s4 p4
- s5 p1 p2 p3 p4 p5
- Greedy matching
- M1(s1, p1), (s2, p2), (s3, p3), (s4, p4), (s5,
p5), signature ?4, 0, 0, 0, 1?,
cost 9 - Rank-minimum matching
- M2(s1, p1), (s2, p5), (s3, p3), (s4, p4), (s5,
p2), signature ?3, 2, 0, 0, 0?,
cost 7
22Greedy matchings vsrank-minimum matchings
- E.g. set of students, projects and lecturers
- Ss1, s2, s3,, s4, s5, Pp1, p2, p3, p4, p5,
Ll1 - Project capacities are all 1
- Student preference lists
- s1 p1
- s2 p2 p5
- s3 p3
- s4 p4
- s5 p1 p2 p3 p4 p5
- Greedy matching
- M1(s1, p1), (s2, p2), (s3, p3), (s4, p4), (s5,
p5), signature ?4, 0, 0, 0, 1?,
cost 9 - Rank-minimum matching
- M2(s1, p1), (s2, p5), (s3, p3), (s4, p4), (s5,
p2), signature ?3, 2, 0, 0, 0?,
cost 7
23Case 3 lecturer capacities
- Assume that each lecturer lk has a capacity dk
- Assume that each student si ranks Ai as before
- Projects have capacities as before
- A matching M is an assignment such that
- if si is assigned to pj in M then si finds pj
acceptable - si is assigned to at most one project in M
- pj is assigned at most cj students in M
- lk is assigned at most dk students in M
- An optimal solution is a rank-minimum matching
24Finding a rank-minimum matching (1)
- Define a weighted network N as follows
- Vertices are Vs?S?P?L?t (s is source and t
is sink) - Add an edge (s, si) of capacity 1 for each si
- Add an edge (si, pj) of capacity 1 for each si
and pj ?Ai - Add an edge (pj, lk) of capacity cj for each lk
and pj ?Pk - Add an edge (lk, t) of capacity dk for each lk
- Edge (si, pj) has cost ranki(pj)
- All other edges have cost 0
25Finding a rank-minimum matching (2)
- The cost of a flow f is cost(f)?cost(e)f(e)
e?E - Find a min cost-max flow f in N
- Using f, create an assignment M as follows
- For each si and pj , if f(si, pj)1 add (si, pj )
to M - M is a rank-minimum matching
- Complexity of algorithm O(e(evlog v)log
B/(mn)) where v is number of
vertices, e is number of edges and B is sum of
edge capacities in N (Goldfarb and Jin, 1999)
26Case 3 example
- Set of students, projects and lecturers
- Ss1, , s5, Pp1, , p7, Ll1, l2, l3
- Lecturers offer projects as follows
- P1p1, p2, P2p3, p4, P3p5, p6, p7
- Project capacities
- p5 has capacity 2 all others have capacity 1
- Lecturer capacities
- d12, d21, d32
- Student preference lists
- s1 p1 p3 p5
- s2 p1 p4 p6
- s3 p4 p1 p5
- s4 p1 p6 p7
- s5 p5 p3 p2
27Example network N
Edge costs in green Edge capacities in red
p1
1
1
s1
p2
1
1
s2
p3
l1
1
2
1
s
1
1
t
1
s3
p4
l2
1
2
2
1
s4
p5
l3
1
2
3
p6
1
s5
All these edges have capacity 1
p7
28Min cost-max flow f in N
p1
s1
p2
s2
p3
l1
2
s
t
1
s3
p4
l2
2
s4
p5
l3
p6
s5
cost(f)10
Blue edges have flow gt0 - flow is 1 unless stated
otherwise
p7
29Case 4student and lecturer preferences
- Assume that each student si has a
strictly-ordered ranking list Ri over Ai - For each lecturer lk , let Bk denote the set of
students who find acceptable a project offered by
lk - lk has a strictly-ordered ranking list over Bk
- A solution is a stable matching
- A matching M is stable if it admits no blocking
pair - Formal definition to follow
- For any student si matched in M, M(si) denotes
the project that si is assigned to - For any project pj, M(pj) denotes the set of
students assigned to pj - For any lecturer lk, M(lk) denotes the set of
students assigned to lk
30Definition of a blocking pair
- (si, pj)?M is a blocking pair of M if
- pj ? Ai
- Either si is unmatched in M, or si prefers pj to
M(si) - Either
- pj is under-subscribed and lk is
under-subscribed - pj is under-subscribed and lk is full, and
either si?M(lk) or lk prefers si to the worst
student in M(lk) - pj is full and lk prefers si to the worst
student in M(pj) - where lk is the lecturer who offers pj
- Given this preference and capacity information,
the problem of finding a stable matching is
called the Student-Project Allocation Problem
(SPA)
31Example SPA instance
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
l1 offers p1, p2,
p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
-
-
32SPA instance blocking pair
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p2 p1 l1 offers
p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 p4
p6 l2 offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- p7 p8 l3 offers p7, p8
- c1 2 all other projects have capacity 1
- (s1, p1) forms a blocking pair
- s1 prefers p1 to M(s1)p7
- p1 is under-subscribed and l1 is under-subscribed
-
33SPA instance blocking pair
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p2 p1 l1 offers
p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 p4
p6 l2 offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- p7 p8 l3 offers p7, p8
- c1 2 all other projects have capacity 1
- (s6, p5) forms a blocking pair
- s6 prefers p5 to M(s6)p6
- p5 is under-subscribed and s6 is assigned to a
project offered by l2 -
34SPA instance blocking pair
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p2 p1 p3 l1
offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 p4
p5 l2 offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- p7 l3 offers p7, p8
- c1 2 all other projects have capacity 1
- (s1, p1) forms a blocking pair
- s1 prefers p1 to M(s1)p7
- p1 is under-subscribed and l1 is full and l1
prefers s1 to the worst student assigned to l1 -
35SPA instance blocking pair
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p2 p1 p3 l1
offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 p4
p5 l2 offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- p7 l3 offers p7, p8
- c1 2 all other projects have capacity 1
- (s5, p3) forms a blocking pair
- s5 is unmatched and finds p3 acceptable
- p3 is full and l1 prefers s5 to the worst student
assigned to p3 -
36SPA instance stable matching
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6 p3 p2
p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 p4 p5 l2
offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- The matching is stable
37Finding a stable matching
- Every instance of SPA admits at least one stable
matching - Previous stable matching was student-optimal
- Each student obtains the best project that he/she
could obtain in any stable matching - HR is a special case of SPA in which all
lecturers have capacity ? - Linear-time algorithms for HR produce stable
matchings that are student-optimal or
lecturer-optimal (Gusfield and
Irving, 1989) - For SPA with arbitrary lecturer capacities, there
are also linear-time algorithms giving
student-optimal and lecturer-optimal stable
matchings
(Abraham, Irving, Manlove, The Student-Project
Allocation Problem, Proc. ISAAC 2003, LNCS vol
2906)
38Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6 l1
offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
-
39Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s1 applies to p1
- p1 remains under-subscribed
- l1 remains under-subscribed
-
40Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p1 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s2 applies to p1
- p1 becomes full p1 deleted from list of s5
- l1 remains under-subscribed
?
41Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p1 p2 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s3 applies to p2
- p2 becomes full p2 deleted from lists of s2, s5
and s6 - l1 becomes full p3 deleted from lists of s5 and
s6
?
?
?
?
?
?
42Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p2 p1 p2 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s4 applies to p2
- p2 becomes over-subscribed p2 rejects s3
?
?
?
?
?
?
43Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p2 p1 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s4 applies to p2
- p2 becomes over-subscribed p2 rejects s3
- p2 becomes full p2 deleted from list of s3
- l1 remains full
?
?
?
?
?
?
?
44Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p2 p1 p1 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s3 applies to p1
- p1 becomes over-subscribed p1 rejects s2
?
?
?
?
?
?
?
45Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p2 p1 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s3 applies to p1
- p1 becomes over-subscribed p1 rejects s2
- p1 becomes full p1 deleted from list of s2
- l1 remains full p3 deleted from list of s2
?
?
?
?
?
?
?
?
?
46Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p2 p1 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4
p4 l2 offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s2 applies to p4
- p4 becomes full p4 deleted from list of s5 and
s6 - l2 remains under-subscribed
?
?
?
?
?
?
?
?
?
?
?
47Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p2 p1 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4
p4 p5 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s6 applies to p5
- p5 becomes full p5 deleted from list of s7
- l2 becomes full
?
?
?
?
?
?
?
?
?
?
?
?
48Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p3 p2 p1 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4
p4 p5 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s7 applies to p3
- l1 becomes over-subscribed l1 rejects s3
?
?
?
?
?
?
?
?
?
?
?
?
49Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p3 p2 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4
p4 p5 l2 offers p4,
p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s7 applies to p3
- l1 becomes over-subscribed l1 rejects s3
- p3 becomes full
- l1 becomes full p1 deleted from list of s3
?
?
?
?
?
?
?
?
?
?
?
?
?
50Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p3 p2 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 p4 p4 p5
l2 offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s3 applies to p4
- p4 becomes over-subscribed p4 rejects s2
?
?
?
?
?
?
?
?
?
?
?
?
?
51Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p3 p2 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 p4 p5
l2 offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s3 applies to p4
- p4 becomes over-subscribed p4 rejects s2
- p4 becomes full p4 deleted from list of s2
- l2 becomes full
?
?
?
?
?
?
?
?
?
?
?
?
?
?
52Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p3 p2 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 p4 p5 p5
l2 offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s2 applies to p5
- p5 becomes over-subscribed p5 rejects s6
?
?
?
?
?
?
?
?
?
?
?
?
?
?
53Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p3 p2 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 p4 p5 l2
offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- s2 applies to p5
- p5 becomes over-subscribed p5 rejects s6
- p5 becomes full p5 deleted from list of s6
- l2 becomes full p6 deleted from list of s6
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
54Execution of the algorithm
- Student preferences Lecturer preferences
- s1 p1 p7 l1 s7 s4 s1 s3 s2 s5
s6 d1 3 - s2 p1 p2 p3 p4 p5 p6
p3 p2 p1 l1 offers p1, p2, p3 - s3 p2 p1 p4
- s4 p2 l2 s3 s2 s6 s7 s5 d2 2
- s5 p1 p2 p3 p4 p4 p5 l2
offers p4, p5, p6 - s6 p2 p3 p4 p5 p6
- s7 p5 p3 p8 l3 s1 s7 d3 2
- l3 offers p7, p8
- c1 2 all other projects have capacity 1
- Algorithm terminates
- Matching is stable
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
55Pseudocode of algorithm (1)
- assign each student to be free
- assign each project and lecturer to be totally
unsubscribed - while (some student si is free and si has a
nonempty list) - pj first project on sis list
- lk lecturer who offers pj
- / si applies to pj /
- provisionally assign si to pj /
and to lk / - if (pj is over-subscribed)
- sr worst student assigned to pj
- break provisional assignment between sr
and pj -
- else if (lk is over-subscribed)
- sr worst student assigned to lk
- pt project assigned sr
- break provisional assignment between sr
and pt -
56Pseudocode of algorithm (2)
- if (pj is full)
- sr worst student assigned to pj
- for (each successor st of sr on lks
list) - delete pj from sts list
-
- if (lk is full)
- sr worst student assigned to lk
- for (each successor st of sr on lks
list) - for (each project pu ? Pk )
- delete pu from sts list
-
- / while loop /
57Theoretical results
- Algorithm produces student-optimal stable
matching, given an instance of SPA - Algorithm may be implemented to run in O(L) time,
where L is total length of the students
preference lists - Second algorithm finds lecturer-optimal stable
matching - Same set of students are matched in all stable
matchings - Each lecturer obtains the same number of students
in all stable matchings - A project offered by an under-subscribed lecturer
has the same number of students in all stable
matchings
58Open problems
- Extend to the case where lecturers have
preferences over (student,project) pairs - Ties in the preferences lists
- Lower bounds on projects
- Complexity of finding a greedy maximum matching