# Stable Marriage with Covering Constraints: A Complete Computational Trichotomy

## Abstract

We consider Stable Marriage with Covering Constraints (SMC): in this variant of Stable Marriage, we distinguish a subset of women as well as a subset of men, and we seek a matching with fewest number of blocking pairs that matches all of the distinguished people. We investigate how a set of natural parameters, namely the maximum length of preference lists for men and women, the number of distinguished men and women, and the number of blocking pairs allowed determine the computational tractability of this problem. Our main result is a complete complexity trichotomy that, for each choice of the studied parameters, classifies SMC as polynomial-time solvable, -hard and fixed-parameter tractable, or -hard and -hard. We also classify all cases of one-sided constraints where only women may be distinguished.

## 1Introduction

The Stable Marriage (SM) problem is a fundamental problem first studied by Gale and Shapley [18] in 1962. An instance of SM consists of a set of men, a set of women, and a preference list for each person ordering members of the opposite sex. We aim to find a stable matching, i.e., a matching for which there exists no pair of a man and a woman who prefer each other to their partners given by the matching; such a pair is called a blocking pair.

We consider a problem that we call Stable Marriage with Covering Constraints (SMC). Here, a set of women and a set of men are distinguished, and a feasible matching is one where each person in gets matched. By the Rural Hospitals Theorem [19] we know that the set of unmatched men and women is the same in all stable matchings, so clearly, feasible stable matchings may not exist. Thus, we define the task in SMC as finding a feasible matching with a minimum number of blocking pairs. Somewhat surprisingly, this natural extension of SM has not been considered before.

### 1.1Motivation

Our main motivation for studying SMC—apart from its natural definition—is its close relationship with the Hospitals/Residents with Lower Quota (HRLQ) problem, modelling a situation where medical residents apply for jobs in hospitals: residents rank hospitals and vice versa, and hospitals declare both *lower* and *upper quotas* which bound the number of residents they can accept; the task is to find an assignment with a minimum number of blocking pairs. By the frequently applied method of “cloning” hospitals, HRLQ reduces to the case where each hospital has unit upper quota. In fact, this is equivalent to the special case of SMC where only women (or, equivalently, men) are distinguished. We refer to this problem with one-sided covering constraints, linking SMC and HRLQ, as SMC-1.

The HRLQ problem and its variants have recently gained quite some interest from the algorithmic community [4]. In his book, Manlove [33] devotes an entire chapter to the algorithmics of different versions of the HRLQ problem.

The reason for this interest in HRLQ is explained by its importance in several real-world matching markets [16] such as school admission systems, centralized assignment of residents to hospitals, or of cadets to military branches. Lower quotas are a common feature of such admission systems. Their purpose is often to remedy the effects of understaffing that are explained by the well-known Rural Hospitals Theorem [19]: as an example, governments usually want to assign at least a small number of medical residents to each rural hospital to guarantee a minimum service level. Minimum quotas are also discussed in controlled school choice programs [12] where students are divided into a small number of types, and schools set lower bounds for each type. Such models can represent various forms of affirmative actions taken by schools to, e.g., admit a certain number of minority students [12]. Another example is the German university admission system for admitting students to highly oversubscribed subjects, where a certain percentage of study places is assigned according to high school grades or waiting time [39]. But lower quotas may also arise due to financial considerations: for instance, a business course with too few (tuition-paying) attendees may not be profitable. Certain aspects of airline preferences for seat upgrade allocations can be also modelled by lower quotas [32].

Another motivation for studying the SMC problem comes from the following scenario that we dub *Control for Stable Marriage*. Consider a two-sided market where each participant of the market expresses its preferences over members of the other party, and some central agent (e.g., a government) performs the task of finding a stable matching in the market. It might happen that this central agency wishes to apply a certain *control* on the stable matching produced: it may favour some participants by trying to assign them a partner in the resulting matching. Such a behaviour might be either malicious (e.g., the central agency may accept bribes and thus favour certain participants) or beneficial (e.g., it may favour those who are at disadvantage, like handicapped or minority participants). However, there might not be a stable matching that covers all participants the agency wants to favour; thus arises the need to produce a matching that is *as stable as possible* among those that fulfil our constraints—the most natural aim in such a case is to minimize the number of blocking pairs in the produced matching, which yields exactly the SMC problem. Similar control problems for voting systems have been extensively studied in the area of social choice following the work initiated by Bartholdi III. et al. [3], but have not yet been considered in connection to stable matchings.

