    # Improved Paths to Stability for the Stable Marriage Problem

The stable marriage problem requires one to find a marriage with no blocking pair. Given a matching that is not stable, Roth and Vande Vate have shown that there exists a sequence of matchings that leads to a stable matching in which each successive matching is obtained by satisfying a blocking pair. The sequence produced by Roth and Vande Vate's algorithm is of length O(n^3) where n is the number of men (and women). In this paper, we present an algorithm that achieves stability in a sequence of matchings of length O(n^2). We also give an efficient algorithm to find the stable matching closest to the given initial matching under an appropriate distance function between matchings.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

The Stable Matching Problem Gale and Shapley (1962) has wide applications in economics, distributed computing, resource allocation and many other fields Maggs and Sitaraman (2015); Iwama and Miyazaki (2008) with multiple books and survey articles Gusfield and Irving (1989); Knuth (1997); Roth and Sotomayor (1992); Iwama and Miyazaki (2008); David (2013). In the standard version of the problem, there are men and women each with their totally ordered preference list. The goal is to find a matching between men and women such that there is no blocking pair, i.e., there is no pair of a woman and a man such that they are not married to each other but prefer each other over their partners. The standard Gale-Shapley (GS) algorithm produces such a matching starting from an empty matching with the deferred acceptance proposal algorithm that takes proposals. The algorithm produces the man-optimal stable matching.

In many applications, it is useful to consider the initial state of the system as an arbitrary assignment of men to women and then to find a path to a stable matching. For example, suppose that we consider a system in which there are more women than men and suppose that every man is matched to a unique woman such that there is no blocking pair. Now, if a new man or a woman joins the system, it is more natural to start with the initial state as the existing assignment rather than the empty matching. In particular, if there is some cost associated with breaking up an existing couple, then we may be interested in the paths to stability that are of short lengths. Hence, this generalization allows one to consider incremental stable matching algorithms.

As another example, suppose that we have a stable matching. In a dynamic preference mechanism, a woman may change her list of preferences. The existing matching may not be stable under new preferences of the woman. Again, it is more natural to start with the existing matching and then to find a path to a stable matching under new preferences. Thus, the generalization allows one to consider a dynamic stable matching algorithm in which preferences of a man or a woman may change and the goal is to find a stable matching under new preferences.

Given a matching, a natural method to make progress towards a stable matching is as follows. The man and the woman in the blocking pair are married and their spouses are divorced. By marrying these divorcees, we get another matching. The reader is referred to the book David (2013) for a detailed discussion of algorithms that go from a matching to a stable matching. Knuth Knuth (1997) showed that starting from any matching and iteratively satisfying a blocking pair may lead to a cycle. Abeledo and Rothblum Abeledo and Rothblum (1995) have shown that a cycle exists even if one chooses the best blocking pair to satisfy at each step. A pair is the best blocking pair for if for any other blocking pair in , prefers to . Indeed, it has been shown by Tamura Tamura (1993) and independently by Tan and Su Tan and Su (1995), that there are matchings for which it is not possible to reach a stable marriage by marrying off divorcees. However, if the divorcees are allowed to remain single, then one can achieve stability. The Roth and Vande Vate (RVV) mechanism Roth and Vate (1990) is the most well known method to determine a path to stability. Their algorithm introduces agents (men or women) incrementally and let them iteratively reach a stable matching. Given any matching , the RVV mechanism produces a sequence of matchings such that is stable matching and for each (), is obtained from by satisfying a blocking pair. The value of is at most (assuming that the number of acceptable pairs is ).

In this paper, we analyze the path to stability from the perspective of traversal in the proposal vector lattice

. Any man-saturating matching corresponds to a unique proposal vector but when the matching is incomplete there may be multiple proposal vectors corresponding to it. Working with proposal vectors instead of matching allows us to generate shorter sequences to a stable matching. In particular, we show that given any proposal vector

, there exists a sequence of proposal vectors such that corresponds to a stable matching and for each (), is obtained from by either increasing the choice number for one man (thereby worsening his match) or decreasing the choice number for one man (thereby improving his match). The value of is at most where is the number of men. Our result can also be phrased in terms of matching as follows. Given any matching , there exists a sequence of matching such that corresponds to a stable matching and for each (), is obtained from by either (1) marrying a man whose current partner is in a blocking pair (or, if he is single) to another woman who is agreeable to his proposal, or (2) by marrying a woman to her best blocking pair partner. The value of is at most where is the number of men. Thus, this sequence is shorter than the RVV sequence by a factor of .

