Understanding the Generalized Median Stable Matchings∗ Christine T. Cheng† Department of Computer Science University of Wisconsin–Milwaukee, Milwaukee, WI 53211, USA. [email protected] March 31, 2009

Abstract Let I be a stable matching instance with N stable matchings. For each man m, order his (not necessarily distinct) N partners from his most preferred to his least preferred. Denote the ith woman in his sorted list as pi (m). Let αi consist of the man-woman pairs where each man m is matched to pi (m). Teo and Sethuraman proved this surprising result: for i = 1 to N , not only is αi a matching, it is also stable. The αi ’s are called the generalized median stable matchings of I. Determining if these stable matchings can be computed efficiently is an open problem. In this paper, we present a new characterization of the generalized median stable matchings that provides interesting insights. It implies that the generalized median stable matchings in the middle – α(N +1)/2 when N is odd, αN/2 and αN/2+1 when N is even – are fair not only in a local sense but also in a global sense because they are also medians of the lattice of stable matchings. We then show that there are some families of SM instances for which computing an αi is easy but that the task is NP-hard in general. Finally, we also consider what it means to approximate a median stable matching and present results for this problem.

1

Introduction

In the stable marriage problem (SM), there are n men and n women each of whom has a list that ranks all individuals of the opposite sex. A matching is a set of man-woman pairs where each individual appears in at most one pair. The objective of the problem is to find a matching µ that has n pairs and has no blocking pairs – i.e., a man and a woman who prefer each other over their partners in µ. The rationale behind the stability condition is that if a blocking pair exists, the man and the woman will likely leave their partners and thereby compromise the integrity of the matching µ. A celebrated result by Gale and Shapley states that every instance of SM has a stable matching that can be found in O(n2 ) time [13]. Today, centralized stable matching algorithms match medical residents to hospitals [24], students to schools [1, 2], etc. In this paper, we focus on a set of stable matchings that is due to Teo and Sethuraman [27]. Let I be an SM instance, and M (I) its set of stable matchings. Let pµ (a) denote the partner of a in stable matching µ. By formulating the stable matchings problem as a linear program, they discovered the following surprising result: ∗ †

A preliminary version [8] of this paper was presented at LATIN 2008. Supported by NSF Award No. CCF-0830678.

1

Theorem 1 [27] Suppose that Z ⊆ M (I) and z = |Z|. For each man m, sort the multiset of women {pµ (m), µ ∈ Z} from m’s most preferred to least preferred woman. Let pi,Z (m) denote the ith woman in this sorted list. Do the same for each woman w. Let αi,Z consist of the man-woman pairs where each man m is matched to pi,Z (m). Similarly, let βi,Z consist of the man-woman pairs where each woman w is matched to pi,Z (w). For i = 1, . . . , z, αi,Z and βi,Z are stable matchings; moreover, αi,Z = βz−i+1,Z . When Z = M (I) and N = |M (I)|, we denote αi,Z and βi,Z as αi and βi respectively. We also follow Klaus and Klijn’s [18] terminology and call αi = βN −i+1 the ith generalized median stable matching of I. The most interesting of the generalized median stable matchings are the ones in the middle – α(N +1)/2 when N is odd, and αN/2 and αN/2+1 when N is even – because they match every participant to his/her (lower or upper) median stable partner and, thus, are fair in a very strong sense. Since Teo and Sethuraman’s work, several authors [22, 12, 18] have proven the existence of the generalized median stable matchings. However, determining if these stable matchings can be computed in polynomial time remains open. Simply using the definition can be inefficient because there are instances whose number of stable matchings is exponential in the input size. Our goal is to fill this gap. It is well known that M (I) forms a distributive lattice under a natural dominance relation . In the early 1960’s, Barbut [5] initiated the study of medians for distributive lattices. Recall that in statistics, the median of a set of test scores is a number that summarizes the entire set. It reflects how good or how bad the scores are as a whole. Specifically, it is one of the numbers whose total distance (or average distance) from all the test scores is the smallest. Extending this idea to distributive lattices, Barbut would define a median of M(I) = (M (I), ) as follows. Let H(I) denote the lattice’s Hasse diagram. For any two stable matchings µ and µ′ , define the distance between µ and µ′ , d(µ, µ′ ), asP the length of a shortest path between µ and µ′ in the undirected version of H(I). Let D(µ) = µ′ ∈M (I) d(µ, µ′ ). A median of M(I) is a stable matching µ∗ such that D(µ∗ ) = min{D(µ), µ ∈ M (I)}. Just as in statistics, one can think of the medians of M(I) as the stable matchings that best describe the set M (I). An intriguing question is what is the relationship of the generalized median stable matchings of I to the medians of M(I)? To better understand the generalized median stable matchings of I, we make use of I’s rotation poset, a structure related to M(I). Algorithmically, the rotation poset is very useful because it encodes all the stable matchings of I, and, yet, its size is always polynomial in the input size. Our main results are as follows: • We present a new characterization of the generalized median stable matchings of I that provides interesting insights into these stable matchings not apparent from their definition. It implies that when N is odd, α(N +1)/2 is the unique median of M(I), and when N is even, the stable matchings µ such that αN/2  µ  αN/2+1 are exactly the medians of M(I). Thus, quite remarkably, a stable matching is “locally median” if and only if it is “globally median”! • We consider the problem of computing a specific αi . We prove that when i = O(log n), αi and αN −i+1 can be computed efficiently. We also note that when I’s rotation poset is a series-parallel poset, an interval order, or a two-dimensional poset in general, computing any of its generalized median stable matchings is easy; and when I’s rotation poset has at most two layers, computing a median of M(I) can be done efficiently. • In spite of these results, however, we show that the task of computing αi is NP-hard in general. In particular, we prove that finding a median of M(I) is NP-hard.

2

• Finally, we consider what it means to approximate a median stable matching of M(I), and present results for this problem. The outline for the rest of the paper is as follows: in Section 2, we define distributive lattices, present important results on the medians of a distributive lattice, and describe rotation posets and their properties. We present the new characterization for the αi ’s in Section 3 and complexity results for computing αi in Section 4. We consider the problem of approximating a median stable matching of M(I) in Section 5 and conclude in Section 6.

2

Distributive lattices, medians, and rotation posets

