1 Introduction
We study the problem of matching agents who arrive to a marketplace over time and leave after a short period. Agents can only be matched while they are present in the marketplace. There is a different value for matching every pair of agents, which does not vary over time. The planner’s goal is to maximize the total value over a given finite time horizon.
Several marketplaces face a such a problem. Ridehailing platforms have to match passengers with drivers, in which case the value of a match may depend on to the distance between the driver and the passenger. Such platforms may also carpool passengers and hence match passengers with each other, in which case the value of a match can represent the reduction in total distance traveled by the two matched passengers, compared to the distance traveled in individual rides. Kidney exchange platforms face the problem of matching incompatible patientdonor pairs with each other. In this context the value of a match can represent, for example, the quality adjusted life years due to the transplant. The common challenge in all these applications comes from the uncertainty associated with future arrivals and potential future matches.
We study matching algorithms that perform well across any sequence of arrivals, when there is no a priori information about the match values or arrival times. The underlying graph structure may be arbitrary and is not necessarily bipartite. Agents can be matched at any moment between their arrival and their departure. In that sense, our framework differs from the classic online matching literature where matching decisions have to be made immediately upon the arrival of an agent.
One important assumption we make is that each agent departs from the market exactly time periods after her arrival. In the case of the carpooling application one may think of as a (selfimposed) service requirement, which ensures that no passenger waits for too long before being matched. In that case, after periods the passenger is assigned to an individual ride. Later on, we relax this assumption to allow for stochastic departures. It is worth noting that when departure times are allowed to be arbitrary, the competitive ratio of any algorithm is unbounded.
Main contributions
We introduce an algorithm, termed Postponed Dynamic Deferred Acceptance (PDDA), that achieves a competitive ratio of . We further show that no algorithm achieves a competitive ratio that is higher than .
A key step of the algorithm is to artificially create a twosided market by randomly assigning each agent to either be a buyer or a seller. In this market, buyers will “bid” to match with a desired seller. With each seller that arrives to the market we associate a price, which is initiated to zero. For each buyer, the marginal utility of matching with a given seller is the value from the match with that seller minus the price that the seller demands. The algorithm maintains these virtual prices (for sellers) and profit margins (for buyers).
Once a buyer joins the market she triggers a bidding process similar to an ascending auction (Kuhn, 1955; Demange et al., 1986; Bertsekas, 1988). This ascending bidding process maintains a tentative matching. A tentative match between a buyer and a seller is converted into a real match only if the seller has been present for time periods and is about to depart. At that time, both the seller and the buyer to whom she is matched depart from the market. Given that sellers are patient and choose their match in the last minute, a buyer will never bid on sellers who arrive after her. This carefully chosen bidding and matching process guarantees that the profits of the agents (sellers’ prices and buyers’ marginal utilities) are monotone over time, which is crucial for our primaldual competitive analysis.
We now describe in more detail how the agents are assigned to become buyers or sellers. One simple way to do so is to flip an unbiased coin, independently for each agent, at the time of arrival. We improve upon this naive assignment by introducing two copies of each agent, and assign one to be a seller and the other to be a buyer. This enables us to postpone the decision until we have more information about the graph structure and the likely matchings.
We extend our model to the case in which departures are stochastic. We show that when the departure distribution has a nondecreasing hazard rate and departure times are known at the last minute, we can adapt our algorithm to achieve a competitive ratios of .
Related literature
This work has ties to the online matching problem. In the classical problem proposed by Karp et al. (1990), the graph is bipartite and a finite number of vertices on one side are waiting, while vertices on the other side arrive dynamically and have to be matched immediately upon arrival. This work has numerous extensions, for example to stochastic arrivals, and the adwords setting Mehta et al. (2007); Goel and Mehta (2008); Feldman et al. (2009); Manshadi et al. (2011); Jaillet and Lu (2013). See Mehta (2013) for a detailed survey.
Our work differs from the above line of work in three ways. First, we allow both sides of the graph to arrive and depart dynamically. This is useful for applications such as dynamic matching of drivers to passengers. Second, we are able to provide algorithms that perform well in the case of edgeweighted inputs. Lastly, we do not require the graph to be bipartite, which is useful in the case of kidney exchange, as well as dynamic matching of carpooling users.
This paper is also related to a presentation by Dutta et al. (2017), which looks at a model where the online algorithm uses advance knowledge of future arrivals. Closely related is Huang et al. (2018), who study a similar model but consider the unweighted case and establish bounds also for adverserial departures.
A large literature has been dedicated to the static matching with heterogeneous match values and a particular problem is finding a maximumweight matching problem efficiently. Classic algorithms that have been proposed include the Hungarian algorithm (Kuhn, 1955), and auction algorithms Demange et al. (1986); Bertsekas (1988). For the case, in which agents have ordinal preferences, Gale and Shapley (1962) proposed the Deferred Acceptance algorithm which finds a stable matching. Our work builds on these algorithms by maintaining a tentative maximumweight matching over time, and matches are made final when a seller is about to depart.
There is also a growing literature that focuses on dynamic matching in the context of kidney exchange, initiated by Ünver (2010). Most papers focus on random graphs, and study various questions such as: the effect of long cycles and chains Anderson et al. (2015), the effect of edge failure Dickerson et al. (2013), or the effect of a having vertex heterogeneity Ashlagi et al. (2017b). Closer to out paper is work by Akbarpour et al. (2017) which studies the effect of knowing when a vertex is about to depart. They show that in a sparse random graph model, matching vertices only when they become critical performs well. Our contribution with respect to these papers are the following. First we provide a framework to study dynamic matching without requiring a specific random graph model. Second, these papers focus on the nonweighted case and in contrast we consider the weighted case. Lastly, we show that in a worstcase setting, having information on critical vertices is necessary but may not be sufficient to obtain an efficient matching algorithm: optimization is also needed.
Few papers have considered the problem of dynamic matching when matches yield different values. In the adversarial setting Emek et al. (2016); Ashlagi et al. (2017a) study the problem of minimizing the sum of distances between matched agents and the sum of their waiting times. Their model has no departing agents and everyone is matched and our model does not account for agents’ waiting times.in the case where o Several papers consider the problem of dynamic matching in stochastic environments (Baccara et al., 2015; Ozkan and Ward, 2016; Hu and Zhou, 2016) (the latter paper allows agents to depart the market). These papers find that some accumulation of agents is beneficial for improving efficiency. More recently, (Truong and Wang, 2018) study matching when the graph is bipartite and vertices arrive stochastically. They provide a approximation in the case where one side departs immediately while the other side departs after some arbitrary time.
2 Model
We consider a model with a finite horizon, in which at each period a single agent, also denoted , arrives to the market. Note that for the simplicity of notation, we refer to the agent that arrives at time as agent . The value (weight) from matching agent with agent is denoted by . Each agent in our model has to leave exactly time steps after arriving to the market. Agents can only be matched when they are in the market and matched agents are removed from the market immediately.
We assume that the planner knows as well as the match value between any pair of agents and only if both and are present in the market. We say that a vertex is critical when she has been in the market for time periods. In that case, the planner has the option to match her before she leaves. The planner has no distributional information about future arrivals or future match values.
The planner’s goal is to find a matching that will yield a maximum total value for any set of values and any order of arrivals. In particular we are interested in designing a matching algorithm that achieves a high competitive ratio with respect to the maximumweight matching at hindsight.
It will be convenient to represent the input as a graph, where each agent is represented by a vertex, and there is an undirected edge between vertices and if and only if .
To illustrate a natural tradeoff, consider the example in Figure 1, in which every agent remains periods in the market. At period the planner can either match agents and or let agent leave the market unmatched. This simple example show that no deterministic algorithm can obtain a constant competitive ratio. Furthermore, no algorithm can achieve a competitive ratio higher than . See Section 6 for a more detailed discussion.
3 Main results
The example in Figure 1
illustrates a necessary condition for the algorithm to achieve a constant competitive ratio: with some probability, vertex
needs to forgo the match with vertex and wait until she becomes critical. In general, we ensure this property by assigning every agent to be either a seller or a buyer. Buyers may get matched and leave the market at any time but sellers do not match before they become critical.We will first consider the case in which the underlying graph is bipartite, with buyers on one side and sellers on the other. To ensure that sellers never leave before they become critical, we further assume that there is no edge between a seller and any buyer who arrived before . Such a graph is called a constrained bipartite graph.
In Section 3.1 we introduce an algorithm for the case in which the input graph is constrained bipartite. Through a primaldual analysis, we establish that the algorithm achieves at least of the offline total reward.
In Section 3.2 we consider arbitrary graphs. For such graphs, we artificially generate a twosided market by creating a buyer and a seller copy of each vertex. The matching produced by the algorithm in this bipartite graph, is then transformed into a matching in the original graph by a carefully constructed randomized process. This process loses an additional factor of .
3.1 Algorithm for constrained bipartite graphs
We assume here that the input is a constrained bipartite graph. Vertices on one side are called buyers and vertices on the other side are called sellers, and there is no edge between a buyer and a seller if arrives before ().
Note that even in this simplified setting no online algorithm can find the optimum solution. This is because when a new buyer arrives, she may create an augmenting path in the offline graph in which some of the vertices are already departed. We describe this in more details in Claim 6.2.
We introduce the Dynamic Deferred Acceptance (DDA) algorithm, which takes as input a constrained bipartite graph and returns a matching. The main idea is to maintain a temporary maximumweight matching at all times during the run of the algorithm. This matching is updated according to an auction mechanism: every seller is associated with a price , which is initiated at zero upon arrival. Every buyer that is present in the market is associated with a profit margin which corresponds to the value of matching to their most prefered seller minus the price associated with that seller. Every time a new buyer joins the market, she bids on her most prefered seller at the current set of prices. This triggers a bidding process that terminates when no unmatched buyer can profitably bid on a seller.
A tentative match between a buyer and a seller is converted into a real match only if the seller is critical, i.e. she has been present for time periods and is about to depart. At that time, both the seller and the buyer to whom she is matched depart from the market. This ensures that sellers never get matched before they become critical. If a buyer becomes critical we let her depart unmatched.
The ascending auction phase in our algorithm is similar to the auction algorithm by Bertsekas (1988). Prices (for overdemanded sellers) in this auction increase by to ensure termination, and optimality is proven through complementary slackness conditions. For the simplicity of exposition we presented the auction algorithm but for the analysis, we consider the limit and assume the auction phase terminates with the maximum weight matching. Another way to update the matching is through the Hungarian algorithm Kuhn (1955), where prices are increased simultaneously along an alternating path that only uses edges for which the dual constraint is tight.
The auction phase is always initiated at the existing prices and profit margins. This, together with the fact that the graph is bipartite, ensures that prices never decrease and and marginal profits never increase throughout the algorithm. Furthermore, the prices and marginal profits of the vertices that are present in the market form an optimum dual for the matching linear program (see Appendix
A for more details).Lemma 3.1.
Consider the DDA algorithm on a constrained bipartite graph.