We propose four algorithms in this paper for achieving stability (see Fig. 1). The first algorithm is a generalization of the GS algorithm to find the man-optimal marriage. The GS algorithm starts with the matching that results when all men propose to their top choice. It then determines the man-optimal stable marriage in moves. What if instead of the top choices, men propose to any arbitrary vector of women? In such a scenario, a woman cannot accept the first proposal she receives (as in the GS algorithm), because that may result in an unstable matching. Algorithm gives the rules for advancing from an arbitrary proposal vector to end up in a stable marriage (whenever possible). Given any initial matching , algorithm produces a sequence of matchings ending in a stable marriage such that the matching only improves from the perspective of women and gets only worse from the perspective of men. This sequence is of length . Since there may not exist any stable matching that is based only on improving from the women’s perspective, algorithm may return null in these cases (for example, when the initial matching assigns some man a partner who is ranked lower than in the man-pessimal matching). The set of stable matchings can be viewed as a sublattice of the lattice of all proposal vectors and the algorithm can be viewed as upward traversal in this lattice from any arbitrary proposal vector to a proposal vector that corresponds to a stable matching.

One of the goals of the paper is to find a matching that is not too far from the original matching (or the initial proposal vector). Given any proposal vector , the regret of a man is defined as the rank the woman he is assigned in , i.e., if a man is assigned his top choice in then his regret is . Given two proposal vectors and , we define the distance between and , as the sum of differences of regrets for all men in and , i.e. the distance between two vectors, . Algorithm guarantees that the stable matching computed has the least distance of all stable matchings that are better than from the women’s perspective.

The second algorithm does the downward traversal in the proposal lattice in search of a stable marriage. Algorithm also takes an arbitrary proposal vector as the starting point and results in a stable marriage whenever possible. It improves the matching from the perspective of men. When men and women are equal then such a traversal can be accomplished by switching the roles of men and women. However, in this paper we assume that the number of men may be much smaller than the number of women . All our algorithms have time complexity of . Switching the roles of men and women is not feasible without increasing the complexity of our algorithms. Algorithm guarantees that the stable matching computed has the least distance of all stable matchings that are better than from the men’s perspective.

The third algorithm combines a downward traversal with an upward traversal to guarantee that irrespective of the initial matching , there always exists a sequence of matchings that results in a stable matching. This sequence consists of two subsequences each of length giving us the path to stability of length , thereby improving on the RVV mechanism. Intuitively, the RVV algorithm may traverse the lattice in the upward direction or downwards direction multiple times. In contrast, our algorithm traverses the proposal lattice once in the downward direction and then in the upward direction ending in a stable matching. It generates a sequence of proposal vectors that results in a stable matching with time complexity.

Our last algorithm finds the closest stable matching to the given initial proposal vector. Algorithm

is based on a linear programming formulation of the stable marriage problem by Rothblum

Rothblum (1992). By appropriately defining the objective function to minimize the distance from the initial proposal vector, we get a polynomial time algorithm to find the closest stable marriage.

Our algorithms are also useful in the context of arriving at more egalitarian matchings than we get using the Gale-Shapley algorithm. If there are men, instead of starting with the proposal vector , we may start with the proposal vector to find a stable vector close to the center of the proposal lattice. Alternatively, we can also start with various proposal vectors chosen at random and obtain multiple stable matchings. Once we have multiple stable matchings, we can use Teo and Sethuraman’s median stable matching theorem Teo and Sethuraman (1998) to return the median stable matching.

We note here that the path to a stable matching from an unstable matching can be of different types. Given any blocking pair, the RVV algorithm is based on a better response dynamics. Under these dynamics, any blocking pair for a matching is chosen and they are matched. The partners of and in , if any, are unmatched. An alternative approach based on best response dynamics is explored in Ackermann et al. (2011). Here, one side, say the set of women, is considered active and the other side is considered passive. An active agent of a blocking pair in plays the best response if is matched to such that is the best blocking pair for . In other words, if there is any other blocking pair in , then prefers to . The paper Ackermann et al. (2011) gives an example of a two sided market with three men and women in which best response dynamics can cycle. They also propose an algorithm to generate a sequence of best responses from any matching that leads to a stable matching. Their algorithm has some similarities with our algorithm in that it also consists of two phases. In the first phase, only matched women can make best response moves whereas in the second phase all women can play the best response. However, a crucial difference from our algorithm is that we are interested in finding a matching that is close to the original matching (where the distance is defined based on the proposal lattice). The algorithm in Ackermann et al. (2011) does not concern itself with the issue of the distance between matchings. In particular, under the best response dynamics, their algorithm has the tendency to get to the woman-optimal marriage irrespective of the initial matching. In contrast, our algorithms provide guarantees on the matching returned. For example, Algorithm returns the proposal vector that has the least distance from , the initial proposal vector of all the proposal vectors that are bigger than .

In summary, the paper makes the following contributions.

• It proposes Algorithm that takes any proposal vector (and therefore any matching) to a stable proposal vector in time such that the resulting proposal vector has the least distance from the initial proposal vector of all stable proposal vectors that are greater than initial proposal vector. This algorithm generalizes the GS algorithm which assumes the initial proposal vector to be the top choices.