Distributive lattices and their medians. Recall that a (finite) lattice L = (L, ≤) is a partially ordered set (or poset) such that every pair of elements x and y of L has a greatest lower bound, x ∧ y, called the meet of x and y, and a least upper bound, x ∨ y, called the join of x and y. It also implies that any subset L′ of L has a well-defined greatest lower bound, ∧L′ , and a well-defined least upper bound, ∨L′ . When x ≤ y, let the interval [x, y] = {z : x ≤ z ≤ y}. We say that y covers x when [x, y] = {x, y}; that is, no element of L lies between x and y. The Hasse diagram of L, H(L), is the directed graph formed by letting every element of L be a vertex and every pair (x, y) of vertices be an edge whenever y covers x. Below, we define a median of L and present important results related to it. Our discussion follows the paper of LeClerc [19]. Define the distance between any two elements x and y of L, d(x, y), as the length of the shortest path between x and y in the undirected version of H(L). Let Lk be P the k-fold product of L. An element X = (x1 , x2 , . . . , xk ) ∈ Lk is called a profile. Let DX (x) = ki=1 d(x, xi ). An X-median is an element m of L such that DX (m) = min{DX (x), x ∈ L}. When X consists of exactly the elements of L, we will also refer to an X-median as a median of L. Let [k] = {1, . . . , k}. For every X ∈ Lk and every j such that 1 ≤ j ≤ k, define cj (X) = ∨{∧i∈J xi : J ⊆ [k], |J| ≥ j}. In other words, cj (X) is the least upper bound of all the elements of L which are the greatest lower bounds of at least j of the xi ’s. The functions cj (X), 1 ≤ j ≤ k, behave nicely. For example, when π is a permutation of X, cj (X π ) = cj (X). When X is a constant profile (i.e., x1 = x2 = · · · = xk = x), cj (X) = x. When j ≤ j ′ , cj (X) ≥ cj ′ (X), and when X ′ = (x′1 , x′2 , . . . , x′k ) ∈ Lk , xi ≤ x′i for each i, cj (X) ≤ cj (X ′ ). There is a natural dual to cj (X) which is defined as c′j (X) = ∧{∨i∈J xi : J ⊆ [k], |J| ≥ j}. When j = ⌈(k + 1)/2⌉, the least integer strictly larger that k/2, we shall denote cj (X) as c(X), and c′j (X) as c′ (X). And when X consists of exactly the elements of L, we will also refer to cj (X) and c′j (X) as cj (L) and c′j (L) respectively. The lattice (L, ≤) is distributive whenever it satisfies the distributive property: for every x, y, z ∈ L, (x ∧ y) ∨ z = (x ∨ z) ∧ (y ∨ z) and (x ∨ y) ∧ z = (x ∧ z) ∨ (y ∧ z). Surprisingly, there is a median characterization of distributive lattices. Theorem 2 [19, 3, 6, 5, 21] Let (L, ≤) be a finite lattice. The following are equivalent: (i) (L, ≤) is a distributive lattice. (ii) For any positive integer k and any profile X ∈ Lk , the elements in the interval [c(X), c′ (X)] are exactly the X-medians. (iii) For any odd integer k and any profile X ∈ Lk , c(X) is the unique X-median. (iv) For any X ∈ L3 , c(X) is the unique X-median. The lattice of stable matchings and its rotation poset. Let I be a stable matching instance of size n (i.e., it has n men and n women). Let µ and µ′ be two of its stable matchings. An individual a 3

prefers µ to µ′ if a prefers his/her partner in µ over his/her partner in µ′ ; otherwise, a prefers µ′ to µ, or is indifferent between them if a has the same partner in both matchings. The stable matching µ dominates µ′ , denoted as µ  µ′ , if every man prefers µ to µ′ or is indifferent between them. It turns out that the dominance relation  induces a nice structure on M (I): M(I) = (M (I), ) is a distributive lattice. The meet and join of µ and µ′ are formed by matching each man to the partner he prefers more and less in µ and µ′ respectively; they can also be obtained by matching each woman to the partner she prefers less and more in µ and µ′ respectively. Hence, in ∧M (I), every man is matched to the woman he prefers the most among all his partners in a stable matching, and, simultaneously, every woman is matched to the man she prefers the least among all her partners in a stable matching. This is the so-called man-optimal/woman-pessimal stable matching; we denote it as µM . Similarly, ∨M (I) = µW , the so-called woman-optimal/man-pessimal stable matching and is defined accordingly. Associated with M(I) is the rotation poset of I. Rotations are the incremental changes that need to be made so that a stable matching µ can be transformed into another stable matching µ′ that it dominates. We define them formally next; we refer readers to [15] for a thorough discussion of the subject. When µ 6= µW , there is a man m so that pµ (m) 6= pµW (m). For each such man m, define his successor woman, sµ (m), as the first woman on his preference list that follows pµ (m), and prefers him over her current partner in µ. For example, pµW (m) is a possible candidate for sµ (m) but there may be other eligible women ahead of her in m’s preference list. A rotation ρ exposed in µ is a cyclic sequence of man-woman pairs ρ = ((m0 , w0 ), (m1 , w1 ), . . . , (mr−1 , wr−1 )) such that (mi , wi ) ∈ µ and sµ (mi ) = wi+1 for all i, where the addition in the subscript is modulo r. To eliminate ρ from µ, each man mi in ρ is matched to wi+1 while the rest of the pairs not in ρ are kept the same. The result is another stable matching, denoted as µ/ρ, which µ dominates. Let R(I) denote the set of all rotations that are exposed in the stable matchings of I. We note the following properties of rotations. First, a man-woman pair (m, w) belongs to a rotation of I if and only if it appears in some stable matching and w is not the worst partner of m in all stable matchings. Since a man-woman pair can be part of at most one rotation, and each rotation has at least two man-woman pairs, |R(I)| ≤ n(n − 1)/2. Second, whenever µ 6= µW , there will always be at least one rotation ρ exposed in µ. Furthermore, there is no stable matching µ′ such that µ ≺ µ′ ≺ µ/ρ. Thus, in the Hasse diagram of M(I), every edge between two stable matchings can be labeled by the rotation whose elimination from the dominant stable matching results in the dominated stable matching. A rotation ρ′ precedes rotation ρ, ρ′ ≤ ρ, if in order to obtain a stable matching in which ρ is exposed, ρ′ must be eliminated first. The pair R(I) = (R(I), ≤) is called the rotation poset of I. A subset S of R(I) is closed if whenever a rotation is in S, all rotations that precede it are also in S. There is a very nice correspondence between the stable matchings of I and the closed subsets of its rotation poset: Theorem 3 [16] There is a one-to-one correspondence between the elements of M (I) and the closed subsets of R(I). In particular, if µ ∈ M (I) corresponds to the closed subset Sµ of R(I), then µ can be obtained by starting at µM and eliminating all the rotations in Sµ . The stable matching µM corresponds to the empty subset while µW corresponds to R(I) itself. It is T also easy to verify that for any S subset of stable matchings Z ⊆ M (I), ∧Z corresponds to µ∈Z Sµ while ∨Z corresponds to µ∈Z Sµ . As an example, consider the SM instance I below:

4

ρ1

µ3

ρ2 ρ3 ρ4

µ1 µ2 ρ3

ρ2

ρ1 ρ2

µ4

ρ3 ρ4

µ5 µ6

Figure 1: The undirected Hasse diagrams for the lattice of stable matchings and rotation poset of the example in Section 2. m1 : m2 : m3 : m4 : m5 : m6 :

w1 w2 w3 w4 w5 w6

w2 w3 w1 w3 w1 w3

w3 w4 w5 w1 w6 w1

w4 w1 w2 w2 w2 w2

w5 w5 w4 w5 w3 w4

w6 w6 w6 w6 w4 w5

w1 : w2 : w3 : w4 : w5 : w6 :

m4 m1 m6 m2 m3 m5

m5 m2 m4 m4 m5 m6

m3 m3 m2 m1 m1 m1

m1 m4 m3 m3 m2 m2

