Matching-Updating Mechanism: A Solution for the Stable Marriage Problem with Dynamic Preferences

We studied the stable marriage problem with dynamic preferences. The dynamic preference model allows the agent to change its preferences at any time, which may cause instability in a matching. However, preference changing in SMP instances does not necessarily break all pairs of an existing match. Sometimes, only a few couples want to change their partners, while others choose to stay with their current partners; this motivates us to find stable matching on a new instance by updating an existing match rather than restarting the matching process from scratch. By using the update mechanism, we try to minimize the revision cost when rematching occurs. The challenge when updating a matching is that a cyclic process may exist, and stable matching is never achieved. Our proposed mechanism can update a match and avoid the cyclic process.


Introduction
Numerous types of research have been conducted on the stable matching problem in fields including computer science, mathematics, and economics. The term "matching" refers to a collection of agents wishing to form a pair that meets each agent's criteria. The stable marriage problem (SMP) was introduced by Gale and Shapley [1]. It is one of the most well-known stable matching problems. Since its original conception in 1962, the SMP has attracted significant attention from researchers. Numerous extended variants of SMP have also emerged, such as the stable roommate problem, the college admissions problem, the hospital/resident problem, and several other stable matching problems [2][3][4][5]. The SMP algorithm has been widely used to solve several real-world problems. One of the most widely used variants is the hospital/resident problem variant [4,6], which is used to place medical students in hospitals or to select new students. Nowadays, the SMP algorithm is also widely applied to large-scale computer applications, such as content delivery networks [7] and job scheduling of virtual machines to servers [8,9].
The SMP is a bipartite matching problem with an equal number of agents on each side. Each agent expresses a strict order preference that includes all members of the opposite side. A matching µ is unstable when at least one blocking pair exists. A blocking pair is formed of a man m and a woman w who are not partners in a matching µ, but prefer each other over their current partners. In the classical SMP, each agent expresses a strict order preference for the opposite side. However, in real-world situations, some agents are occasionally unable to express their actual preference list due to a lack of information or observations about the opposing side, leading to the agents' preferences changing dynamically. For example, consider job scheduling for virtual machines (VMs) to servers. Computer resource consumption is dynamic, and users must understand the behavior of their virtual machines to define the minimum and maximum resource requirements before deploying to the server. However, several users do not have the ability to define the minimum and maximum resource requirements for their virtual machines. If the assigned resources exceed the actual usage of their VM, this leads to a large amount of unused resources on the server. Meanwhile, the VM's performance suffers if the allocated resources are insufficient. All virtual machines and servers need to be rescheduled to improve their effectiveness. When rescheduling, the scheduler determines the new preference for VMs and servers by examining the VMs' historical information. This study aims to find a stable matching for the SMP with the dynamic preference model, where dynamic preferences refer to a scenario in which agents' preferences might change dynamically over time. To illustrate the problem, we use a simple 3 × 3 SMP.

Example 1.
There is a set of men M = {m 1 , m 2 , m 3 } and a set of women W = {w 1 , w 2 , w 3 }. Assume that agent m 1 has dynamic preferences by changing his preference order. Specifically, these dynamic preferences generate two SMP instances, as depicted in Figure 1: Traditionally, we can use the Gale-Shapley algorithm to find a stable matching solution for each instance. In Example 1, we can find the stable matching for Instances 0 and 1 by processing it separately. However, a change in preference for an agent does not necessarily affect the stability of all pairs in a matching. Some small preference changes may not affect all agents, and only a few pairs want to change their partners, while others prefer to stay with their current partners. This motivates us to maintain stability in the SMP with dynamic preferences by using a matching-updating mechanism. The SMP with dynamic preferences is an extended version of the original SMP; the goal is to obtain a stable matching on the SMP instance. The Gale-Shapley algorithm is one way to find a stable matching for the SMP; by starting with an empty matching, the Gale-Shapley algorithm takes O(n 2 ) to find a stable matching. This study does not focus on the computational costs of finding a stable matching, but we try to minimize the revision costs when preferences change. The definition of revision cost here is the cost/impact when we rematch the instance. Using the Gale-Shapley algorithm, we can always find a stable matching, but the rematching process starts from the beginning (empty matching). We try to minimize the revision cost when rematching by using the match-updating mechanism. As a practical example, when we perform rematching between VMs and servers, if we perform the rematching using the Gale-Shapley algorithm, we need to involve all agents in the instance, which means all VMs and servers need to temporarily stop. However, we can minimize the number of VMs and servers that have to stop with the match-updating mechanism.
Our contribution in this research is the minimization of the revision cost when performing the rematching. Our theorems and mechanism demonstrate the process of finding stable matching by updating the previous matching. Our paper is organized as follows. Section 2 contains a number of studies relevant to this research. In Section 3, we discuss how to deal with dynamic preferences in the stable marriage problem by updating the previous stable matching. In Section 4, we discuss our findings and their impacts on future research. In Section 5, we provide the conclusions of our study.