• It proposes Algorithm that takes any input proposal vector and generates a stable proposal vector that has the least distance from the initial proposal vector to all stable proposal vectors that are less than or equal to the initial proposal vector. This algorithm give a dual of the GS algorithm in which the active agents improve their choices to get a stable proposal vector (if one exists).

• It proposes Algorithm that takes any input proposal vector and always generates a stable proposal vector by combining aspects of algorithms and .

• It proposes a polynomial time algorithm (based on linear programming) that takes any input proposal vector and generates a stable proposal vector that is closest to the input proposal vector.

## 2 Proposal Vector Lattice

We consider stable marriage instances with men numbered and women numbered . We assume that the number of women is at least ; otherwise, the roles of men and women can be switched. The variables and specify the men preferences and the women preferences, respectively. Thus, iff woman is the preference for man . Fig. 2 shows an instance of the stable matching problem.

We use the notion of a proposal vector for our algorithms. A (man) proposal vector, , is of dimension , the number of men. We view any vector as follows: if man has proposed to his preference, i.e. the woman given by . If equals , then equals corresponds to man proposing to woman . For convenience, let denote the woman . The vector corresponds the proposal vector in which every man has proposed to his top choice. Similarly, corresponds to the vector in which every man has proposed to his last choice. Our algorithms can also handle the case when the lists are incomplete, i.e., a man prefers staying alone to being matched to some women. However, for simplicity, we assume complete lists. It is clear that the set of all proposal vectors forms a distributive lattice under the natural less than order in which the meet and join are given by the component-wise minimum and the component-wise maximum, respectively. This lattice has elements.

Given any proposal vector, , there is a unique matching defined as follows: man and are matched in if the proposal by man is the best for that woman in . A man is unmatched in if his proposal is not the best proposal for that woman in . A woman is unmatched in if she does not receive any proposal in ; otherwise, she is matched with the best proposal for her in .

A proposal vector represents a man-saturating matching iff no woman receives more than one proposal in . Formally, is a man-saturating matching if . When the number of men equals the number women, a man-saturating matching is a perfect matching (all men and women are matched). When the number of men is less than the number of women, then is a man-saturating matching if every man is matched (but some women are unmatched). We say that a matching (or a marriage) is less than another matching if the proposal vector for is less than that of . Thus, the man-optimal marriage is the least stable matching in the proposal lattice and woman-optimal marriage is the greatest stable matching.

A proposal vector may have one or more blocking pairs. A pair of man and woman is a blocking pair in iff is not , man prefers to , and woman prefers to any proposal she receives in . Observe that this definition works even when woman is unmatched, i.e. she has not received any proposals in . In this case, woman prefers to staying alone, and prefers to .

A proposal vector is a stable marriage (or a stable proposal vector) iff it is a man-saturating matching and there are no blocking pairs in . The usual stable matching problem is to determine such a proposal vector given and . The problem that we consider in this paper includes an additional input: the initial proposal vector, . The goal is to traverse the proposal lattice starting from to find a stable proposal vector . In this paper, we use two different mechanisms — upward traversal and downward traversal — to reach a stable matching proposal vector.

Algorithm uses upward traversal. Suppose that is matched with in and is part of the blocking pair . Instead of satisfying the blocking pair , we move to his next choice in his preference list. This move makes the proposal vector better from the women’s perspective and worse from the men’s perspective. By continuing in this manner if some man makes a proposal to who is even better than , the blocking pair gets eliminated. If no man better than ever makes a proposal to , then there is no proposal vector bigger than that corresponds to a stable matching.

Algorithm uses downward traversal in the proposal lattice. Let be a proposal vector that is not stable. Of all the blocking pairs that is part of, we choose the best blocking pair from ’s perspective. Let be such a blocking pair. We construct a proposal vector that moves man to woman by changing the proposal of man from his current proposal to that for woman and keeping all other proposals as before.

Since Algorithm traverses the lattice upwards, any sequence of proposal vector it generates can be of length at most . Similarly, Algorithm also generates a sequence of length at most . Algorithm combines one downward traversal and one upward traversal to go from any proposal vector to a stable matching proposal vector in a sequence of length at most .

We now describe Algorithms , and in detail.

## 3 Algorithm α: Upward Traversal

Given any initial proposal vector , Algorithm , finds a stable matching such that whenever there exists such a stable matching. The initial proposal vector is arbitrary instead of the top choice for each man. This generalizes the GS algorithm which starts with . Observe that the GS algorithm does not work when the starting proposal vector is arbitrary. The GS algorithm requires men to make proposals and women to accept the best proposals they have received so far. If the starting proposal vector is a man-saturating matching but not stable, then each woman gets a unique proposal. All women would accept the only proposal received, but the resulting marriage would not be stable.

