Date post: | 17-Jan-2016 |
Category: |
Documents |
Upload: | vivian-waters |
View: | 212 times |
Download: | 0 times |
1
Algorithms 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
2
Background
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
3
Efficient 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 Capacities
Case Students
Lecturers
Projects
Lecturers
1
2
3
4
4
Case 1: formal definition
No explicit preferences; project capacities only
Set of students S={s1, s2, …, sn} Set of projects P={p1, p2, …, pm} Set of lecturers L={l1, 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
5
Definition of a matching
An assignment M is a subset of S×P 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:1. if si is assigned to pj in M then si finds pj acceptable
2. si is assigned to at most one project in M
3. pj is assigned at most cj students in M
6
Case 1: example
Set of students, projects and lecturers: S={s1, s2, s3, s4, s5}, P={p1, p2, p3, p4, p5}, L={l1, l2, l3}
Lecturers offer projects as follows: P1={p1, p2}, P2={p3}, P3={p4, p5}
Project capacities: c1= c2 = c4 = c5 = 1, c3 =2
Students find projects acceptable as follows: A1={p1, p3} A2={p1 , p4} A3={p2, p4} A4={p1, p2, p4} A5={p2, p4}
7
Corresponding bipartite graph
capacitys1
s2
s3
s4
p1
p2
p3
p4
s5 p5
1
1
2
1
1
8
A matchingcapacity
s1
s2
s3
s4
p1
p2
p3
p4
s5 p5
1
1
2
1
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
9
n
jjcL
1.
A maximum matchingcapacity
s1
s2
s3
s4
p1
p2
p3
p4
s5 p5
1
1
2
1
1
Degree-constrained subgraph problem:A maximum matching may be found in time Owhere L is the number of edges (Gabow, 1983)
10
Case 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 student’s
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.
11
Case 2: example
Set of students, projects and lecturers: S={s1, s2, s3}, P={p1, p2, p3}, L={l1}
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
12
Case 2: example
Set of students, projects and lecturers: S={s1, s2, s3}, P={p1, p2, p3}, L={l1}
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
13
Case 2: example
Set of students, projects and lecturers: S={s1, s2, s3}, P={p1, p2, p3}, L={l1}
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
14
Finding a greedy matching
Traditional method: transform to instance of assignment problem
Create weighted bipartite graph G=(V, E) with V=SP and E={(si, pj) : pjAi}
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 k=ranki(pj) Compute a maximum weight matching in G Complexity of algorithm: O(rn(L+nlog n))
(Fredman and Tarjan, 1987) Two problems:
Arithmetic operations involving edge weights O(r) Possible implementation difficulties
15
A direct algorithm
Combinatorial algorithm: O(min(n+R, Rn)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
16
Greedy matchings vs maximum matchings
Greedy matchings need not be maximum matchings
E.g. set of students, projects and lecturers: S={s1, s2, s3}, P={p1, p2, p3}, L={l1}
Project capacities are all 1 Student preference lists:
s1 : p1 p3 s2 : p2 s3 : p2 p1
17
Greedy matchings vs maximum matchings
Greedy matchings need not be maximum matchings
E.g. set of students, projects and lecturers: S={s1, s2, s3}, P={p1, p2, p3}, L={l1}
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
18
Greedy matchings vs maximum matchings
Greedy matchings need not be maximum matchings
E.g. set of students, projects and lecturers: S={s1, s2, s3}, P={p1, p2, p3}, L={l1}
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
19
Greedy 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
20
Greedy matchings vsrank-minimum matchings
E.g. set of students, projects and lecturers: S={s1, s2, s3,, s4, s5}, P={p1, p2, p3, p4, p5}, L={l1}
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
21
Greedy matchings vsrank-minimum matchings
E.g. set of students, projects and lecturers: S={s1, s2, s3,, s4, s5}, P={p1, p2, p3, p4, p5}, L={l1}
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
22
Greedy matchings vsrank-minimum matchings
E.g. set of students, projects and lecturers: S={s1, s2, s3,, s4, s5}, P={p1, p2, p3, p4, p5}, L={l1}
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
23
Case 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:
1. if si is assigned to pj in M then si finds pj acceptable
2. si is assigned to at most one project in M
3. pj is assigned at most cj students in M
4. lk is assigned at most dk students in M
An optimal solution is a rank-minimum matching
24
Finding a rank-minimum matching (1)
Define a weighted network N as follows:
Vertices are V={s}SPL{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
25
The cost of a flow f is cost(f)={cost(e)f(e) : eE} 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(e+vlog v)log B/(m+n)) where v is number of vertices, e is number of edges and B is sum of edge capacities in N (Goldfarb and Jin, 1999)
Finding a rank-minimum matching (2)
26
Case 3: example Set of students, projects and lecturers:
S={s1, …, s5}, P={p1, …, p7}, L={l1, l2, l3}
Lecturers offer projects as follows: P1={p1, p2}, P2={p3, p4}, P3={p5, p6, p7}
Project capacities: p5 has capacity 2; all others have capacity 1
Lecturer capacities: d1=2, d2=1, d3=2
Student preference lists: s1 : p1 p3 p5 s2 : p1 p4 p6 s3 : p4 p1 p5 s4 : p1 p6 p7 s5 : p5 p3 p2
27
Example network N
s1
s2
s3
s4
p2
p3
p4
p5
s5p6
p1
p7
l1
l2
l3
s t
2
2
1
1
1
1
1
1
1
1
1
1
2
1
13
1
2
Edge costs in greenEdge capacities in red
All these edgeshave capacity 1
28
Min cost-max flow f in N
s1
s2
s3
s4
p2
p3
p4
p5
s5p6
p1
p7
l1
l2
l3
s t
2
2
1
Blue edges have flow >0- flow is 1 unless stated otherwise
cost(f)=10
29
Case 4:student 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
30
Definition of a blocking pair
(si, pj)M is a blocking pair of M if:
1. pj Ai
2. Either si is unmatched in M, or si prefers pj to M(si)3. Either
a) pj is under-subscribed and lk is under-subscribed
b) pj is under-subscribed and lk is full, and either siM(lk) or lk prefers si to the worst student in M(lk)
c) 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)
31
Example SPA instance
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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
32
SPA instance: blocking pair
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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
33
SPA instance: blocking pair
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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
34
SPA instance: blocking pair
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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
35
SPA instance: blocking pair
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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
36
SPA instance: stable matching
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 offers p7, p8
c1 = 2; all other projects have capacity 1
The matching is stable
37
Finding 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)
38
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 offers p7, p8
c1 = 2; all other projects have capacity 1
39
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 offers p7, p8
c1 = 2; all other projects have capacity 1
s1 applies to p1
p1 remains under-subscribedl1 remains under-subscribed
40
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 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
41
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 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
42
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 offers p7, p8
c1 = 2; all other projects have capacity 1
s4 applies to p2
p2 becomes over-subscribed; p2 rejects s3
43
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 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
44
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 offers p7, p8
c1 = 2; all other projects have capacity 1
s3 applies to p1
p1 becomes over-subscribed; p1 rejects s2
45
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 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
46
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 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
47
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 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
48
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 offers p7, p8
c1 = 2; all other projects have capacity 1
s7 applies to p3
l1 becomes over-subscribed; l1 rejects s3
49
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 offers p7, p8
c1 = 2; all other projects have capacity 1
s7 applies to p3
l1 becomes over-subscribed; l1 rejects s3
p3 becomes fulll1 becomes full; p1 deleted from list of s3
50
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 offers p7, p8
c1 = 2; all other projects have capacity 1
s3 applies to p4
p4 becomes over-subscribed; p4 rejects s2
51
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 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
52
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 offers p7, p8
c1 = 2; all other projects have capacity 1
s2 applies to p5
p5 becomes over-subscribed; p5 rejects s6
53
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 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
54
Execution of the algorithm
Student preferences Lecturer preferencess1 : p1 p7 l1 : s7 s4 s1 s3 s2 s5 s6 d1 = 3s2 : 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 = 2l3 offers p7, p8
c1 = 2; all other projects have capacity 1
Algorithm terminates
Matching is stable
55
Pseudocode 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 si’s 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 ; }
56
Pseudocode of algorithm (2)
if (pj is full) { sr = worst student assigned to pj ; for (each successor st of sr on lk’s list) delete pj from st’s list ; } if (lk is full) { sr = worst student assigned to lk ; for (each successor st of sr on lk’s list) for (each project pu Pk ) delete pu from st’s list ; }} /* while loop */
57
Theoretical 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
58
Open 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