Preliminaries
In this study, we deal with SMP instances that have dynamic preferences. In the dynamic preference model, the agent is allowed to change their preferences. The agent's preference changes may affect the original SMP instance. In other words, changing the preference of one agent will create another SMP instance. Numerous studies on dynamic preferences in stable matching have been published. Kanade et al. [10] proposed an algorithm that maintains a matching for evolving preferences of stable matching. Evolving preference is similar to our dynamic preference model. The goal of their study was to maintain an approximately stable matching, whereas our goal is to find the stable matching for all available instances. Chen et al. [11] proposed the concept of robustness and the near-stability of matching for dynamic preferences. Tobustness means maintaining all instances produced by dynamic preferences that remain stable in a classical way, whereas near-stability tries to find the stability by measuring the strength of incentive between two agents in a blocking pair.
The aim of this study is to find a stable matching within dynamic instances by updating a previous stable matching. With respect to the creation of a new instance, the previous stable matching may be stable or unstable for the newly created instance. In order to update a stable matching, we need to identify the presence of a blocking pair in the matching. If no blocking pair is confirmed, it means that the given matching from the previous instance remains stable in the newly created instance. However, when a blocking pair is encountered in the matching, we need to satisfy the blocking pair. Otherwise, the matching will remain unstable. When updating a matching, it is essential to keep in mind the domino effect while we attempt to satisfy the blocking pair. The domino effect of attempting to satisfy the blocking pair means that we also need to break another pair. Furthermore, we must be able to re-satisfy the pair that was previously disengaged by the previous step. When we attempt to revise a pair in matching, the worst-case scenario is that an infinite loop occurs in a process. As in the open question of Knuth [12], which states that there is a cyclic process when attempting to satisfy the blocking pair using the Gale-Shapley algorithm, this situation leads to the matching remaining unstable. Knuth's open question also shows that updating a stable matching using the Gale-Shapley algorithm is not possible.
Roth and Vande [13] demonstrated in their work that stable matching is always possible, even when starting with arbitrary matching. Additionally, this research addressed Knuth's [12] open question. Jinpeng Ma [14] examined the Roth and Vande (RV) mechanism and admitted that stable matching will always be found with a probability of one when using the RV mechanism, even though it starts from arbitrary matching. Unlike the Gale-Shapley algorithm, which always produces the same stable matching, the RV mechanism could produce a variety of stable matchings for each execution, including man-optimal, woman-optimal, and some fair matching (intermediate) in the lattice structure. However, Jinpeng Ma also claimed that in the RV mechanism, not all stable matching options can be achieved using the RV mechanism. In our study, we try to update the stable matching by modifying the Roth and Vande mechanism. In our dynamic preference model, we have the previous SMP instance and its stable matching. Furthermore, we use those properties as input for our proposed algorithm.

The Stable Marriage Problem
The stable marriage problem (SMP) was introduced by Gale and Shapley [1]. An SMP is a two-sided matching problem with an equal number of agents on each side. Each agent expresses a strict order preference that includes all members of the opposite side. The goal of the Gale-Shapley algorithm is to find a stable matching for all involved agents. The term "matching" refers to the process of pairing or matching participants (groups of men and women) in order to satisfy a specified criterion. A matching process is a step to determine the pairs of participants (sets of men and women) to meet the specified criteria. The size n of the SMP instance is I = (M, W, L), where M denotes the set of male agents M = {m 1 , m 2 , . . . , m n }, W denotes the set of female agents W = {w 1 , w 2 , . . . , w n }, and L represents a list of the preference order of an agent for the opposite sex. To express the preference order list of agent m 1 , we can denote it by L(m 1 ). For such an instance, a matching µ is a one-one correspondence between the men and the women. If a man m and a woman w are matched in µ, they are referred to as partners, and we write m = µ(w) and w = µ(m). µ(m) is the partner of w in µ, and µ(w) is the partner of m in µ. In the SMP, the stability of matching is determined by the existence of a blocking pair. In a matching µ, a pair (m, w) is said to be a blocking pair if m and w are not a pair in µ, but m prefers w over µ(m) and w prefers m over µ(w). That is, (w m µ(m)) ∧ (m w µ(w)). A matching that contains at least one blocking pair is called unstable; otherwise, it is stable.