This instability may arise due to two reasons. First, it may arise when the number of women exceeds the number of men. If we start with the top choices of all men, then the GS algorithm would still return a man-optimal stable matching with the excess women unmatched. However, if we start from an arbitrary proposal vector, we can end up with all women getting unique proposals but there may exist an unmatched woman who is preferred by some man over his current match.

To tackle this problem, we first do a simple check on the initial proposal vector as given by the following Lemma. Let be the total number of unique women that have been proposed in all vectors that are less than or equal to , i.e., .

###### Lemma 1

Let be the initial proposal vector for any stable marriage instance with men. There is no stable marriage for any proposal vector whenever .

Proof: Consider any proposal vector . Since the total number of men is , there is at least one woman who has been proposed to in a vector less than and who does not have any proposal in . Suppose that proposal was made by man . Then, man prefers to and prefers to staying alone.

Hence, in our algorithm we only consider such that the total number of women proposed until (in all vectors less than or equal to ) is at most .

Instability may arise even when the number of men and women are equal. In Fig. 2, this situation would arise if we started with . The initial proposal vector may be a perfect matching but not stable. A woman may receive a unique proposal from a man but she prefers who has made his proposal to even though prefers to . Such a scenario cannot happen when men propose starting from the top choice and in the decreasing order as in the GS algorithm. However, now the starting vector is arbitrary and a blocking pair may exist in the man-saturating matching.

To address this problem, we define the notion of a forbidden man in a proposal vector.

###### Definition 1 (forbidden)

A man is forbidden in if either he is unmatched in or matched to a woman in who is part of a blocking pair. Formally, the predicate holds if there exists another man such that either (1) both and have proposed to the same woman in and that woman prefers , or (2) is a blocking pair in .

We first show that

###### Lemma 2

Let be any proposal vector such that . There exists a man such that iff is not a stable marriage.

Proof: First suppose that there exists such that . This mean that there exists a man such that has proposed to the same woman and that woman prefers or is a blocking pair in . If both and have proposed to the same woman in , then it is clearly not a matching. If is a blocking pair then is not stable.

Conversely, assume that is not a stable marriage. This means that either is not a man-saturating matching or there is a blocking pair for . If it is not a man-saturating matching, then there must be some woman who has been proposed by multiple men. Any man who is not the most favored in the set of proposals satisfies . If is a man-saturating matching but not a stable marriage, then there must be a blocking pair . If has been proposed in by man , then is a blocking pair, and therefore holds. If has not been proposed in then we know there are at least women that are in which violates our assumption on .

Algorithm shown in Fig. 3 exploits the function to search for the stable marriage in the proposal lattice. The basic idea is that if a man is forbidden in the current proposal vector , then he must go down his preference list until he finds a woman who is either unmatched or prefers him to her current match. The while loop at line (1) iterates until none of the men are forbidden in . If the while loop terminates then is a stable marriage on account of Lemma 2. At line (2), man advances on his preference list until his proposal is the most preferred proposal to the woman among all proposals that are made to her in any proposal vector less than or equal to . If there is no such proposal, then there does not exist any such that is stable and in line (3), the algorithm returns null. Otherwise, the man makes that proposal at line (4).

For example, consider the initial proposal vector in Fig. 2. In this proposal vector, we have the matching . While this is a man-saturating matching, it is not stable because it has blocking pairs. Consider the blocking pair (because, prefers to and prefers to ). In an upward traversal, we advance the partner of the woman in the blocking pair, , to his next choice. The next choice for is . This results in rejecting and therefore moves to his next choice . This proposal, in turn, results in rejecting . Next, makes a proposal to and now is not a blocking pair. The new proposal vector which corresponds to the matching is a stable matching with all women getting their top choices.

There are two main differences between the GS algorithm and Algorithm . The first difference is the simple check on the number of women that have been proposed until . We require . Clearly, if the number of women is equal to the number of men, then can never exceed and this check can be dropped.

The second difference is in the definition of . In the standard GS algorithm, a man advances on his preference list only when he is unmatched, i.e., the woman he has proposed to is either matched with someone more preferable or receives a proposal from a more preferable man. Whenever the GS algorithm reaches a man-saturating matching, it is a stable matching. For any arbitrary (for example, a man-saturating matching that is not stable), it is important to take blocking pairs in consideration as part of the forbidden predicate. This difference can be summarized as follows.

• GS Algorithm: A man proposes to the next woman on his preference list if he is currently unmatched.

• Algorithm : A man proposes to the next woman on his preference list if he is currently unmatched or matched with a woman who is in a blocking pair.

Observe that if all men propose starting from their top choices, then the rule for Algorithm becomes identical to that for the GS Algorithm.

To prove the correctness of the algorithm , the following Lemma is crucial.

###### Lemma 3