### 1.2Our Results

We provide an extensive algorithmic analysis of the SMC problem and its special case SMC-1. In our analysis, we examine how different aspects of the input influence the tractability of these problems. To this end, we apply the framework of parameterized complexity, which deals with computationally hard problems and focuses on how certain *parameters* of a problem instance influence its tractability; for background, we refer to the book by Cygan et al. [10]. We aim to design so-called *fixed-parameter algorithms*, which perform well in practice if the value of the parameter on hand is small (for the precise definitions, see Sect. Section 2).

The parameters we consider are

the number of blocking pairs allowed,

the number of women with covering constraint,

the number of men with covering constraint,

the maximum length of women’s preference lists, and

the maximum length of men’s preference lists.

The choice of each of these parameters is motivated by the aforementioned applications. For instance, we seek matchings where ideally no blocking pairs at all or at least only few of them appear, to ensure stability of the matching and happiness of those getting matched. The number of women/men with covering constraints corresponds, for instance, to the number of rural hospitals for which a minimum quota specifically must be enforced, which we can expect to be small among the set of all hospitals accepting medical residents. Finally, preference lists of hospitals and residents can be expected to be small, as each hospital might not rank many more candidates than the number of positions it has to fill, whereas residents might rank only their top choices of hospitals.

We investigate in detail how these parameters influence the complexity of the SMC problem. A *parameterized restriction of SMC* with respect to the set means a (possibly parameterized) special case of SMC where each element of is either restricted to be some constant integer, or regarded as a parameter, or left unbounded. Intuitively, these different choices for the elements of correspond to their expected “range” in applications, from very small to mid-range to large (compared to the size of the entire system). By considering all combinations, we can flexibly model the whole range of applications mentioned above.

A decision diagram in Section 7 shows that the presented results indeed cover all restrictions of SMC with respect to the set . Table 1 summarizes our results on the complexity of SMC. Note that some results are implied directly by the symmetrical roles of men and women in SMC, and thus are not stated explicitly.

constants | parameters | complexity |
---|---|---|

, | in (Gale-Shapley alg.) | |

in (Thm. ) | ||

in (Thm. ) | ||

in (Thm. ) | ||

in (Observ. ) | ||

in (Observ. ) | ||

-hard (Thm. ) | ||

-hard (Thm. ) | ||

-hard (Thm. ) | ||

-hard (Thm. ) | ||

(Thm. ) | ||

(Cor. ) | ||

As a special case, we answer a question by Hamada et al. [23] who gave an exponential-time algorithm that in time decides for a given instance of HRLQ whether it admits a feasible matching with at most blocking pairs^{1}

### 1.3Related Work

There is a dynamically growing literature on matching markets with lower quotas [4]. These papers study several variants of HRLQ, adapting the general model to the various specialties of practical problems. However, there are only a few papers which consider the problem of minimizing the number of blocking pairs [16]. The most closely related work to ours is the paper by Hamada et al. [23]: they prove that the HRLQ problem is -hard and give strong inapproximability results; they also consider the SMC-1 problem directly and propose an time algorithm for it.

A different line of research connected to SMC is the problem of *arranged marriages*, an early extension of SM suggested by Knuth [30] in 1976. Here, a set of man-woman pairs is distinguished, and we seek a stable matching that contains as a subset. Thus, as opposed to SMC, we not only require that each distinguished person is assigned *some* partner, but instead prescribe its partner exactly. Initial work on arranged marriages [30] was extended by Dias et al. [11] to consider also *forbidden marriages*, and was further generalized by Fleiner et al. [14] and Cseh and Manlove [9]. Despite the similar flavour of the studied problems, none of these papers have a direct consequence on the complexity of SMC.

Our work also fits into the line of research that addresses computationally hard problems in the area of stable matchings by focusing on instances with bounded preference lists [6] or by applying the more flexible approach of parameterized complexity [1].