Throughout the algorithm, prices corresponding the sellers never decrease and the profit margins of buyers never increase.

At the end of every ascending auction, prices of the sellers and the marginal profits of the buyers form an optimal solution to the dual of the matching linear program associated with buyers and sellers present at that particular time.
Maintaining a maximumweight matching along with optimum dual variables does not guarantee an efficient matching for the whole graph. The dual values are not always feasible for the offline problem. Indeed, the profit margin of some buyer may decrease after some seller departs the market. This is because may face increasing competition from new buyers, while the bidding process excludes sellers that have already departed the market (whether matched or not).
Proposition 3.2.
DDA is competitive for constrained bipartite graphs.
The proof, given in Section 4, relies on a primaldual argument. For any arriving buyer we denote by her initial profit margin after the ascending auction terminates. When a buyer is matched or departs, we set to be her final profit margin at that time. Similarly when a seller departs or is matched, we denote by her final price at that time.
The proof of the proposition relies on the following three ingredients. First, letting and , then the algorithm collects
Second, although the final dual variables are not dual feasible, the pair is a feasible dual solution of the offline matching problem. Finally, we obtain a factor by observing that
3.2 Arbitrary graphs
In the previous section, we constructed an algorithm for constrained bipartite graphs, we now extend it to arbitrary graphs.
A naive way to generate a constrained bipartite graph from an arbitrary one is to randomly assign each vertex to be either a seller or a buyer, independently and with probability . Then we remove any edge between each seller and buyers who have arrived before her. This approach yields the Simple Dynamic Deferred Acceptance (SDDA) algorithm:
Corollary 3.3.
SDDA is competitive for arbitrary graphs.
Observe that for , edge in the original graph remains in the generated bipartite graph with probability (if is a seller and is a buyer). We then use proposition 3.2 to prove that SDDA is competitive.
One source of inefficiency in SDDA is that the decision whether an agent is a seller or a buyer is done independently at random and without taking the graph structure into consideration. We next introduce the Postponed Dynamic Deferred Acceptance algorithm that postpones these decisions for as long as possible to enable a more careful construction of the constrained bipartite graph.
When a vertex arrives, we add two copies of to an virtual graph: first a seller and then a buyer . Seller initially does not have any edges, and buyer has edges towards any vertex with value . Then we run the DDA algorithm with the virtual graph as input. When a vertex becomes critical, and successively become critical in the virtual graph, and we compute their matches generated by .
Both and can be matched in this process. If we were to honor both matches, the outcome would correspond to a 2matching, in which each vertex has degree at most 2. Now observe that because of the structure of the constrained bipartite graph, this 2matching does not have any cycles; it is just a collection of disjoint paths. We decompose each path into two disjoint matchings and choose each matching with probability .
In order to do that, the algorithm must determine, for each original vertex , whether the virtual buyer or virtual seller will be used in the final matching. We will say that is a buyer or seller depending on which copy is used. We say that vertex is undetermined when the algorithm has not yet determined which virtual vertex will be used. When an undetermined vertex becomes critical, the algorithm flips a fair coin to decide whether to match according to the buyer or seller copy. This decision is then propagated to the next vertex in the 2matching: if is a seller then the next vertex will be a buyer and viceversa. That ensures that assignments are correlated and saves a factor compared to uncorrelated assignments in SDDA.
Theorem 3.4.
PDDA is competitive.
The proof of Theorem 3.4 is deferred to Section 4. It relies on the following three ingredients. First, the algorithm collects
where the expectation is taken over the random assignments of undetermined vertices to be sellers or buyers. Second, is a feasible dual solution of the offline matching problem. Finally, similar to the proof of 3.2, we use the following equality:
4 Analysis
In this section, we prove our three main results. We use to denote the expected sum of all match values collected by the algorithm, and to denote the value of the offline maximumweight matching.
4.1 Proof of Proposition 3.2
We prove that DDA (Algorithm 1) obtains a competitive ratio of at least on constrained bipartite graphs. The proof follows the primaldual framework.
First, we observe that by complementary slackness, any seller (buyer ) that departs unmatched has a final price (final profit margin ). When a seller is critical and matches to , we have . Therefore, DDA collects a reward of .
Second, let us consider a buyer and a seller who has arrived before but not more than steps before. Because sellers do not finalize their matching before they are critical, we know that . An ascending auction may be triggered at the time of ’s arrival, after which we have: , where the second inequality follows from the definition that and from the monotonicity of sellers’ prices (Lemma 3.1). Thus, is a feasible solution to the offline dual problem.
Finally, we observe that upon the arrival of a new buyer, the ascending auction does not change the sum of prices and margins for vertices who were already present:
Claim 4.1.
Let be a new buyer in the market, and let be the prices and margins before arrived, and let and be the set of sellers and buyers present before arrived. Let , be the prices and margins at the end of the ascending auction phase (Step 2(a) in Algorithm 1). Then:
(1) 
The proof of Claim 4.1 is deferred to Appendix A. By applying this equality iteratively after each arrival, we can relate the initial margins to the final margins and prices :
Claim 4.2.
.
This completes the proof of Proposition 3.2 given that the offline algorithm achieves at most:
It remains to prove Claim 4.2.
Proof of Claim 4.2.
The idea of the proof is to iteratively apply the result of Claim 4.1 after any new arrival. Let (resp. ) be the set of sellers (buyers) who have departed, or already been matched before time . We show by induction over that:
(2) 
This is obvious for . Suppose that it is true for . Note that departures do not affect (2). If the agent arrivint at is a seller, then for all other sellers , and for all buyers , , thus (2), is clearly still satisfied. Suppose that vertex is a buyer. Using equation (1), we have:
Note that at time , every vertex has departed. Thus, , and . This enables us to conclude our induction and the proof for (2).
∎
4.2 Proof of Corollary 3.3
We prove that SDDA is competitive for arbitrary graphs.
The Offline algorithm solves the following maximumweight matching problem:
(Offline Primal) 
Suppose that we have assigned each vertex to be either a buyer or a seller with probability . For , let . Consider the constrained offline problem obtained by running (Offline Primal) with edge values . Its expected reward is at least of the offline reward : Let be an optimal solution to equation (Offline Primal). It is feasible for the constrained problem, and yields value equal to .
We can conclude using Claim 4.2 along with the fact that is a feasible solution to the constrained offline dual problem. This yields the competitive ratio. ∎
4.3 Proof of Theorem 3.4
We prove that the PDDA algorithm achieves a competitive ratio of at least for arbitrary graphs. Observe that because of the randomization, we collect in expectation
Using the convention that for a pair of vertices , when , the dual of the offline matching problem linear programs can be written as:
(Offline Dual) 
It is enough to show that is a feasible solution to equation (Offline Dual). This is similar to the proof in the simplified setting. Fix and assume that . When arrives, we have , therefore by dual feasibility during the online matching procedure. Using the Lemma 3.1, we get feasibility for equation (Offline Dual):
We can conclude the factor using Claim 4.2. ∎
5 Extensions: Stochastic departures
We relax the assumption that all vertices depart after exactly time steps. In Section 6, we show that if departure times are chosen in an adversarial way, then no algorithm can obtain a constant fraction of the offline matching, even when departure times are known at the time of arrival.
We focus here on the stochastic case, in which the departure time of vertex is sampled independently from a distribution . We first assume that the realizations are known upfront (Section 5.1) and next we consider the case, in which is revealed only when becomes critical (Section 5.2).
5.1 Known departure times
We assume here that the for every agent , her departure time is sampled i.i.d from a distribution , and that is revealed to the online algorithm at the time when arrives.
Claim 5.1.
Suppose that there exists such that satisfies the property that for all ,
Then PDDA is .
Observe in particular that if is constant with value , we recover our previous result. Furthermore, if has a nondecreasing hazard rate, then this property is verified with .
Proof.
The main idea is to preprocess the graph by removing edges for which the two endpoints do not arrive and depart in the same order. Consider a modified graph, where we set edge value to when . Each nonzero edge is kept with probability at least .
Note that the offline optimal matching on the initial graph is a feasible matching on the modified graph. Thus, the offline matching on the modified graph collects a reward of at least .
Observe that the PDDA algorithm only requires that when a buyer becomes critical, any compatible seller has already departed. This is the case in our modified graph, which yields our factor . ∎
5.2 Unknown departure times
We assume now that the online algorithm only learns once becomes critical. The main difficulty is that a buyer may become critical before the seller that she is tentatively matched to. Because we want the seller to wait until she becomes critical, we cannot conduct the match. However, the departure of may cause the price to decrease, which violates the monotonicity property in Lemma 3.1.
We modify the PDDA algorithm in the following way: we set the buyer copy to never become critical in the auxiliary graph. Because buyer vertices can only match to sellers who arrive before them, there will eventually be a time when does not have any edge left in the auxiliary graph.
Proposition 5.2.
Suppose that there exists such that satisfies the property that for all ,
Then PDDA is competitive.
Proof.
When a vertex becomes critical in the original graph, if , we try to match vertex to vertex such that . With probability at least , vertex is still present in the original graph. ∎
Corollary 5.3.
PDDA is competitive when has a nondecreasing hazard rate.
6 Examples
We will present six examples. The first one shows an upper bound of for the online matching on arbitrary graphs. The second and third show that, even in the case of a bipartite constrained graph, randomized and deterministic algorithms cannot obtain competitive ratios higher than and respectively. The fourth one shows that our analyses of Proposition 3.2 and Theorem 3.4 are tight. The last two examples show that no algorithm is constantcompetitive in the case where we let departures be chosen by an adversary, or if the departures are stochastic and the algorithm does not know when vertices become critical.
Upper Bounds
Claim 6.1.
No deterministic algorithm is constantcompetitive, and no randomized algorithm is more than competitive.
Proof.
Observe that in Figure 1, ∎
Claim 6.2.
When the input is a bipartite constrained graph:

No deterministic algorithm can obtain a competitive ratio above .

No randomized algorithm can obtain a competitive ratio above .
Proof.
Deterministic case: Consider the example on the left of Figure 2. When seller becomes critical, the algorithm either matches her to buyer , or lets depart unmatched. The adversary then chooses accordingly. Thus the competitive ratio cannot exceed:
Stochastic case: Consider the example on the right of Figure 2. Similarly to the deterministic case, when seller becomes critical, the algorithm decides to match her to with probability . The adversary then chooses accordingly. Thus the competitive ratio cannot exceed:
∎
Tightness of the analysis
We will now show that our analyses for both the DDA and PDDA algorithms are tight:
Claim 6.3.
There exists a constrained bipartite graph for which DDA is competitive and for which the PDDA is competitive.
Proof.
Consider the input graph in Figure 3.
DDA case: Vertex will be temporarily matched to , and vertex will depart unmatched, hence the factor .
PDDA case: Similarly, will depart unmatched. When becomes critical, with probability , she will be determined to be a buyer and will depart unmatched. Therefore the PDDA collects in expectation while the offline algorithm collects . ∎
Relaxing our assumptions
We consider the Adversarial departures (AD) setting, where the adversary is allowed to choose the departure time of vertex . We assume that the online algorithm knows at the time of arrival of .
Claim 6.4.
No algorithm is constantcompetitive in the AD setting.
Proof.
Let us consider a graph with vertices, where will be chosen later by the adversary. For all , , and for all other , . Assume that vertex departs after arrivals, while all other vertices depart right away. For , let be the probability that the online algorithm matches vertex to when arrives. Observe that because the algorithm does not know , the has to be valid when . Therefore, . Therefore, there exists such that . The adversary chooses . This implies that , where the last inequality is obtained by taking . ∎
We now consider the Adversarial departure distribution (ADD) setting where are sampled i.i.d from a distribution chosen by the adversary. We assume furthermore that the online algorithm knows the realization upon the arrival of vertex .
Claim 6.5.
No algorithm is constantcompetitive in the ADD setting
Proof.
The idea is that we can construct a graph that exhibits the same properties as Figure 4, even with i.i.d departures. Fix and assume that departures are distributed according to the following distribution: w.p. , , and w.p. , .
The arrivals are defined as follows: the first vertices have no edge between themselves. The adversary then selects . For and , . Where is a large constant to be defined later. Vertices have no edges.
Let be the event that there exists such that .
Let be the event that there are less than vertices such that . The (random) number of such vertices
is binomially distributed with parameters
and . ThusWe can write: Conditional on and , the best any algorithm can do is match each vertex with probability . Therefore .
Let be the event that there exists such that . . Therefore, . For M large enough, we can conclude that .
∎
Finally, we consider the Stochastic Unknown Departures (SUD) setting where the adversary chooses a departure rate , and departures
are i.i.d geometric random variables with parameter
. The online algorithm knows but does not know even when becomes critical.Claim 6.6.
Even when the departure process is memoryless, if the algorithm doesn’t know when vertices become critical, it cannot obtain a constant competitive ratio.
Proof.
Consider the graph in Figure 4, and assume that at each time step, an unmatched vertex in the graph has probability of departing.
Conditional on vertex being present at time , let be the probability that the algorithm matches to . We have: . Furthermore, observe that . Therefore there exists such that . Then take .
Therefore for small enough and large enough. ∎
7 Numerical results
In PDDA, we compute a 2matching over the vertices that are currently present, and select each edge with probability . Although this randomization is useful to hedge against the worst case instance, it may be ineffective when the compatibility graph is not generated by an adversary.
Nonetheless, some of the key ideas behind PDDA may be useful to construct algorithms that perform well on nonadversarial graphs. This motivates a modified version of the Dynamic Defered Dcceptance algorithm, termed MDDA, in which vertices are no longer separated into buyers and sellers and every vertex now has a price.
Under MDDA, prices are reset to after each arrival, and an auction is conducted on the nonbipartite graph: while there exists an unmatched vertex, one is selected at random and it bids on its most prefered match. This leads to a tentative matching over all the vertices that are currently present in the graph^{1}^{1}1Note that because the graph is nonbipartite, this auction mechanism may fail to converge to a maximumweight matching.. When a vertex becomes critical, it is matched according to the tentative matching . This modified algorithm does not have theoretical guarantees, but we will show that it performs well on datadriven compatibility graphs.
Note that MDDA can be thought of as a reoptimization algorithm, where the optimal matching is recomputed when new information becomes available. One can replace the auction mechanism with any algorithm that computes a maximumweight matching. We implemented this algorithm, termed here ReOpt, where the matching is found by solving a mixedinteger program at each time step.
We compare the MDDA and ReOpt algorithms against three benchmarks that have been previously consdiered, or that are commonly used in practice:

The Greedy algorithm. The algorithm matches vertices as soon as possible to their available neighbor with the highest value (ties are broken in favor of the earliest arrival).

The Batching() algorithm. The algorithm waits timessteps and then finds a maximumweight matching. Unmatched vertices are kept in the next batch.^{2}^{2}2See Agatz et al. (2011); Ashlagi et al. (2013) in the case of ridesharing and kidney exchange respectively. We report the best simulation results across parameters .

The Patient algorithm. This algorithm waits until waits until a vertex becomes critical, and matches it to the neighbor with the highest match value (ties are broken in favor of the earliest arrival). This allows to seperate the value from knowing the time in which vertices become critical and the value of optimization.
Data
The first experiment uses data from the National Kidney Registry (NKR), which consists of 1681 patientdonor pairs who have joined the NKR. For any two patientdonor pairs and , we can determine whether the patient from each pair would have been medically eligible to receive the kidney from the other pair’s donor, had they had been present at the same time. If that is the case, we set , otherwise and (in particular we simply try to maximize the number of matches)^{3}^{3}3We ignore here the possibility of larger cyclic exchanges (3 or 4cycles) or chains, which are common in practice..
In the second instance, we use New York City yellow cabs dataset ^{4}^{4}4http://www.andresmh.com/nyctaxitrips/, which consists of rides taken in NYC over a year. For any pair of trips, we can compute the Euclidian distance that would have been traveled had the two passengers taken the same taxi (with multiple stops). The value represents the “distance saved” by combining the trips.
In both cases, this enables us to generate a dynamic graph in the following way. For :