Dynamic Preferences in the SMP
In the traditional SMP, each agent's preference order or rank is fixed. As discussed in the introduction, we attempted to solve the SMP with a dynamic preference model. In this study, we assume that the preference list of agents is complete, meaning that each agent must include all available members of the opposite side in their preference list. As illustrated in Figure 2, a preference change of agents in the SMP instance may lead to the creation of another SMP instance.

Definition 1.
The dynamic preferences describe a situation in which an agent's preference for an SMP instance can change through permutation at anytime, leading to the formation of another SMP instance.
As a consequence of the preference changes, a new instance will be created based on the number of preferences expressed by agents.

Definition 2.
A dynamic instance is a set of SMP instances generated from an original SMP instance with dynamic preferences.
Dynamic preferences result in a more realistic scenario for a stable matching problem in which agents do not always express their preferences correctly due to a lack of observations or information about their opposite side. In the classical SMP, an instance is defined as I = (M, W, L), where M and W denote the sets of male and female agents, respectively; L denotes the order of each agent's preference list for the opposite side. The preference list of a male agent m can be written as L(m). However, in the case of the SMP with dynamic preferences, multiple SMP instances may exist as a result of changes in one or more agents' preferences. In other words, the number of possible instances that will occur is i = k 1 × k 2 × · · · × k 2n , where k denotes the number of preferences expressed by each agent, and n is the size of the SMP. The dynamic instance set is DI = {I 1 , I 1 , . . . , I i }. For example, if there is a single agent with two distinct preferences in size n of the SMP, there will be two SMP instances available. In the dynamic preference model, changes in an agent's preferences are a permutation of their previous preference list. This means that no new members will be added or removed from an agent's preference list during the preference changes.

Updating the Stable Matching
As mentioned in the introduction, our goal is to find a stable matching for each instance. This study attempts to find stable matching for each instance by updating the previous instance's stable matching. The steps of finding stable matching using the previous matching update mechanism are depicted in Figure 3. Our steps for determining stable matching for a dynamic instance are as follows: 1.
Determining the impacts of modifying an agent's preferences: We identify the effects of changing an agent's preference and determine whether it leads to the occurrence of a blocking pair in a matching.

2.
Initiating an update of the matching if a blocking pair exists.

3.
If there is no blocking pair, the previous instance's matching will likely be stable for the new instance.

Identifying the Preference Changes
The preference change of an agent does not always affect the stability of a previous matching. We classify the types of changes in an agent's preferences as either major or minor changes.

Definition 3.
A minor preference change is a permutation-based change in an agent's preference that does not affect the pair in a stable matching. As a result, this preference change has no direct impact on the creation of blocking pairs. Definition 4. A major preference change is a permutation-based change in an agent's preference that leads to the creation of a blocking pair. These preference changes may result in the instability of a matching.
Every agent is allowed to change their preferences at any time in the dynamic preference model. A change in an agent's preference does not always lead to a change in matching. However, it can occasionally allow for the appearance of blocking pairs, leading to the instability of a previous matching.
Given an SMP with dynamic preferences of size n and with the initial instance I 0 = (M 0 , W 0 , L 0 ) and stable matching µ 0 , where M 0 = {m 1 , m 2 , . . . , m n }, W 0 = {w 1 , w 2 , . . . , w n }, if we suppose that a male agent (m 1 ) changes his preference through permutation, we will have another instance of the SMP: I 1 = (M 1 , W 1 , L 1 ), where L 0 (m 1 ) = L 1 (m 1 ). By referencing the previous SMP instance, we determine the occurrence of potential blocking pairs. We identify whether the preference change for agent m 1 is a minor change or not.

