1 Introduction
In the Hospitals/Residents problem, every hospital has an upper quota that limits the number of residents assigned to it. While, in some applications, each hospital also has a lower quota for the number of residents it receives. This extension of the HR problem is referred to as the Hospitals/Residents problem with Lower Quotas (HRLQ, for short) in the literature. However, the existence of a stable matching is not always true for a given HRLQ instance. This can be easily observed by the wellknown Rural Hospitals theorem [2, 6, 7] stating that each hospital is assigned the same number of residents in any stable matching for a given HR instance.
Since there might be no stable matching given a HRLQ instance, one natural approach is to weaken the requirement of stability. Envyfreeness is a relaxation of stability that allows blocking pairs involving a resident and an empty position of a hospital. Structural results of envyfree matchings were investigated in [8] showing that the set of envyfree matchings forms a lattice. Envyfree matchings with lower quotas has recently been studied in [9]. Fragiadalis et al. [1] studies envyfree matchings (called fairness in their papar) when the preference lists are complete and the sum of lower quotas of all hospitals does not exceed the number of residents. In this restricted setting, envyfree matching always exists and they gave a lineartime algorithm called extendedseat deferred acceptance (ESDA) to find an envyfree matching. However, if the preference lists are not complete, envyfree matching may not exist. Yokoi [9] provided a characterization of envyfree matchings in HRLQ, connecting them to stable matchings in a modified HR instance so that the existence of envyfree matching can be decided by running DA on this modified HR instance.
Given a HRLQ instance, we know that stable matchings or envyfree matchings might not exist. Hamada et al. [3] considered the problem of minimizing the number of blocking pairs among all feasible matchings (feasible matching means a matching satisfies both lower and upper quotas of each hospital). They showed hardness of approximation of the problem and provided an exponentialtime exact algorithm.
In this paper, we consider the problem of minimizing envy (defined later) among all feasible matchings given a HRLQ instance. Given a feasible matching, the envy among all residents can be measured by the number of envypairs or the number of residents involved in some envypairs.
We show that for both measurements, the problem is NPhard. We also provide an exponentialtime algorithm to find a feasible matching minimizing the number of envypairs.
1.1 Related Works
Popular matching is another relaxation of stability which preserves “global” stability in the sense that no majority of residents wish to alter into another feasible matching. Popular matching always exists. Nasre and Nimbhorkar [5] proposed an efficient algorithm to compute a maximum cardinality matching that is popular amongst all the feasible matchings in an HRLQ instance. When there exists a stable matching given a HRLQ instance, it is known that every stable matching is popular.
2 Preliminaries
An instance of the Hospitals/Residents Problem with Lower Quotas (HRLQ for short) consists of a bipartite graph , where is a set of residents and is a set of hospitals, and an edge denotes that and are mutually acceptable, and a preference system such that every vertex (resident and hospital) in ranks its neighbors in a strict order, referred as the preference list of the vertex. If a vertex prefers its neighbor over , we denote it by . Each hospital has a lower quota and an upper quota (). Sometimes we write to denote the lower and upper quota for some hospital .
A matching in is an assignment of residents to hospitals such that each resident is matched to at most one hospital, and every hospital is matched to at most residents. Let denote the hospital that is matched in . If is unmatched in , we let . For any neighbor of , we have since we assume that any resident prefers to be matched over to be unmatched. We say that a hospital is undersubscribed in if , is fullysubscribed if , is oversubscribed if and is deficient if . A matching is feasible in a HRLQ instance if no hospital is deficient or oversubscribed in . The HRLQ problem is to match residents to hospitals under some optimality condition such that the matching is feasible. Envyfreeness is defined as follows.
Definition 1.
Given a matching , a residenthospital pair is an envypair if and for some .
Definition 2.
Given a matching , a resident has justified envy toward who is matched to hospital if and .
Definition 3.
A matching is envyfree if there is no envypair in . Equivalently, a matching is envyfree if no resident has justified envy toward other residents in .
In case that envyfree matchings may not exist in a given HRLQ instance. We define two other problems that minimizes envy in terms of envypairs and envyresidents.
MinimumEnvyPair Hospitals/Residents Problem with Lower Quotas (MinEP HRLQ for short) is the problem of finding a feasible matching with the minimum number of envypairs. 01 MinEP HRLQ is the restriction of MinEP HRLQ where a quota of each hospital is either or .
Definition 4.
Given a matching , a resident is an envyresident if there exists such that is an envypair in .
MinimumEnvyResident Hospitals/Residents Problem with Lower Quotas (MinER HRLQ for short) is the problem of finding a feasible matching with minimum number of envyresidents. 01 MinER HRLQ is defined similarly.
We assume without loss of generality that the number of residents is at least the sum of the lower quotas of all hospitals, since otherwise there is no feasible matching. In other papers, they impose the Complete List restriction (CLrestriction for short). There always exists envyfree matchings in CLrestriction instances, and a maximumsize one can be found in polynomial time [1, 4].
3 MinimumEnvyPair HRLQ
In this section, we consider the problem of minimizing the number of envypairs in HRLQ. We prove a NPhardness result for 01 MinEP HRLQ in the following theorem.
Theorem 5.
01 MinEP HRLQ is NPhard.
Proof.
We give a polynomialtime reduction from the wellknown NPcomplete problem Vertex Cover. Below is the definition of the decision version of the Vertex Cover problem. Given a graph and a positive integer , we are asked if there is a subset such that , which contains at least one endpoint of each edge of .
Reduction: Given a graph and a positive integer , which is an instance of the Vertex Cover problem, we construct an instance of 01 MinEP HRLQ. Define , and . The set of residents is and the set of hospitals is . Each set is defined as follows:
Each hospital in has a quota . Note that and . Thus , which is polynomial in and .
Next, we construct the preference lists of . The preference lists of residents is shown as follows:
, where denotes a fixed order of elements in in an increasing order of indices.
The preference lists of hospitals is shown as follows:
, where and are as before a fixed order of all the residents in and , respectively, in an increasing order of indices, is an arbitrary order of all the residents in that is acceptable to as determined by the preference lists of residents.
Since each hospital in has a quota , any feasible matching must be a perfect matching in . Further, the subgraph between and is a complete graph and there is no edge between and in . Thus, any feasible matching must include a perfect matching between and .
For each edge , there are the set of residents and the set of hospitals . We call this pair of sets a gadget, and write it as . For each gadget , let us define two perfect matchings between and as follows:
Figure 1 shows and on preference lists of .
Lemma 6.
For a gadget , and are the only perfect matchings between and . Furthermore, each and contains an unique envypair such that and .
Proof.
Consider the induced subgraph that contains only and . One can see that is a cycle of length . Hence there are only two perfect matchings between and , and they are actually and . Moreover, it is easy to check that contains only one envypair and contains only one envypair . ∎
We now ready to show the NPhardness of 01 MinEP HRLQ.
Lemma 7.
If is a “yes” instance of the Vertex Cover problem, then has a solution with at most envypairs.
Proof.
If is a “yes” instance of the Vertex Cover problem, then has a vertex cover of size exactly . Let this vertex cover be and let . We construct a matching of according to . We match each hospital in to each resident in and each hospital in to each resident in in an arbitrary way. Since , there are at most envypairs between and .
Since is a vertex cover of , for each edge , either or is included in . Thus for each gadget corresponding to the edge , if , we use as part of our matching , otherwise, use . By constructing in this way, it is easy to see that neither nor can be involved in an envypair. Also, by Lemma 6, there is only one envypair between and . Thus, the total number of envypairs is at most w.r.t . ∎
Lemma 8.
If is a “no” instance of the Vertex Cover problem, then any solution of has at least envypairs.
Proof.
It is equivalent to prove that if admits a feasible matching with less than envypairs, then has a vertex cover of size at most . must be a perfect matching and must be a onetoone correspondence between and in order to be a feasible matching. Since all are matched to , for each gadget , by Lemma 6, there are only two possibilities, and and either matching admits one envypair within each . Totally we have envypairs between and .
Suppose we choose for . If is matched with a resident in , there are envypairs between and . Then we have envypairs, contradicting the assumption. Thus, must be matched with a resident in . By the same argument, if is chosen, must be matched with a resident in . Hence, for each edge , either or is matched with a resident in . It is obvious that the set of vertices matched with residents in is a vertex cover of size . This completes the proof. ∎
Thus a polynomialtime algorithm for 01 MinEP HRLQ would solve the Vertex Cover problem, implying P=NP. ∎
Note that the reduction above also implies NPhardness of 01 MinBP HRLQ because all envypairs are blocking pairs and the construction in Lemma 7 does not generate any wasteful pairs (nonenvy blocking pairs). [3] gives stronger results showing 01 MinBP HRLQ is hard to approximate within the ratio of for any positive constant even if all preference lists are complete. While, the reduction can not be used for 01 MinEP HRLQ because there exists envyfree matchings when all preference lists are complete [1] (or a weaker requirement such that all hospitals with positive lower quotas has complete preference lists over all residents [4]) and a maximumsize envyfree matching can be found in linear time.
3.1 A Simple ExponentialTime Algorithm
Let be a given instance. Starting from , we guess a set of envypairs. There are at most choices of . For each choice of , we delete each . Let be the modified instance. We apply Yokoi’s algorithm to find an envyfree matching in . If the algorithm outputs an envyfree matching , then it is the desired solution, otherwise, we proceed to the next guess. If we run out of all guess of for a fixed , we increment by 1 and proceed as before until we find a desired solution.
Theorem 9.
There is an time exact algorithm for MinEP HRLQ where is the number of envypairs in an optimal solution of a given instance.
Proof.
If the algorithm ends when , then the output matching is an envyfree matching in and the set can only introduce at most envypairs, contradicting that is minimum number of envypairs in any feasible matching of instance . Consider the execution of the algorithm for and any optimal solution and let our current guess contains exactly the envypairs of . Then it is easy to see that is envyfree in and satisfies all the lower quotas. Hence if we apply Yokoi’s algorithm, we find a matching is envyfree and satisfies all the lower quotas. Thus has at most envypairs in the original instance and it is our desired solution.
For the time complexity, Yokoi’s algorithm runs in time and for each , we apply Yokoi’s algorithm at most times. Therefore, the total time is at most . ∎
4 MinimumEnvyResident HRLQ
In this section, we consider the problem of minimizing the number of envyresidents in HRLQ. We prove a NPhardness result for MinER HRLQ in the following theorem.
Theorem 10.
MinER HRLQ is NPhard.
Proof.
We give a polynomialtime reduction from the NPcomplete problem CLIQUE. In CLIQUE, we are given a graph and a positive integer , and asked if contains a complete graph with vertices as a subgraph.
Reduction: Given a graph , and a positive integer , which is an instance of the CLIQUE problem, we construct in instance of MinER HRLQ. Define , and . The set of residents is and the set of hospital is . Each set is defined as follows:
Each hospital in has a quota and the hospital has a quota .
The preference lists of residents and hospitals is shown as follows:
, where are a fixed order of all hospitals in in an increasing order of indices, and are a fixed order of all the residents in and , respectively, in an increasing order of indices, is an arbitrary order of all the residents in that is acceptable to as determined by the preference lists of residents. are a fixed order of all residents in in an increasing order of indices.
Lemma 11.
If is a “yes” instance of CLIQUE, then there is a feasible matching of having at most envyresidents.
Proof.
Suppose that has a clique of size . We will construct a matching of from . We assign all the residents in to the hospitals in in an arbitrary way and all the residents in to the hospitals in in an arbitrary way. Further, we match all the residents in to . Clearly, is feasible. Since is a clique, for any pair . There are residents associated with the edge . Each of these residents are assigned to the hospital in , which is the worst in ’s preference list and the hospitals and are assigned to residents in , better than . Hence all these residents are not envyresidents. There are such residents and total number of residents is . Hence there are at most envyresidents. ∎
Lemma 12.
If is a “no” instance of CLIQUE, then any feasible matching of contains at least envyresidents.
Proof.
Suppose that there is a feasible matching of that contains less than envyresidents. We show that contains a clique of size . Note that must match all the resident in to because has a quota and is only acceptable to . Thus the hospitals must only match to the residents in and there is onetoone correspondence between and in order for to be feasible. Define be the set of hospitals matched with . Clearly . We claim that is a clique.
The total number of residents is . Since we assume that there are less than envyresidents, there are more than nonenvyresidents (obviously an nonenvyresident is a resident that is not an envyresident). Since , there are more than nonenvyresidents in . Consider the following partition of into subsets: for each . There must exists a such that contains at least nonenvyresidents by Pigeonhole principle. In order for to be a nonenvyresident, we note that both and must match to some resident in because if or is matched to , we have an envypair contains . Thus any pair of vertices in causes such a nonenvyresident, implying that is a clique. ∎
5 Conclusion and Open Problems
In this paper, we give NP hardness results of minimizing envy in terms of envypairs and envyresidents in the Hospitals/Resident problem with Lower Quota. Hamada et al. [3] showed hardness of approximation for the problem of minimizing the number of blocking pairs among all feasible matchings. It would be interesting to show hardness of approximation for minimizing envy in the HRLQ problem.
References
 [1] Daniel Fragiadakis, Atsushi Iwasaki, Peter Troyan, Suguru Ueda, and Makoto Yokoo. Strategyproof matching with minimum quotas. ACM Transactions on Economics and Computation (TEAC), 4(1):1–40, 2016.
 [2] David Gale and Marilda Sotomayor. Some remarks on the stable matching problem. Discrete Applied Mathematics, 11(3):223–232, 1985.
 [3] Koki Hamada, Kazuo Iwama, and Shuichi Miyazaki. The hospitals/residents problem with lower quotas. Algorithmica, 74(1):440–465, 2016.

[4]
Prem Krishnaa, Girija Limaye, Meghana Nasre, and Prajakta Nimbhorkar.
Envyfreeness and relaxed stability: Hardness and approximation
algorithms.
In
International Symposium on Algorithmic Game Theory
, pages 193–208. Springer, 2020.  [5] Meghana Nasre and Prajakta Nimbhorkar. Popular matching with lower quotas. arXiv preprint arXiv:1704.07546, 2017.
 [6] Alvin E Roth. The evolution of the labor market for medical interns and residents: a case study in game theory. Journal of political Economy, 92(6):991–1016, 1984.
 [7] Alvin E Roth. On the allocation of residents to rural hospitals: a general property of twosided matching markets. Econometrica: Journal of the Econometric Society, pages 425–427, 1986.
 [8] Qingyun Wu and Alvin E Roth. The lattice of envyfree matchings. Games and Economic Behavior, 109:201–211, 2018.
 [9] Yu Yokoi. Envyfree matchings with lower quotas. Algorithmica, 82(2):188–211, 2020.