If holds, then there is no proposal vector such that and and is a stable marriage.

Proof: Consider any such that and . We show that is not a stable marriage. The predicate implies that there exists a man such that prefers man to man and the proposal by to is in a proposal vector less than or equal to . Since , and equals , we get that also holds. Hence, is not a stable marriage from Lemma 2.

A consequence of Lemma 3 is that if holds, then it is safe to advance man to the next choice without any danger of missing a proposal vector that is a stable marriage. We can now show the correctness of Algorithm .

###### Theorem 1

Algorithm returns the least stable proposal vector in the proposal lattice whenever it exists. If there is no stable proposal vector greater than or equal to , then the algorithm returns null.

Proof: First suppose that a stable marriage exists that is greater than or equal to . Since the set of stable marriages form a sublattice of the proposal lattice Knuth (1997), there exists , the least proposal vector that is a stable marriage and greater than or equal to . Consider any . By definition of , is not a stable marriage and there exists such that due to Lemma 2. From Lemma 3, the advancement along guarantees that . Hence, the algorithm will continue to advance until it is identical to .

Now suppose that there is no stable marriage that is greater than or equal to . In this case, the algorithm will continue to find such that until some man runs out of choices. If we run out of choices, then from repeated application of Lemma 3, there is no stable marriage which is greater than or equal to .

The following Corollary states that the stable marriage returned by Algorithm has the least distance of all stable marriages greater than .

###### Corollary 1

Given any proposal vector , Algorithm returns the stable marriage greater than or equal to with the least distance from .

Proof: Suppose that Algorithm returns and is any other stable marriage such that . From Theorem 1, we get that . It follows that the distance between and is less than or equal to the distance between and .

As another application of Algorithm consider a scenario where we have a stable marriage and a new man joins the system (we can assume that initially the number of women were more than the number of men). Instead of running the GS from scratch, algorithm can start from the existing proposal vector for existing men and the median choice for the new entrant. If the existing matching had certain desirable properties (e.g. fairness), then the new stable matching found would be close to the existing matching. As another example, consider a system with a stable matching. Suppose that a man and a woman have a slight change in the order of their preferences and start preferring each other over their spouses. Again, one can use Algorithm that finds a stable matching which is close to the original matching.

## 4 Algorithm β: Downward Traversal

We now give the dual of Algorithm that does the downward traversal in the proposal vector lattice and returns the greatest stable marriage less than or equal to . In the standard literature, one does not consider the dual of the GS algorithm to find the woman-optimal stable marriage. Just by switching roles of men and women from the man-optimal GS, we get the woman-optimal GS algorithm. We cannot employ this strategy because we had assumed that the number of men is less than or equal to the number of women. Switching men and women violates this assumption.

In addition, the downward traversal of the proposal lattice gives different insights into the algorithm for finding a stable matching even when the number of men equals the number of women.

We first give a necessary condition for a stable marriage to exist that is less than or equal to .

###### Lemma 4

If (the number of unique women who have proposals in any vector less than or equal to ) is less than , then there cannot be any stable proposal vector less than or equal to .

Proof: The claim follows because any proposal vector less than or equal to cannot be a man-saturating matching if the number of unique women is less than .

If , there may or may not be a proposal vector that corresponds to a stable marriage depending upon the women’s preferences.

While traversing the proposal lattice in the downward direction, we use the predicate (short for reverse-Forbidden) which uses the notion of best blocking pair.

###### Definition 2 (Best blocking pair)

A blocking pair is the best blocking pair in for if for all blocking pairs in , the woman prefers to .

###### Definition 3 (rForbidden)

A man is rForbidden in if there exists a woman such that is the best blocking pair in for .

We first show that

###### Lemma 5

Let be any proposal vector such that . There exists a man such that iff is not a stable marriage.

Proof: First suppose that there exists such that . Then, there exists a woman such that man and woman form a blocking pair for . Hence is not a stable marriage.

Conversely, assume that is not a stable marriage. If is not a man-saturating matching, then there exists at least one woman who has not received any proposal in but has received it earlier because . Of all such proposals to let the most favorable proposal be from man . Then, holds. If is a man-saturating matching, but not stable, then there exists at least one blocking pair. Therefore, there exists at least one best blocking pair.

Analogous to upward traversal using forbidden predicate, we get that

###### Lemma 6

Assume . If holds, then there is no stable proposal vector such that and .

Proof: If holds, there exists a woman such that prefers to all men who have proposed to until . First suppose that does not have any proposal to . Then, cannot be stable because is single and man prefers to . Now suppose that has a proposal to . Since , we know that any proposal to in is less preferable to that by man . Hence, continues to be a blocking pair in .