Sample with replacement an arrival from the dataset.

For any vertex that is present in the pool, compute the value of matching to .

Sample a departure time .
We consider two settings, termed deterministic and stochastic respectively, in which is either constant with value
, or exponentially distributed with mean
. We will report simulation results for .Results
In Figure 5, we observe that both the Patient and Batching algorithms outperform Greedy. Intuitively, having vertices wait until they become critical helps to thicken the market and gives vertices higher valued match options. We notice that when departures are deterministic, Batching with the optimal batch size will be almost as efficient as ReOpt. However when the departures are stochastic, there is value in matching vertices as they become critical (MDDA and ReOpt).
Figure 6 provides the results for the kidney exchange simulations. In this case, the compatibility graph is unweighted, which implies that because we break ties in favor of the earliest arrival and departures are in order of arrival, Greedy and Patient are equivalent. Again, Batching performs relatively well in the deterministic case (if , no vertex will depart before it is included in one batch), but very poorly in the stochastic case.
In both datasets, we observe that ReOpt outperforms all other algorithm, although in the cases where the departures are deterministic, Batching performs close to ReOpt when the batch size is carefully chosen. This shows the value of both having information on agents’ departure times and also subsequent optimization.
It is important to note that the experiments we ran do not take into account the cost of waiting. We think that a richer model that accounts for this would be an interesting future direction. Two interesting areas for future work include the setting when the information about agent’s departure times is uncertain, as well as models that are less restrictive than the adversarial setting (see, e.g., Ozkan and Ward (2016)).
8 Conclusion
This paper introduces a model for dynamic matching, in which all agents arrive and depart over time. Match values are heterogenous and the underlying graph is arbitrary and can thus can be nonbipartite. We study algorithms that perform well across any sequence of arrivals and on any set of match values.
Importantly, our model imposes restrictions on the departure process and requires the algorithm to know when vertices become critical. There are many interesting directions for future research. An immediate open problem is to close the gap between the upper bound of , and the achievable competitive ratios ( for deterministic departures, and for stochastic departures). Independently, our model imposes that matches retain the same value regardless of when they are conducted. Being able to account for agent’s waiting costs would also be very interesting. Another direction is to design algorithms that achieve both a high total value but also a large fraction of matched agents.
References
 Agatz et al. (2011) Agatz, N. A., Erera, A. L., Savelsbergh, M. W., and Wang, X. (2011). Dynamic ridesharing: A simulation study in metro atlanta. Transportation Research Part B: Methodological, 45(9):1450–1464.
 Akbarpour et al. (2017) Akbarpour, M., Li, S., and Oveis Gharan, S. (2017). Thickness and information in dynamic matching markets.
 Anderson et al. (2015) Anderson, R., Ashlagi, I., Gamarnik, D., and Kanoria, Y. (2015). A dynamic model of barter exchange. In Proceedings of the twentysixth annual ACMSIAM symposium on Discrete algorithms, pages 1925–1933. Society for Industrial and Applied Mathematics.
 Ashlagi et al. (2017a) Ashlagi, I., Azar, Y., Charikar, M., Chiplunkar, A., Geri, O., Kaplan, H., Makhijani, R., Wang, Y., and Wattenhofer, R. (2017a). Mincost bipartite perfect matching with delays. In LIPIcsLeibniz International Proceedings in Informatics, volume 81. Schloss DagstuhlLeibnizZentrum fuer Informatik.
 Ashlagi et al. (2017b) Ashlagi, I., Burq, M., Jaillet, P., and Manshadi, V. (2017b). On matching and thickness in heterogeneous dynamic markets.
 Ashlagi et al. (2013) Ashlagi, I., Jaillet, P., and Manshadi, V. (2013). Kidney exchange in dynamic sparse heterogenous pools. arXiv preprint arXiv:1301.3509.
 Baccara et al. (2015) Baccara, M., Lee, S., and Yariv, L. (2015). Optimal dynamic matching. Working paper.
 Bertsekas (1988) Bertsekas, D. P. (1988). The auction algorithm: A distributed relaxation method for the assignment problem. Annals of operations research, 14(1):105–123.
 Demange et al. (1986) Demange, G., Gale, D., and Sotomayor, M. (1986). Multiitem auctions. Journal of Political Economy, 94(4):863–872.
 Dickerson et al. (2013) Dickerson, J. P., Procaccia, A. D., and Sandholm, T. (2013). Failureaware kidney exchange. In Proceedings of the fourteenth ACM conference on Electronic commerce, pages 323–340. ACM.
 Dutta et al. (2017) Dutta, C., Greenhall, A., Puranmalka, K., and Sholley, C. (2017). Online matching in a ride sharing platform.