**Organization.** After the preliminaries in Sect. Section 2, we start with the main intractability result in Sect. Section 3, which answers Hamada et al.’s question. This result shows -hardness of SMC parameterized by even when and . Thus, we explore three directions to achieve tractability: (i) to lower to be a constant, (ii) to lower to be a constant, or (iii) to lower either or to . We cover the cases (i) and (ii) in Sect. Section 5, and case (iii) in Sect. Section 6. In addition, Sect. Section 4 provides polynomial-time approximation results for HRLQ and SMC, used also in the polynomial-time algorithms of Sect. Section 5.

## 2Preliminaries

An instance of the Stable Marriage (SM) problem consists of a set of men and a set of women. Each person has a preference list that strictly orders the members of the other party acceptable for . We thus write as a vector , denoting that is (strictly) *preferred* by over for each and with . A *matching* for is a set of man-woman pairs appearing in each other’s preference lists such that each person is contained in at most one pair of ; some persons may be left unmatched by . For each person we denote by the person assigned by to . For a matching , a man and a woman included in each other’s preference lists form a *blocking pair* if (i) is either unmatched or prefers to , and (ii) is either unmatched or prefers to . In the Stable Marriage with Covering Constraints (SMC) problem, we are given additional subsets and of *distinguished* people that must be matched; a matching is *feasible* if it matches everybody in . The objective of SMC is to find a feasible matching for with minimum number of blocking pairs. If only people from one gender are distinguished, then without loss of generality, we assume these to be women; this special case will be denoted by SMC-1.

The many-to-one extension of SMC-1 is the Hospitals/Residents with Lower Quotas (HRLQ) problem whose input consists of a set of residents and a set of hospitals that have ordered preferences over the acceptable members of the other party. Each hospital has a quota lower bound and a quota upper bound , which bound the number of residents that can be assigned to from below and above. One seeks an *assignment* that maps a subset of the residents to hospitals that respects acceptability and is *feasible*, that is, for each hospital . Here, is the set of residents assigned to some by . We say that a hospital is *under-subscribed* if . For an assignment of an instance of HRLQ, a pair of a resident and a hospital is *blocking* if (i) is unassigned or prefers to the hospital assigned to by , and (ii) is under-subscribed or prefers to one of the residents in . The task in HRLQ is to find a feasible assignment with minimum number of blocking pairs.

Some instances of SMC may admit a *master list* over women, which is a total ordering of all women, such that for each man , the preference list is the restriction of to those women that finds acceptable. Similarly, we consider master lists over men.

With each instance of SMC (or HRLQ) we can naturally associate a bipartite graph whose vertex partitions correspond to and (or and , respectively), and there is an edge between a man and a woman (or between a resident and a hospital , respectively) if they appear in each other’s preference lists. We may refer to entities of as vertices, or a pair of entities as edges, without mentioning explicitly.

**Parameterized complexity.** The framework of parameterized complexity deals with computationally hard problems, examining their complexity in a more detailed way than classical complexity theory. In a parameterized problem problem , each input instance is associated with an integer called the *parameter*. An algorithm which decides instances of in time for some computable function is called a *fixed-parameter algorithm*. Note that the dependence of the polynomial in the run time is constant, but the dependence on the parameter can be arbitrary (and is typically exponential). However, if the parameter of a given instance is small, then such an algorithm can be useful in practice even if the overall size of the instance is large.

The class of problems admitting fixed-parameter algorithms is denoted by . To argue that a problem is *not* in , parameterized complexity provides a hardness theory. For two parameterized problems and , a *parameterized reduction* from to is a function , computable by a fixed-parameter algorithm, that maps each instance of to an instance of such that (i) is a “yes”-instance of if and only if is a “yes”-instance of , and (ii) for some function . The basic class of parameterized intractability is : proving a problem to be -hard is strong evidence that . Given some problem that is known to be -hard, a parameterized reduction from to some parameterized problem implies -hardness of as well.

For more on parameterized complexity, we refer the reader to the book by Cygan et al. [10].

## 3Strong Parameterized Intractability of SMC

This section provides parameterized intractability and inapproximability results for SMC showing the hardness of finding feasible matchings with minimum number of blocking pairs.