Fig. 4 shows a high-level description of a downward traversal of the proposal lattice. At line (1), we ensure that is at most because due to Lemma 1, we know that there cannot be any stable marriage in which any component exceeds . At line (2), we first ensure that is at least equal to , the proposal vector corresponding to the man-optimal stable marriage. Otherwise, there cannot be a stable marriage vector less than or equal to . At line (3) we pick such that holds. This means that there exists a woman such that is a best blocking pair. At line (4), we satisfy the pair by decreasing until . This step corresponds to a downward traversal in the proposal lattice. At line (6), when we exit from the while loop, we know that must be a stable marriage on account of Lemma 5. This algorithm ensures that the match for any man can only improve.

For example of Algorithm , consider the initial proposal vector . The pair is blocking. Of all the blocking pairs in for , is best. Even though prefers to , the pair is not blocking because is at his choice in and corresponds to his third choice. Since is the best blocking pair for , we make propose to . Hence, the new proposal vector is . In this proposal vector, is unmatched and is the best blocking pair for . The new proposal vector is . Now, is unmatched and her best blocking pair is . When proposes to , we get the stable marriage proposal vector . This corresponds to the man-optimal stable marriage.

## 5 Algorithm γ: Path to Stability

We now present an algorithm that gives a path from any proposal vector to a stable marriage vector. Note that depending on the initial proposal vector, both Algorithms and may return null. For example, when the number of men is equal to the number of women and the initial vector is greater than or incomparable to the woman-optimal vector, then the algorithm will return null. Similarly, if the initial vector is less than or incomparable to the man-optimal vector, then the algorithm returns null. If the initial vector is incomparable to both the man-optimal and the woman-optimal proposal vectors, then both algorithms and will return null. In the RVV setting, we need to combine a downwards traversal with an upwards traversal to go from an arbitrary proposal vector to a stable matching. There are two choices for combining these traversals — a downward traversal followed by an upwards traversal, or vice-versa. We will use the former approach. The RVV algorithm introduces men and women incrementally and does multiple upward and downward traversals.

The Algorithm is shown in Fig. 5. Given any arbitrary initial vector , we first do a downward traversal to get to a proposal vector that is less than or equal to , the largest possible stable marriage. If the initial vector is at most , then this step is not necessary. can be computed using Algorithm by using a downward traversal starting from the vector . Our goal is to find blocking pairs in such that by satisfying them we get to a proposal vector . In contrast to algorithms in literature, we pick blocking pairs to satisfy carefully. Specifically, during the downward traversal, we satisfy only those men whose component in the proposal vector is beyond . To find a sequence from to such that , we first compute a vector as . We now invoke a downward traversal on using function of algorithm . Since Algorithm returns the greatest stable marriage less than the initial proposal vector (in our case ), it finds as blocking pair only those men such that . By definition of any such that equals can not satisfy because is a stable marriage.

###### Lemma 7

Let . Then, for any , implies .

Proof: Suppose is not in . This means that there exists a stable marriage less than or equal to such that . Since is less than or equal to , we get that is a stable marriage less than or equal to . However, this implies that is not in .    Since is in it is safe to decrement in search for a stable marriage. By repeating this process, we generate a sequence of proposal vectors that makes less than or equal to . Note that consecutive proposal vectors generated in this phase differ in the proposals by at most one man. The downward traversal step can be viewed as invocation of Algorithm on such that whenever is updated, is updated as well. This downward traversal can be done in time. At the end of this step , and we can start the second phase of the algorithm.

In the second phase, we do an upward traversal in which women improve their match. We use the function to find the least stable marriage that is greater than or equal to . In this phase, we satisfy blocking pairs by improving the match of women. Since the input to algorithm is less than or equal to , we are guaranteed to get a stable marriage at the end.

Hence, we have the following result.

###### Theorem 2

Given any initial proposal vector , there exists a sequence of proposal vectors such that is equal to , corresponds to a stable matching and for each (), is obtained from by either increasing the choice number for one man (thereby worsening his match) or decreasing the choice number for one man (thereby improving his match). The value of is at most where is the number of men.

This sequence can be obtained using algorithm that takes computation time given all the data structures (preference lists and rankings) in memory.

Since the RVV Algorithm generates a sequence of matchings instead of proposal vectors, we show how to generate a sequence of matchings explicitly instead of proposal vectors in Fig. 6. The downward traversal is performed by using the best blocking pairs in . The matching is generated from the proposal vector as defined in Section 2. Observe that these matchings may not be men-saturating and therefore some men and women may be unmatched. The upward traversal is performed by matching those men who are either unmatched or matched to a woman in a blocking pair. Clearly, the length of the sequence of these matchings is at most .

## 6 Algorithm δ: Stable Matching at the Shortest Distance

In this section, we give an algorithm, called Algorithm , that finds the stable matching with the least distance of all stable matchings relative to the initial proposal vector.