Emek et al. (2016)
Emek, Y., Kutten, S., and Wattenhofer, R. (2016).
Online matching: haste makes waste!
In
Proceedings of the fortyeighth annual ACM symposium on Theory of Computing
, pages 333–344. ACM.  Feldman et al. (2009) Feldman, J., Mehta, A., Mirrokni, V. S., and Muthukrishnan, S. (2009). Online stochastic matching: Beating 11/e. In Proceedings of the 50th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 117–126.
 Gale and Shapley (1962) Gale, D. and Shapley, L. S. (1962). College admissions and the stability of marriage. The American Mathematical Monthly, 69(1):9–15.
 Goel and Mehta (2008) Goel, G. and Mehta, A. (2008). Online budgeted matching in random input models with applications to adwords. In Proceedings of the nineteenth annual ACMSIAM symposium on Discrete algorithms (SODA), pages 982–991.
 Hu and Zhou (2016) Hu, M. and Zhou, Y. (2016). Dynamic type matching.
 Huang et al. (2018) Huang, Z., Kang, N., Tang, Z. G., Wu, X., and Zhang, Y. (2018). How to match when all vertices arrive online.
 Jaillet and Lu (2013) Jaillet, P. and Lu, X. (2013). Online stochastic matching: New algorithms with better bounds. Mathematics of Operations Research, 39(3):624–646.
 Karp et al. (1990) Karp, R. M., Vazirani, U. V., and Vazirani, V. V. (1990). An optimal algorithm for online bipartite matching. In Proceedings of the twentysecond annual ACM symposium on Theory of computing (STOC), pages 352–358.
 Kuhn (1955) Kuhn, H. W. (1955). The hungarian method for the assignment problem. Naval Research Logistics (NRL), 2(12):83–97.
 Manshadi et al. (2011) Manshadi, V. H., OveisGharan, S., and Saberi, A. (2011). Online stochastic matching: online actions based on offline statistics. In Proceedings of the TwentySecond Annual ACMSIAM Symposium on Discrete Algorithms (SODA), pages 1285–1294.
 Mehta (2013) Mehta, A. (2013). Online matching and ad allocation. Foundations and Trends® in Theoretical Computer Science, 8(4):265–368.
 Mehta et al. (2007) Mehta, A., Saberi, A., Vazirani, U., and Vazirani, V. (2007). Adwords and generalized online matching. Journal of the ACM (JACM), 54(5):22.
 Ozkan and Ward (2016) Ozkan, E. and Ward, A. R. (2016). Dynamic matching for realtime ridesharing.
 Truong and Wang (2018) Truong, V.A. and Wang, X. (2018). Online matching in a ride sharing platform.
 Ünver (2010) Ünver, M. U. (2010). Dynamic Kidney Exchange. Review of Economic Studies, 77(1):372–414.