We give a reduction from the -hard Multicolored Clique parameterized by the size of the solution [13]. Let be the input graph, with its vertex set partitioned into sets ; the task is to find a clique of size in containing exactly one vertex from each of the sets . We let denote those edges that run between and for some . We fix an ordering on the vertices and edges of that places vertices of before vertices of whenever . We will write to denote the vertex following in this ordering, and we let and denote the first and last vertices in , respectively. Similarly, we write for the edge following , and we let and denote the first and last edges in , respectively. We will also write and for the predecessor of or , respectively. Also, we denote the -th neighbor of some vertex as . For simplicity, we assume that there is no isolated vertex in .

We construct an instance of SMC as follows; see Figure 1 and Figure 2 for an illustration.

We set the number of blocking pairs allowed for to be . Together with the instance , we will define a stable matching for as well, and for each woman of , we will denote the man by . Some women will need “dummy” partners in their preference lists: we denote the dummy of by . The dummy will always appear as the last item on ’s preference list, and its preference list will always be .

For each and with , we construct an *edge selecting gadget* that involves women and , together with women , , and for each edge . All women in are matched by except for , and contains the man for each of these women , together with additional dummies for each with preceding .

For each , we also construct a *node selecting gadget* involving women , and , together with women , , and for each . The men in include for each woman of except for , and additional dummies and for each .

We define the following sets of women:

To define the set of women in with covering constraint we let ; note . The finish the definition of , we define the precise structure of these gadgets as well as the connections between them by the preference lists shown in Tables ? and ?; when not stated otherwise, indices take all possible values.

For simplicity, we write , , and for any vertex .

Let us define a master list over all women as follows. The first women in are those in , in any ordering. They are followed by women in , ordered according to the reversed ordering over , that is, precedes exactly if precedes . Next follow women of , ordered according to the reversed ordering over . Next come women in . To order them, we first order those in by putting before in if and only if precedes or and , then for each edge with preceding , and we insert just before , and we insert just before , thus determining the ordering of . After women in come women of , with preceding exactly if or and precedes . We finish the definition of the master list by putting all women in at the end of in an arbitrary order.

The master list over men is derived from by letting precede whenever precedes in , and adding all dummies at the end in an arbitrary order. It is easy to check that the preference lists given in Tables ? and ? are indeed compatible with these master lists. This completes the construction of the instance.

We are going to prove that the constructed instance admits a feasible assignment with at most blocking pairs if and only if there is a clique of size in the graph .

””: Suppose there is a feasible matching of men to women with at most blocking pairs. Let be the symmetric difference . Notice that for each woman , the difference must contain exactly one path containing as its endpoint, since the women in must be matched in , but are unmatched in . Similarly, no path of can contain a woman in . We call a path in with an endpoint in an *augmenting path*. We say that *starts* at and *ends* at its other endpoint, and we refer to that path starting at (or ) as (or , respectively).

We define the *cost* of some path of as the number of blocking pairs for involving a woman that appears on . Since is stable, it should be clear that each augmenting path contains at least one edge that is blocking for , so each path in has cost at least . As there are exactly augmenting paths (as all women in must be matched by ), we get a minimum cost of . Note also that the total cost of all paths in cannot exceed . Claim ? is therefore crucial.

To prove (a), suppose for contradiction that ends at , where . Clearly, must contain at least one woman from each of the sets , . Fix , and let us consider the last for which is incident to an edge of . Let if , or otherwise let . Then the edge yields a blocking pair in , as , and thus prefers to . This reasoning gives us different blocking pairs for , one for each index , contradicting our assumption on .

To prove (b), let us consider the case when for some ; the argument goes the same way for the case where for some and . If ends at for some , then forms a blocking pair with in . If does not end at a woman in , then it must contain the edge for some , in which case is again blocking in , showing (b).

To see (c), first observe that if is not disjoint from , then ends in , simply because of its property that it contains edges from and in an alternating fashion. Therefore, the last woman on must be in . If for some , then the edge is blocking , as cannot get its first choice in (and cannot be on , as that would imply that is on , contradicting the choice of ). If, by contrast, for some , then must end at by (a), and then forms a blocking pair with the third man in its preference list (for whom is the first choice). In either case, is involved in a blocking pair, which together with the blocking pair guaranteed by (b) implies that has cost at least . This completes the proof of Claim ?.