Given an arbitrary proposal vector (not necessarily a matching) , we want to find a stable matching such that the distance between the proposal vector and the stable matching is minimized over all stable matchings, . The distance we consider here is distance, a.k.a Manhattan distance between two vectors. We denote the distance as . The problem hence can be rephrased as: find the marriage that minimizes .

It is well-known that the convex hull of stable matchings of an arbitrary bipartite preference system can be described by a linear system Rothblum (1992) as follows:

 ∑j∈[w]xi,j≤1 ∀i∈[m] (1a) ∑i∈[m]xi,j≤1 ∀j∈[w] (1b) ∑i′∈[m];i′>jixi′,j+∑j′∈[w];j′>ijxi,j′+xi,j≥1 ∀(i,j)∈[m]×[w] (1c)

Here, we define that for each man or woman , denotes that prefers over in his/her preference list. Rothblum Rothblum (1992) proved that the linear system above is integral, i.e. every basic feasible solution of Equation 1 is integral. Suppose that every possible marriage has a cost , we can find a minimum-cost stable matching in polynomial time by solving the LP above.

Now we show that our problem of minimizing the distance between an initial proposal vector and any stable matching can be translated into a minimum-cost stable matching problem with a carefully designed cost function.

For each pair , we assign the cost . Hence, for each stable matching , we have:

 dist(I,M) =∑i∈[m]|I[i]−M[i]| =∑(i,j)∈[m]×[w]c(i,j)⋅1ρ(M,i)=j

Hence, we can rewrite our problem as:

∑_(i,j) ∈[m] ×[w] c_i,j ⋅x_i,j ∑_j ∈[w] x_i,j ≤1   ∀i ∈[m] ∑_i ∈[m] x_i,j ≤1   ∀j ∈[w] ∑_i’ ∈[m]; i’ ¿_j i x_i’,j + ∑_j’ ∈[w]; j’ ¿_i j x_i,j’ + x_i,j ≥1    ∀(i,j) ∈[m] ×[w]

Solving the above LP gives us a stable matching that is nearest to the initial proposal vector. This LP has variables and constraints where is the total number of men and women. However, we note that the minimum-cost stable matching problem can be reduced to the minimum-cost closed subset of a poset due to the rotation poset structure of stable matching problem. See Gusfield and Irving (1989) for more details of rotation poset. Feder Feder (1994) has shown that the minimum-cost stable matching problem in a bipartite preference system can be solved in time if .

We summarize the preceding discussion as the following theorem.

###### Theorem 3

Given an arbitrary proposal vector , we can find a stable matching that minimizes the distance over all stable matchings in time where is the total number of men and women.

## 7 Conclusions and Future Work

We have proposed algorithms to find a stable matching starting from a given initial matching or an initial proposal vector. Algorithm () returns the stable matching with least distance of all stable matching that are better than the initial matching from the women’s perspective (the man’s perspective) in time. Algorithm returns the stable matching with least distance from the initial proposal vector in time. The following problem is open. Is there an efficient algorithm that returns the closest stable proposal vector given any initial proposal vector ?

## 8 Appendix

### 8.1 An Efficient Implementation of Algorithm α

In this section, we give an implementation of Algorithm . The GS algorithm maintains two data structures. First, it maintains a list of men who are unmatched and must advance on their preference list. We also maintain , a list of men that are forbidden in the current proposal vector. Second, the GS algorithm maintains an array such that returns the partner for woman in the proposal vector .

We maintain an array instead of such that returns the most preferred match for woman among all proposals such that the proposal to woman by man is for a choice less than or equal to . Note that if the most preferred match for is before , then may be zero even though is nonzero. Such a scenario cannot happen in the GS algorithm because a man can advance on his list only when his current matched woman gets a better proposal. For example, consider the men’s preference lists in Fig. 2. Suppose the initial vector is . In this proposal vector, (the current best proposal to ) is from . However, has moved on to the next woman on his list . Hence, is not the partner of .

The implementation shown in Fig. 7 takes as input a stable marriage instance specified by (the men’s preferences) and (the women’s ranking of men), and the initial proposal vector . Step 1 goes over all proposals made in or before and computes the current best proposal for every woman . It also counts the number of unique women who have received proposals. If that number exceeds , the algorithm returns null.

Step 2 goes over all men whose proposals are not the current best proposals and inserts them in . All man in are such that they satisfy .

Step 3 advances over proposals that are forbidden. It takes out an element from . It advances to the next choice of woman . If does not have any proposal and proposing to her does not increase beyond , or if is preferred over the current best proposal for so far, we have succeeded in removing from . If had a partner, then that man is added to . If we run out of choices for any man , then the algorithm returns null. If the while loop terminates, we have that there is no such that and therefore is a stable marriage and it is returned.

The correctness of the implementation easily follows from Lemma 8 and Lemma 3.

###### Lemma 8

The while loop in Fig. 7 satisfies the following invariants.

