Finding Stable Matchings in PhD Markets with Consistent Preferences and Cooperative Partners
Maximilian Mordig, Riccardo Della Vecchia, Nicolò Cesa-Bianchi, Bernhard Schölkopf
MMulti-Sided Matching Markets with Consistent Preferences andCooperative Partners
Maximilian Mordig
MPI for Intelligent Systems and ETH Z¨urich
Riccardo Della Vecchia
Artificial Intelligence Lab, Institute for Data Science & AnalyticsBocconi University, Milano, Italy
Nicol`o Cesa-Bianchi
Dipartimento di Informatica & DSRC,Universit`a degli Studi di Milano, Milano, Italy
Bernhard Sch¨olkopf
MPI for Intelligent Systems and ETH Z¨urichFebruary 24, 2021
Abstract
We introduce a variant of the three-sided stable matching problem for a PhD marketwith students, advisors, and co-advisors. In our formalization, students have consistent (lexicographic) preferences over advisors and co-advisors, and the latter have preferencesover students only (hence advisors and co-advisors are cooperative ). A student must bematched to one advisor and one co-advisor, or not at all. In contrast to previous work,advisor-student and student-co-advisor pairs may not be mutually acceptable, e.g., a stu-dent may not want to work with an advisor or co-advisor and vice versa. We show thatstable three-sided matchings always exist, and present the PhD algorithm, a three-sidedmatching algorithm with polynomial running time which uses any two-sided stable match-ing algorithm as matching engine. Borrowing from results on two-sided markets, we providesome approximate optimality results. We also present an extension to three-sided marketswith quotas, where each student conducts several projects, and each project is supervisedby one advisor and one co-advisor. As it is often the case in practice that the same stu-dent should not do more than one project with the same advisor or co-advisor, we modifyour PhD algorithm for this setting by adapting the two-sided Gale–Shapley algorithm tomany-to-many two-sided markets, in which the same pair can match at most once. We alsogeneralize the three-sided market to an n -sided market consisting of n − a r X i v : . [ c s . G T ] F e b Introduction
Two-sided stable matching is a classical combinatorial problem consisting of N men and N women where each person has ordinal preferences over all the persons of the opposite sex andthey have to be matched together. The goal is to find a stable matching such that any man andwoman that are not matched together do not both prefer each other to their actual partners.In their landmark paper, Gale and Shapley showed that a stable matching always exists, andgive an algorithm, the Gale–Shapley (GS) algorithm, to construct it [8]. The problem canbe extended to the case where the number of men and women is not identical, and a personmay prefer to stay single rather than match with an unacceptable partner (in which case thisperson is said to have incomplete preferences), see [11, 12, 27]. A (valid) matching must matcheach person to a person from the opposite sex or himself. The GS matching is man-optimaland woman-pessimal in the lattice of stable matchings [8, 12]. As Gale and Shapley initiallyintended to assign medical students to hospitals, with each hospital taking students up to itscapacity, subsequent works studied the problems of many-to-one (known as hospital-residentsor college admissions problem) and many-to-many matchings [8, 23, 24]. Other works exploredmore general concepts like group stability, and the connection to the game-theoretic core [7].Under additional assumptions, optimality continues to hold for many-to-many markets in theusual sense [4, 7].A natural extension are three-sided markets such as the family/man–woman–child market,where each man must be matched to exactly one woman and one child (or stay single), andlikewise for women and children. In his 11-th open question, Knuth asked under which conditionsstable matchings exist in three-sided markets [12]. A matching µ is stable if there exists no man m , woman w , and child c such that ( m, w ) > c µ ( c ) , ( m, c ) > w µ ( w ) , ( w, c ) > m µ ( m ) [10], wherethe notation p > p p means that person p prefers p over p . When each side has preferencesover couples from the other two sides, a stable matching does not always exist [1]. In fact,deciding whether a stable matching exists is NP-complete, so finding one, when it exists, is alsoNP-complete [17]. In models of kidney exchange networks, persons have cyclic preferences andeach side has preferences over the next side only, e.g., men over women, women over children,and children over men, denoted as M → W → C . Even in this restricted setting of cyclicpreferences, stable matchings need not exist, and deciding whether a stable matching exists isNP-complete [13].Preferences over couples are said to be consistent if they are a product order (lexicographicorder). That is, a man primarily cares about the woman and secondarily about the child. Onemay wonder whether stable matchings exist when preferences are consistent. Again, decidingwhether stable matchings exist is NP-complete when preferences are consistent and complete[10]. Using the same idea mentioned in the conclusion of [10], [6] shows that when men andwomen have preferences that are strict, complete and consistent (i.e., men care most about thewoman and less about the child, and women care most about the man and less about the child),then a stable three-sided matching can be constructed in the following way. First, compute astable matching between men and women (e.g., via the GS algorithm), and then match eachcouple of man and woman to a child, where the couple has the man’s preferences over children. The work [28] considers other special cases of complete preferences. An important assump-tion in these approaches is that preferences are complete, so that each couple can be matchedto a child. If preferences are incomplete , a woman may match to a man who does not match toany child, so that the woman stays single. The woman could be better off if she chose a differentman. The assumption of complete preferences is strong because a person may not find all otherpersons acceptable to match with. A person can only mitigate it if he forms preferences about → reads as “has preferences over”. This effectively ignores the preferences of the women over the children so that the problem depends on thefollowing preferences: C ← M ↔ W, C → M × W . A, S, C ) where each student in S must be matched to exactlyone advisor in A and one co-advisor in C or stay single. We assume that a student caresmore about the advisor than about the co-advisor. Hence, students have consistent preferencesover advisors and co-advisors, favoring advisors over co-advisors. We further assume that theadvisors (co-advisors) only care about students, they are indifferent about their co-advisor(advisor). This is reasonable if the student works with the advisor and co-advisor on separateprojects, or if an advisor is happy to work with any co-advisor that the student would workwith. The same professor may independently advise and co-advise students, so the number ofstudents he advises has no influence on the number of students he can co-advise. Importantly,the two-sided preferences A ↔ S ↔ C are not complete, e.g., a student may not want to workwith all advisors A . For this reason, we design an extension of the setting in [6].A closely related problem to the one presented here is the hospital-residents problem withcouples (HPC), where each couple of medical students is a single unit, and must be matchedto exactly two hospitals or stay unmatched [20, 14]. Deciding whether stable matchings existin this case is again NP-complete [18], therefore research has focused on finding good heuristicsto find (almost) stable matchings [2, 3]. Our variant of the three-sided problem ( A, S, C ) canbe transformed into a two-sided problem ( A ∪ C, S ), with the property that pairs outside of A × C are not acceptable to any s ∈ S , and each student must be matched to exactly two orzero elements of A ∪ C . Hence, it is a special case of the two-sided HPC matching problem,where each student can match to zero or two elements of ( A ∪ C ) × ( A ∪ C ). Whereas thegeneral HPC problem is NP-complete, and stable matchings need not exist even when studentshave consistent preferences [16], we show that our variant always admits stable matchings.Finally, note that our problem is not a many-to-many matching problem with substitutable preferences as in the UK medical market [23] for which [23, 7] provide algorithms: students whoare not matched to an advisor cannot be matched to a co-advisor, so their preferences cannotbe substitutable (unless these preferences are empty). Outline and Contributions
We start by reviewing two-sided many-to-many markets in Section 2 and explore variants ofthe GS algorithm. In Section 3, we introduce the setting of three-sided markets and proposethe PhD algorithm which finds a stable matching on such three-sided markets in Section 3.1.Section 3.2 discusses its running time and Section 3.3 applies the optimality results from two-sided markets. Section 3.4 discusses the difficulties associated with adapting the PhD algorithmto incompatible advisor pairs. In fact, Appendix D shows, by providing a counterexample, thatanother algorithm found in the literature [30] also does not work. Section 3.5 discusses theextension to quotas, where each person can be involved in several projects, as well as a fewvariants. Finally, Section 4 extends the theory to n -sided markets. We conclude in Section 5.We summarize the main contribution of our work: • We explore a variant of the GS algorithm in two-sided many-to-many matching marketsthat matches the same pair at most once, for which the extended market constructiondoes not work. • For the setting of three-sided matching markets (without quotas), we present the PhD al-gorithm, an algorithm for finding stable three-sided matchings using any two-sided match-ing algorithm as matching engine. We show that the PhD algorithm can be efficiently The motivation for this work came from a major pan-continental PhD program which assigns students totwo advisors in different countries, see https://ellis.eu/phd-postdoc . See Appendix A.2.1 for a definition of substitutable preferences. • We extend the PhD algorithm to arbitrary quotas and consider the case when the sameadvisor-student and/or student-co-advisor pair can match at most once. • We discuss the challenges with incompatible advisor pairs in the PhD algorithm anddemonstrate why some straightforward modifications do not work by providing coun-terexamples. We also give a counterexample for an algorithm presented in [30]. • We generalize the theory to multi-sided markets, come up with a suitable definition ofstability, and adapt the PhD algorithms to this multi-sided setting. We prove that ouralgorithm provides such stable matchings in a running time that is quadratic in the sizesof each side of the market.
In this introductory section, we summarize the relevant literature on two-sided markets (see[8, 20, 26] for a more in-depth treatment). A two-sided many-to-many matching market is aquadruple (
M, W, P, Q ) with a set of “men” M , a set of “women” W , a function Q : M ∪ W → N such that q p := Q ( p ) is the quota of person p , and where P ( m ) is a total pre-order on W ∪ { m } for each man m ∈ M denoted by ≤ m , and P ( w ) is a total pre-order on M ∪ { w } for each woman w ∈ W . Given that ≥ p is a total pre-order, we define = p and < p by p = p p if and only if p ≥ p p ∧ p ≥ p p and p < p p if and only if p ≤ p p ∧ p (cid:54) = p p . If p = p p , we say that p is indifferent between p and p . We assume that a person is never indifferent between himselfand anyone else, i.e., w (cid:54) = m m, m (cid:54) = w w ∀ m ∈ M, w ∈ W . A person with capacity greater thanone considers all spots to be equal such that preferences over individuals rather than groupsare sufficient. Person p stays single at one of his spots if he is matched to himself at that spot.If p < p p , it means that person p prefers to be self-matched rather than be matched to p . If p > p p , person p is acceptable to p . A person has complete preferences if he prefers everyoneelse to himself. Preferences are strict if all pre-orders are strict, i.e., if p = p p implies p = p for all persons p ∈ M ∪ W .A matching on this market is a set µ ⊂ M × W such that | µ ( p ) | ≤ q p ∀ p ∈ M ∪ W , where µ ( m ) = { w | ( m, w ) ∈ µ } , similarly for women. We order µ ( p ), the match partners of p , interms of ≥ p so that it can be indexed, so µ ( p ) i refers to the i -th most preferred match partnerof p in µ ( p ). Whenever | µ ( p ) | < q p for some person p , we fill µ ( p ) with identical copies of p up to its capacity and it becomes an ordered multi-set (or a finite sequence). A matching is individually rational if each person prefers each match partner to being matched to himself, i.e., µ ( p ) i ≥ p p ∀ p ∈ M ∪ W, i = 1 , . . . , q p . A matching is blocked by the pair ( m, w ) ∈ M × W if( m, w ) / ∈ µ , w > m µ ( m ) i and m > w µ ( w ) j for some i = 1 , . . . , q m , j = 1 , . . . , q w . Note that weadditionally require ( m, w ) / ∈ µ which is not necessary for one-to-one and many-to-one markets.In words, if m and w are not already matched and prefer each other to one of their matchpartners respectively, they have a strong incentive to match instead and disrespect the matching.A matching is (pairwise) stable if it is individually rational and not blocked by any pair. Stabilityis of utmost importance in practical applications since the persons will otherwise find their ownarrangements [20]. A matching µ is man-optimal if µ ( m ) i ≥ m λ ( m ) i ∀ m ∈ M, i = 1 , . . . , q m for any stable matching λ , where µ ( m ) and λ ( m ) are ordered with respect to ≥ m . Woman-optimality is analogous and pessimality inverts the inequalities. A pre-order ≤ is a partial order, except that x ≤ y ∧ y ≤ x = ⇒ x = y is not required. Whenever p ≤ p p ∧ p ≤ p p , we write p = p p to say that person p is indifferent between persons p and p . This is necessary for the stability definition below. Removing an element p from the multi-set (denoted with µ ( p ) \ { p } ) removes the first occurrence of p in µ ( p ). The element p is added (denoted with µ ( p ) ∪ { p } ) byappending it at the end of the ordered multi-set. marriage market . Whenone side has quotas all equal to one, it is referred to as the college admissions or hospital-residents problem . We first restrict to marriage markets. It is not clear a priori whether a stablematching always exists. The Gale–Shapley (GS) algorithm constructively shows that a stablematching always exists. The GS algorithm works by letting men propose to women and womenconditionally accept unless they get an offer from a better man later on. It starts with all menunmatched and all women matched to themselves. As long as a man is unmatched, considerany unmatched man. He proposes to his next most preferred woman he has not proposed toalready. In case of indifferent preferences, a man arbitrarily picks any of the equally preferredwomen. If a man has proposed to all of his acceptable women, he proposes to himself insteadand accepts (so he is self-matched/single). If the woman prefers the man to her current partner,she disengages from her old partner (a man or herself), leaving her old partner unmatched again.She engages/matches with this new man. The algorithm stops once each man is matched (to awoman or himself). The matched men and women are “married”. This algorithm is formallystated in Algorithm 5 in Appendix A.1.The GS algorithm produces a stable matching in time O ( | M || W | ). When preferences arestrict, the result is unique, independently of the order in which men propose. Moreover, thematching is man-optimal and woman-pessimal among all stable matchings, also known as man-man/woman-woman coincidence of interest and man-woman conflict of interest [7, 21]. Byswapping the roles of men and women, it returns a man-pessimal and woman-optimal matching.For non-strict preferences, the matching is generally non-unique and non-optimal.We now go back to many-to-many markets. They also admit a stable matching which canbe constructed by a slight modification/generalization of the GS algorithm. This is depictedin Algorithm 1. Each woman w is initially matched to herself q w times. Whenever a man isnot matched q m times (to women or himself), he proposes to his most preferred woman amongthe women to whom he did not propose yet (function offerNext ). If that woman prefers theman to any partner (a man or herself) she is currently matched with, she unmatches from thispartner and matches with the new man. If a man has proposed to all his acceptable women, hefills the remaining spots with himself (since he is always acceptable to himself). The function weakestMatch ( µ ( w ) , P ( w )) returns the (currently) weakest partner of woman w in µ ( w ). We can prove that this many-to-many GS algorithm returns a stable, man-optimal and woman-pessimal matching by extending the proof in one-to-one markets, see Appendix A.2. Moreover,we show possible extensions in Appendix A.2.2. Using optimality, we can show that the set ofmatched persons is the same among all stable matchings, see the proof in Appendix A.2.
Proposition 1.
Let ( M , W , P ) a two-sided market with strict preferences. The matchedpersons are the same in any stable matching. A three-sided matching market , denoted by ( A, S, C, P, Q ), consists of advisors A , students S and co-advisors C with preferences P and function Q : A ∪ S ∪ C → N such that person p hasquota q p := Q ( p ). In the most general case, each side has preferences over the other two sides,i.e., student s ∈ S has preferences over A × C ∪ { ( s, s ) } , advisor a ∈ A over S × C ∪ { ( a, a ) } and co-advisor c ∈ C over A × S ∪ { ( c, c ) } , where ( p, p ) means that person p stays single.Since stable matchings may not exist for arbitrary preferences [17, 10], we consider the specialcase where advisors/co-advisors only care about students and they are indifferent between co-advisors/advisors, i.e., they are cooperative partners. In addition, students have consistent The extended market construction used for many-to-one markets [20] does not work because the same manand woman can match at most once. During the execution of the algorithm, we define µ ( m ) = { m | ( m, w ) ∈ µ } in terms of the temporary µ defined in the algorithm. lgorithm 1: Extended Gale–Shapley Algorithm on Many-to-Many Markets
Input: market (
M, W, P, Q ), quotas Q Output: matching µµ ← ∪ w ∈ W ∪ q w i =1 { ( w, w ) } // every woman is matched q w times to herself, every man has q m freespots while there is a man m with some unmatched spots, i.e., | µ ( m ) | < q m do w ← offerNext ( P, m ) // best woman w to whom m has not yet proposed q m times,otherwise m if w = m then µ ← µ ∪ { ( m, m ) } // man proposed to himself and accepts else if m > w m (cid:48) = weakestMatch ( µ ( w ) , P ( w )) then µ ← µ \ { ( m (cid:48) , w ) } ∪ { ( m, w ) } // unmatch ( m (cid:48) , w ) (once), match ( m, w ) endendreturn µ preferences in the sense that they primarily care about the advisor and less about the co-advisor. More precisely, student s has separate preferences over advisors and co-advisors, ≤ As and ≤ Cs , and his compound preferences between advisor pairs ( a, c ) , (˜ a, ˜ c ) ∈ ( A × C ) ∪ { ( s, s ) } are constructed in the following way:( a, c ) > s (˜ a, ˜ c ) ⇐⇒ a > As ˜ a ∨ ( a = As ˜ a ∧ c > Cs ˜ c ) , ( a, c ) ≥ s (˜ a, ˜ c ) ⇐⇒ a > As ˜ a ∨ ( a = As ˜ a ∧ c ≥ Cs ˜ c ) , ( a, c ) = s (˜ a, ˜ c ) ⇐⇒ a = As ˜ a ∧ c = Cs ˜ c . (1)We will drop the superscripts A and C in ≤ As and ≤ Cs , since it will be clear from the context. Inother words, we have preferences over the two two-sided markets ( A, S ) and (
S, C ): A ↔ S ↔ C .Preferences are strict if they are strict on both markets. We define a matching similarly to thecase of two-sided markets. Definition 2.
A matching is a set µ ⊂ A × S × C such that: • | µ ( a ) | ≤ q a ∀ a ∈ A , where µ ( a ) = { ( s, c ) | ( a, s, c ) ∈ µ } , and • | µ ( s ) | ≤ q s ∀ s ∈ S , where µ ( s ) = { ( a, c ) | ( a, s, c ) ∈ µ } , and • | µ ( c ) | ≤ q c ∀ c ∈ C , where µ ( c ) = { ( a, s ) | ( a, s, c ) ∈ µ } .When | µ ( p ) | < q p , the remaining spots are filled with identical copies of ( p, p ) up to size q p ,where ( p, p ) means that p is matched to himself/single in µ . Define the students matched to advisor a as µ ( a ) S = { s | ( s, c ) ∈ µ ( a ) } , the co-advisorsmatched to advisor a as µ ( a ) C = { c | ( s, c ) ∈ µ ( a ) } etc. Let µ | ( A,S ) the two-sided matching thatis obtained when the information about co-advisors is discarded. The matching is individuallyrational if the two-sided matchings µ | ( A,S ) and µ | ( S,C ) are individually rational. A matching isstable if it is individually rational and not blocked by any triple. We first define a blocking triplewhen quotas all equal one. When quotas are equal to one, µ ( p ) refers to the single element of µ ( p ) with a slight abuse of notation, and similarly for sets like µ ( s ) A . Definition 3.
For quotas equal to one, the matching µ is blocked by ( a, s, c ) ∈ A × S × C if µ ( a ) S is a multi-set in which each student can appear at most once, and the advisor a can appear severaltimes (if he appears several times in µ ( a )). student s is unmatched in µ and ( a, s ) blocks µ | ( A,S ) and ( s, c ) blocks µ | ( S,C ) , or • student s is matched in µ and ( a, s ) blocks µ | ( A,S ) or ( s, c ) blocks µ | ( S,C ) .Student s is matched in µ if µ ( s ) ∈ A × C , otherwise µ ( s ) = ( s, s ) and s is unmatched/singlein µ . In other words, either s is unmatched and all of ( a, s, c ) can improve their matches on thetwo-sided markets, or s is matched and either ( a, s ) can improve or ( s, c ) can improve. Again,stability is a crucial property because persons will not stick to matches they are assigned inunstable matchings. Whenever ( a, s, c ) is a blocking triple and s is matched, either ( µ ( s ) A , s, c )or ( a, s, µ ( s ) C ) is a blocking triple. This is not true when s is single, µ ( s ) = ( s, s ), since then( µ ( s ) A , s, c ) = ( s, s, c ) and ( a, s, µ ( s ) C ) = ( a, s, s ) are not in A × S × C . If a blocking pair existson one of the markets, it only forms part of a blocking triple if the involved student is matchedor forms part of a blocking pair on the other market. This coincides with the definitions in[29, 10, 14], see Appendix B.1. In fact, these definitions show that advisors and co-advisors aretreated symmetrically (unlike what one expects from Eq. (1)).When a matching is blocked, we have the following proposition: Proposition 4.
Assume quotas equal to one. If ( a, s, c ) blocks µ on the market A × S × C , oneof the following must hold: (cid:40) a > s µ ( s ) A s > a µ ( a ) S or a = µ ( s ) A c > s µ ( s ) C s > c µ ( c ) S . ( a, s, c ) blocks µ if either ( a, s ) blocks µ | ( A,S ) or s ∈ S m and ( s, c ) blocks µ | ( S m ,C ) , where S m = { s | µ ( s ) (cid:54) = ( s, s ) } are the students who are matched in µ .Proof. If ( a, s ) does not block µ | ( A,S ) , s must be matched to some advisor a ∈ µ ( s ) A and ( s, c )blocks µ | ( S,C ) .Hence, when µ is unstable on ( A, S, C ), µ | ( A,S ) or µ | ( S,C ) is unstable. Equivalently, this saysthat when µ | ( A,S ) and µ | ( S,C ) are stable, then µ is also stable. The converse does not hold andwe can say more generally: when µ is stable on ( A, S, C ), µ | ( A,S ) and µ | ( S,C ) can be stable ornot, see Figure 1. For quotas equal to one, when µ is stable on ( A, S, C ), µ | ( A,S m ) and µ | ( S m ,C ) are stable, where S m are the matched students as in the proposition. Moreover, any unmatchedstudent (in S \ S m ) cannot simultaneously be part of a blocking pair on both sides.When quotas are arbitrary, one must be a bit careful and we have deferred the analogues ofDefinition 3 and Proposition 4 to Appendix B.2. We give an example of a three-sided market. Example 1.
Consider the PhD market with advisors A = { a , a } , students S = { s , s , s } and co-advisors C = { c , c } all with quota one and with preferences (listing acceptable personsonly in decreasing order of preference): P ( a ) = { s , s , s } , P ( a ) = { s , s } , P A ( s ) = { a , a } , P A ( s ) = { a } , P A ( s ) = { a } ,P C ( s ) = { c , c } , P C ( s ) = { c } , P C ( s ) = { c } , P ( c ) = { s , s , s } , P ( c ) = { s } . The compound preferences of student s are P ( s ) = { ( a , c ) , ( a , c ) , ( a , c ) , ( a , c ) } (last en-try ( s , s ) omitted). The preferences of advisor a are P ( a ) = { [( s , c ) , ( s , c )] , [( s , c ) , ( s , c )] } ,where [ · ] denotes indifferent preferences among its elements. A valid and stable matching is µ = { ( a , s , c ) } . The matching µ = { ( a , s , c ) } is unstable because it is blocked by the triple ( a , s , c ) . Note that we have µ ( s ) A = { a } , µ ( s ) C = { c } , µ ( a ) S = { s } , µ ( a ) S = { a } (filled to capacity 1). : s s : ac c : s ASC stable, AS stable, SC stable a : s s : ac c : ∅ ASC stable, AS unstable, SC stable a : ∅ s : ac c : s ASC stable, AS stable, SC unstable a s a ∅ s a c s a c c ∅ c s Figure 1: Three-sided stability does not correspond to two-sided stability on the markets (
A, S )and (
S, C ). Except for the first case, the stable three-sided matching on (
A, S, C ) is {} . Thedotted pairs indicate blocking pairs on the two-sided markets, the solid line is the three-sidedmatching. Each person p corresponds to a node labelled by “ p : preferences”. The prefer-ences list the acceptable persons in decreasing order. For students, the product preferences arespecified by the preferences over advisors and co-advisors. In this section we prove that stable matchings exist for three-sided matching markets. To gainan intuition, we first restrict to the case when everyone has quotas equal to one. The idea is toiteratively apply the GS algorithm to the two two-sided markets and remove students when theycannot find an advisor and co-advisor simultaneously. Initially, all students S participate. Stu-dents and advisors are matched in a GS algorithm. The matched students S m ⊂ S participatein a GS algorithm together with co-advisors. Students S u who participate in the second marketwith co-advisors and don’t find a co-advisor (partial advisor-student match) are removed. Theremaining students S \ S u can participate in the next round, including students who did not findan advisor. This is repeated until no students are removed. The removed students as well asthe students who could not find an advisor at the last iteration are matched to themselves/staysingle. We call this algorithm the PhD algorithm and it is depicted in Algorithm 2. Algorithm 2:
PhD Market - PhD Algorithm without Quotas
Input:
PhD market (
A, S, C, P ), quotas Q = 1 Output: stable matching µ strictify the preferences P AS on ( A, S ) and P SC on ( S, C ) do µ AS ← GS ( M = S, W = A, P AS )let S m the matched students in µ AS µ SC ← GS ( M = S m , W = C, P SC )let S u ⊂ S m the unmatched students in µ SC S ← S \ S u while S u (cid:54) = ∅ students in S are matched to their respective advisor in µ AS and co-advisor in µ SC , theothers remain single return µ Preferences are initially strictified by breaking (all) ties and the function GS ( M, W, P ) standsfor the GS algorithm where men M propose to women W under preferences P . The algorithmterminates because the GS algorithm itself terminates and the number of students | S | decreasesat each iteration, unless S u is empty and the while-loop ends. The algorithm returns a valid7atching since no student is partially matched. Indeed, student s is matched to an advisor ifand only if s ∈ S m at the final iteration. Since S u is empty at the final iteration, s ∈ S m is alsomatched to a co-advisor. In Figure 4, we show that the PhD algorithm evolves in a non-trivialway. Intuitively, students who are removed are “bad” and would also not find a co-advisor inlater iterations. The algorithm returns a stable matching independently of whether students oradvisors propose in the ( A, S ) market and whether students or co-advisors propose in the (
S, C )market. For now, we assume that the proposing side does not change over iterations, we willsee that this does not matter. Who proposes at the last iteration only matters for optimality(discussed later). Because the GS algorithm returns a unique matching for strict preferences,the PhD algorithm returns a unique matching when the preferences on the two-sided markets(
A, S ) and (
S, C ) are strict. If preferences are not strictified initially, the matching may notbe stable or the number of matches between stable matchings may differ, see Appendix C.2. Ifpreferences are strictified initially, Proposition 29 in Appendix B.5 shows that the matching isalso stable under the original non-strict preferences. So we assume that preferences are strictfrom now on.To prove stability, we establish a few properties first. One iteration refers to one iterationof the PhD algorithm after which unmatched students are removed. Superscripts refer to theiteration number: µ ( τ ) AS is the matching at iteration τ = 1 , . . . , T and S ( τ ) are the remainingstudents at the start of iteration τ . T is the total number of iterations. For clarity, we haveexplicitly defined these sets in Algorithm 6 in the Appendix, which is equivalent to Algorithm 2.To understand how matches evolve over iterations on the two-sided markets, we start by studyingthe matchings produced by the GS algorithm when people on one side are removed. When menpropose and new men are added to the market, the existing men cannot get better matchesand the women cannot get worse matches since there is more competition between men andthere are more offers for women. When women propose and men are added to the market, themen cannot get better matches and the existing women cannot get worse matches since thereis more competition between men, and women can make more offers. Given a matching µ ona two-sided market ( M, W, P ) and subsets M ⊂ M, W ⊂ W , we denote with P | ( M ,W ) therestricted preferences where persons not in M ∪ W are removed from the preference lists. Thematching µ | ( M ,W ) is the matching restricted to the market ( M , W , P | ( M ,W ) ), where personswho are matched to persons not in M ∪ W are matched to themselves instead. For three-sidedmatchings, we define the restriction analogously. The following result was already proven in[9] for one-to-one markets, and we show in Appendix A.3 that it also holds for many-to-manymarkets. Lemma 5.
Consider a market ( M, W, P ) and subsets M ⊂ M, W ⊂ W . Let µ = GS ( M, W, P ) , µ = GS ( M , W, P | ( M ,W ) ) and µ = GS ( M, W , P | ( M,W ) ) . • Independently of whether men or women propose (but the same for µ and µ ), it holdsthat µ ( m ) ≥ m µ ( m ) ∀ m ∈ M , µ ( w ) ≤ w µ ( w ) ∀ w ∈ W . • Independently of whether men or women propose (but the same for µ and µ ), it holdsthat µ ( m ) ≤ m µ ( m ) ∀ m ∈ M, µ ( w ) ≥ w µ ( w ) ∀ w ∈ W . We apply this result to the (
A, S ) and (
S, C ) market. These results are independent ofwhether students or advisors or co-advisors propose.
Lemma 6.
A student’s match on the ( A, S ) market cannot worsen over iterations (providedthat he still participates). More precisely, if student s still participates in iteration τ , s ∈ S ( τ ) ,then µ ( τ ) AS ( s ) ≥ s µ ( τ − AS ( s ) ∀ τ ≥ . This implies that S ( τ − m \ S ( τ − u ⊂ S ( τ ) m ∀ τ ≥ .Proof. Since the number of students decreases, Lemma 5 applies with M = S ( τ ) ⊂ S ( τ − = M . s ∈ S ( τ − m \ S ( τ − u means that µ ( τ − AS ( s ) > s s and s ∈ S ( τ ) . Therefore, µ ( τ ) AS ( s ) > s s , i.e., s ∈ S ( τ ) m . 8ntuitively, the remaining students face less competition from other students over iterations.The evolution of matchings on the student-co-advisor market is a bit less evident. Althoughstudents are removed, the co-advisors’ matches do not decrease since only “bad” students thatno co-advisor wants are removed. Lemma 7.
A co-advisor’s match on the ( S, C ) market cannot worsen over iterations: µ ( τ ) SC ( c ) ≥ s µ ( τ − SC ( c ) ∀ τ ≥ , c ∈ C .Proof. Consider iteration τ and the ( S, C ) market where students S ( τ ) m participate. First letonly students S ( τ − m ∩ S ( τ ) m participate to obtain the temporary matching λ ( τ ) SC . By Lemma 6, S ( τ − m ∩ S ( τ ) m = (( S ( τ − m \ S ( τ − u ) ∩ S ( τ ) m ) ∪ (( S ( τ − m ∩ S ( τ − u ) ∩ S ( τ ) m ) = S ( τ − m \ S ( τ − u . Since thestudents S ( τ − u are not matched to any co-advisors, λ ( τ ) SC = µ ( τ − SC on the market restricted to( S ( τ − m \ S ( τ − u , C ). Let the remaining students S ( τ ) m \ S ( τ − m participate as well. By Lemma 5,since more students have joined the market, we must have µ ( τ ) SC ( s ) ≤ s λ ( τ ) SC ( s ) = µ ( τ − SC ( s ) ∀ s ∈ S ( τ − m \ S ( τ − u . Similarly, we obtain µ ( τ ) SC ( c ) ≥ c µ ( τ − SC ( c ) ∀ c ∈ C .In fact, Lemma 7 can make an additional statement as indicated in the proof. A student’smatch on the ( S, C ) market cannot increase over iterations (once he is part of the (
S, C ) market):if student s participates in iterations τ − τ , i.e., s ∈ S ( τ − m ∩ S ( τ ) m = S ( τ − m \ S ( τ − u , then µ ( τ ) SC ( s ) ≤ s µ ( τ − SC ( s ). So, even if we kept a student for some more iterations in the hope thathe finds a co-advisor, he never will and instead unnecessarily hinders an advisor from matchingwith another student. Therefore, it is safe to remove all students S u and not just a subset.With this, we can finally prove stability. Theorem 8.
The PhD algorithm returns a stable matching.Proof.
By Proposition 29, it is sufficient to show that the matching µ is stable under the stricti-fied preferences (first line of the algorithm). We proceed by contradiction. The algorithm cannotreturn an individually irrational matching since the GS algorithms never return individually ir-rational matchings on the two-sided markets ( A, S ) and (
S, C ). Assume that ( a, s, c ) ∈ A × S × C blocks µ . If student s was not removed during the iterations of the PhD algorithm, this means s ∈ S ( T ) , where S ( T ) is the set at the final iteration T . ( a, s, c ) must also block µ | ( A,S ( T ) ,C ) . ByProposition 4 applied to the market ( A, S ( T ) , C ), either the matching µ | ( A,S ( T ) ) = µ ( T ) AS is blockedby ( a, s ) or the matching µ | ( S ( T ) m ,C ) = µ ( T ) SC is blocked by ( s, c ). This contradicts the stability ofthe GS algorithms applied to the markets ( A, S ( T ) ) and ( S ( T ) m , C ). If student s was removed atsome iteration τ , s could find an advisor, but no co-advisor at that iteration. Since ( a, s, c ) isa blocking triple, s and c are mutually acceptable. If students propose to co-advisors, s musthave proposed to c in the GS algorithm. c must have rejected s in favor of another student˜ s > c s . If co-advisors propose, c must not have proposed to s (since s would not have rejected)and must therefore have matched with another student ˜ s > c s . In both cases, µ ( τ ) SC ( c ) ≥ c ˜ s > c s at that iteration. By Lemma 7, we must have µ ( c ) S = µ ( T ) SC ( c ) ≥ c µ ( τ ) SC ( c ) ≥ c ˜ s > c s . Hence µ ( c ) S > c s and ( a, s, c ) cannot block µ .The PhD algorithm returns a stable matching independently of which side proposes on thetwo-sided markets. If S = ⇒ A means that students propose to advisors, we have the variants: A = ⇒ S = ⇒ C , A ⇐ = S = ⇒ C , A ⇐ = S ⇐ = C and A = ⇒ S ⇐ = C . Thesevariants have different optimality properties as discussed in Section 3.3. Another variant is toswap the roles of advisors and co-advisors, i.e., first run the student-co-advisor market and thenthe student-advisor market on the matched students. The stability notion is the same sincethe definition in Eq. (3) is symmetric, but the matching returned by this variant is generallydifferent, see Figure 2. 9e now discuss an important invariance property of the PhD algorithm. By Proposition 1,the set of matched persons is the same for any stable matchings on two-sided markets, sothe set S m is independent of which stable matching algorithm is used on the market ( A, S )at each iteration. Given S m , the set of unmatched students S u is independent of the stablematching algorithm that is used on the ( S m , C ) market. Suppose that the PhD algorithm runsfor T iterations. Then, we can replace the two invocations of the GS algorithm by any othertwo-sided (individually rational) stable matching algorithm at iterations 1 , . . . , T −
1. In fact,the matchings µ AS and µ SC at iterations 1 , . . . , T − S m ) and which students are removed( S u ). Moreover, by looking at the proof of Proposition 8, we see that the GS algorithmsat the last iteration can also be replaced by any other stable matching algorithms. If s wasnot removed, it is clear. If s was removed, suppose that we have used the GS algorithm withstudents proposing to co-advisors at iterations 1 , . . . , T −
1. At iteration T , either we use anotherstable matching mechanism to obtain λ or we use the GS algorithm with students proposing toco-advisors to obtain µ . Since µ is co-advisor-pessimal on the market ( S ( T ) m , C ), we have that λ ( c ) S ≥ c µ ( c ) S > c s , hence ( a, s, c ) cannot block λ . So, the stable matching mechanisms used atthe final iteration do not affect stability and the set of matched people, but determine propertiesof the matching such as optimality. From now on, we will assume that the GS algorithms areused and the same side proposes in each market at each iteration of the PhD algorithm for tworeasons. First, the PhD algorithm can be implemented more efficiently, and second, it has someoptimality properties. Since the GS algorithm runs in time O ( | M || W | ) on the market ( M, W ), a naive bound ofthe running time of the PhD algorithm is O (( | A | + | C | ) | S | ). Indeed, at least one student isremoved at each iteration and O ( (cid:80) Tτ =1 | A || S ( τ ) | + | C || S ( τ ) m | ) = O (( | A | + | C | ) | S | ). A carefulimplementation can achieve O (( | A | + | C | ) | S | ) as we show now. The idea is that the GS algorithmin one iteration builds upon the matching of the GS algorithm in the previous iteration andonly needs to know the differences between the matchings. Proposition 9.
Modify the GS algorithm such that each woman keeps track of the men sherejected in a waiting list, and let GS ( M, W ) be the result of the GS algorithm when men proposeon the market ( M, W ) . Then we have: • if { M ( τ ) } Tτ =1 is a decreasing sequence of men such that M ( τ +1) ⊂ M ( τ ) and M (1) = M ,then all the GS matchings { µ ( τ ) = GS ( M ( τ ) , W ) } Tτ =1 can be output in O ( | M || W | + T ) total time in terms of their differences; • if { W ( τ ) } Tτ =1 is a decreasing sequence of women such that W ( τ +1) ⊂ W ( τ ) and W (1) = W ,then the GS matchings { µ ( τ ) = GS ( M, W ( τ ) ) } Tτ =1 can be output in O ( | M || W | + T ) totaltime in terms of their differences.Proof. Compute the initial matching µ (1) = µ in time O ( | M || W | ). We will show that listingthe consecutive differences between µ ( τ +1) and µ ( τ ) takes at most O ( | M || W | + T ) summed overall τ = 2 , . . . , τ . Without loss of generality, we assume that a single man (woman) is removedbetween M ( τ ) and M ( τ +1) ( W ( τ ) and W ( τ +1) ).Suppose that man m is removed. Remove m from everyone’s preferences. If he was notmatched to any woman, µ ( τ +1) is the same as µ ( τ ) , except that man m is not listed. If hewas matched to woman w , woman w picks the most preferred man ˜ m on her waiting list,removes him from this list and accepts ˜ m . If ˜ m was matched to a woman, apply the same to We output the first matching µ (1) . Matching µ ( τ +1) is output in terms of its difference to the matching µ ( τ ) ;If the matching µ ( τ +1) were output without reference to µ ( τ ) , it takes O ( | M || W | + ( | M | + | W | ) T ) total time. : s , s s acs ac c : s , s Figure 2: The stable matchings are µ = { ( a, s , c ) } (solid) and µ = { ( a, s , c ) } (dashed).The PhD algorithm returns µ , independently of whether advisors or students or co-advisorspropose. The matching is not student-optimal: s prefers µ and s prefers µ . It shows thatthe set of matched students can differ between stable matchings. In fact, the PhD algorithmreturns the matching µ for the variant in which the student-co-advisor market is first and thestudent-advisor market is second.˜ m . Since each woman lists at most | M | men on her waiting list, the total running time is atmost O ( | M || W | + T ) summed over all τ = 2 , . . . , T . We leave the proof to the reader that thecomputed matchings correspond to the GS matchings.Suppose that woman w is removed. Remove w from everyone’s preferences. If she was notmatched to any man, µ ( τ +1) is the same as µ ( τ ) , except that woman w is not listed. If woman w was matched to a man m , continue the GS algorithm starting from the matching µ ( τ ) . Sinceeach man lists at most | W | women, the total running time is at most O ( | M || W | + T ) summedover all τ = 2 , . . . , T .For the PhD algorithm, it is enough to keep track of the matching and the matched peopleon the ( A, S ) and (
S, C ) markets at each iteration. Therefore, the total time spent is O (( | A | + | C | ) | S | ). The space overhead for the waiting lists is bounded by the space needed to storethe preference lists. Since the matching returned by the PhD algorithm only depends on thematching algorithms used at the last iteration, we can use the GS algorithms for iterations1 , . . . , T −
1. Therefore, the PhD algorithm generally runs in time O (( | A | + | C | ) | S | ) plus therunning time of the matching algorithms at the final iteration. We will focus on the optimality properties that are inherited from the optimality properties ofthe GS algorithm and its variants on the two-sided markets. Since the GS algorithm itself isgenerally not optimal when preferences are not strict, we consider the case of strict preferenceson the markets (
A, S ) and (
S, C ). We focus on optimality based on two-sided optimality sincethree-sided student-optimality is not possible. In fact, Figure 2 shows that generally no student-optimal stable matching µ exists such that µ ( s ) ≥ s λ ( s ) ∀ s ∈ S for all stable matchings λ . Inparticular, three-sided markets do not have a lattice structure as it is the case for two-sidedmarkets. However, we conjecture that the PhD algorithm, with advisors proposing to students,returns a matching that is advisor-optimal among all three-sided matchings.We now apply the optimality results from two-sided markets and show how they applyto any three-sided stable matchings λ such that λ | ( A, ˜ S ) and λ | ( ˜ S m ,C ) are stable. Let ˜ S = S ( T ) , ˜ S m = S ( T ) m the sets of the remaining students and matched students at the final iteration T of the PhD algorithm that returns the matching µ . Given an arbitrary matching λ , definethe matched students as S m ( λ ) = { s ∈ S | λ ( s ) (cid:54) = ( s, s ) } . Then ˜ S m = S m ( µ ). By the optimality(and pessimality) of the GS algorithms at the last iteration, µ | ( A, ˜ S ) and µ | ( ˜ S m ,C ) are optimal.Since the set of matched persons is the same for any stable matchings on two-sided markets(Proposition 1), the sets ˜ S, ˜ S m are the same, independently of which side proposes in the PhDalgorithm. Let µ = µ A ⇐ = S = ⇒ C the matching returned by the PhD algorithm when studentspropose to advisors and co-advisors and µ = µ A = ⇒ S ⇐ = C the matching when advisors andco-advisors propose to students. Then, for any three-sided matching λ such that λ | ( A, ˜ S ) and11 | ( ˜ S m ,C ) are stable, we have: µ | ( A, ˜ S ) ( s ) ≥ s λ | ( A, ˜ S ) ( s ) ≥ s µ | ( A, ˜ S ) ( s ) ∀ s ∈ ˜ S ,µ | ( A, ˜ S ) ( a ) ≤ a λ | ( A, ˜ S ) ( a ) ≤ a µ | ( A, ˜ S ) ( a ) ∀ a ∈ A ,µ | ( ˜ S m ,C ) ( s ) ≥ s λ | ( ˜ S m ,C ) ( s ) ≥ s µ | ( ˜ S m ,C ) ( s ) ∀ s ∈ ˜ S m ,µ | ( ˜ S m ,C ) ( c ) ≤ c λ | ( ˜ S m ,C ) ( c ) ≤ c µ | ( ˜ S m ,C ) ( c ) ∀ c ∈ C . (2)For example, assume that students propose to advisors and co-advisors and the PhD algorithmstops after one iteration. (For example, if preferences are complete in the (
S, C ) market and | C | ≥ | S | , the PhD algorithm stops after exactly one iteration.) If the algorithm only runsfor one iteration, S = ˜ S and all students get the best advisor they could possibly get amongall triple matchings λ such that λ | ( A,S ) is stable. If additionally all students find an advisor, S = ˜ S m , they get the best co-advisor they could possibly have among all triple matchings λ such that λ | ( S,C ) is stable.Note that the sets ˜ S, ˜ S m are not intrinsic to the market, but depend on the PhD algorithm,see Figure 2. For this reason and the fact that λ | ( A, ˜ S ) and λ | ( ˜ S m ,C ) need not be stable foran arbitrary stable matching λ , we do not call it optimality, but rather a tendency towardsoptimality. We now characterize the matchings λ for which Eq. (2) holds. Proposition 10.
Consider a three-sided individually rational matching λ on the market ( A, S, C ) .Let us assume that ˜ S, ˜ S m , µ are produced by the PhD algorithm. If λ | ( A, ˜ S ) and λ | ( ˜ S m ,C ) are stable,both λ | ( A, ˜ S,C ) and λ are stable. Furthermore, λ matches the same persons as µ .Proof. The matching λ may match students outside of ˜ S . We first show that λ matches thesame students as µ . We know that µ | ( A, ˜ S ) and µ | ( ˜ S m ,C ) are stable since they correspond to thestable matchings at the last iteration of the PhD algorithm. These matchings both match thepersons ˜ S m . By Proposition 1, λ | ( A, ˜ S ) matches everyone in ˜ S m and no one in ˜ S \ ˜ S m , the same istrue for λ . Suppose λ matches a student s ∈ S \ ˜ S such that λ ( s ) = (˜ a, ˜ c ). Since λ is individuallyrational, (˜ a, s, ˜ c ) are mutually acceptable. If ˜ a were matched in µ , Proposition 1 implies that ˜ a is also matched in λ | ( A, ˜ S ) and ˜ a cannot be matched to s / ∈ ˜ S in λ . Similarly, if ˜ c were matchedin µ , Proposition 1 implies that ˜ c is also matched in λ | ( ˜ S m ,C ) and ˜ c cannot be matched to s / ∈ ˜ S m ⊂ ˜ S in λ . Hence ˜ a and ˜ c are unmatched in µ . Because (˜ a, s, ˜ c ) are mutually acceptableand are all unmatched, µ must be unstable, a contradiction to Proposition 8. Therefore, theset of matched students in λ must be the same as in µ , i.e., S m ( λ ) = ˜ S m . Proposition 4 impliesthat λ | ( A, ˜ S,C ) is stable.In Section 3.1, we have already noted that the GS algorithms can be replaced by any otherstable matching algorithms at the last iteration of the PhD algorithm. Consider the last iterationof the PhD algorithm and replace the GS algorithms by the stable matching algorithms thatreturn the stable matchings λ | ( A, ˜ S ) and λ | ( ˜ S m ,C ) . Then λ must be stable since it does not matchany students outside ˜ S as we have proven. By Proposition 1, λ and µ must match the samepersons on the market ( A, ˜ S ), so they match the same advisors. Analogously, they match thesame co-advisors.This is encouraging because it means that the matchings λ for which Eq. (2) holds are stableon the full market ( A, S, C ). However, there are three-sided stable matchings λ for which Eq. (2)does not hold. As noted in Section 3, a similar statement holds for arbitrary S : when µ | ( A,S ) and µ | ( S,C ) are stable, µ is also stable. We refer to Appendix C.3 for additional characterizationsof the set ˜ S m . 12 s = ca s s : a , a c c : s a s , s a s = c a s s a c s a , a c , c s a c c s c s , s Figure 3: The PhD Algorithm fails when some advisor pairs are incompatible. Note thatthis reasoning works independently of which side proposes on the two-sided markets.
Left:
When the PhD Algorithm (Algorithm 2) does not take incompatible advisor pairs into account,it returns the matching { ( a , s, c ) } , which is not valid since a and c are incompatible. If astudent only considers co-advisors who are compatible with his matched advisor, s is removedat the first iteration and the algorithm returns the unstable matching {} which is blocked by( a , s, c ). If the student removes advisor a from his list of acceptable advisors after the firstiteration, the algorithm produces the stable matching { ( a , s, c ) } (in dotted style). Right:
However, this modification does not work for this example where the PhD algorithm returnsthe unstable matching { ( a , s , c ) } which is blocked by ( a , s , c ). At the first iteration, thetemporary matching is { ( a , s , c ) } , s removes a (from his list) and s removes advisor a .The algorithm terminates after the second iteration. The reason this happens is that a is notcompatible with c , so s matches with c , so that s removes a from his list of acceptableadvisors. At the second iteration, s matches with advisor a who is compatible with s ’s morepreferred co-advisor c . If s were still part of the market, it could match to ( a , c ). We now consider the case when only some advisor pairs K ⊂ A × C are compatible. A matching µ has to be a subset of { ( a, s, c ) ∈ A × S × C | ( a, c ) ∈ K } rather than A × S × C . Let K ( a ) = { c | ( a, c ) ∈ K } the co-advisors that are acceptable to a and K ( c ) = { a | ( a, c ) ∈ K } theadvisors that are acceptable to c . The objective of this section is to show that incompatiblepairs cannot be incorporated by simple modifications of the PhD algorithm.Suppose that we adapt the PhD algorithm such that a student who is matched to an advisor,at a given iteration, only considers co-advisors who are compatible with his matched advisor.This is clearly necessary since the algorithm may otherwise match advisors to incompatibleco-advisors. The left part of Figure 3 shows that this modification generally does not work.Whenever a student cannot find a co-advisor among those that are compatible with his matchedadvisor a , the student is removed. However, it could be that a is not compatible with manyco-advisors. If s changed his advisor, he could find a match. So the idea is to (greedily) remove a from s ’s preferences in all future iterations , so s cannot match again with a . When thestudent is matched to advisor a and cannot find a co-advisor at an iteration, he marks advisor a as unacceptable starting from that iteration. Then, this modified algorithm applied to theleft part of Figure 3 works. However, the right part of this figure shows that it generally doesnot work. To understand why this happens, note that the PhD algorithm first addresses the( A, S ) market and then the (
S, C ) market. It treats them as separate entities with very limitedinteraction, only through the set S m of matched students and the set of removed students S u at each iteration. A different approach could be that when a student finds an advisor,he immediately tries to find a co-advisor as well, and this is repeated until all students arematched. The authors of [30] provide an algorithm based on this idea (additionally assumingcomplete preferences). However, their algorithm appears to be incorrect, and we provide acounterexample in Appendix D. In fact, their algorithm provides a stable matching only whenall advisor pairs are compatible, i.e., K = A × C . The advantage of our PhD algorithm, with That is, student s marks a as unacceptable. It would beinteresting to see if stable matchings always exist in this setting.
This section studies the more general case when quotas can be different from one. As a use case,think that each student needs to complete a maximum number of projects and each professorcan advise and/or co-advise a maximum number of students/projects. With Definition 2 of avalid three-sided matching µ , the same advisor-student or student-co-advisor pair can matchmore than once, so the matchings µ | ( A,S ) , µ | ( S,C ) can be multi-sets and not (plain) sets. The GScan be modified to work for multi-sets on two-sided markets, see Appendix A.2.2. We can alsoextend Definition 2 of a three-sided matching µ such that µ ⊂ A × S × C is a multi-set, so thesame triple can match more than once. Definition 21 about blocking triples stays unmodified.First, we consider the variant when both the three-sided matching µ and the correspondingtwo-sided matchings µ | ( A,S ) , µ | ( S,C ) are multi-sets. Similarly to two-sided markets, we can con-struct an extended market of a three-sided market, see Appendix B.4. Proposition 27 showsthat a matching is stable on the original three-sided market if and only if it is stable on the ex-tended three-sided market (where quotas are equal to one). So, we can run the GS algorithm onthe extended market and then map it back to obtain a stable matching on the original market.In this section, we aim for a more explicit algorithm, as we did in Section 2. This developmentwill make the variants we consider straightforward.In the PhD algorithm without quotas, a student is removed if he does not find a co-advisor.Here, when a student has a quota on the ( S, C ) market and does not use all of his quota, wereduce his quota on the (
A, S ) market by the number of unfilled spots. More precisely, saya student matches with k a advisors. Then, he is assigned quota k a on the student-co-advisormarket. If this student then matches to k c ≤ k a co-advisors, reduce his capacity on the advisormarket by k a − k c (instead of removing the student). This is depicted in Algorithm 3. Thefunction countMatches ( µ, s ) counts the number of matches of s excluding self-matches. Weuse dictionary notation to describe the quota function. The function
Q.update updates quotas Q by replacing the quotas of the specified persons only. Q | ( A,S ) are the quotas restricted to themarket ( A, S ), ˜ Q SC are the quotas defined in the algorithm on the market ( S, C ).By generalizing the developments in Section 3.1 to quotas, we can prove the stability of thisalgorithm, see Appendix C.4:
Theorem 11.
The PhD algorithm with quotas returns a stable matching.
As in Section 3.1, we can replace the GS algorithms at each iteration by any other stablematchings algorithms. In particular, the side which proposes on the two-sided markets can bechosen to achieve a desired optimality. Moreover, we can adapt the results about optimalityfrom Section 3.3. Recall that the matchings are ordered, e.g., µ | ( A, ˜ S ) ( s ) in terms of ≥ s . Thefirst line of Eq. (2) becomes: µ | ( A, ˜ S ) ( s ) i ≥ s λ | ( A, ˜ S ) ( s ) i ≥ s µ | ( A, ˜ S ) ( s ) i ∀ s ∈ ˜ S, i = 1 , . . . , q s . In their stability proof, the authors of [29] assume that co-advisors’ matches can only increase. This neednot be the case and their algorithm is also not guaranteed to terminate. We specify the quota function Q on the two-sided market ( A, S ) through the Python-dictionary notation { a : Q ( a ) } ∪ { s : Q ( s ) } , analogously on three-sided markets. lgorithm 3: PhD Market - PhD Algorithm with Quotas
Input:
PhD market (
A, S, C, P, Q ) Output: stable matching µ strictify the preferences P AS on ( A, S ) and P SC on ( S, C ) do µ AS ← GS ( M = S, W = A, P AS , Q | ( A,S ) ).˜ Q SC ← { s : countMatches ( µ AS , s ) | s ∈ S } ∪ { c : q c | c ∈ C } µ SC ← GS ( M = S, W = C, P SC , ˜ Q SC ). Q.update ( { s : Q ( s ) + countMatches ( µ SC , s ) − ˜ Q SC ( s ) | s ∈ S } ) while Q | ( S,C ) (cid:54) = ˜ Q SC let matching µ such that student s is matched to advisors µ AS ( s ) and co-advisors µ SC ( s ), fill the remaining spots of all persons with themselves return µ Propositions 10, 30, 31 are similar. For example in Proposition 10, if Q ( T ) AS , ˜ Q ( T ) SC are the quotason the ( A, S ) and (
S, C ) market at the final iteration of the PhD algorithm, ( A, ˜ S ) is replacedby ( A, S, Q ( T ) AS ) and ( ˜ S m , C ) by ( S, C, ˜ Q ( T ) SC ).We now explore a few variants of Algorithm 3. Call PolyGS the variant of the two-sided GS algorithm that allows the same pair to match more than once (in Appendix A.2.2),and
UniqueGS the variant in which the same pair can match at most once (as discussed inSection 2), each with a different definition of what a valid and stable matching is (contrastDefinition 21 with Definition 23). Now suppose that each student can have several projects,but should never be assigned two projects with the same advisor or the same co-advisor. Fromthe proof of Theorem 11, it is easy to see that it continues to work if we use the
UniqueGS algorithm on both sides of the market. This would not have been possible with the extendedmarket construction since the extended market discards the information that some persons arereplicas of the same person. Another variant could be that any student should never have twoprojects with the same advisor, but he can be co-advised by the same person more than once.Then, one can use the
UniqueGS algorithm on the (
A, S ) market and the
PolyGS algorithmon the (
S, C ) market. Optimality also holds for these variants. However, if we only requirethat the three-sided matching µ is a set, i.e. the same triple can match at most once, but thesame pair on either ( A, S ) or (
S, C ) can match more than once, this cannot be addressed withAlgorithm 3.
In this section, we extend 3-sided markets to n -sided markets for n ≥
2. This model is appro-priate when n sides must be matched in the following way. There is a start side and an end sideand the i -th side only cares about the ( i − i + 1)-th side separately. As an example,consider the four-sided market that consists of advisors, students, co-advisors and buildings.The additional market is such that the co-advisor is responsible for finding a building once heis matched to a student. Only full matches are possible: if a co-advisor cannot find a building,the student cannot match with this co-advisor. The student only cares about the building inthe sense that he prefers being in any building rather than not being matched at all. We giveanother example in Appendix E.1 for parcel shipments.Let S , . . . , S n the n ≥ n -sided matching market with preferences P and quotas Q is described by (( S , . . . , S n ) , P, Q ). In general, preferences P are such that n -sided markets with cyclic preferences are different in the sense that they assume that the i -th side haspreferences over the ( i + 1)-th side modulo n [13]. ( s k ) are the preferences of s k ∈ S k and can be described by a total pre-order on S × · · · × S k − × S k +1 × · · · × S n ∪ { ( s k , . . . , s k ) } , where ( s k , . . . , s k ) ∈ S n − k means that s k stays single.We consider markets such that s k ∈ S k has separate preferences P k − ← k over S k − ∪ { s k } (for k >
1) and P k → k +1 over S k +1 ∪{ s k } (for k < n ), and is indifferent between participants from theother sides. Call market k the two-sided market ( S k , S k +1 , P k ), where P k = { P k ← k +1 , P k → k +1 } are the two-sided preferences between S k and S k +1 . The PhD market in our setting is hencespecified by (( S , . . . , S n ) , ( P , . . . , P n − ) , Q ). When we write > s k , it is implicit whether it refersto P k − ← k ( s k ) or P k → k +1 ( s k ). Definition 12.
A matching is a set µ ⊂ S × · · · × S n such that each person is matched up tohis quota q p . For s k ∈ S k , define the match partners of s k as µ ( s k ) = { ( s , . . . , s k − , s k +1 , . . . , s n ) | ( s , . . . , s k − , s k , s k +1 , . . . , s n ) ∈ µ } . The matching must satisfy | µ ( p ) | ≤ q p := Q ( p ) ∀ p ∈ S ∪ · · · ∪ S n . When | µ ( p ) | < q p , we fill µ ( p ) to size q p with copies of the ( n − -tuple ( p, . . . , p ) . Let µ k the matching restricted to the market ( S k , S k +1 , P k ), i.e., µ k = { ( s k , s k +1 ) | ( s , . . . , s n ) ∈ µ } ⊂ S k × S k +1 . We also fill µ k − ( s k ) and µ k ( s k ), the match partners of s k , to capacity q s k . Wenow define stability in these n -sided markets, but restrict all quotas to one for simplicity. Anextension to arbitrary quotas is possible in the same spirit as Section 3.5. With a slight abuseof notation, we again use µ ( p ) , µ k ( p ) to refer to the single elements of the sets respectively. Thematching µ is individually rational if it is individually rational on the two-sided markets. Wenow define stability in terms of two-sided stability. Definition 13.
The matching is stable if it is individually rational and there exists no blocking n -tuple ( s , . . . , s n ) ∈ S × · · · × S n \ µ such that for all k = 1 , . . . , n − we have either ( s k , s k +1 ) ∈ µ k or ( s k , s k +1 ) blocks µ k . In other words, for all k = 2 , . . . , n , both persons in the couple ( s k − , s k ) improve theirmatch or, if s k is matched, they can keep their match, i.e., s k − = µ k − ( s k ). At least one( s k − , s k ) has to improve their match for some k . Analogously to Proposition 4, we have anecessary condition for blocking tuples in n -sided markets, which is proven in Appendix E.2. Proposition 14. If ( s , . . . , s n ) ∈ S × · · · × S n blocks µ , there exists some k = 1 , . . . , n − such that µ j − ( s j − ) = s j ∀ ≤ j ≤ ks k +1 > s k µ k ( s k ) s k > s k +1 µ k ( s k +1 ) . Define M = S and, for k > , M k = { s k ∈ S k | µ k ( s k ) (cid:54) = s k } is the set of matched personsamong S k . Then, at least one of the matchings µ k | ( M k ,S k +1 ) must be blocked by ( s k , s k +1 ) . Again, stable matchings exist and the extension of the PhD algorithm to n sides is depictedin Algorithm 4. The superscript ( τ ) denotes the iteration number and the subscript k refers toa submarket of the k -th market ( S k , S k +1 ). The algorithm progresses by consecutively findinga matching on a submarket of ( S k , S k +1 ) for k = 1 , . . . , n −
1. In the k -th market, only thepersons in S k participate who found a match in the ( k − k + 1)-th two-sided market, this person will also not find a matchin later iterations and he is therefore removed unless he is part of the first or last side. Thealgorithm iterates until no person is removed. All removed and unmatched persons stay single. A submarket consists of a subset of the persons with preferences restricted to the persons that are part ofthe submarket. lgorithm 4: n -Sided PhD Market – n -Sided PhD Algorithm without Quotas Input:
PhD market (cid:0) ( S , . . . , S n ) , ( P , . . . , P n − ) (cid:1) , quotas Q = 1 Output: stable matching µ strictify the preferences P , . . . , P n − , set τ ← S (1) k ← S k for all k = 1 , . . . , n do τ ← τ + 1 M ( τ )1 ← S ( τ )1 for k = 1 , . . . , n − do µ ( τ ) k ← GS ( M ( τ ) k , S ( τ ) k +1 , P k ) // matching on a submarket of ( S k , S k +1 ) let M ( τ ) k +1 the matched persons among S ( τ ) k +1 in µ ( τ ) k let U ( τ ) k the unmatched persons among S ( τ ) k in µ ( τ ) k endfor k = 2 , . . . , n − do S ( τ +1) k ← S ( τ ) k \ U ( τ ) k endwhile (cid:83) n − k =2 U ( τ ) k (cid:54) = ∅ match the persons according to matchings µ ( τ )1 , . . . , µ ( τ ) n − , the removed and unmatchedpersons stay single return µ The algorithm produces a valid matching, i.e., no person is partially matched or matchedmore than once. Indeed, a person can be matched at most once since the GS algorithm matchesthe same person at most once on each two-sided market, in particular at the final iteration.Suppose that a person is partially matched, then he must be returned as part of some tuple( s , . . . , s k ) ⊂ S ×· · ·× S k with 1 < k < n . This can only happen if s k could not find a match onthe market (cid:0) S ( T ) k , S ( T ) k +1 (cid:1) , hence s k ∈ U ( T ) k at the final iteration T of the PhD algorithm. Then, (cid:83) n − k =2 U ( T ) k could not have been empty. For the stability proof, we assume that the proposingside is fixed over iterations in each two-sided market. As for three-sided markets, this doesnot matter. In fact, we can replace the GS algorithms by any other (individually rational)stable matching algorithms since the set of matched persons is the same at each iteration.The matching algorithms used at the final iteration affect the properties of the matching, e.g.,optimality. When the GS algorithms are used on the two-sided markets, the PhD algorithmcan again be efficiently implemented in O ( (cid:80) n − k =1 | S k || S k +1 | ).Before proving stability, we establish a property that extends Lemmas 6 and 7. First of all,note that M ( τ )1 and S ( τ ) n never change over iterations and M ( τ ) k ⊂ S ( τ ) k ∀ τ and k = 1 , . . . , n .Furthermore, the sets of available persons cannot increase over iterations: S ( τ +1) k ⊂ S ( τ ) k ∀ τ and k = 2 , . . . , n −
1. For s k ∈ S k , we call ( S k − , S k ) s k ’s left market since it is the first market s k participates in, and ( S k , S k +1 ) its right market. Similarly to the three-sided case, a person’smatch cannot decrease over iterations on its left market, unless the person cannot find a matchon its right market and is removed. Lemma 15.
The match of person s k +1 ∈ S k +1 on the market ( S k , S k +1 ) cannot decrease.More precisely, let µ ( τ ) k the matching at iteration τ as in the algorithm. Then, µ ( τ ) k ( s k +1 ) ≥ s k +1 µ ( τ − k ( s k +1 ) ∀ τ ≥ , with s k +1 ∈ S ( τ ) k +1 , and k = 1 , . . . , n − . Moreover, M ( τ − k \ U ( τ − k ⊂ M ( τ ) k ∀ k = 2 , . . . , n − . The proof of this Lemma is given in Appendix E.2. Finally, we prove that the PhD algorithmin Algorithm 4 produces a stable matching. 17 heorem 16.
The n -sided PhD Algorithm returns a stable matching.Proof. By an analogue of Proposition 29, we can assume strict preferences. The matching mustbe individually rational since the GS algorithms never match unacceptable partners on the two-sided markets. Suppose that ( s , . . . , s n ) ∈ S × · · · × S n is a blocking tuple. Proposition 14means that µ k | ( M ( T ) k ,S k +1 ) is blocked by ( s k , s k +1 ) for some k . Since µ j − ( s j − ) = s j ∀ ≤ j ≤ k , s , . . . , s k must all be matched and cannot have been removed. Assume that s k +1 was notremoved during the PhD algorithm. Since s k +1 ∈ S ( T ) k +1 , Fact 26 implies that ( s k , s k +1 ) alsoblocks µ k | ( M ( T ) k ,S ( T ) k +1 ) . This contradicts the stability of the GS algorithm in the k -th market( M ( T ) k , S ( T ) k +1 ) at the final iteration. If s k +1 was removed during the PhD algorithm, k + 1 < n and it must be that s k +1 participated in the market ( M ( τ ) k +1 , S ( τ ) k +2 ) at some iteration τ when s k +1 was removed. Independently of which side proposes, this means that s k +2 was already removedbefore or matched to a better ˜ s k +1 > s k +2 s k +1 . Suppose that s k +2 is not removed in the PhDalgorithm. By Lemma 15, s k +2 is matched in µ k +1 to µ k +1 ( s k +2 ) ≥ s k +2 ˜ s k +1 > s k +2 s k +1 . Hence( s k +1 , s k +2 ) / ∈ µ and it also does not block µ k +1 (since this would require µ k +1 ( s k +2 ) ≤ s k +2 s k +1 ). So ( s , . . . , s n ) cannot block µ . If s k +2 was removed, apply the reasoning to s k +2 insteadof s k +1 . It must eventually stop because no student among S n is removed in the algorithm. We have shown that stable matchings exist in three-sided markets for matching students withadvisors and co-advisors under suitably defined preferences. We have introduced an algorithmfor generating three-sided stable matchings using any two-sided stable matching algorithm asbase matching engine. It runs in polynomial time, and it has a number of optimality propertieswhen the two-sided GS algorithm is used. We further illustrated the challenges with incompati-ble advisor pairs. Although the proposed modification does not always return a stable matching(Section 3.4), it may work well in practice. Finally, we generalized the setting to n -sided mar-kets with arbitrary quotas and extended the PhD algorithm to find stable matchings in thesemarkets.We have shown that three-sided student-optimality is not possible, but conjecture thatthe PhD algorithm returns an advisor-optimal matching when advisors propose to students.Future work could study three-sided optimality more in detail, rather than relying on two-sided optimality as we did. Note that the PhD algorithm is not strategy-proof, i.e., personscan misrepresent their preferences to obtain more satisfying matches. An interesting questionis how much information a person needs to successfully manipulate the outcome (see [22] fortwo-sided markets with incomplete information).As mentioned in Section 3.5, the PhD algorithm cannot (easily) be extended when the sametriple (rather than pair) can be matched at most once. We wonder if stable matchings exist, andhow to find them. We also ask the same question when not all advisor pairs are compatible, orwhen students’ preferences need not be consistent (Section 3.4). Even if stable matchings do notalways exist for these variants, it would be interesting to study if deciding so is NP-complete,similarly to the line of work in [17, 13, 10].Our approach assumes that all persons know their (true) preferences. Especially if the mar-ket is large, persons may not know each other. In practice, the PhD algorithm can be combinedwith preference modelling techniques, such as preference elicitation [5] or handcrafted criteria[15]. These techniques make use of a preliminary matching (based on tentative preferences) togive people time to form their preferences. 18 eferences [1] Ahmet Alkan. “Nonexistence of stable threesome matchings”. In: Mathematical socialsciences
Journal of Experimental Algorithmics (JEA)
16 (2011), pp. 1–1.[3] P´eter Bir´o and Flip Klijn. “Matching with couples: a multidisciplinary survey”. In:
Inter-national Game Theory Review
Mathematics of operations research
Mathematical Social Sciences
A theory of stability in many-to-many matchingmarkets . 2004.[8] David Gale and Lloyd S Shapley. “College admissions and the stability of marriage”. In:
The American Mathematical Monthly
The American Mathematical Monthly
European Symposium on Algorithms . Springer. 2007, pp. 558–569.[11] Stephen Y Itoga. “The upper bound for the stable marriage problem”. In:
Journal of theOperational Research Society
Stable marriage and its relation to other combi-natorial problems: An introduction to the mathematical analysis of algorithms . 1997.[13] Chi-Kit Lam and C Gregory Plaxton. “On the existence of three-dimensional stable match-ings with cyclic preferences”. In:
International Symposium on Algorithmic Game Theory .Springer. 2019, pp. 329–342.[14] David F Manlove, Iain McBride, and James Trimble. ““Almost-stable” matchings in theHospitals/Residents problem with Couples”. In:
Constraints
Two-Sided Matching Markets in the ELLIS 2020 PhD Program .2021. arXiv: .[16] Eric J McDermid and David F Manlove. “Keeping partners together: algorithmic resultsfor the hospitals/residents problem with couples”. In:
Journal of Combinatorial Optimiza-tion
SIAM Journal on Discrete Mathematics
Journal of Algorithms
Econometrica:Journal of the Econometric Society (1984), pp. 47–57.[20] Alvin E Roth. “The evolution of the labor market for medical interns and residents: acase study in game theory”. In:
Journal of political Economy
Mathematics of Operations Research
Games and Economic Behavior
The Americaneconomic review (1991), pp. 415–440.[24] Alvin E Roth and Marilda Sotomayor. “Two-sided matching”. In:
Handbook of gametheory with economic applications
Mathematical social sciences
Two-sided matching: study in game-theoretic modeling andanalysis . Cambridge University Press, 1990.[27] LB Wilson. “An analysis of the stable marriage assignment algorithm”. In:
BIT NumericalMathematics
Journal of Combinatorial Optimization (2019).[29] Feng Zhang et al. “Three-dimensional stable matching with hybrid preferences”. In:
Jour-nal of Combinatorial Optimization
Journal of Combinatorial Optimization
A Gale–Shapley Algorithm and Variants
A.1 Original GS Algorithm
The GS algorithm [8] is depicted in Algorithm 5. It is typically exposed by letting men proposein parallel, this is equivalent.
Algorithm 5:
Marriage Market - GS Algorithm [8]
Input: marriage market (
M, W, P ) Output: matching µµ ← { ( w, w ) | w ∈ W } // match every woman to herself while there is an unmatched man m , i.e., µ ( m ) = ∅ do w ← offerNext ( P, m ) // partner: woman or man himself if w = m then µ ← µ ∪ { ( m, m ) } // man proposed to himself and accepts else if m > w µ ( w ) then µ ← µ \ { ( µ ( w ) , w ) } ∪ { ( m, w ) } // unmatch ( µ ( w ) , w ) , match ( m, w ) endendreturn µ A.2 Stability and Optimality of the Many-to-Many GS Algorithm
In this section, we prove stability, man-optimality and woman-pessimality of the matchingreturned by Algorithm 1 discussed in Section 2. We also prove that the set of matched personsis the same in all stable matchings (when preferences are strict). The proofs are similar to theproofs in one-to-one markets [8, 12, 26]. 20e are in the setting when both men and women have quotas, yet the same man and womancan match at most once. We formally recall the definition of stability.
Definition 17.
A matching µ is unstable if there exists a pair ( m, w ) ∈ ( M × W ) ∪ { ( m, m ) | m ∈ M } ∪ { ( w, w ) | w ∈ W } such that ( m = w ∨ m / ∈ µ ( w )) and w > m µ ( m ) and m > w µ ( w ) . ( m, w ) is called a blocking pair of µ . (The case m = w corresponds to individual rationality.) We show stability. This works for non-strict preferences as well.
Proposition 18.
Algorithm 1 terminates and returns a valid and stable matching.Proof.
The algorithm terminates because each man proposes to each woman at most once, soit runs in time O ( | M || W | ). The returned matching µ satisfies the quota because | µ ( w ) | = q w ispreserved over iterations for all women w and the algorithm terminates only once | µ ( m ) | = q m for all men m . Furthermore, a man can be matched to a woman at most once. Therefore, thematching is valid.To prove stability, we use the following property: over iterations, the weakest match of anywoman w cannot decrease. Now let ( m, w ) a blocking pair of the matching µ . If m = w := p ∈ M ∪ W , this implies p > p µ ( p ), but this can never happen because only acceptable partnersare matched. Otherwise, m is a man and w is a woman and there exist m (cid:48) , w (cid:48) (not necessarilyman and woman) such that w > m w (cid:48) ∈ µ ( m ) and m > w m (cid:48) ∈ µ ( w ), where m (cid:48) is the weakestelement of µ ( w ). Since w > m w (cid:48) ∈ µ ( m ) and m proposes to women in decreasing order of hispreferences, m must have proposed to w . Since m > w m (cid:48) ∈ µ ( w ) and the weakest match cannever decrease, w would never have rejected m , which contradicts m / ∈ µ ( w ).The remaining results of this section only hold for strict preferences. We have man-optimality for strict preferences. Proposition 19.
Assume strict preferences and men propose. The algorithm returns a man-optimal result µ , i.e., for every man m : µ ( m ) i ≥ m λ ( m ) i ∀ i = 1 , . . . , q m , where λ is stable (andthe assignments µ ( m ) , λ ( m ) are ordered from best to worst in terms of ≥ m ). The algorithmreturns a unique result independently of the order in which men propose.Proof. Uniqueness follows immediately from optimality. We say that woman w is achievableto man m if there exists a stable matching λ such that m ∈ λ ( w ). It is enough to prove thata man m is never rejected by an achievable woman. Let m the first man who is rejected byan achievable woman w during the execution of the algorithm. Since w is achievable to m , let λ the stable matching in which m is matched to w , i.e., m ∈ λ ( w ) (and w ∈ λ ( m )). Since m was rejected (and is acceptable to w ), there must be q w other men who are all preferred by thewoman: m i > w m ∈ λ ( w ) ∀ i = 1 , . . . , q w . Because none of these other men m i was yet rejectedby an achievable woman, w ≥ m i λ ( m i ) q mi ∀ i . Since m ∈ λ ( w ), there must exist m i / ∈ λ ( w ).Thus w (cid:54) = λ ( m i ) q mi and w > m i λ ( m i ) q mi ∈ λ ( m i ). Thus, ( m i , w ) (with the additional property m i / ∈ λ ( w )) blocks λ , which contradicts the stability of λ . Hence w is not achievable to m .We can prove man-man/woman-woman coincidence of interest and man-woman conflict ofinterest, as was shown for one-to-one and many-to-one markets [21, 12]. Proposition 20.
Let ( M, W, P ) a two-sided market with strict preferences and µ, λ two stablematchings on this market. The preferences of men and women are opposed, i.e., µ ( m ) i ≥ m λ ( m ) i ∀ m ∈ M, i = 1 , . . . , q m ⇐⇒ µ ( w ) i ≤ w λ ( w ) i ∀ w ∈ W, i = 1 , . . . , q w . By contradiction, assume there exists a man m and let i the smallest index such that µ ( m ) i < m λ ( m ) i . Byassumption, µ ( m ) j ≥ m λ ( m ) j > m λ ( m ) i for all j < i . Also, λ ( m ) i > m µ ( m ) i ≥ m µ ( m ) j for all j ≥ i and thismeans that man m was rejected by λ ( m ) i since m applied to µ ( m ) i < s λ ( m ) i . roof. It is enough to prove one direction because men and women are handled symmetrically.Suppose µ ( m ) i ≥ m λ ( m ) i ∀ m ∈ M, i = 1 , . . . , q m and there exists a woman w such that µ ( w ) j > w λ ( w ) j for some j . Let j the smallest index with this property. Let m = µ ( w ) j and k the index such that w = µ ( m ) k . We have w / ∈ λ ( m ) since λ ( w ) l ≥ w µ ( w ) l > w µ ( w ) k = m if l < k and λ ( w ) l ≤ w λ ( w ) k < w µ ( w ) k = m if l ≥ k . This implies µ ( m ) k (cid:54) = λ ( m ) k , so µ ( m ) k > m λ ( m ) k . Therefore, ( m, w ) blocks λ , so λ cannot be stable.Proposition 19 tells us that the algorithm returns a man-optimal matching. From Propo-sition 20, we know that the matching is also woman-pessimal. Based on man-optimality andwoman-pessimality, we now show that the set of matched persons is the same in all stablematchings, as already stated in Section 2. A proof for the one-to-one case can be found in [12]. Proposition 1.
Let ( M , W , P ) a two-sided market with strict preferences. The matchedpersons are the same in any stable matching.Proof. Denote the matched men in an arbitrary matching µ by R ( µ ). Let µ the GS matching(with men proposing) and λ an arbitrary stable matching. It is sufficient to show that thematched persons are the same in µ and λ . By man-optimality, µ ( m ) ≥ m λ ( m ) ∀ m ∈ M .Whenever m is matched in λ , we have µ ( m ) ≥ m λ ( m ) > m m , hence µ ( m ) > m m , so m is alsomatched in µ . In other words, R ( λ ) ⊂ R ( µ ). In particular, the number of matched men in µ is greater or equal to the number of matched men in λ . From woman-pessimality, we havethat the number of matched women in λ must be greater or equal to the number of matchedwomen in µ . Since the number of matched men equals the number of matched women for agiven matching, we have | R ( λ ) | ≥ | R ( µ ) | , hence R ( λ ) = R ( µ ). We can apply a similar reasoningto show that the matched women are the same in all matchings. A.2.1 Interpretation as a Two-Sided Market with Substitutable Preferences
We found the above proofs most intuitive and they are extensions of the proofs in the one-to-onesetting. However, one may also see the many-to-many setting of Section 2 as a special case of[23, 7] with strongly substitutable preferences. The algorithm presented here is a special caseof the algorithm presented in [23] and of the T-algorithm presented in [7]. Below, we show thatpreferences are indeed strongly substitutable.Define the choice set Ch p ( S ) of person p as p ’s most preferred subset of persons S . Pref-erences are substitutable if for any person p and any sets S ⊂ S (cid:48) , b ∈ Ch p ( S (cid:48) ∪ { b } ) implies b ∈ Ch p ( S ∪ { b } ). In other words, b is preferred independently of who else is preferred by p .Preferences are strongly substitutable if this holds whenever S (cid:48) is preferred to S (instead of S ⊂ S (cid:48) ). Strong substitutability implies substitutability.In our setting, all preferences are strongly substitutable. Assume strict individual prefer-ences. Man m ’s preferences over subsets of W are such that [19]: • Any multi-set S ⊂ W of size larger than q m is unacceptable: S < m ∅ . • For any sets
S, T ⊂ W of size at most q m , obtain ˜ S = { s , . . . , s q m } , ˜ T = { t , . . . , t q m } byfilling S and T to size q m with copies of m and ordering them with respect to the individualpreferences ≤ m . If s i ≤ m t i ∀ i ∈ , . . . , q m (and at least one inequality is strict), then S ≤ m T ( S < m T ), where the latter ≤ m , < m are over sets.For the case with unique pairs, m ’s choice set Ch m ( W (cid:48) ) of any set of women W (cid:48) ⊂ W consistsof the q m most preferred acceptable women among W (cid:48) or fewer if less women are acceptable.Women’s preferences are analogous. The authors of [19] note that these preferences are sub-stitutable, and it is easy to verify that they are strongly substitutable so that the additionalresults from [7] apply. 22ince all preferences are substitutable, the algorithm described in [23] finds a stable match-ing that is man-optimal. Nothing is said about woman-pessimality. Moreover, pairwise-stablematchings are generally not group-stable in many-to-many markets [26]. However, strongerstatements can be made for strongly substitutable preferences [7]. When one side has substi-tutable preferences and the other side has strongly substitutable preferences, the man-optimalmatching is woman-pessimal and vice versa [7, Theorems 6.1 and 9.8]. In addition, the set of(pairwise) stable matchings equals the set of setwise-stable matchings [7, Corollary 9.9]. Thesetwise-stable set is the set of individually rational matchings that cannot be blocked by acoalition that forms new links only among its members, but may preserve its links to agentsoutside of the coalition [20, 25]. Setwise stability is a more useful notion than group stability inmany-to-many markets since the core may be empty or may contain individually irrational orpairwise unstable matchings [7]. Since all preferences are strongly substitutable, these resultsimply that the matching returned by Algorithm 1 is stable, man-optimal and woman-optimal.Moreover, it is setwise-stable. Note however that setwise-stability is not a too strong propertyhere because the preferences over groups are treating all spots as independent (except for thefact that a person can appear in at most one spot). A.2.2 Generalizations of the Two-Sided Gale–Shapley Matching Algorithm
The setting for Algorithm 1 can be generalized when the same man and woman can match morethan once. As an example, consider the market made up of households and cleaning persons. Ahousehold wants to be cleaned a maximum number of times per month and a cleaning personcan clean a maximum number of times per month. Different from before, it is possible that thesame cleaning person cleans the same household more than once. Cleaning person w wants toclean at most q w households.This can be modelled as before with the following differences. A matching µ is a multi-set µ ⊂ M × W such that | µ ( p ) | ≤ q p . From the definition of a blocking pair, we remove therequirement ( m, w ) / ∈ µ . Then, we can modify the many-to-many GS algorithm as follows. Eachman proposes to his most preferred woman among the women to whom he did not propose q m times yet. If a man has proposed to all his acceptable women q m times, he fills the remainingspots with himself (since he is always acceptable to himself). The resulting matching is stable,man-optimal and woman-pessimal (if men propose). Inspired by the GS algorithm applied tothe college admissions problem [20], this is equivalent if we map both sides to an extendedmarket, run the one-to-one GS algorithm on the extended market, and finally map it back tothe original market. See Appendix B.4 to see how this is done for three-sided markets.In another extension, each cleaning person w may want to clean household m at most q m,w times. Then, a matching must additionally satisfy that w is matched at most q m,w times to m . A pair ( m, w ) only blocks the matching µ if m and w are matched less than q m,w timesin µ . We can adapt the many-to-many GS algorithm as follows. Man m proposes to his mostpreferred woman w to whom he did not propose q m,w times yet. If no acceptable women withthis property are left, he fills the remaining spots with himself (since he is always acceptable tohimself). The resulting matching is stable, man-optimal and woman-pessimal (if men propose). A.3 Behavior of the GS Algorithm when People are Removed
We prove Lemma 5 for many-to-many markets, see [9] for one-to-one markets. In a multi-set, the same element can appear more than once, so that the same man and woman can bematched more than once. An (ordered) multi-set A can be thought of as a finite sequence. Removing an element a ∈ A from the list (with A \ { a } ) removes the first occurrence of a in the sequence A . The element a is added(with A ∪ { a } ) by appending it at the end of the sequence, independently of whether a ∈ A or a / ∈ A . Note thatwhen µ is a multi-set, the notation µ ( m ) = { m | ( m, w ) ∈ µ } is a multi-set and lists men more than once if theyappear in multiple pairs in µ , same for µ ( w ). emma 5. Consider a market ( M, W, P ) with strict preferences P and subsets M ⊂ M, W ⊂ W . Let µ = GS ( M, W, P ) , µ = GS ( M , W, P | ( M ,W ) ) and µ = GS ( M, W , P | ( M,W ) ) . • Independently of whether men or women propose (but the same for µ and µ ), it holdsthat µ ( m ) ≥ m µ ( m ) ∀ m ∈ M , µ ( w ) ≤ w µ ( w ) ∀ w ∈ W . • Independently of whether men or women propose (but the same for µ and µ ), it holdsthat µ ( m ) ≤ m µ ( m ) ∀ m ∈ M, µ ( w ) ≥ w µ ( w ) ∀ w ∈ W .Proof. By the man-optimality of the GS algorithm in the many-to-many setting (with strictpreferences), the order in which free men propose does not matter. So we can choose the orderin a suitable fashion.We first prove µ ( m ) ≥ m µ ( m ) ∀ m ∈ M , µ ( w ) ≤ w µ ( w ) ∀ w ∈ W when men propose.Consider the execution of GS ( M, W, P ) and first let only men M propose in the GS algorithmuntil it terminates and returns µ . Continue the GS algorithm and let all men propose, includingmen M if they become unmatched, until it returns µ . The inequalities follow since men M cannot get better matches when they continue proposing to less preferred women and womenonly accept better men.We next prove µ ( m ) ≤ m µ ( m ) ∀ m ∈ M, µ ( w ) ≥ w µ ( w ) ∀ w ∈ W when men propose.Consider the execution of µ = GS ( M, W , P | ( M,W ) ). This is the same as running GS ( M, W, P )where in addition a man is rejected whenever he proposes to a woman in W \ W . Whenever aman is rejected by a woman w ∈ W in the execution of µ , he is also rejected by a woman inthe execution of µ , hence µ ( m ) ≤ m µ ( m ) ∀ m ∈ M . This also means that each man proposesto at least as many women in µ as in µ and the women’s matches can only become better, µ ( w ) ≥ w µ ( w ) ∀ w ∈ W .When women propose, it follows from symmetry.Note that this result holds for the many-to-many GS algorithm (Algorithm 1) as well as forthe extensions in Section A.2.2. B Three-Sided Markets
B.1 Three-Sided Stability for Consistent Preferences
When quotas are equal to one, the two-sided stability definition can be extended as follows basedon the student preferences in Eq. (1), where we additionally allow only the advisor-student orthe student-co-advisor side to change: ( a, c ) > s µ ( s ) ⇐⇒ a > s µ ( s ) A ∨ ( a = s µ ( s ) A ∧ c > s µ ( s ) C ) s > a µ ( a ) S ∨ s = µ ( a ) S s > c µ ( c ) S ∨ s = µ ( c ) S . To check whether a matching is stable, a = s µ ( s ) A can be replaced by a = µ ( s ) A . Indeed,whenever ( a, s, c ) blocks µ and a = s µ ( s ) A , this means that µ ( s ) A (cid:54) = s and (˜ a = µ ( s ) A , s, c ) alsoblocks µ such that ˜ a = s µ ( s ) A is satisfied with an equality. From now on, we assume that theblocking triple always has this property. Then, the previous can be reformulated as: a > s µ ( s ) A s > a µ ( a ) S s > c µ ( c ) S c > s µ ( s ) C (added) ∨ c > s µ ( s ) C s = µ ( a ) S s > c µ ( c ) S ∨ a > s µ ( s ) A s > a µ ( a ) S s = µ ( c ) S . µ ( s ) A ∈ A ∪ { s } and a = s µ ( s ) A together imply µ ( s ) A ∈ A because no student is indifferent between himselfand any advisor, so ( µ ( s ) A , s, c ) ∈ A × S × C .
24e have added the line in the first clause as highlighted since it does not change the definitionof stability. If not, s < s c ≤ s µ ( s ) C implies that s is matched and is hence covered by thethird clause already for ( a, s, µ ( s ) C ). It is clear that the same matchings are stable under thisdefinition as under Definition 3.We can also arrive at this stability definition if we define the student’s preferences symmet-rically: ( a, c ) > s (˜ a, ˜ c ) ⇐⇒ ( a > s ˜ a ∧ ( c > s ˜ c ∨ c = ˜ c )) ∨ (( a > s ˜ a ∨ a = ˜ a ) ∧ c > s ˜ c ) , ( a, c ) ≥ s (˜ a, ˜ c ) ⇐⇒ a ≥ s ˜ a ∧ c ≥ s ˜ c, which defines ( a, c ) = s (˜ a, ˜ c ) ⇐⇒ a = s ˜ a ∧ c = s ˜ c. (3)The same matchings are stable, whether we define > s as in Eq. (1) or as in Eq. (3). Importantly,this definition shows that advisors and co-advisors are treated symmetrically. B.2 Stability Definition for Arbitrary Quotas
We extend Definition 3 of stability to arbitrary quotas. For person p , define the preferencebetween an individual p and a set K as p > p K ⇐⇒ ∃ p ∈ K : p > p p . Definition 21.
The triple ( a, s, c ) ∈ A × S × C blocks µ if there exists k ∈ { , . . . , q s } such that:if µ ( s ) k = ( s, s ) (unmatched): (cid:40) a > s µ ( s ) k,A s > a µ ( a ) S and (cid:40) c > s µ ( s ) k,C s > c µ ( c ) S , or if µ ( s ) k (cid:54) = ( s, s ) (matched): (cid:40) a > s µ ( s ) k,A s > a µ ( a ) S or (cid:40) c > s µ ( s ) k,C s > c µ ( c ) S .µ ( s ) k,A is the advisor that is matched to the k -th spot of s in µ . We want to point out thatwhen student s matches with several advisors and co-advisors, say µ ( s ) A = { a , a } , µ ( s ) C = { c , c } , a > s a , c > s c , quotas q a = q a = q c = q c = 1 , q s = 2 for simplicity, the matchescan be either µ = { ( a , s, c ) , ( a , s, c ) } or µ = { ( a , s, c ) , ( a , s, c ) } . None of them isblocked because advisors and co-advisors have no incentive to change because they are alreadymatched to s .Analogously to Proposition 4, we have the following proposition. We omit the proof. Proposition 22. If ( a, s, c ) blocks µ on the market ( A, S, C, P, Q ) , one of the following musthold: (cid:40) a > s µ ( s ) A s > a µ ( a ) S or a ∈ µ ( s ) A c > s µ ( s ) C s > c µ ( c ) S . In other words, either ( a, s ) blocks µ | ( A,S,Q AS ) or ( s, c ) blocks µ | ( S,C,Q SC ) , where the quotas Q AS , Q SC on the markets ( A, S ) and ( S, C ) satisfy • Q AS ( p ) = Q ( p ) ∀ p ∈ A ∪ { s } and, • Q SC ( p ) = Q ( p ) ∀ p ∈ C , Q SC ( s ) ≥ countMatches ( µ, s ) , where countMatches ( µ, s ) counts the number of times that s is matched in µ excluding himself. When the same pair can match at most once on the associated two-sided markets, we adaptDefinition 17 as follows: 25 efinition 23.
The triple ( a, s, c ) ∈ A × S × C blocks µ if there exists k ∈ { , . . . , q s } such that:if µ ( s ) k = ( s, s ) (unmatched): a > s µ ( s ) k,A s > a µ ( a ) S s / ∈ µ ( a ) S and c > s µ ( s ) k,C s > c µ ( c ) S s / ∈ µ ( c ) S , or if µ ( s ) k (cid:54) = ( s, s ) (matched): a > s µ ( s ) k,A s > a µ ( a ) S s / ∈ µ ( a ) S or c > s µ ( s ) k,C s > c µ ( c ) S s / ∈ µ ( c ) S . B.3 Stability on Two-Sided and Three-Sided Submarkets
We use the following facts rather often for two-sided and three-sided markets. Assume strictpreferences and assume quotas are equal to one for simplicity. When unmatched persons areremoved from a market, the restricted matching continues to be stable.
Fact 24.
For two-sided and three-sided markets, we have the following facts respectively: • Let µ a stable matching on the two-sided market ( M, W ) , and ( ˜ M , ˜ W ) a submarket thatcontains all matched persons, i.e., such that { m ∈ M | µ ( m ) (cid:54) = m } ⊂ ˜ M ⊂ M and { w ∈ W | µ ( w ) (cid:54) = w } ⊂ ˜ W ⊂ W . Then, the matching µ | ( ˜ M, ˜ W ) is stable on the market ( ˜ M , ˜ W ) . • Let µ a stable matching on the three-sided market ( A, S, C ) and ( ˜ A, ˜ S, ˜ C ) a submarketthat contains all matched persons, i.e., such that { a ∈ A | µ ( a ) (cid:54) = ( a, a ) } ⊂ ˜ A ⊂ A , { s ∈ S | µ ( s ) (cid:54) = ( s, s ) } ⊂ ˜ S ⊂ S and { c ∈ C | µ ( c ) (cid:54) = ( c, c ) } ⊂ ˜ C ⊂ C . Then, the matching µ | ( ˜ A, ˜ S, ˜ C ) is also stable on the market ( ˜ A, ˜ S, ˜ C ) .Proof. We exemplarily prove it for two-sided markets. By contradiction, let ( m, w ) ∈ ˜ M × ˜ W a blocking pair of µ | ( ˜ M, ˜ W ) . Then, it also blocks µ . Since w ∈ ˜ W , we have µ | ( ˜ M, ˜ W ) ( w ) = µ ( w )because w ∈ ˜ W means that its partner µ ( w ) must also be in the submarket, so w ’s match doesnot change. Since m ∈ ˜ M , we similarly have µ | ( ˜ M, ˜ W ) ( m ) = µ ( m ). If ( m, m ) with m ∈ ˜ M or( w, w ) with w ∈ ˜ W is a blocking pair, it is also the case.The extension to the case with quotas is straightforward and omitted. We use Fact 24 inthe proof of Proposition 4. We now show that when a person is unmatched in a market, he isalso unmatched in a larger market where more persons on the side of the person are added. Fact 25.
Let ( M, W ) a market and ( M , W ) , ( M, W ) two submarkets with M ⊂ M, W ⊂ W .Define R ( M, W ) as the set of matched persons in any stable matching on the market ( M, W ) (which is well-defined by Proposition 1). Then, p / ∈ R ( M , W ) implies p / ∈ R ( M, W ) , and p / ∈ R ( M, W ) implies p / ∈ R ( M, W ) .Proof. Use the GS algorithm to obtain R ( M, W ) for any market (
M, W ). The statement thenfollows from Lemma 5.If a pair blocks a matching, it also blocks the matching when restricted to any market thatcontains both persons of the blocking pair, analogously for three-sided markets.
Fact 26.
For two-sided and three-sided markets, we have the following facts respectively: A submarket consists of a subset of the persons with preferences restricted to the persons that are part ofthe submarket. Let µ an individually rational matching on the two-sided market ( M, W ) which is blockedby ( m, w ) . Let ( ˜ M , ˜ W ) a submarket such that m, w ∈ ˜ M ∪ ˜ W , ˜ M ⊂ M, ˜ W ⊂ W . Then, ( m, w ) also blocks µ | ( ˜ M, ˜ W ) . • Let µ an individually rational matching on the three-sided market ( A, S, C ) which is blockedby ( a, s, c ) . Let ( ˜ A, ˜ S, ˜ C ) a submarket such that a, s, c ∈ ˜ A ∪ ˜ S ∪ ˜ C, ˜ A ⊂ A, ˜ S ⊂ S, ˜ C ⊂ C .Then, ( a, s, c ) also blocks µ | ( ˜ A, ˜ S, ˜ C ) .Proof. In the matching µ | ( ˜ M, ˜ W ) , a person that is matched in µ on the market ( M, W ) staysmatched to the same partner if the partner is part of the market ( ˜
M , ˜ W ), and becomes matchedto himself otherwise. Therefore, µ ( p ) ≥ p µ | ( ˜ M, ˜ W ) ( p ) ∀ p ∈ ˜ M ∪ ˜ W . So ( m, w ) also blocks µ | ( ˜ M, ˜ W ) .This is analogous for three-sided markets. B.4 Extended Market
The extended three-sided PhD market is constructed from the extended markets of (
A, S ) and(
S, C ). On the two-sided market, replicate each person p according to his capacity q p withidentical preferences to obtain persons p , . . . , p q p , all with preferences equal to P ( p ). When-ever another person lists p , replace p by the indifferent preferences [ p , . . . , p q p ]. A matching ismapped from the extended market to the original market by assigning person p all the matchesof p , . . . , p q p in this order. This defines the inverse mapping. For example, µ ext is mapped tothe ordered multi-set µ ( s ) = { ( µ ext ( s k ) A , µ ext ( s k ) C ) | k = 1 , . . . , q s } for student s . The ordered µ ( s ) is mapped back to µ ext such that µ ext ( s k ) = ( µ ( s ) k,A , µ ( s ) k,C ) , k = 1 , . . . , q s , similarly foradvisors and co-advisors. Proposition 27.
Consider the original market with preferences P and the corresponding ex-tended market with preferences P ext . If µ ext is a stable matching under P ext , the correspondingmatching µ on the original market is stable under P . The converse is also true.Proof. If ( a, s ) blocks µ on the ( A, S ) side, there exists some k ∈ { , . . . , q s } such that: (cid:40) a > s µ ( s ) k,A =: p s,A s > a µ ( a ) S ⇐⇒ ∃ p a ∈ µ ( a ) S : s > a p a . Denote by p ext a person on the extended market that is mapped back to person p on the originalmarket. µ ( s ) k,A = p s,A implies that there exist s ext , p exts,A such that p exts,A = µ ext ( s ext ) A . Similarly,there exist a ext , p exta such that p exta = µ ext ( a ext ) S . Since p > p p = ⇒ p ext > p ext p ext forarbitrary persons p, p , p , we have that a ext > s ext p exts,A = µ ext ( s ext ) A and s ext > a ext p exta = µ ext ( a ext ) S . Hence ( a ext , s ext ) blocks µ ext | ( A ext ,S ext ) .If ( s, c ) blocks µ on the ( S, C ) side, we similarly have that ( s ext , c ext ) blocks µ ext | ( S ext ,C ext ) .If µ ( s ) k = ( s, s ), we can choose s ext and s ext such that s ext = s ext . Then, ( a ext , s ext , c ext ) blocks µ ext on the extended market. If µ ( s ) k (cid:54) = ( s, s ), either ( a ext , s ext , µ ( s ) k,C ) or ( µ ( s ) k,A , s ext , c ext )is a blocking triple.For the other direction, assume that ( a ext , s ext , c ext ) blocks µ ext . Then, ( a, s, c ) blocks µ . B.5 Strictification of Preferences
We show that a stable matching under the strictified preferences is also stable under the originalpreferences. Preferences are strictified by breaking some (or all) ties. The PhD algorithmstrictifies preferences by breaking all ties at the beginning. For simplicity, quotas are all equalto one and µ ( p ) refers to the single element of the set µ ( p ). More precisely, for i = 1 , . . . , q p , P ( p i ) is P ( p ) except that p is replaced by p i . efinition 28. The pre-order ≥ ˜ P is a strictification of the pre-order ≥ P on the two-sidedmarket ( A, S ) if p > Pp p = ⇒ p > ˜ Pp p for person p and p , p are persons for which > Pp isdefined. The superscript refers to the preferences which are used. Equivalently, p ≥ ˜ Pp p = ⇒ p ≥ Pp p . ˜ P is a strictification of P on the three-sided market ( A, S, C ) if the associated preferenceson the markets ( A, S ) and ( S, C ) are a strictification respectively. > Pp is also known as relaxation of the pre-order > ˜ Pp . Proposition 29.
Consider a two-sided or a three-sided market and let ˜ P be a strictification of P . If the matching µ is stable under ˜ P , it is stable under P .Proof. We first prove it for two-sided markets. By contradiction, assume that µ is not stableunder P . Then, there must exist a blocking pair ( m, w ) of µ such that m > Pw µ ( w ) and w > Pm µ ( m ) ( m = w also possible). This implies m > ˜ Pw µ ( w ) and w > ˜ Pm µ ( m ). Therefore,( m, w ) blocks µ under ˜ P and µ is not stable under ˜ P .Now consider three-sided markets. By contradiction, there must either exist an individuallyirrational person or a blocking triple. If the matching is individually irrational under P , it isindividually irrational under ˜ P . Suppose there exists a blocking triple ( a, s, c ) ∈ A × S × C . Sincethree-sided stability is defined in terms of two-sided stability (see Definition 3), this follows. C Some Technicalities for the PhD Algorithm
C.1 PhD Algorithm with Explicitly Defined Sets
Algorithm 6 states the PhD algorithm (Algorithm 2) by explicitly defining the sets S ( τ ) , S ( τ ) m , S ( τ ) u , µ ( τ ) AS , µ ( τ ) SC at each iteration τ . This is useful for the stability proof. Algorithm 6:
PhD Market - PhD Algorithm without Quotas - Sets S ( τ ) , S ( τ ) m , S ( τ ) u Explicitly Defined
Input:
PhD market (
A, S, C, P ), quotas Q = 1 Output: stable matching µ strictify the preferences P AS on ( A, S ) and P SC on ( S, C )set S ← S and i ← do τ ← τ + 1 µ ( τ ) AS ← GS ( M = S ( τ ) , W = A, P AS )let S ( τ ) m the matched students in µ ( τ ) AS µ ( τ ) SC ← GS ( M = S ( τ ) m , W = C, P SC )let S ( τ ) u ⊂ S ( τ ) m the unmatched students in µ ( τ ) SC S i +1 ← S ( τ ) \ S ( τ ) u while S ( τ ) u (cid:54) = ∅ let matching µ such that all students in S are matched to their respective advisor in µ ( τ ) AS and co-advisor in µ ( τ ) SC , and all other persons remain single return µ Figure 4 shows how the PhD algorithm can evolve in a non-trivial way on both two-sidedmarkets. 28 s , s a s s a c s a c s a c , c c s c s , s Figure 4: Example of a run of the PhD algorithm which shows that it evolves in a non-trivialway on both markets. The first iteration is in dashed lines and student s is removed, thesecond iteration is in solid lines. a s , s a s s a c s a c s a c c s , s c s , s a s , s a s , s a s s a c s a c s a c c s , s c s , s a s , s a s , s a s s a c s a c s a c c s , s c s , s a s , s
1, 2nd iter: a s , s Figure 5: Matchings are indicated with solid lines, blocking triples are in dotted style. Advisorshave non-strict preferences. In the bottom, s is removed in the first iteration. The matching { ( a , s , c ) } is blocked by ( a , s , c ). C.2 Why Preferences Must Be Strictified
Figures 5, 6, 7 and 8 demonstrate that the PhD algorithm may fail to return a stable matchingswhen preferences are not strictified consistently between iterations. On the top left and rightof each figure, the ties are broken consistently between iterations. This can be achieved bybreaking ties before calling the PhD algorithm. The bottom of each figure shows what happenswhen ties are not broken consistently. In addition, the number of matched students can differbetween stable matchings (compare the top left vs. top right).
C.3 Characterization of the Set of Matched Students
In this section, we give a few additional characterizations of the set ˜ S m , the set of matchedstudents in the matching returned by the PhD algorithm. We first show that all stable matchingson ( A, ˜ S m , C ) must match all students ˜ S m and therefore match the same advisors, students andco-advisors. Proposition 30.
Let ˜ S m , µ be given by the PhD algorithm and λ an arbitrary stable matchingon ( A, ˜ S m , C ) . Then, λ and µ match the same persons.Proof. Suppose that V (cid:40) ˜ S m students are matched in λ . Then λ | ( A,V ) and λ | ( V,C ) must be29 s a s , s a s s a , a c s a c s a c c s c s , s s a , a a s a s , s a s s a , a c s a c s a c c s c s , s s a , a a s a s , s a s s a , a c s a c s a c c s c s , s s a , a
2, 2nd iter: s a , a Figure 6: Matchings are indicated with solid lines, blocking triples are in dotted style. Studentshave non-strict preferences over advisors. In the bottom, s is removed in the first iteration.The matching { ( a , s , c ) } is not stable since it is blocked by ( a , s , c ). a s a s s a c s a c , c c s , s c s s c , c a s a s s a c s a c , c c s , s c s s c , c a s a s s a c s a c , c c s , s c s s c , c
2, 2nd iter: s c , c Figure 7: Matchings are indicated with solid lines, blocking triples are in dotted style. Studentshave non-strict preferences over co-advisors. In the bottom, s is removed in the first iteration.The matching { ( a , s , c ) } is not stable since it is blocked by ( a , s , c ).30 s a s a s s a c s a c , c s a c c s , s c s , s c s , s a s a s a s s a c s a c , c s a c c s , s c s , s c s , s a s a s a s s a c s a c , c s a c c s , s c s , s c s , s
2, 2nd and 3rd iter: c s , s Figure 8: Matchings are indicated with solid lines, blocking triples are in dotted style. Co-advisors have non-strict preferences. In the bottom, s is removed in the first iteration and s is removed in the second iteration. The returned matching { ( a , s , c ) } is unstable since it isblocked by ( a , s , c ).stable.Let µ the matching returned by the PhD algorithm when advisors and co-advisors propose. µ | ( A, ˜ S m ) and µ | ( ˜ S m ,C ) are advisor-optimal and co-advisor-optimal stable matchings. Let ¯ µ , ¯ µ the advisor-optimal and co-advisor-optimal two-sided matchings on the markets ( A, V ) and(
V, C ) respectively. By Lemma 5 and optimality on the markets (
A, V ) and (
V, C ), we have µ ( a ) S ≥ a ¯ µ ( a ) ≥ a λ ( a ) S ∀ a ∈ A and µ ( c ) S ≥ c ¯ µ ( c ) ≥ c λ ( c ) S ∀ c ∈ C . Let s ∈ ˜ S m \ V anunmatched student in λ such that µ ( s ) = ( a, c ). Then, s = µ ( a ) S > a λ ( a ) S and s = µ ( c ) S > c λ ( c ) S . Since ( a, s, c ) are mutually acceptable, ( a, s, c ) blocks λ .Since all students V = ˜ S m are matched, λ | ( A, ˜ S m ) and λ | ( ˜ S m ,C ) are stable. Therefore, λ matches the same advisors and co-advisors as µ .It is not true that all stable matchings on ( A, S, C ) match all students ˜ S m , see the coun-terexample in Figure 2. However, we can state the following Proposition. Proposition 31.
Let ˜ S m , µ be given by the PhD algorithm and λ a stable matching on themarket ( A, S, C ) such that the set of matched students S m ( λ ) contains the set ˜ S m . Then, λ and µ match the same persons.Proof. We first show that λ and µ match the same students. Let s ∈ S m ( λ ) \ ˜ S m a studentwho is matched in λ , but not in µ . Suppose s was not removed in the PhD algorithm, s ∈ ˜ S . Since µ | ( A, ˜ S ) is stable, ˜ S m ∪ { s } ⊂ ˜ S and no one outside ˜ S m is matched in µ , µ | ( A, ˜ S m ∪{ s } ) mustalso be stable by Fact 24. Since µ | ( A, ˜ S m ∪{ s } ) does not match s and ˜ S m ∪ { s } ⊂ S m ( λ ), s canalso not be matched in the larger market ( A, S m ( λ )) by Fact 25. However, λ | ( A,S m ( λ )) is stableand matches s , a contradiction.So student s was removed in the PhD algorithm because s found an advisor, but no co-advisor. By Lemma 7, the co-advisors’ matches can only increase, so s is also not matched inany stable matching on the market ( ˜ S m ∪ { s } , C ). Since ˜ S m ∪ { s } ⊂ S m ( λ ), s is unmatched in( S m ( λ ) , C ) by Fact 25. However, λ | ( S m ( λ ) ,C ) is stable and matches s , a contradiction.Since λ, µ match the same students and both λ | ( A,S m ( λ )) and µ | ( A,S m ( µ )) are stable on( A, S m ( µ )), they match the same advisors. Analogously, they match the same co-advisors. Recall that ˜ S is the set of non-removed students at the last iteration of the PhD algorithm. .4 PhD Algorithm with Quotas (Proof of Theorem 11) This section proves Theorem 11 about the stability of the PhD algorithm with quotas.Before proving stability, we establish a few properties. The proof is omitted for some ofthem. At iteration τ , define q ( τ ) s and ˜ q ( τ ) s as the capacities of student s in the ( A, S ) and (
S, C )market: q ( τ ) s = q ( τ − s + countMatches ( µ ( τ − SC , s ) − ˜ q ( τ − s for τ > , ˜ q ( τ ) s = countMatches ( µ ( τ ) AS , s ) . Since countMatches ( µ, s ) is upper-bounded by the capacity of s , we have ˜ q ( τ ) s ≤ q ( τ ) s and q ( τ − s ≥ q ( τ ) s ≥ countMatches ( µ ( τ − SC , s ) (for τ > q ( τ ) s can increase or decreaseover iterations.Based on this, Lemmas 5, 6 and 7 can be adapted as follows. Assume strict preferences. Asbefore, the match partners of p , i.e. µ ( p ) , µ AS ( p ) , µ SC ( p ), are ordered from best to worst. Forexample, the matching µ ( τ ) AS ( s ) of student s at iteration τ is ordered in terms of ≥ s from themost preferred to the least preferred advisor. Lemma 32.
Let a market ( M, W, P, Q ) and quotas Q , Q such that Q ( m ) ≤ Q ( m ) ∀ m ∈ M, Q ( w ) = Q ( w ) ∀ w ∈ W and Q ( m ) = Q ( m ) ∀ m ∈ M, Q ( w ) ≤ Q ( w ) ∀ w ∈ W . Let µ = GS ( M, W, Q ) and µ i = GS ( M, W, Q i ) , i = 1 , . Independently of whether men or womenpropose (but the same for ( µ , µ ) and ( µ , µ ) respectively), it holds that µ ( m ) k ≥ m µ ( m ) k ∀ m ∈ M, k = 1 , . . . , Q ( m ) , µ ( w ) k ≤ w µ ( w ) k ∀ w ∈ W, k = 1 , . . . , Q ( w ) and µ ( m ) k ≤ m µ ( m ) k ∀ m ∈ M, k = 1 , . . . , Q ( m ) , µ ( w ) k ≥ w µ ( w ) k ∀ w ∈ W, k = 1 , . . . , Q ( w ) . Lemma 33.
A student’s matches (excluding self-matches) on the ( A, S, Q ) market cannot de-crease over iterations. More precisely, for student s with capacity q ( τ ) s at iteration τ ≥ , wehave µ ( τ ) AS ( s ) k ≥ s µ ( τ − AS ( s ) k ∀ k = 1 , . . . , q ( τ ) s . This implies that countMatches ( µ ( τ ) AS , s ) ≥ min( q ( τ ) s , countMatches ( µ ( τ − AS , s )) . Proof.
Since q ( τ ) s ≤ q ( τ − s ∀ s , it follows from Lemma 32. Intuitively, the q ( τ ) s spots of student s face less competition from other students than in the previous iteration. Lemma 34.
A co-advisor’s matches on the ( S, C, Q ) market cannot decrease over iterations.More precisely, for co-advisor c at iteration τ > , µ ( τ ) SC ( c ) k ≥ c µ ( τ − SC ( c ) k ∀ k = 1 , . . . , q c . Proof.
We first prove that countMatches ( µ ( τ − SC , s ) ≤ ˜ q ( τ ) s . By Lemma 33,˜ q ( τ ) s = countMatches ( µ ( τ ) AS , s ) ≥ min( q ( τ ) s , countMatches ( µ ( τ − AS , s )) ≥ countMatches ( µ ( τ − SC , s ) . Now apply Lemma 32 by first matching students with capacity countMatches ( µ ( τ − SC , s ) ≤ ˜ q ( τ ) s on the ( S, C ) market. This returns a matching that is the same as at iteration τ − q ( τ ) s . Co-advisors cannot worsen,students cannot get better matches. Since q ( τ ) s ≤ q ( τ − s , the inequality may not apply to all spots which were occupied at iteration τ −
1. Wefurther have for advisor a , µ ( τ ) AS ( a ) k ≤ a µ ( τ − AS ( a ) k ∀ k = 1 , . . . , q a . We do not need this fact in the followingproofs. For student s , it also holds that µ ( τ ) SC ( s ) k ≤ s µ ( τ − SC ( s ) k ∀ k = 1 , . . . , countMatches ( µ ( τ − SC , s ). In otherwords, a student’s matches (excluding self-matches) on the ( S, C, Q ) market cannot increase over iterations. Wedo not need this fact to prove stability though.
Theorem 11.
The PhD algorithm with quotas returns a stable matching.Proof.
By Proposition 29, it is sufficient to show that the matching µ is stable under thestrictified preferences (first line of the algorithm). We proceed by contradiction. The algorithmcannot return an individually irrational matching since the two-sided GS algorithms do not.Assume that ( a, s, c ) ∈ A × S × C blocks µ . Let T the last iteration of the PhD algorithmand Q ( τ ) the quotas at iteration τ on the market ( A, S, C ). If s ’s capacity has not changed, q (1) s = q ( T ) s , Proposition 22 implies that either ( a, s ) blocks µ | ( A,S,Q ( T ) | ( A,S ) ) or ( s, c ) blocks µ | ( S,C,Q ( T ) | ( S,C ) ) . Since Q ( T ) | ( S,C ) = ˜ Q ( T ) SC at the final iteration, this contradicts the stability ofthe GS algorithm on one of the two markets.If s ’s capacity has changed, q ( T ) s < q (1) s , s matched to ˜ q ( τ ) s = countMatches ( µ ( τ ) AS , s )advisors and less co-advisors at some iteration τ (since q ( τ ) s can only decrease). Consider c ’sweakest student ˜ s = µ ( τ ) SC ( c ) q c at that time. Since c and s are mutually acceptable, c matcheswith ˜ s > c s at that iteration, independently of whether students or co-advisors propose. ByLemma 34, c ’s weakest student satisfies µ ( c ) S,q c = µ ( T ) SC ( c ) q c ≥ c µ ( τ ) SC ( c ) q c = ˜ s > c s . Hence τ > c s ∀ τ ∈ µ ( c ) S and ( a, s, c ) cannot be a blocking triple. D Challenges with Incompatible Advisor Pairs
This section describes the algorithm given in [30] when advisors can be incompatible, andpreferences are complete and strict. Their algorithm supposedly computes a stable matchingwhen advisor pairs can be incompatible. We first carefully write down the algorithm theydescribe. Then, we give a counterexample to show that it does not work with incompatibleadvisor pairs. In the special case when all advisor pairs are compatible, we finally show thatit is a special case of the PhD algorithm. We explicitly mention any reasoning that we takedirectly from their paper.As discussed in Section 3.4, their algorithm can be motivated from the PhD algorithm.Rather than running two separate two-sided markets, the idea is to interleave them. Pick anycurrently unmatched advisor and let him propose to the most preferred student that did notreject him. If the student is already matched to an advisor that is worse than the proposingadvisor and the proposing advisor is compatible with the student’s current co-advisor, thestudent rejects the old advisor and accepts the new advisor, keeping the co-advisor. Otherwise,the student rejects the proposing advisor. If the student is not already matched, he proposesto and matches with the most preferred compatible co-advisor who prefers the student to hiscurrent student. If no such co-advisor exists, the student rejects the advisor. This algorithmis depicted in Algorithm 7. The function offerNext ( P, p ) returns the most preferred personof p who did not reject p yet. When p rejects p , this can be implemented by removing p from P ( p ), the preferences of p . When s is unmatched, s only considers co-advisors in ˜ C whichensures that ( a, s, c ) can be matched because c prefers s to his current match. Student s couldinstead propose to the most preferred co-advisor who did not reject him yet and the co-advisoronly accepts if he prefers s to his current match. The function bestAmong ( ˜ C, P ( s )) picks s ’s most preferred co-advisor among ˜ C . Note that when s matches with co-advisor c and thisunmatches (˜ a, ˜ s, c ), the advisor ˜ a is not (immediately) rejected by s . Advisor ˜ a can propose to˜ s again and ˜ s can find a new co-advisor. The algorithm returns a valid matching in the sensethat each person is matched to himself or exactly one acceptable couple of persons of the othertwo sides. We present it slightly differently by letting persons propose one after the other rather than all at once.Moreover, we avoid their terminology of “active” agents. This does not change our conclusions. lgorithm 7: PhD Algorithm without Quotas and Incompatible Advisor Pairs [30]
Input:
PhD market (
A, S, C, P ), quotas Q = 1 Output: matching µ For all a ∈ A , modify P ( a ) such that a only lists a student s as acceptable when thestudent lists the advisor as acceptable, i.e., when a > s s µ ← { ( s, s, s ) | s ∈ S } ∪ { ( c, c, c ) | c ∈ C } // all students and co-advisors areself-matched while there is an unmatched advisor a do s ← offerNext ( P, a ) // advisor offers to best student who did not reject himyet, or himself if s = a then µ ← µ ∪ { ( a, a, a ) } // advisor proposed to himself and accepts else if s is matched to (˜ a, ˜ c ) ∈ A × C then if a > s ˜ a and a ∈ K (˜ c ) then µ ← µ \ { (˜ a, s, ˜ c ) } ∪ { ( a, s, ˜ c ) } Reject ˜ a else Reject a // failure mode: a is also rejected when a > s ˜ a and a / ∈ K (˜ c ) end else ˜ C ← { c : s > c µ ( c ) S ∧ c ∈ K ( a ) } if ˜ C = ∅ then Reject a else c ← bestAmong ( ˜ C, P ( s )) // s offers to and matches with best c in ˜ C µ ← µ \ { ( µ ( c ) A , µ ( c ) S , c ) } ∪ { ( a, s, c ) } end end end end return µ We show that the algorithm’s running time is O (( | A | + | C | ) | S | ). For simplicity, assume alladvisor pairs are compatible. We study the contribution to the running time of a given student s . The total running time of the “if” (starting at Line 8) is O ( | A | ) since a student can rejectat most | A | advisors. The total running time of the “else” (starting at Line 15) is O ( | A | + | C | )since either an advisor is rejected (which can happen at most | A | times) or the size of the set˜ C shrinks by at least 1 until the next iteration when s receives a proposal (which can happenat most | C | times). Therefore, each student takes O ( | A | + | C | ) and the total running timeis O (( | A | + | C | ) | S | ). If some advisor pairs are incompatible, we can say instead that the set { c : s > c µ ( c ) S } shrinks by at least 1.The algorithm fails when some advisor pairs are incompatible as shown by the counterex-ample in Figure 9, even under complete preferences and when | A | = | S | = | C | . The intuitionis as follows. Suppose that a student s receives an offer from an advisor a and then matchesto his most preferred co-advisor c who himself is not compatible with any other advisor. Allother advisors now propose to this student s who is their favorite one, but are all rejected be-cause none of them is compatible with the co-advisor c . Finally, an advisor proposes to anotherstudent ˜ s and this student is preferred to s by c such that s and c are unmatched. Any of the34 s a s , s , s = c a s = c s a , a c s a c s a , a c , c c s , s c s , s c s Figure 9: Algorithm 7 from [30] fails when some advisor pairs are incompatible. It returnsthe shown matching { ( a , s , c ) , ( a , s , c ) , ( a , s , c ) } which is blocked by ( a , s , c ). Thecompatible advisor pairs are K = A × C \ { ( a , c ) , ( a , c ) } . Even if people propose inparallel (as originally presented in [30]), it does not work. Call a round when all advisorspropose to students and the students propose to co-advisors (if they are unmatched). Af-ter the first round, the matching is { ( a , s , c ) , ( a , s , c ) } because ( a , c ) / ∈ K . In thesecond round, s rejects a since ( a , c ) / ∈ K . In the third round, the matching becomes { ( a , s , c ) , ( a , s , c ) , ( a , s , c ) } . Since everyone is matched, the matching stays the same ifthe unacceptable persons are appended at the end of each person’s preferences as acceptablepersons. Therefore, this is also a counterexample when preferences must be complete. Thematching { ( a , s , c ) , ( a , s , c ) } is stable. As an aside, the PhD algorithm (Algorithm 2)happens to produce the stable matching { ( a , s , c ) , ( a , s , c ) } on this example.advisors that s rejected does not propose again and s ends up single even if he could match toanother co-advisor.We could not find any small tweaks to make the algorithm work with incompatibilities.For this reason, we now restrict to the setting K = A × C and prove stability. We assumestrict preferences. We mark the statements that are wrong with incompatible advisor pairswith a “(+)”. Suppose ( a, s, c ) blocks the matching µ returned by the algorithm. During thealgorithm, the co-advisors’ student matches cannot decrease. Since c ’s student cannot decrease, c ∈ ˜ C (defined for student s in Line 16) at all iterations (+). If a never proposed to s , a mustbe matched to some ˜ s > a s , so ( a, s, c ) cannot be blocking. If a proposed to s and ( a, s, c (cid:48) ) arematched, it must be that s picked c (cid:48) > s c since c ∈ ˜ C at all times (+). If a proposed to s and s rejected a , either s could not find a co-advisor (which contradicts c ∈ ˜ C ). Or s got an offerfrom a more preferred advisor ˜ a > s a . ( a, s, c ) cannot be blocking because ˜ C is non-empty, so s must be matched to µ ( s ) A ≥ s ˜ a > s a .The failure mode with incompatibilities is at Line 13. We can try the following when anadvisor applies to a student, but is not compatible with the student’s currently matched co-advisor. When a > s ˜ a and a / ∈ K (˜ c ), s can put a on a waiting list. When student s is unmatchedfrom ˜ a because his co-advisor rejected him (and no other co-advisor that is compatible with ˜ a accepts), he can notify a that he is free. s may find a co-advisor if a is compatible with moreco-advisors. This newly found co-advisor potentially rejects a less preferred student who himselfhas a waiting list. It seems to us that this is not guaranteed to terminate since a student canbe unmatched from the advisor whenever the advisor is on the waiting list of some other morepreferred student and gets an offer from that student.Let us call Algorithm 7 the PhD2 algorithm. When all advisor pairs are compatible, we nowsketch why the PhD2 algorithm is equivalent to the variant of the PhD algorithm when advisorspropose to students and students propose to co-advisors. As a first check, both algorithms havethe same running time O (( | A | + | C | ) | S | ). The PhD2 algorithm can be reformulated such thatadvisors first apply to students and form partial advisor-student matches. Whenever an advisor By Proposition 29, we can first strictify preferences by breaking ties, run the algorithm on the strictifiedpreferences and the resulting matching is also stable with respect to the original preferences.
35s unmatched, he proposes to the most preferred student that did not reject him. If the studentprefers the advisor, he rejects and unmatches from his (potential) old advisor and partiallymatches with the advisor. Once all advisors are matched, partially matched students apply toco-advisors (second market). A student applies to his most preferred co-advisor. It is sufficient ifhe applies only to co-advisors that would accept him, i.e., who are in ˜ C . If the co-advisor prefersthe student, he rejects and unmatches from his (potential) old student. The old student revertsto be partially matched to the advisor he was matched to, whereas the new student convertshis partial match into a full match with the co-advisor. Whenever the student cannot find aco-advisor, i.e., ˜ C is empty, his partial match with the advisor is dissolved and he rejects theadvisor. Once no partial matches remain, the iteration is complete and the algorithm returnsto the first step and the (unmatched) advisors apply to students. The rejections given by co-advisors to students are cleared at each iteration. It stops once all advisors are fully matched(including to themselves). The iterations coincide in both algorithms. Advisors propose tostudents and students propose to co-advisors as in the GS algorithm since the order how freemen apply in the GS algorithm does not matter. A student participates in the second marketif he found a partial advisor match, i.e., if he is in S m . A student rejects all advisors once hisset ˜ C is empty, so he is effectively removed. He is part of the set S u at the iteration when hisset ˜ C is empty for the first time. E Multi-Sided Markets
E.1 Parcel Shipment Example
The n -sided market can be used to model parcel shipments. Suppose we want to ship parcelsfrom country A to country B and it does not matter at which post office a parcel arrives incountry B. Each parcel corresponds to an object in the first side of the market. The secondside consists of post offices in the starting country A. The third side consists of large logisticcompanies that ship parcels across countries. The fourth side comprises the post offices in thedestination country B. Each parcel in the first side has quota one, each post office, logisticcompany and post office in the second, third and fourth sides have arbitrary quotas. Eachparcel has preferences over postal offices, e.g., distance from the location where it is packaged.Each postal office has preferences over parcels, e.g., based on a parcel’s weight. Each postaloffice and logistic company have preferences over each other based on negotiated contracts, e.g.,in terms of pricing. This model cannot be used to model internet routing because each packethas a source and a destination. Suppose packets go from one country to another country. Amatching on an n -sided market would find a route for a packet such that the packet arrives inthe other country, but not necessarily at the precise destination in that country. The matchingprovides no guarantees about the precise destination if a packet is matched, except that it is inthe destination country. Even if the packet is routed via one router only such that the market is3-sided, the preferences of the router need not be consistent because the router has preferencesover the destinations based on the packet he matched to. E.2 Missing Proofs on Multi-Sided Matching Markets
Analogously to Proposition 4, we have a necessary condition for blocking tuples in n -sidedmarkets. Proposition 14. If ( s , . . . , s n ) ∈ S × · · · × S n blocks µ , there exists some k = 1 , . . . , n − This is similar to a maximum flow problem with several sources and sinks. The difference is that the nodesare grouped into n categories, each route must visit exactly one node of each category, and a node of market i has preferences over nodes in markets i − i + 1, i.e., a node in market i + 1 may not accept a connectionwith a node from market i . uch that µ j − ( s j − ) = s j ∀ ≤ j ≤ ks k +1 > s k µ k ( s k ) s k > s k +1 µ k ( s k +1 ) . Define M = S and, for k > , M k = { s k ∈ S k | µ k ( s k ) (cid:54) = s k } is the set of matched personsamong S k . Then, at least one of the matchings µ k | ( M k ,S k +1 ) must be blocked by ( s k , s k +1 ) .Proof. Say H k is the statement that the above does not hold for a given k . If there exists no k for which the above holds, H , . . . , H n − all hold. Statement H means that ( s , s ) ∈ µ . H (together with H ) then implies that ( s , s ) ∈ µ . By iterating, we find that ( s k , s k +1 ) ∈ µ k ∀ k = 1 , . . . , n −
1, hence ( s , . . . , s n ) ∈ µ , so ( s , . . . , s n ) cannot be a blocking tuple. Hence µ k must be blocked by ( s k , s k +1 ) for some k . If k > µ k − ( s k − ) = s k implies that s k ismatched in µ , hence s k ∈ M k . (The case k = 1 is immediate.) By Fact 26, ( s k , s k +1 ) also blocks µ k | ( M k ,S k +1 ) . Lemma 15.
The match of person s k +1 ∈ S k +1 on the market ( S k , S k +1 ) cannot decrease.More precisely, let µ ( τ ) k the matching at iteration τ as in the algorithm. Then, µ ( τ ) k ( s k +1 ) ≥ s k +1 µ ( τ − k ( s k +1 ) ∀ τ ≥ , with s k +1 ∈ S ( τ ) k +1 and k = 1 , . . . , n − . Moreover, M ( τ − k \ U ( τ − k ⊂ M ( τ ) k ∀ k = 2 , . . . , n − .Proof. The second statement follows from the first. Indeed, suppose s k ∈ M ( τ − k \ U ( τ − k forsome k = 2 , . . . , n − k −
1. Since M ( τ − k ⊂ S ( τ − k , s k ∈ S ( τ − k \ U ( τ − k = S ( τ ) k . s k ∈ M ( τ − k means that s k is matched in µ ( τ − k − , i.e., µ ( τ − k − ( s k ) > s k s k .Since s k ∈ S ( τ ) k , we have by the first statement, µ ( τ ) k − ( s k ) ≥ s k µ ( τ − k − ( s k ) > s k s k , hence s k is alsomatched in µ ( τ ) k − , i.e., s k ∈ M ( τ ) k .For fixed n , we prove the first argument by induction over k . For the base case k = 1, µ ( τ )1 = GS ( M ( τ )1 , S ( τ )2 ). Since M ( τ )1 does not change over iterations and S ( τ )2 does not increase,Lemma 5 implies that µ ( τ )1 ( s ) ≥ s µ ( τ − ( s ) ∀ s ∈ S ( τ )2 , τ ≥
2. Assume that the statementholds for k −
1, then we prove that it holds for k < n . Consider the τ -th iteration. First runthe k -th GS algorithm on the market ( M ( τ − k ∩ M ( τ ) k , S ( τ − k +1 ) to obtain the matching λ ( τ ) k . Byinduction, M ( τ − k ∩ M ( τ ) k = M ( τ − k \ U ( τ − k (which depends on the hypothesis for k − U ( τ − k are unmatched in µ ( τ − k , λ ( τ ) k is the same as the matching µ ( τ − k restrictedto the market ( M ( τ − k \ U ( τ − k , S ( τ − k +1 ). Now add the remaining M ( τ ) k \ M ( τ − k and remove S ( τ − k +1 \ S ( τ ) k +1 to obtain the market ( M ( τ ) k , S ( τ ) k +1 ). By applying Lemma 5 twice, we see that µ ( τ ) k ( s k +1 ) ≥ s k +1 λ ( τ ) k ( s k +1 ) = µ ( τ − k ( s k +1 ) ∀ τ ≥ , s k +1 ∈ S ( τ ) k +1 .The extension of Algorithm 4 to the setting with quotas is straightforward. At itera-tion τ , person s k participates with quota q ( τ ) s k on its left market ( S ( τ ) k − , S ( τ ) k ) which resultsin the matching µ ( τ ) k − . s k then participates with quota ˜ q ( τ ) s k = countMatches ( µ ( τ ) k − , s k ) onits right market ( S ( τ ) k , S ( τ ) k +1 ). If s k is only matched countMatches ( µ ( τ ) k , s k ) < ˜ q ( τ ) s k timeson its right market, its quota is reduced by ˜ q ( τ ) s k − countMatches ( µ ( τ ) k , s k ), i.e., q ( τ +1) s k = q ( τ ) s k + countMatches ( µ ( τ ) k , s k ) − ˜ q ( τ ) s k at the next iteration. The algorithm stops once thequotas do not change.We can allow the same pairs of persons to match more than once as we did for three-sidedmarkets in Section 3.5. In this case, we define µ as a multi-setmulti-set