m2 m5 m1 m5 m4 m3

m4 m6 m5 m6 m6 m4

It has six stable matchings, where µ1 is the man-optimal stable matching and µ6 is the womanoptimal stable matching: µ1 µ2 µ3 µ4 µ5 µ6

: {(m1 , w1 ), (m2 , w2 ), (m3 , w3 ), (m4 , w4 ), (m5 , w5 ), (m6 , w6 )} : {(m1 , w2 ), (m2 , w3 ), (m3 , w1 ), (m4 , w4 ), (m5 , w5 ), (m6 , w6 )} : {(m1 , w2 ), (m2 , w4 ), (m3 , w1 ), (m4 , w3 ), (m5 , w5 ), (m6 , w6 )} : {(m1 , w2 ), (m2 , w3 ), (m3 , w5 ), (m4 , w4 ), (m5 , w1 ), (m6 , w6 )} : {(m1 , w2 ), (m2 , w4 ), (m3 , w5 ), (m4 , w3 ), (m5 , w1 ), (m6 , w6 )} : {(m1 , w2 ), (m2 , w4 ), (m3 , w5 ), (m4 , w1 ), (m5 , w6 ), (m6 , w3 )}

It has four rotations: ρ1 = ((m1 , w1 ), (m2 , w2 ), (m3 , w3 )), ρ2 = ((m2 , w3 ), (m4 , w4 )), ρ3 = ((m3 , w1 ), (m5 , w5 )) ρ4 = ((m4 , w3 ), (m5 , w1 ), (m6 , w6 )). Figure 1 shows the undirected Hasse diagrams of M(I) and R(I). The correspondence between the stable matchings of I and the closed subsets of R(I) are: µ1 and ∅, µ2 and {ρ1 }, µ3 and {ρ1 , ρ2 }, µ4 and {ρ1 , ρ3 }, µ5 and {ρ1 , ρ2 , ρ3 }, µ6 and {ρ1 , ρ2 , ρ3 , ρ4 }. Computational aspects. Let P = (P, ≤) be an arbitrary poset. Throughout the paper, we will assume that it is represented by a digraph G(P) whose vertex set is P and whose transitive closure contains all the order relations of the poset. Hence, G(P) contains O(|P |) vertices and O(|P |2 ) edges. Let P = (P, ≤1 ) and Q = (Q, ≤2 ) be posets with P ∩ Q = ∅. Their disjoint sum is the poset P +D Q = (P ∪ Q, ≤) such that x ≤ y if and only if (i) x, y ∈ P and x ≤1 y or (ii) x, y ∈ Q and x ≤2 y. Their ordinal sum is the poset P +O Q = (P ∪Q, ≤′ ) such that x ≤′ y if condition (i), (ii), or (iii) x ∈ P and y ∈ Q is true. For example, if we simply let ρi denote the singleton poset containing the rotation ρi , the rotation poset shown in Figure 1 can be written as (ρ1 +O (ρ2 +D ρ3 )) +O ρ4 . The next lemma is easy to establish. Lemma 1 Let P = (P, ≤1 ) and Q = (Q, ≤2 ) be posets with P ∩ Q = ∅. Let cs(·) be a function that counts the number of closed subsets of a poset. Then (i) cs(P +D Q) = cs(P) × cs(Q) and (ii) cs(P +O Q) = cs(P) + cs(Q) − 1. 5

Moreover, given G(P) and G(Q), representations for P +D Q and P +O Q can be derived in O(|P |2 + |Q|2 + |P ||Q|) time. Here is a technical lemma we will need later. Lemma 2 Let M be a positive integer. There is a poset QM = (QM , ≤) so that cs(QM ) = M and |QM | = O(log2 M ). Additionally, a representation for QM can be constructed in O(log3 M ) time. Proof Consider the binary representation of M : b0 20 + b1 21 + . . . + bk 2k . This can be obtained in O(log M ) time. Let Ai and Ci denote an antichain of size i and a chain of size i, respectively. When b0 = 0 (i.e., M is even), let QM = Ab1 ×1 +O Ab2 ×2 +O . . . +O Abk ×k +O Cnz−1 where nz is the number of non-zero bits in the binary representation of M . From Lemma 1, it is straightforward to check that cs(Ab1 ×1 +O Ab2 ×2 +O . . . +O Abk ×k ) = M − (nz − 1) and cs(Cnz−1 ) = nz, so c(QM ) = M − (nz − 1) + nz − 1 = M . Furthermore, |QM | ≤ 1 + 2 + . . . + k + k = O(k2 ) = O(log2 M ). Finally, the Hasse diagram of QM , which shall be its representative, has at most 1 × 2 + 2 × 3 + . . . + (k − 1) × k + k + k − 1 = O(k3 ) = O(log3 M ) edges and so QM can be constructed in O(log3 M ) time. When b0 = 1 (i.e., M is odd), let QM = QM −1 +O C1 . By applying the same analysis when b0 = 0, QM satisfies the three properties in the lemma as well. 2 We also note the following fact. Theorem 4 [15, 23] A poset has the same number of closed subsets and antichains. Since counting the number of antichains of an arbitrary poset is #P-complete, counting the number of closed subsets of an arbitrary poset is also #P-complete. When I has size n, Gusfield [14] showed that a representation for the rotation poset R(I) can be constructed in O(n2 ) time. He called it the rotation digraph G(I); it has O(n2 ) vertices and O(n2 ) edges. Given I and S, a closed subset of R(I), the stable matching that corresponds to S can be obtained by constructing µM , topologically ordering the rotations in S and then eliminating them in that order. It is easy to verify that this takes O(n2 ) time. Conversely, finding the closed subset that corresponds to a stable matching µ of I also takes O(n2 ) time. This can be done by starting at µM , and then eliminating exposed rotations until the partner of every man m is pµ (m). The set containing all the eliminated rotations corresponds to µ. Interestingly, the rotation posets of SM instances do not have any special structure in the following sense – Blair [7] showed that for every poset P = (P, ≤), there is an SM instance whose rotation poset is isomorphic to P. In [16], Irving and Leather presented an algorithm that given P will construct such an SM instance, I(P), whose size and construction time is O(|P |2 ). Moreover, the rotations of I(P) and the isomorphism between P and the rotations of I(P) can also be determined in O(|P |2 ) time. Combining this result with Theorem 3 and Theorem 4, Irving and Leather proved this result: Theorem 5 [16] Let I be an SM instance. Counting the number of stable matchings of I is #Pcomplete.

6

3

New characterization