Appendix A Missing proofs
a.1 Missing proof of Claim 4.1
Proof.
The proof of termination in Bertsekas (1988) relies on the introduction of a minimum bid in step of the auction algorithm to ensure that the algorithm does not get stuck in a cycle of bids of . In the limit where , the algorithm ressembles the hungarian algorithm Kuhn (1955). The idea is to search for an augmenting path along the edges for which the dual constraint is tight. If such a path is found, the matching is augmented, otherwise we perform simultaneous bid increases in way that ensures that prices and margins are still dual feasible.
We assume that we are given at time an optimal matching and optimal duals corresponding to the graph with vertices . We assume that we added a new vertex to , and that we initialized
Initialize , , . Note that primal and dual feasibility are satisfied. Therefore, is optimal iff the following three complementary slackness condition are satisfied:
(CS1) 
(CS2) 
(CS3) 
Note that (CS1) and (CS2) are already satisfied. If then (CS3) is also satisfied and we have an optimal solution.
Suppose now that . We will update in a way that maintains primal and dual feasibility, as well as (CS1) and (CS2).
Our objective is to find an augmenting path in the graph. First we will start by trying to find an alternating path that starts on and only uses edges for which the dual constraint is tight: . Observe that by (CS1) all the matched edges in are in . We will now successively color vertices as follows:

Start by coloring in blue.

For any blue buyer , for any seller such that and , we color in red.

For any red seller , let , then color in blue.
Observe that there is an alternating path between and any red seller. If at one point we color an unmatched seller in red, this means that we have found an augmenting path from to that only utilizes edges in . In that case, we change according to the augmenting path. Because of the way we chose edges in , (CS1) is still satisfied. (CS2) and (CS3) are now also satisfied, which means we have an optimal solution .
We terminate when we are unable to color vertices any further. In that case, let us define . If , then there exists with and an alternating path form to . We update according to that path, and verify that all CS conditions are now satisfied.
Suppose that . Define
(3) 
The fact that we cannot color any more vertices implies that . Let . For every red seller , we update . For every blue buyer , we update . Observe that dual feasibility is still verified, as well as (CS1).
If , taking the argmin in (3), we now have such that which means we can add to and color in red. We will eventually have , and this leads to and we can terminate. This proves both the termination and correctness. Furthermore, monotonicity of the dual variables is also straightforward. Let us now prove the conservation property:
(4) 
Note that when we update the dual variables, then every seller we colored in red was matched in and we colored that match in blue. Therefore, apart from the initial vertex , there are the same number of red and blue vertices. ∎
Comments
There are no comments yet.