Claim ? proves that for each the augmenting path has cost at least . Since all the remaining augmenting paths have cost at least , and the total cost of these paths must be at most , we get that any path (or ) must have cost *exactly* (or , respectively). Furthermore, it also follows that no other path of can enter or start in , for any , as that would imply that the number of blocking pairs for is more than . In addition, it is not hard to see that does not contain any cycle, because all cycles in the graph underlying contain two consecutive edges not in . Hence, it follows that the only connected component in that is not disjoint from is .

To deal with the possibly courses the path may take for some , let denote the vertex in for which is the blocking edge guaranteed by statement (b) of Claim ?. Observe that either ends at or contains the edge . In either case, we say that *selects* from ; clearly, there can be only one vertex in selected by .

Consider now for some . Recall that has cost . Therefore, statement (b) of Claim ? proves that the only blocking edge incident to some woman on must be for some . We say that *selects* the edge ; without loss of generality, let us assume that precedes . By statement (c) of Claim ?, we also know that cannot leave , which means that it can only have cost if it ends at . In particular, it contains the edges and . Observe that the edge where is such that cannot be blocking in (as this would indicate a cost of for ), yielding that must be matched to in . By the arguments of the previous paragraph, this means that must contain the subpath . Hence, we obtain that must be selected by . Similarly, from the fact that the edge where is not blocking in we get that must be selected by .

Thus, we obtain that if an edge is selected by for some and , then its endpoints must be selected by and . As this must hold for each pair of indices with , we obtain that there must be edges in whose endpoints are among the selected vertices. This can only happen if these edges are the edges of a clique of size .

””: Suppose now that has a clique of size formed by the vertices , with for each . Instead of directly defining the required matching that is feasible and admits at most blocking pairs, we give as the union of paths for , and paths for , defined as follows.

We set as the path

Similarly, we define

It is straightforward to verify that the blocking pairs for are then the edges , , the edges , and the edges , . The feasibility of is trivial; this completes the proof of Theorem ?.

A fundamental hypothesis about the complexity of -hard problems is the *Exponential Time Hypothesis* (ETH), which stipulates that algorithms solving all Satisfiability instances in subexponential time cannot exist [27]. Assuming ETH, the fundamental Clique problem parameterized by solution size was shown not to admit any algorithm giving the correct answer in time for all -vertex instances and any computable function [8]. The known reduction from Clique to Multicolored Clique does not change the parameter [13]. Finally, in the proof of Theorem ?, an instance of Multicolored Clique with solution size is reduced to an instance of SMC-1 with parameter .

## 4Polynomial-Time Approximation

Here we first provide a polynomial-time algorithm that yields a -factor approximation for HRLQ. Then we use this result to propose a polynomial-time algorithm for HRLQ for the case where both the maximum length of residents’ preference lists and the total sum of all lower quotas is constant. Recall that in HRLQ, our objective is to find an assignment that satisfies all quota lower and upper bounds and minimizes the number of blocking pairs.

We start by finding an assignment that assigns residents to each hospital , and has the following property:

Such an assignment can be obtained as follows. We start from an arbitrary assignment that assigns residents to each (if no such assignment exists, then we can stop and reject); such an assignment, if existent, can be found in polynomial time by an algorithm of Hopcroft and Karp [24]. Then we greedily re-assign residents to hospitals of , one-by-one: at each step, we take a hospital , and if there exists a resident not assigned to any other hospital in that prefers to the least preferred resident in , then we replace with in . If this step cannot be applied anymore, then we arrive at an assignment with the desired property .

Given , we reduce the upper quotas of each hospital by , set all lower quotas to , and delete all residents in . We then find a stable assignment in the resulting instance ; note that is an instance of HR, so we can find in polynomial time [18]. Finally, we output . Clearly, is feasible. Also, any blocking pair that admits must involve either a hospital from or a resident from by the stability of with respect to . Observe that if some is involved in some blocking pair of , then we must have . To see this, recall that each resident that is preferred by to its least preferred resident in must be in because of property , and furthermore, is under-subscribed in (within ) if and only if is under-subscribed in (within ). Therefore, we can conclude that each blocking pair for must involve some resident in ; recall . Since each resident in is incident to at most edges not in , we also have that admits at most blocking pairs.