1. For all : is the highest ranked proposer to who has made proposal to in any proposal vector less than or equal to .

2. For all : iff .

3. iff .

is advanced on index only when . Lemma 8 proves that this holds iff . When is empty, none of the components of are forbidden and it corresponds to a stable marriage. If it is not possible to advance on some forbidden index or if more than woman have been proposed before , the algorithm returns null in accordance with Lemma 1 and Lemma 3.

Proof:

1. Step 1 establishes the invariant for equal to . In the while loop of Step 3, whenever is incremented such that woman is proposed by , the invariant is maintained by updating .

2. Let be equal to . We first show that implies . If has another proposal in and is not equal to , then man is unmatched in and therefore holds. If does not have any other proposal in , then implies .

Conversely, if then either is unmatched in or her match in is part of a blocking pair. In either case, there exists such that prefers to and has a proposal in or before . Hence, .

3. Step 2 establishes the invariant at the beginning of the while loop. Any man is removed from only when .

Let us analyze the time complexity of Algorithm . Initialization takes time. Step 1 takes time because . Step 2 takes time to compute . Step 3 increases for some in every iteration. Each iteration can be done in time and no can exceed . Thus, the algorithm takes time which reduces to the standard time complexity of the GS algorithm when both and are equal to . The algorithm does not process more than choices for any man even if the number of women exceeds the number of men. This is sufficient because there cannot exist any stable marriage that includes a choice beyond the choice number for any man.

### 8.2 An Efficient Implementation of Algorithm β

We now discuss an efficient implementation of the downward traversal shown in Fig. 8. The implementation uses the following data structures. The variable is the rank of the best proposal that a woman may have in any vector less than or equal to . If , then the woman has a proposal from her top choice in some vector less than or equal to . The variable is the list of all women who may be part of some blocking pair in . When becomes empty we know that is stable. The variable stores the rank of woman for man . If equals , then is the top choice for man .

In the first step, we ensure that no component of exceeds . Since there are men and , there are proposals up to . These proposals may be to different women. In step 2, we further trim to guarantee that we never have to handle more than women. Recall that our goal is to get an algorithm whose complexity is at most linear in the number of women. To that end, we first claim the following

###### Theorem 4

Let be the set of women that are part of the man-optimal marriage.
(a) Any stable marriage can only include women from .
(b) Any matching such that a man prefers a woman outside of to is not stable.

Proof: (a) Consider any that is a man-saturating matching with a woman outside of . Suppose for contradiction is a stable matching. Let be the man optimal stable matching. Then . However, this means that the number of unique women proposed until exceeds . Hence, or any proposal vector greater than cannot be a stable marriage from Lemma 1.
(b) Consider any that is a man-saturating matching such that some man prefers a woman outside of to . Suppose is stable. From part (a), we conclude that includes proposal to women in . Furthermore, if man prefers a woman outside of , we get that the number of unique women proposed until exceeds . Hence, from Lemma 1, cannot be stable.

We exploit Theorem 4 as follows. At step 2, we find the man-optimal stable marriage . If there is any component of such that is less than , then clearly there cannot be a stable marriage before . Now based on , we can determine , the set of women that can be part of any stable marriage. We now decrease for each such that proposals are made until are only to women in . This step would not be required if the number of men and women were equal.

In the third step, we ensure that there is no man such that . Instead of maintaining forbidden men, it is easier to maintain , the list of all women in who may be part of blocking pairs in . We initialize to all women in . Whenever becomes empty, there are no blocking pairs. To satisfy a blocking pair, we first remove a woman from . We determine , the top choice of that woman in a vector less than or equal to . There are three possibilities: (1) If is matched with in , then we are done with processing of and is deleted from . (2) If has not made proposal to in any vector before , then the woman must move on to her next choice. (3) If had a proposal to before but not in , then we have that is a blocking pair. Since we are exploring choices in the order of , is the best blocking pair for . We satisfy this blocking pair by moving to the choice given by the woman . This step corresponds to a downward traversal in the proposal lattice and the assignment for man improves with this step. Since has her best proposal, she is deleted from . The current partner of is added to , if not already on the list.

In the algorithm , for any woman can only increase. As increases, women are assigned less preferable choices. Similarly, the vector which corresponds to choices by men only decreases with the algorithm. Hence, the assignment to men only improves with the execution of the algorithm.

We now have the following result that shows correctness of the implementation of Algorithm .

###### Theorem 5

Given any proposal vector , Algorithm in Fig. 8 returns the greatest stable proposal vector less than or equal to .

### 8.3 Proof of Theorem 5

###### Theorem 6

Given any proposal vector , Algorithm in Fig. 8 returns the greatest stable proposal vector less than or equal to .

To show the correctness of the implementation, we first show the following Lemma.

###### Lemma 9

The while loop in Step 3 of Fig.