Theorem 1.
Under the assumption that the preference change occurs on only one side, and if no agent with a rank lower than µ 0 (m 1 ) in L 0 (m 1 ) becomes higher than µ 0 (m 1 ) in L 1 (m 1 ), the change is considered minor.
Proof. Assume that the position of agent µ 0 (m 1 ) in L 0 (m 1 ) is the (n − 1) th rank; this means that agents from the first rank to the (n − 2) th rank in L 0 (m 1 ) prefer other male agents over m 1 . The agent at the n th rank is a worse agent than µ 0 (m 1 ), which means that µ 0 (m 1 ) is the best option for m 1 at I 0 (man-optimal). Thus, as long as the n th agent's position remains lower than µ 0 (m 1 ) in L 1 (m 1 ), any permutation in the agent from the 1 st rank to µ 0 (m 1 ) in L 0 (m 1 ) does not affect the pair (m 1 , µ 0 (m 1 )). This results in µ 0 (m 1 ) = µ 1 (m 1 ).
Based on Theorem 1, we describe the following corollaries.
, then any permutation in L 0 (m 1 ) leads to minor change.
Proof. If µ 0 (m 1 ) is the last order in L 0 (m 1 ), µ 0 (m 1 ) is considered the best choice that m 1 can get because other female agents prefer other male agents over m 1 . As a result, (m 1 , µ 0 (m 1 )) will not change, although the rank of µ 0 (m 1 ) increases in L 1 (m 1 ).

Corollary 3.
If there is any permutation in L 0 (m 1 ) from the first rank to µ 0 (m 1 ) or any permutation from the rank of µ 0 (m 1 ) + 1 to the n th rank, then it is a minor change.
Proof. The permutation of the first rank to µ 0 (m 1 ) does not lead to a worse agent being superior to µ 0 (m 1 ). Meanwhile, permutations from the rank of µ 0 (m 1 ) +1 to the lowestranked agent will also be inferior to µ 0 (m 1 ). According to Theorem 1, it is a minor change if no agent worse than µ 0 (m 1 ) at L 0 (m 1 ) improves in L 1 (m 1 ).
Theorem 1 and its corollary define the constraints under which the effect of changing agents on male agents (proposing side) can be identified. However, Theorem 1 and its corollary hold true when female agents (the proposed side) possess a change in their preferences. We identify the impact of changing an agent's preferences using Theorem 1 and its corollary and whether the change has the potential to lead to the establishment of a blocking pair in the new instance or not. This identification accelerates the decision making regarding updating a matching.
We define Algorithm 1 to detect potential blocking pairs based on Theorem 1 and its corollaries. If Theorem 1 and its corollaries are satisfied in an agent, the agent might not have an incentive to change his/her partner. However, if Theorem 1 and its corollary are not satisfied, a deeper checking process using the stability-checking algorithm [3] will be performed. If a blocking pair is detected, the algorithm will mark the pair for removal and initiate the update of the matching process.
Theorem 1 assumes that the preference changes only occur on one side. Theorem 1 is used to determine the type of preference change that occurs in an agent, i.e., whether it is a major or minor change. The aim is to determine whether the preference changes incentivize an agent to change their partner. By checking the type of preference change for all agents with Theorem 1, we are still able to identify the potential blocking pair, even though both sides of the agents change their preferences simultaneously. Given an SMP with dynamic preferences of size n and with initial instance I 0 = (M 0 , W 0 , L 0 ) and stable matching µ0, where M 0 = {m 1 , m 2 , . . . , m n }, W 0 = {w 1 , w 2 , . . . , w n }, if we suppose that a male agent (m 1 ) and his partner (µ(m 1 )) change their preference simultaneously, we will have another instance of the SMP: I 1 = (M 1 , W 1 , L 1 ), where L 0 (m 1 ) = L 1 (m 1 ) and L 0 (µ(m 1 )) = L 1 (µ(m 1 )). if woman in potentialBP then 10: if wPref[woman].rank(m) > wPref [woman].rank(SM(woman)) then 11: removedPair.append(m, w) 12: end if 13: end if 14: end for 15: end if 16: end for Corollary 4. If m 1 and mµ 0 (m 1 ) confirm a minor change in I 1 , then the pair (m 1 , mµ 0 (m 1 )) does not trigger a blocking pair.
Proof. If agent m 1 confirms that his preference change is minor, µ 0 (m 1 ) is the best possible woman that agent m 1 can get. In addition, if agent µ 0 (m 1 ) also confirms that her preference change is minor, then agent m 1 is the best possible option for agent µ 0 (m 1 ) because the proposer is m 1 . Thus, if both agents agree that their current partners are the best partners they can get, then the preference changes of agents µ 1 and µ 0 (m 1 ) do not have the potential to create a blocking pair.
It is worth noting that Theorem 1 is employed to determine whether a change in an agent's preference can motivate an agent to change their current partner. Theorem 1 is used to verify agents' wishes about their partners following their preference changes. In other words, although both agents in a pair confirm a minor change, the pair is still likely to change if provoked by another agent that does not confirm a minor change.