If both and are constant, then Theorem ? implies that HRLQ becomes polynomial-time solvable. Indeed, we can use the following simple strategy, depending on the number of blocking pairs allowed: if , then we apply Theorem ? directly; if , then we use the algorithm by Hamada et al. [23] running in time which is polynomial, since is upper-bounded by a constant.

Another application of Theorem ? is an approximation algorithm that works regardless of whether or is a constant. In fact, the algorithm of Theorem ? can be turned into a -factor approximation algorithm as follows. First, we find a stable assignment for in polynomial time using the extension of the Gale-Shapley algorithm for the Hospitals/Residents problem. If is not feasible, then by the Rural Hospitals Theorem [19], we know that any feasible assignment for must admit at least one blocking pair; hence, the algorithm presented in Theorem ? clearly yields an approximation with (multiplicative and also additive) factor .

To close this section, we also state an analogue of Theorem ? that deals with SMC: it can handle covering constraints on both sides, but assumes that all quota upper bounds are .

We start by finding an arbitrary matching that covers each distinguished person (if no such matching exists, then we can stop and reject); such a matching, if existent, can be found in polynomial time by standard flow techniques. We assume, without loss of generality, that each edge in is incident to some distinguished person. Let us define , and let be the set of those persons whose partner is also in .

We proceed by modifying into a matching that covers and has the following property:

Such an assignment can be obtained as follows. We greedily re-assign partners to the men and women in , one-by-one: at each step, we take a person , and if forms a blocking pair (with respect to the current matching) with some that is not the partner of a distinguished person, then we replace the partner of with : we add the edge to the matching, and delete all the other edges incident to or . Observe that the obtained matching is still feasible. If this step cannot be applied anymore, then we arrive at a matching with the desired property ; note also that each edge in is incident to some distinguished person.

Given , we delete all men and women covered by . We then find a stable matching in the resulting instance ; note that is an instance of Stable Marriage, so we can find in polynomial time [18]. Finally, we output . Clearly, is feasible. Also, any blocking pair that admits must involve a person covered by due to the stability of with respect to .

We claim that any blocking pair involves a person whose partner by is distinguished, so either or . We can assume that is covered by (because this holds for at least one of and ). To see the claim, first note that if is not distinguished, then must be distinguished, because each edge of contains a distinguished person. Second, if , then either (in which case ) or because of property . Therefore, we can conclude that each blocking pair for must involve the partner of some distinguished resident. The partners of distinguished women can be incident to at most blocking pairs, and similarly, the partners of distinguished men can be incident to at most blocking pairs, proving the theorem.

## 5SMC with Bounded Number of Distinguished Persons or Blocking Pairs

In Theorem ? we proved -hardness of SMC-1 for the case where , with parameter . Here we investigate those instances of SMC and SMC-1 where the length of preference lists may be unbounded, but either , or the number of distinguished persons is constant.

First, if the number of blocking pairs allowed is constant, then SMC can be solved by simply running the extended Gale-Shapley algorithm after guessing and deleting all blocking pairs. This complements the result by Hamada et al. [23].

In Theorem ? we prove hardness of SMC-1 even if only one woman must be covered. If we require preferences to follow master lists, then a slightly weaker version of Theorem ?, where , still holds.

We present a reduction based on the one from Multicolored Clique given in the proof of Theorem ?. Given some graph and an integer as inputs, we are going to re-use the instance constructed in the proof of Theorem ?. Recall that has a feasible matching with at most blocking pairs exactly if has a clique of size . Recall also that the set of women that must be covered in is ; here we denote this set by .

We define a modified instance of SMC as follows. For each , we create a *forcing gadget* containing the newly introduced women and men . We also add the distinguished woman , who must be covered in , and the unique man in . See Figure 3 for an illustration.

Let denote the unique man acceptable for some in . Additionally, we let , and we write for an arbitrarily fixed ordering of the elements of . The preferences of the newly introduced men and women, as well as the modified preferences of those agents that find them acceptable, is given below. Here, again, indices take all possible values, and can be any woman in . We let contain all other women and men defined in , having the same preferences as in .