In this section, we present a new characterization of the generalized median stable matchings of I by describing the closed subsets of R(I) they correspond to and their location in M(I). Let X = (µ1 , µ2 , . . . , µk ) ∈ M (I)k . For each man m sort the multiset {pµi (m), 1 ≤ i ≤ k} and denote by pi,X (m) the ith woman in the sorted list. Do the same for each woman. Let αi,X consist of the man-woman pairs where each man m is matched to pi,X (m); let βi,X consist of the manwoman pairs where each woman w is matched to pi,X (w). Notice that a man’s assigned partner in αi,X never gets better as i increases from 1 to k so α1,X  α2,X  . . .  αk,X . For the opposite reason, βk,X  βk−1,X  . . .  β1,X . For each ρ ∈ R(I), let nρ,X = |{µi : ρ ∈ Sµi , 1 ≤ i ≤ k}|; that is, nρ,X is equal to the number of µi ’s whose corresponding closed subsets contain ρ. Similarly, let n ¯ ρ,X = |{µi : ρ 6∈ Sµi , 1 ≤ i ≤ k}|. When ρ′ precedes ρ in R(I), nρ′ ,X ≥ nρ,X and n ¯ ρ′ ,X ≤ n ¯ ρ,X . Thus, the sets S(i, X) = {ρ : nρ,X > i} ¯ X) = {ρ : n and S(i, ¯ ρ,X < i} for 1 ≤ i ≤ k are closed subsets of R(I). Theorem 6 Let X = (µ1 , µ2 , . . . , µk ) ∈ M (I)k . For 1 ≤ i ≤ k, the following sets of man-woman pairs are equivalent: (1) αi,X , (2) βk−i+1,X , (3) the stable matching corresponding to S(k − i, X), ¯ X), (5) ck−i+1 (X), and (6) c′ (X). (4) the stable matching corresponding to S(i, i Proof (4)=(1)=(2) For a closed subset S of R(I), let µS be the stable matching corresponding = αi,X , we will show that every man m is matched to the same woman to S. To prove that µS(i,X) ¯ in both sets of man-woman pairs. If m has the same partner in all the stable matchings of I, this is clearly true. So suppose m is matched to more than one woman in the stable matchings of I. Let them be w1 , w2 , . . . , wr+1 arranged in increasing order of m’s preference (i.e., in the order in which they appear in m’s preference list). For j = 1, . . . , r, let the rotation ρj contain the pair (m, wj ). From Section 2, we know that ρ1 , . . . , ρj have to be eliminated from µM in order for m to be matched to wj+1 in a stable matching. Consequently, if the closed subset of a stable matching does not contain ρj , m must be matched to w1 , w2 , . . ., or wj . Let ηj denote the number of stable matchings in X which match m to wj . For j = 1, . . . , r, our discussion implies that n ¯ ρj ,X = η1 + η2 + · · · + ηj . Suppose that j ∗ is the largest index such that n ¯ ρj∗ ,X < i. Thus, m is matched to wj ∗ +1 in . It also means that µS(i,X) ¯ η1 + η2 + . . . + ηj ∗

< i ≤ η1 + η2 + . . . + ηj ∗ +1 ,

(1)

so m is matched to wj ∗ +1 in αi,X as well. Since m was chosen arbitrarily, it follows that (4)=(1). , we apply the same argument as above with a few changes. To prove that βk−i+1,X = µS(i,X) ¯ Replace the man m with a woman w, and let her partners be m1 , m2 , . . . , mr+1 arranged in decreasing order of w’s preference. This time, if j ∗ is the largest index such that n ¯ ρj∗ ,X < i, then w and in βk−i+1,X . Hence, (4)=(2). is matched to mj ∗ +1 in µS(i,X) ¯ ¯ X) (3)=(4) Since nρ,X + n ¯ ρ,X = k, nρ,X > k − i if and only if n ¯ ρ,X < i. Thus, S(k − i, X) = S(i, so the stable matchings corresponding to these closed subsets are exactly the same. (5)=(3) By definition, ck−i+1 (X) S = ∨{∧j∈J µjT: J ⊆ [k], |J| ≥ k − i + 1}. Thus, the closed subset corresponding to ck−i+1 (X) is J⊆[k],|J|≥k−i+1 j∈J Sµj , which contains all rotations that are part of at least k − i + 1 Sµj ’s. But this is precisely the set S(k − i, X). Hence, (5)=(3). (6)=(4) Similarly, c′i (X) = ∧{∨j∈J µj : J ⊆ [k], |J| ≥ i}, so the closed subset corresponding to it is T S J⊆[k],|J|≥i j∈J Sµj . A rotation ρ is not part of this closed subset if and only if there are at least i Sµj ’s that do not contain ρ. In other words, the complement of the closed subset is {ρ : n ¯ ρ,X ≥ i}. ¯ X) = {ρ : n Thus, the closed subset is S(i, ¯ ρ,X < i} so (6)=(4). 2 7

Notice that Theorem 6 is slightly stronger than Theorem 1 since the stable matchings in X need not be distinct. Combining it with Theorem 2, we have the next result. Corollary 1 Let I be an SM instance and X ∈ M (I)k . When k is even, the stable matchings in the interval [αk/2,X , αk/2+1,X ] are exactly the X-medians; when k is odd, α(k+1)/2,X is the unique X-median. We also arrive at the following characterizations of the generalized median stable matchings. Corollary 2 Let I be an SM instance with N stable matchings. For each ρ ∈ R(I), let n ¯ ρ denote the number of closed subsets of R(I) that do not contain ρ. For i = 1, . . . , N , αi = βN −i+1 is the ¯ = {ρ : n stable matching corresponding to the closed subset S(i) ¯ ρ < i}, and to cN −i+1 (M (I)) and ′ ci (M (I)). Additionally, when N is even, the stable matchings in the interval [αN/2 , αN/2+1 ] are exactly the medians of M(I); when N is odd, α(N +1)/2 is the unique median of M(I). In the example in Section 2, nρ1 = 1, nρ2 = nρ3 = 3, nρ4 = 5, and N = 6 so S(3) = {ρ1 } and S(4) = {ρ1 , ρ2 , ρ3 }, which are the closed subsets that correspond to µ2 and µ5 respectively. Hence, the stable matchings in the interval [µ2 , µ5 ] are the medians of M(I); that is, µ2 , µ3 , µ4 and µ5 are all medians of M(I). Next, we mention some implications of our results. 1. The fairness of a median stable matching of M(I). Corollary 2 states that a stable matching µ is a median of M(I) if and only if every person is matched to his/her lower or upper median stable partner in µ. That is, stable matchings are “globally median” if and only if they are “locally median”. This is quite remarkable since one does not expect that a stable matching that is fair in a global sense will also be fair in a local sense – and, yet, in this case it is! 2. Bypassing enumeration. Our results also imply that αi can be determined without enumerat¯ ing all the stable matchings of I. What must be computed is S(i), the closed subset of R(I) ¯ that corresponds to αi . In the next section, we show that there are situations in which S(i) can be computed efficiently. 3. Number of distinct generalized median stable matchings. Teo and Sethuraman [27] had already observed that an instance’s generalized median stable matchings need not be all distinct. For example, when R(I) is an antichain of size r, I has 2r stable matchings. For each ¯ ρ ∈ R(I), n ¯ ρ = 2r−1 . Thus, for 1 ≤ i ≤ 2r−1 , S(i) = ∅ which corresponds to µM , and for r−1 r ¯ 2 + 1 ≤ i ≤ 2 , S(i) = R(I) which corresponds to µW . In other words, I has only two types of generalized median stable matchings even though it has an exponential number of stable matchings. In general, how many could there be? By Corollary 2, it is equal to the ¯ sets. But this number is simply one more than the number of distinct number of distinct S(i) ¯ n ¯ ρ values; the additional one accounts for the fact that none of the rotations belong to S(1). Thus, I can have at most |R(I)| + 1 distinct types of generalized median stable matchings. Finally, we note that some of our results were proven independently by other authors. Fleiner [12] proved parts of the result in Theorem 6 – that αi,X = βk−i+1,X for i = 1, . . . , k are stable matchings using a fixed point approach. Nemoto [22] also proved a result equivalent to parts of Corollary 2 – ¯ is the closed subset corresponding to αi for i = 1, . . . , N . that S(i)

8

4

Computing the generalized median stable matchings

Given an SM instance I of size n, suppose we want to compute its ith generalized median stable matching αi . Without knowing N = |M (I)| ahead of time, it can be tricky to specify αi because its subscript may be a function of N . But computing N prior to specifying αi is not an option either since it is a #P-complete problem. Thus, we consider two kinds of problems. Since I has at most n(n − 1)/2 rotations and the number of closed subsets of R(I) cannot exceed its number of subsets, N ≤ 2n(n−1)/2 . In our first problem, we will assume that 1 ≤ i ≤ 2n(n−1)/2 . We will also adopt the convention that when i > N , αi = µW , the woman-optimal stable matching of I. In our second problem, we will assume that we are given two relatively prime positive integers p and q such that 1 ≤ p < q ≤ 2n(n−1)/2 , and i = ⌈pN/q⌉. Note that in both cases, the number of bits needed to specify i is O(n2 ), which is also the combined size of the preference lists in I. Here are our problems. GEN-MEDIAN-1(I, i) Given: an SM instance I of size n, a positive integer i such that 1 ≤ i ≤ 2n(n−1)/2 . Goal: compute αi . GEN-MEDIAN-2(I, p, q) Given: an SM instance I of size n, relatively prime positive integers p and q such that 1 ≤ p < q ≤ 2n(n−1)/2 . Goal: compute α⌈pN/q⌉ . We also define a version of GEN-MEDIAN-2 where p and q are “built into” the problem and are, therefore, constants. It captures the situation when we may simply be interested in computing a specific generalized median stable matching of I such as α⌈N/2⌉ . GEN-MEDIAN-(p,q)(I) Given: an SM instance I of size n. Goal: compute α⌈pN/q⌉ . Finally, we consider the dual versions of these problems where GEN-MEDIAN-DUAL-1(I, i) outputs αN −i+1 , and both GEN-MEDIAN-DUAL-2(I, p, q) and GEN-MEDIAN-DUAL-(p,q)(I) output αN −⌈pN/q⌉+1 . Notice that if one of the problems above can be solved efficiently, its dual can also be solved efficiently by using the same algorithm but with the roles of men and women reversed. We shall demonstrate next that the problems we have defined are closely related to the problem of computing the number of closed subsets of an arbitrary poset.

4.1

Easy cases

Let P = (P, ≤) be a poset. For each element x ∈ P , let P x = P − {y ∈ P : x ≤ y}. Notice that the number of closed subsets of P that do not contain x is exactly the number of closed subsets of the poset P x = (P x , ≤). Theorem 7 Let I be an SM instance of size n and i be a positive integer such that 1 ≤ i ≤ 2n(n−1)/2 . When i = O(log n), GEN-MEDIAN-1(I, i) and its dual can be solved in polynomial time. ¯ = {ρ ∈ R(I) : n Proof According to Corollary 2, S(i) ¯ ρ < i} is the closed subset that corresponds ¯ ¯ to αi . To determine the set S(i), we note that when R(I)ρ has at least i − 1 rotations, ρ 6∈ S(i) ρ ρ since R(I) has at least i closed subsets; on the other hand, when R(I) has at most i − 2 rotations, we can check which of its subsets are closed to compute n ¯ ρ . Our algorithm is as follows:

9

COMPUTE-GM(I, i) 1. Construct G(I), the rotation digraph of I. 2. For each rotation ρ, determine the elements in R(I)ρ . If it has at most i − 2 rotations, do the following: set n ¯ ρ = 0. For each subset S of R(I)ρ , determine if S is closed. If it is closed, ¯ increase n ¯ ρ by 1. When the for loop has ended, if n ¯ ρ < i, add ρ to S(i). ¯ 3. Construct µM , the man-optimal stable matching of I. Eliminate S(i) from µM and return the resulting stable matching. The correctness of the algorithm follows from Corollary 2 and our discussion above. Let us analyze its run-time. To implement COMPUTE-GM(I, i), we first compute the transitive closure of G(I) and store the information in a table T . That is, the rows and columns of T are indexed by the rotations of I such that T (ρ, ρ′ ) = 1 if and only if ρ ≤ ρ′ . Using the Floyd-Warshall algorithm, the transitive closure of G(I) and T can be determined in O(n6 ) time. Using T , it is easy to determine if S ⊆ R(I) is a closed subset: for each ρ ∈ S, scan the row indexed by ρ to check if all of its predecessors also belong to S. This can be done in O(|S|n2 ) time. In ρ step 2 of COMPUTE-GM(I, i), determining the elements in R(I)ρ takes O(n2 ) time. P When |R(I)2 | ≤ ρ i − 2, checking which subsets of R(I) are closed to determine n ¯ ρ takes O( S⊆R(I)ρ |S|n ) = i 2 2 i 4 O(i2 n ) time. Since I has O(n ) rotations, step 2 takes O(i2 n ) time. Steps 1 and 3 take O(n2 ) time. Thus, the algorithm can be implemented in O(n6 + i2i n4 ) time, which is polynomial in n when i is O(log n). 2 Next, we consider families of SM instances for which all the problems we mentioned above can be solved efficiently. Let us say that a class of posets C is hereditary if for each poset P = (P, ≤) ∈ C and each x ∈ P , the subposet P x also belongs to C. Theorem 8 Suppose C is a class of posets that is hereditary. Additionally, for any poset P = (P, ≤) ∈ C, cs(P) can be computed in time polynomial in |P |. Let I be an SM instance of size n. If the rotation poset of I belongs to C, then the problems GEN-MEDIAN-1(I, i), GEN-MEDIAN-2(I, p, q), GEN-MEDIAN-(p,q)(I) and their duals can be solved in time polynomial in n. Proof Let P ∈ C. Suppose cs(P) can be computed in f (|P |) time, where f (|P |) is a polynomial in |P |. First, construct R(I) and compute N = cs(R(I)). Next, for each rotation ρ, compute n ¯ ρ = cs(R(I)ρ ). Since I has at most n(n − 1)/2 rotations, all these values can be computed in O(n2 f (n2 )) total time. Finally, find the appropriate closed subset that corresponds to αi or α⌈pN/q⌉ and eliminate it from µM . This takes O(n2 ) time. Hence, when R(I) ∈ C, a specific αi or α⌈pN/q⌉ can be computed in time polynomial in n. 2 Computing the number of closed subsets of a poset can be determined efficiently for several classes of posets. Faigle, et al. [10] showed that this was the case for series-parallel posets and interval orders, while Steiner [25, 26] did so for the more general class of two-dimensional posets. See [20] for a nice survey on these ordered set classes. It is also straightforward to verify that each of these classes of posets is hereditary. Corollary 3 Let I be an SM instance of size n. When R(I) is a series-parallel poset, an interval order or a two-dimensional poset, the problems GEN-MEDIAN-1(I, i), GEN-MEDIAN-2(I, p, q), GEN-MEDIAN-(p,q)(I) and their duals can be solved in time polynomial in n. We also note a family of SM instances with N stable matchings where computing α⌈N/2⌉ is easy. 10

Lemma 3 Let I be an SM instance with N stable matchings. If ρ ∈ R(I) has no predecessors but ¯ has some successors in R(I), then ρ ∈ S(⌈N/2⌉). If ρ ∈ R(I) has no successors in R(I), then ¯ ρ 6∈ S(⌈N/2⌉). Proof Suppose ρ has no predecessors but has some successors in R(I). Let f be a function that maps a closed subset S that does not contain ρ to S ∪ {ρ}, clearly a closed subset that contains ρ. It is easy to check that f is one-to-one. Furthermore, f is not onto since the closed subsets that contain the successors of ρ have no pre-images under f (e.g., R(I)). Hence, n ¯ ρ < nρ . Since n ¯ ρ + nρ = N , n ¯ ρ < N/2. On the other hand, when ρ ∈ R(I) has no successors but has some predecessors in R(I), a similar argument would imply that n ¯ ρ > N/2. Finally, when ρ is a singleton (i.e., it has no predecessors and no successors in R(I)), the function f described above will be both one-to-one and onto so n ¯ ρ = nρ = N/2. When N is even, clearly all rotations with no predecessors but with some successors belong to ¯ S(N/2) while those with no successors do not. When N is odd, there are no singleton rotations. Once again, the same result holds. 2 The following is immediate. Theorem 9 Let I be an SM instance of size n with N stable matchings. Suppose that each ρ ∈ R(I) either has no predecessors or has no successors in R(I) (i.e., R(I) consists of at most two layers). Then ¯ S(⌈N/2⌉) = {ρ : ρ has no predecessor but has at least one successor in R(I)}. Thus, problem GEN-MEDIAN-(1,2)(I) and its dual can be solved in O(n2 ) time. Interestingly, we do not know if the other problems can be solved efficiently for the instances described in Theorem 9.

4.2

Hard cases

Theorem 10 GEN-MEDIAN-1(I, i) and its dual are #P-hard. Proof Let ALG-1(I, i) be an algorithm that solves GEN-MEDIAN-1(I, i) in time f (|I|, i), where |I| denotes the size of I. Let P = (P, ≤) be a poset. The main idea behind our proof is that ALG-1(I, i) can be used to answer queries of the form “Is cs(P) < i?”. Query(P, i) 1. Construct the poset P0 = P +O x, where x is the singleton poset containing x. 2. Construct an SM instance I(P0 ) whose rotation poset is isomorphic to P0 . Find the rotation ρx in R(I(P0 )) that corresponds to x. 3. Let µ be the stable matching returned by ALG(I(P0 ), i). Determine Sµ , the closed subset of R(I(P0 )) that corresponds to µ. 4. If ρx ∈ Sµ return “yes”; else, return “no”. By construction, cs(P0 ) = cs(P) + 1 and n ¯ x = cs(P). Since µ is the ith generalized median stable matching of I(P0 ), ρx ∈ Sµ if and only if n ¯ ρx < i. But n ¯x = n ¯ ρx so ρx ∈ Sµ if and only if cs(P) < i. The correctness of Query(P, i) follows. Let P0 = P ∪ {x}. Since |P0 | = |P | + 1, and I(P0 ) has size and construction time that is O(|P0 |2 ), it is easy to verify that the run-time of Query(P, i) is polynomial in |P | and f (|P |2 , i).

11

Now, cs(P) ≤ 2|P | . To determine cs(P) exactly, we do a binary search over the range [1, 2|P | ] using Query(P, i) as a subroutine. Clearly, O(|P |) queries are sufficient where the value of i in each query is at most 2|P | . If ALG-1(I, i) also runs in time polynomial in its input size (i.e., f (|I|, i) is polynomial in |I| and log i), the algorithm we have just described computes cs(P) in time polynomial in |P |. But from Theorem 4, computing cs(P) is #P-complete. It follows that GEN-MEDIAN-1(I, i) is #P-hard. By interchanging the roles of men and women, it is also the case that GEN-MEDIAN-DUAL-1(I, i) is #P-hard. 2 Theorem 11 Let p and q be relatively prime positive integers such that p < q. GEN-MEDIAN-(p,q)(I) and its dual are #P-hard. Thus, GEN-MEDIAN-2(I, p, q) and its dual are also #P-hard. Proof Let us first consider the case when p = 1. Our argument is very similar to the one used for Theorem 10. Suppose ALG-2-(1,q)(I) solves GEN-MEDIAN-(1,q)(I) in f (|I|) time. Let P = (P, ≤) be a poset. Here is a query algorithm for determining if cs(P) < i. Query-2(P, i) 1. Construct the poset P0 = ((Qq +D P) +O x) +O Qq(q−1)i , where x is the singleton poset containing x and QM is the poset described in Lemma 2. 2. Construct an SM instance I(P0 ) whose rotation poset is isomorphic to P0 . Find the rotation ρx in R(I(P0 )) that corresponds to x. 3. Let µ be the stable matching returned by ALG-2-(1,q)(I(P0)). Determine Sµ , the closed subset of R(I(P0 )) that corresponds to µ. 4. If ρx ∈ Sµ return “yes”; else, return “no”. It is easy to verify that cs(P0 ) = q × cs(P) + q(q − 1)i and n ¯ x = q × cs(P). Now, ρx ∈ Sµ if and only if n ¯ ρx < cs(P) + (q − 1)i. And since n ¯x = n ¯ ρx , it follows that ρx ∈ Sµ if and only if cs(P) < i. The correctness of Query-2(P, i) follows. Applying Lemma 2 and the fact that q is a constant, the size of |P0 | is polynomial in |P | + log2 i. It follows that steps 1, 2, and 4 also run in time polynomial in |P | + log2 i. If the run-time of ALG-2-(1,q)(I) is polynomial in its input size, step 3 runs in time polynomial in |P | + log 2 i. Consequently, Query-2(P, i) can be implemented to run in time polynomial in |P | and log2 i. As in the proof of Theorem 10, this implies that we can determine cs(P) efficiently, a known #P-complete problem. Hence, GEN-MEDIAN-(1,q)(I) has to be an #P-hard problem. Let us now consider GEN-MEDIAN-(p,q)(I) for p > 1. Suppose ALG-2-(p,q)(I) is an algorithm that solves the problem in g(|I|) time. This time we shall use the algorithm to find the ⌈|M (I)|/q⌉generalized median stable matching of I. ConstructMedian-q(I) 1. Find positive integers k and r so that pk = qr + 1. (Since p and q are relatively prime, these integers exist. Also, 1 ≤ k ≤ q and 1 ≤ r ≤ p.) 2. Let P = R(I). Create the poset P0 = P (1) +O x(1) +O P (2) +O x(2) +O . . . +O x(k−1) +O P (k) so that there are k copies of P and k − 1 copies of x alternating in P0 . For each ρ ∈ R(I), label as ρ(j) the element that corresponds to ρ in the jth copy of P. Similarly, label as x(j) the jth copy of x. Construct an SM instance I(P0 ) whose rotation poset is isomorphic to P0 . 3. Let µ be the stable matching returned by ALG-2-(p, q)(I(P0 )). Determine Sµ , its corresponding subset in R(I(P0 )). 4. Let Sµ′ consist of the rotations in P0 that have corresponding rotations in Sµ . (Find these rotations using the isomorphism from P0 to the rotation poset of I(P0 ).) Let Sµ′′ = {ρ ∈ P : ρ(r+1) ∈ Sµ′ }. 12

5. Find the man-optimal matching of I, µM . Create the ⌈|M (I)|/q⌉-generalized median stable matching of I by eliminating Sµ′′ from µM and return the stable matching. It is straightforward to verify the following: cs(P0 ) = k × cs(P), n ¯ x(j) = j × cs(P) for 1 ≤ j ≤ ¯ ρ for each ρ ∈ R(I), 1 ≤ j ≤ k. By our choice of k and r, k − 1, and n ¯ ρ(j) = (j − 1) × cs(P) + n we know that pk/q = r + 1/q. Thus, ⌈p × cs(P0 )/q⌉ = ⌈pk × cs(P)/q⌉ = r × cs(P) + ⌈cs(P)/q⌉. Consequently, in step 4, Sµ′ = ∪rj=1 {ρ(j) : ρ ∈ R(I)} ∪ {ρ(r+1) : n ¯ ρ < ⌈cs(R(I))/q⌉} ∪ {x(j) : j ≤ r}. ¯ ρ < ⌈cs(R(I))/q⌉}. Since Sµ′′ is the closed subset that corresponds to the Thus, Sµ′′ = {ρ : n ⌈|M (I)|/q⌉-generalized stable matching of I, step 5 outputs the correct stable matching. Since p and q are constants, |P0 | = O(|R(I)|). Also, |I(P0 )| = O(|R(I)|2 ) so |I(P0 )| = O(|I|4 ). It is easy to verify that steps 1, 2, 4 and 5 can be accomplished in time polynomial in |I|. If ALG-2-(p, q)(I) runs in time polynomial in its input size, step 4 will also run in time that is polynomial in |I|; that is, ConstructMedian-q(I) is an efficient algorithm. But we just showed that finding the ⌈|M (I)|/q⌉-generalized stable matching of I is an #P-hard problem. It follows that computing the ⌈p|M (I)|/q⌉-generalized stable matching of I when p > 1 is also #P-hard. Finally, by interchanging the roles of men and women, GEN-MEDIAN-DUAL-2(I, p, q) is also #Phard. 2 Corollary 4 Let I be an SM instance. Computing a median of M(I) is #P-hard. Proof First, we make the following observations. Let P = (P, ≤) be a poset. Let P0 = x1 +O (x2 +D P) where, again, xi is a singleton poset containing xi . Hence, cs(P0 ) = 1 + 2cs(P), an odd number. For each x ∈ P , let n ¯ x,P0 and n ¯ x,P denote the number of closed subsets that do not contain x in P0 and in P respectively. It is easy to verify that n ¯ x,P0 = 2¯ nx,P + 1 so that n ¯ x,P0 < cs(P20 )+1 if and only if n ¯ x,P < cs(P) 2 . Given SM instance I, let P = R(I). Construct I0 so that P0 is isomorphic to R(I0 ). Clearly I0 can be obtained from I in time polynomial in the size of I. For each ρ ∈ R(I), let ρ0 be its corresponding element in R(I0 ). Let κi and δi denote the ith generalized median stable matchings of I and I0 respectively. Since N0 = |M (I0 )| is odd, M(I0 ) has a unique median κ(N0 +1)/2 . Our discussion from the previous paragraph implies that ρ0 ∈ Sκ(N0 +1)/2 if and only if ρ ∈ Sδ⌈N/2⌉ . Hence, the problem of computing the ⌈N/2⌉- generalized median stable matching of I can be polynomially reduced to the problem of computing a median for I0 . Since the former is an #P-hard problem, it follows that the latter must also be #P-hard. 2 We note that Corollary 4 can also be inferred from Lemma 3.54 of Feder’s thesis [11], where a median set is called a distance center.

5

Approximating a median stable matching

We have shown that the median stable matchings of M(I) are very fair stable matchings of I. However, our negative results from the previous section show that finding any one of them is likely to be computationally hard. A natural direction then is to approximate such stable matchings. We define one such notion below. ¯ Recall that S(i) contains all the rotations ρ of I such that n ¯ ρ < i. In our definition, we will ¯ = S(⌈i⌉). ¯ allow i to be any non-negative real number, so S(i) 13

Definition 1 Let I be an SM instance with N stable matchings and µmed be a median stable matching of M(I). Let 0 ≤ ǫ ≤ 1. We say that a stable matching µ ∈ M (I) is an ǫ-approximation 1 ¯ ǫN ) ⊆ Sµ ⊆ S(N ¯ of µmed if S( − ǫN 2 2 + 2 ). Thus, when ǫ = 1, µ ∈ [αN/2 , αN/2+1 ] if N is even, and µ = α(N +1)/2 if N is odd; when ǫ = 1/2, µ ∈ [αi , αi′ ] where i and i′ are approximately N/4 and 3N/4 respectively. We also note that the closer ǫ is to 1, the less variable are the rankings of the participants’ partners in µ and, consequently, the fairer is µ. Theorem 7 implies that when I is an SM instance of size n with N stable matchings, an O(log n/N )-approximation to µmed can be computed efficiently. Next, we present a slight improvement over this result. Lemma 4 Let P = (P, ≤) be a poset. Suppose that P ′ = (P, ≤′ ) is another poset defined on P such that x ≤ y implies x ≤′ y. Let N and N ′ be the number of closed subsets of P and P ′ respectively. For each x ∈ P , let n ¯ x,P and n ¯ x,P ′ denote the number of closed subsets not containing x in P and P ′ respectively. For i = 1, . . . , N ′ , ¯ ¯ = {ρ : n − N ′ + i) = {ρ : n ¯ x,P < N − N ′ + i}. S(i) ¯ x,P < i} ⊆ S¯′ (i) = {ρ : n ¯ x,P ′ < i} ⊆ S(N ′ /2⌉) ⊆ S ¯ ¯′ (⌈N ′ /2⌉) ⊆ S(N ¯ In particular, S(⌈N − ⌊N ′ /2⌋).

Proof It is easy to verify that every closed subset of P ′ is also a closed subset of P. Thus, for ¯ ⊆ S¯′ (i). ¯ x,P . This implies that if n ¯ x,P < i, then n ¯ x,P ′ < i as well so that S(i) each x ∈ P , n ¯ x,P ′ ≤ n ¯ x,P ′ < i, nx,P ′ > N ′ − i and ¯ x,P ′ + nx,P ′ = N ′ so if n Similarly, for each x ∈ P, nx,P ≥ nx,P ′ . Now, n ′ ′ ¯ ¯ nx,P > N − i. But n ¯ x,P + nx,P = N so n ¯ x,P < N − N + i. That is, S ′ (i) ⊆ S(N − N ′ + i). 2 The above lemma becomes useful to us in the following way. Let P = R(I). Embed P into so that S¯′ (⌈N ′ /2⌉) can be computed efficiently – e.g., let P ′ be a series-parallel poset. Since ′ ¯ S (⌈N ′ /2⌉) is also a closed subset of R(I), there is a stable matching µ that corresponds to this subset. According to Lemma 4, µ is an ǫ-approximation of µmed where ǫ ≈ N ′ /N . P′

Theorem 12 Let I be an SM instance of size n with N stable matchings. An O(log N/N )approximation to a median stable matching of M(I) can be computed in O(n2 ) time. Proof Choose P ′ so that it is a linear ordering of R(I), and let µ be the stable matching that corresponds to the closed subset containing the first ⌈r/2⌉ rotations of the linear ordering, where r = |R(I)|. Since N ′ = r + 1 and N ≤ 2r , it follows that µ is an O(log N/N )-approximation of a median stable matching of M(I). Constructing R(I) and its accompanying digraph G(I) takes O(n2 ) time. Topologically sorting its rotations also takes O(n2 ) time. Finding µM , and then eliminating the first ⌈r/2⌉ rotations from µM also takes O(n2 ) time. Thus, finding the stable matching in the theorem takes O(n2 ) time. 2 Unfortunately, this is the best that we can do – we have not been able to find a P ′ that provides a better guarantee. We suspect though that our result can be improved since choosing a chain for P ′ seems too simple. Open Problem: Given an SM instance I, design an efficient algorithm that finds an ǫ-approximation to a median of M(I) where ǫ is ω(log N/N ), N = |M (I)|.

14

6

Final remarks

Throughout this paper, we have assumed that the preference lists in an SM instance are complete – that is, every man has every woman in his preference list and vice versa. But what about other variants of the stable marriage problem? For our main characterization result (Theorem 6) to work, the important ingredients are (i) the set of stable matchings forms a distributive lattice so that the fifth and sixth stable matchings in the theorem are well-defined, (ii) rotations exist and there is a one-to-one correspondence between the closed subsets of the rotation poset and the stable matchings so that the third and fourth stable matchings in the theorem are again well-defined and are equal to the fifth and sixth ones, and (iii) the stable partners of the participants are reflected in the rotations so that the first and second sets of man-woman pairs are equal to the fourth stable matching in the theorem. These are satisfied, for example, by SM instances with incomplete preference lists (see p.28 of [15]), and by the many-to-one version of SM or the so-called hospital/residents (HR) problem (see [4, 9]). Hence, the results in this paper apply to these variants of the stable marriage problem too. Finally, we refer readers to a recent preprint of Kijima and Nemoto [17] which contains improvements to some of our computational results.

Acknowledgments The author would like to thank Buck McMorris for pointing her to the literature on medians in distributive lattices, and the anonymous reviewers whose comments helped improve the presentation of the paper.

References [1] A. Abdulkadiroglu, P. Pathak, and A. Roth. The New York City high school match. American Economic Review, Papers and Proceedings, 95:364–367, 2005. [2] A. Abdulkadiroglu, P. Pathak, A. Roth, and T. S¨ onmez. The Boston public school match. American Economic Review, Papers and Proceedings, 95:368–371, 2005. [3] H. Bandelt and J. Barthelemy. Medians in median graphs. Discrete Applied Mathematics, 8:131–142, 1984. [4] V. Bansal, A. Agrawal, and V. Malhotra. Polynomial time algorithm for an optimal stable assignment with multiple partners. Theoretical Computer Science, 379:317–328, 2007. [5] M. Barbut. M´ediane, distributivit´e, ´eloignements, 1961. Reprinted in Math´ematiques et Sciences Humaines,70:5–31, 1980. [6] G. Birkhoff and S. Kiss. A ternary operation in distributive lattices. Bulletin of the American Mathematical Society, 53:749–752, 1947. [7] C. Blair. Every finite distributive lattice is a set of stable matchings. Journal of Combinatorial Theory A, 37:353–356, 1984. [8] C. Cheng. The generalized median stable matchings: finding them is not that easy. In Proceedings of the 8th Latin Theoretical Informatics Conference, pages 568–579, 2008.

15

[9] C. Cheng, E. McDermid, and I. Suzuki. A unified approach to finding good stable matchings in the hospitals/residents setting. Theoretical Computer Science, 400:84–99, 2008. [10] U. Faigle, L. Lov´asz, R. Schrader, and G. Tur´ an. Searching in trees, series-parallel and interval orders. SIAM Journal on Computing, 15:1075–1084, 1986. [11] T. Feder. Stable networks and product graphs, volume 116 of Memoirs of the American Mathematical Society. AMS Bookstore, 1995. [12] T. Fleiner. A fixed-point approach to stable matchings and some applications. Mathematics of Operations Research, 28:103–126, 2003. [13] D. Gale and L. Shapley. College admissions and the stability of marriage. American Mathematical Monthly, 69:9–15, 1962. [14] D. Gusfield. Three fast algorithms for four problems in stable marriage. SIAM Journal on Computing, 16:111–128, 1987. [15] D. Gusfield and R. Irving. The Stable Marriage Problem: Structure and Algorithms. The MIT Press, 1989. [16] R. Irving and P. Leather. The complexity of counting stable marriages. SIAM Journal on Computing, 15:655–667, 1986. [17] S. Kijima and T. Nemoto. Randomized approximation for the generalize median stable matchings. A preprint, RIMS-1648, 2008. [18] B. Klaus and F. Klijn. Median stable matchings for college admissions. International Journal of Game Theory, 34:1–11, 2006. [19] B. LeClerc. Medians and majorities in semimodular lattices. SIAM Journal of Discrete Mathematics, 3:266–276, 1990. [20] R. M¨ohring. Computationally tractable classes of ordered sets. In I. Rival, editor, Algorithms and Order, pages 105–193. Kluwer Academic Publishers, 1989. [21] B. Monjardet. Th´eorie et application de la m´ediane dans les treillis distributifs finis. Annals of Discrete Mathematics, 9:87–91, 1980. [22] T. Nemoto. Some remarks on the median stable marriage problem. Proceedings of the 17th International Symposium on Mathematical Programming, 2000. [23] J. Provan and M. Ball. The complexity of counting cuts and of computing the probability that a graph is connected. SIAM Journal on Computing, 12:777–788, 1983. [24] A. Roth and E. Peranson. The redesign of the matching market of American physicians: Some engineering aspects of economic design. American Economic Review, 89:748–780, 1999. [25] G. Steiner. Single machine scheduling with precedence constraints of dimension 2. Mathematics of Operations Research, 9:248–259, 1984. [26] G. Steiner. Searching in 2-dimensional partial orders. Journal of Algorithms, 8:95–105, 1987. [27] C.-P. Teo and J. Sethuraman. The geometry of fractional stable matchings and its applications. Mathematics of Operations Research, 23:874–891, 1998.

16