Initiating the Matching Update
Once a blocking pair is confirmed to exist in a matching, the next step is to initiate a matching update. We modified Roth's and Vande's mechanism to update the stable matching. Random Paths to Stability [13] is a mechanism for discovering a stable matching solution by satisfying the matching's blocking pair. Ref. [14] summarized the RV mechanism and admitted that stable matching can always be achieved with a probability of one starting from satisfying blocking pairs in arbitrary matching. Roth's and Vande's work can be analogized as follows:

1.
Imagine that there is one room with one entrance; randomly select a pair from each matching process. Let the selected pair enter the room. The selected pair can be confirmed as a stable matching in this room because no other choice can break the pair. Meanwhile, the rest of the agents form a queue outside the room to enter the room one by one.

2.
Ask an agent who is in front of the room to enter the room. There will be a matching process inside the room. The door of the room will remain closed before a stable matching is formed in the room.

3.
Repeat the second step until there are no remaining queues and a stable matching is obtained. As a result, a stable matching will be obtained without any blocking pairs.
The RV mechanism begins the matching process by asking a single random pair to enter the room. Typically, a blocking pair will be selected in the initialization process. Following that, the remaining agents in the queue will be asked to enter the room separately. In the RV mechanism, new agents are not permitted to enter the room until all agents in the room reach stability. Therefore, this motivated us to shorten the finding of stable matching in the RV mechanism. The RV mechanism begins the matching process with a single pair for the initial part, while our proposed algorithm enables the initial process with multiple pairs. This significantly speeds up the process of finding stable matches by introducing multiple pairs into the room simultaneously. Here is our mechanism for updating a stable matching:

1.
Imagine that there is one room with one entrance; select some pairs that have been confirmed as a stable matching. Let of all the selected pairs enter the room together. Meanwhile, the rest of the agents form a queue outside the room to enter the room one by one.

2.
Ask an agent who is in front of the room to enter the room. There will be a matching process inside the room. The door of the room will remain closed before a stable matching is formed in the room.

3.
Repeat the second step until there is no remaining queue and a stable matching is obtained. As a result, a stable matching will be obtained without any blocking pairs. Figure 4 shows an illustration of the original RV mechanism and our updating mechanism. Our mechanism allows more than one pair to enter the room at the initial stage.