We will show that has a feasible matching with at most blocking pairs if and only if has such a matching; this clearly proves the theorem.

First observe that any feasible matching for contains the edge . Thus, if some woman in is not matched by to her first choice, then is blocking in . Consider now for some . It is straightforward to check that if , then there are at least two blocking pairs incident to a woman in . Indeed, assume first that is the only blocking pair in ; this quickly implies and , which in turn leads to blocking , a contradiction. Second, assume that does not block ; from this follows and we have that is a blocking pair for . Now either is blocking (in which case our claim holds), or we get , which implies that blocks , again a contradiction.

Now, let be the women in that must be covered in , i.e., . Consider the number of blocking pairs for that involve a woman either in the gadget or in a gadget for some . On the one hand, if some is not matched by to , then because of the blocking pairs in . On the other hand, if each is matched by to , then using the arguments of the proof for Theorem ?, we again know because of the blocking pairs in . Also, can only be achieved if (i) , as otherwise would be blocking for , in addition to the two blocking pairs in , and (ii) for each , as otherwise we would have (so as to avoid having four blocking pairs due to women in and ), implying at least one blocking pair in in addition to those in .

Analogously, let denote the number of blocking pairs for that involve a woman either in the gadget or in a gadget for some . Then either , or we know that for both women ; in this case, from the proof of Theorem ? we get . However, supposing that has at most blocking pairs, it follows that and must hold for each and each with , respectively.

Along the same lines as in the proof of Theorem ?, it can also be verified that for each pair of indices can only be achieved if contains a path in each gadget . From for each we get that such a path contains at least one blocking pair. This implies , as otherwise we would end up with because of the blocking pairs incident to women of .

Altogether, we have proved that for each . Hence, the restriction of to yields a feasible matching for that admits at most blocking pairs.

For the other direction, suppose that has a feasible matching . Then it is easy to see that adding the edges , , , and for each together with the edge to yields a feasible matching for that contains exactly the same number of blocking pairs in as does in .

The proof is very similar to the one for Theorem ?, so we will only sketch it. Again, we are going to re-use the instance constructed in the proof of Theorem ?, and construct a modified instance of SMC, adding only two new women and and two men and to . We append and , in this order, to the master list over women, and similarly, we append to the master list over men. We define the women to be covered in as and .

Again, we denote the set of women to be covered in by , and we denote by the unique man acceptable for some in . The preferences of the newly introduced men and women, as well as the modified preferences of those agents that find them acceptable, is given below (here, denotes the ordering of given by the master list). We let contain all other women and men defined in , having the same preferences as in .

Arguing analogously as before in the proof of Theorem ?, one can show that has a feasible matching with at most blocking pairs if and only if has such a matching; this suffices to prove the theorem.

To contrast our intractability results, we show next that if each of , , , and is constant, then SMC becomes polynomial-time solvable. Our algorithm relies on the observation that in this case, the number of blocking pairs in an optimal solution is at most by Theorem ?. Note that for instances of SMC-1, Theorem ? yields a polynomial-time algorithm already if both and are constant.

By Theorem ?, there is a matching with at most blocking pairs. Hence, if the number of blocking pairs allowed is at least , then we can simply run the algorithm of Theorem ?. Otherwise, we can use Observation ?, which gives us the required run time.

Importantly, restricting only three of the values , , , and to be constant does not yield tractability for SMC, showing that Theorem ? is tight in this sense. Indeed, Theorem ? implies immediately that restricting the maximum length of the preference lists on only one side still results in a hard problem: SMC remains -hard with parameter , even if , , and . On the other hand, Theorem ? shows that the problem remains hard even if and .

## 6SMC with Preference Lists of Length at most Two

In this section we investigate the computational complexity of SMC where the maximum length of preference lists is bounded by on one side. This restriction leads to important tractable special cases: we obtain both polynomial-time algorithms and fixed-parameter tractability results for various parameterizations.

Let be an instance of SMC with underlying graph . Let be a stable matching in , and let and denote the set of distinguished men and women, respectively, unmatched by . Furthermore, let and denote the set of all men and women, respectively, unmatched by . A path in is called an *augmenting path*, if is a matching, and either both endpoints of are in