Theorem 2.
If we remove any one pair from the stable matching µ and SMP instance I, the reduced matching µ r will remain stable for the reduced instance I r .
When we remove m 1 from the preference list of women and w 1 from the preference list of men, there are only two possibilities for men: m i prefers w 1 to the partner µ(m i ) in the stable matching µ, or m i prefers the partner µ(m i ) to w 1 in the stable matching µ. Likewise, there are only two possibilities for women, which makes 2 × 2 = 4 combined cases altogether. We will check the stability condition above for the reduced matching µ r for the reduced instance I r .
Case 1: If (w 1 m i µ(m i )) and (µ(w j ) w j µ(m 1 )), then the statement (µ r (w j ) w j m i ) for the stability condition of matching µ r is true.
Case 2: If (µ(m i ) m i w 1 ) and (m 1 w j µ(w j )), then the statement (µ r (m i ) m i w j ) for the stability condition of matching µ r is true.
Case 3: If (µ(m i ) m i w 1 ) and (µ(w j ) w j µ(m 1 )), then both statements (µ r (m i ) m i w j ) and (µ r (w j ) w j m i ) for the stability conditions of matching µ r are true.
Case 4: If (w 1 m i and (m 1 w j µ(w j )), since both conditions of agents cannot directly provide the true statement, then we need further investigation for this condition: m i and w j are a pair µ and are also in µ r . Then, we can write m i = µ(w j ) and w j = µ(m i ). If we remove w 1 from the men's preferences, then µ(m i ) increases; still, we cannot confirm whether µ(m i ) becomes m i 's first choice or not. If we assume that µ(m i ) is not m i 's first choice, then m i prefers another woman (w x ) over µ(m i ), that is, (w x m i µ(m i )). Currently, the partner of w x is µ(w x ). Since µ is stable, then (m i w x µ(w x )) is not possible in µ, although we also remove m 1 from the women's preferences. Then, w x and m i never become partners in µ. Thus, the statement (µ r (m i ) m i w j ) holds true for the stability condition of matching µ r . The true condition holds for all possible combinations of pair removals. That said, the stability condition for matching µr still holds true.
As discussed in Section 3.2, we meant to obtain as many pairs as possible for the initial stage. The pairs wishing to enter at the initial step must be stable with each other. Therefore, we reduce the size of the previous matching to obtain a stable matching with a smaller size. The reduction procedure is performed by removing the unwanted pairs (m, w) from a matching µ that causes the formation of a blocking pair. It should be noted that removing m and w from the previous matching is not permanent. The removal is intended to keep the remaining pairs stable. Thus, the stable reduced matching can be used as the initial stage for finding a stable matching. To accomplish this, we must introduce a procedure for determining which pairs to exclude from the matching µ. By using Theorem 2, we can safely remove any pair from the previous matching to get the reduced stable matching.
Consider the following examples in Figure 5. Men preference Women preference Figure 5. A 4 × 4 SMP instance before reduction.
We have stable matching (man-optimal) {(w 1 , m 4 ), (w 2 , m 3 ), (w 3 , m 2 ), (w 4 , m 1 )}. Now, we will try to reduce the instance by randomly removing one pair in the stable matching. Suppose that we remove (w 2 , m 3 ). Thus, the size of the SMP instance will change to 3 × 3, as depicted in Figure 6. Figure 6 shows the result of reducing the SMP instance from 4 × 4 to 3 × 3 by randomly deleting one pair, which keeps the reduced matching stable with respect to the reduced instance.  The stable matching of instance 0 is µ 0 = {(w 1 , m 2 ), (w 2 , m 4 ), (w 3 , m 3 ), (w 4 , m 1 ), (w 5 , m 5 )}. Now, we want to find the stable matching of instance 1 by updating µ 0 . Comparing L 0 and L 1 , it is known that the pair (w 3 , m 1 ) will become a blocking pair in matching µ 0 if we use L 1 as the preference. (w 3 , m 1 ) blocks (w 3 , m 3 ) and (w 4 , m 1 ) in matching µ 0 . By using Theorem 2, we allow the removal of the pair (w 4 , m 1 ). Removing (w 4 , m 1 ) from instance 1 will produce the reduced matching µ r = {(w 1 , m 2 ), (w 2 , m 4 ), (w 3 , m 3 ), (w 5 , m 5 )}, which is stable with respect to the reduced SMP instance (I r ). As illustrated in Figure 4b, members of µ r may immediately enter the room together. Meanwhile, the removed pair (w 4 , m 1 ) forms a queue outside the room.
Algorithm 2 summarizes our work in this study. By combining Algorithm 1 with the reduced pair, we can start updating the previous matching and obtain the new stable matching for a new instance. Since we can start the initial stage by processing several pairs simultaneously, the revision cost of rematching can be minimized.

Controlling the Matching Orientation
An exciting aspect of the RV mechanism is the variety of the stable matchings obtained. Unlike the Gale-Shapley algorithm, which always provides the same stable matching, the RV mechanism can produce a different stable matching for each execution. While it is impossible to guarantee that all stable matchings in the lattice structure are obtained, manand woman-optimal matching can be guaranteed. According to Jinpeng Ma's research, certain circumstances can result in a stable match that leads to a particular orientation or, at the very least, in close proximity to the optimal orientation within the lattice structure. According to his study, if the last agent in the matching process is a male agent, a manoptimal or fairly stable match is obtained that is close to the man-optimal orientation in the lattice structure. In the opposite direction, if the last agent in the matching process is a woman, it will obtain a woman-optimal or fair stable matching that is close to the woman-optimal orientation in the lattice structure. This allows us to control the orientation of the stable matching that we want to produce by sorting the queueMember variable in Algorithm 2. By simply putting all male agents at the end of the queue, we will be able to obtain the man-optimal matching, or we can put all the female agents at the end of the queue if we want woman-optimal matching. for prevW in prevMPref[m] do 4: if prevMPref[m].rank(w) > prevMPref [m].rank(SM(prevW)) then 5: potentialBP.append(prevW) 6: end if 7: end for 8: for woman in mPref[m] do 9: if woman in potentialBP then 10: if wPref[woman].rank(m) > wPref [woman].rank(SM(woman)) then 11: removedPair.append(m, w) 12: end if 13: end if 14: end for 15: end if 16

Discussion
We propose an algorithm for finding stable matching in the SMP with dynamic preferences. In the SMP with dynamic preferences, an agent's preferences might change dynamically, affecting the stability of the previous stable matching. One traditional method for maintaining matching stability is to perform rematching each time the preferences change, as illustrated in Figure 2. However, in some situations, preference changes do not always affect the matching stability, such as with minor changes in preference. In other words, the prior matching remains stable in the presence of the new preference. This motivates us to update the matching to find a stable matching with dynamic preferences. In certain circumstances, such as when the preferences changes are minor, the match-updating method can accelerate the discovery of a stable match for the new instance. In this study, we are not focused on the computational cost while performing the rematching process. With the match-updating mechanism, we try to minimize the revision cost that needs to be paid.
Our current study is a preliminary step toward resolving issues in the SMP with dynamic preferences. In the SMP with the dynamic preferences, changing an agent's preferences will generate new instances, which may affect the stability of the matching obtained. Refs. [15,16] investigated the new concept of stability for stable matching problems with dynamic preferences. They tried to broaden the definition of stability in stable matching problems with dynamic preferences. The concept of new stability in stable matching problems with dynamic preferences was determined by measuring the strength of each founded matching against all available instances. To measure a matching's stability and strength, they needed to find a stable matching for each instance. Our current study will positively impact this problem by empowering the discovery of stable matching for each available stable matching instance. Our findings will aid future research in stable matching, especially with the dynamic preference model. The process of determining stable matching in an SMP with dynamic preferences can be accelerated by employing our theorem and proposed algorithm.
In our previous studies [8,9], we tried to find a matching between containers and servers. A matching process was carried out by using the Gale-Shapley algorithm between three containers and three servers [9]. The rematching process was performed in the traditional way by processing the new preferences using the Gale-Shapley algorithm. In our previous study, we also tried to find the matching between containers and servers under probabilistic preferences [8]. We focused on managing the rematching process between containers and servers when dealing with dynamic preferences. When an agent's preferences changed, the container scheduler performed the rematching process. With our current research, we can speed up rematching by updating the previous matching. Our match-updating method can accelerate the search for a stable matching for the new instance if the preference changes are minor. However, this update method still has limitations and weaknesses. For some situations, such as if all agents' preferences are changed and no one confirms the minor preference changes, the match-updating process cannot be accelerated. Moreover, if all agents want to change their current partners, the computational cost of finding a stable matching in a new instance will be higher than with the traditional way of finding a stable matching due to the extra cost of the preference change checking process.

Conclusions
In the SMP with dynamic preferences, agents can modify their preferences at any time, leading to the creation of a new SMP instance. As the consequence of the preference changes, the matching obtained may become unstable. We proposed a mechanism for finding a stable matching by updating an existing matching. A cyclic process (infinite loop) may exist when updating a matching. We employed the RV mechanism to prevent this cyclic process when updating a matching. We attempted to update a matching by isolating the pairs that contribute to its instability, thus generating a smaller matching with a stable condition (reduced stable matching). Our proposed mechanism can update a matching without worrying about the cyclic process. As a result, our match-updating method can accelerate the process of finding a stable matching for a new instance when the preference changes are minor. That said, the main contributions of this paper are Theorems 1 and 2, which can shorten the search for stable matching with dynamic preferences. Thus, we can minimize the revision cost when performing the rematching.
For the SMP with dynamic preferences, our current work is a preliminary step toward resolving the bigger issues of the SMP with dynamic preferences. This paper aims to find a stable matching for each generated instance of the SMP with dynamic preferences. However, defining the new stability concept for the SMP with dynamic preferences would be the interesting part of the SMP with dynamic preferences.  freeMember.append(newMember) 4: while freeMember do 5: proposer = freemember.pop(0) 6: if proposer == woman then 7: womanList = womanPrefers[proposer] 8: for man in womanList do 9: if man is roomMember then 10: manList = manPrefers[man] 11: if man in M then 12: manFiance = M(man) 13: if manList.index(proposer) < manList.index(manFiance) then 14: freeMember.append(manFiance) 15