Maximum Weight Online Matching with Deadlines

08/09/2018 ∙ by Itai Ashlagi, et al. ∙ MIT lyft Stanford University 0

We study the problem of matching agents who arrive at a marketplace over time and leave after d time periods. Agents can only be matched while they are present in the marketplace. Each pair of agents can yield a different match value, and the planner's goal is to maximize the total value over a finite time horizon. First we study the case in which vertices arrive in an adversarial order. We provide a randomized 0.25-competitive algorithm building on a result by Feldman et al. (2009) and Lehman et al. (2006). We extend the model to the case in which departure times are drawn independently from a distribution with non-decreasing hazard rate, for which we establish a 1/8-competitive algorithm. When the arrival order is chosen uniformly at random, we show that a batching algorithm, which computes a maximum-weighted matching every (d+1) periods, is 0.279-competitive.



There are no comments yet.


page 1

page 2

page 3

page 4

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

Traffic congestion is a severe problem in metropolitan areas around the world. A resident in Los Angeles is estimated to lose around $6,000 per year due to spending extra hours in traffic (Economist 2014). This does not account for extra carbon emissions. A couple of ways to relieve congestion are pricing

(Vickrey, 1965) and carpooling, and online platforms and other technological advances are now available to assist with these tasks (Ostrovsky and Schwarz, 2018).222Ostrovsky and Schwarz (2018) discusses the complementarities between autonomous vehicles, carpooling and pricing.

Online platforms now offer the option to share rides. An immediate benefit is that passengers who share rides pay a lower price for the trip. However, the passenger may also experience a disutility from additional waiting, detours, and less privacy. Facing these trade-offs, ride-sharing platforms and carpooling applications seek to increase the volume of ride-sharing, which will in turn help in reducing congestion.

In this paper, we present and study a graph-theoretic matching problem that captures the following three key features faced by ride-sharing platforms. First is spatial; the farther away two passengers are from each other, the higher the disutility from being matched. Second is temporal; passengers cannot match passengers who request rides at very different times. Third, the platform faces uncertainty about future demand.


Next we describe our basic graph-theoretic model and contributions. Time is discrete and one vertex of a given graph arrives at each time period. Every edge has a non-negative weight, representing the reward from matching these two vertices. A vertex cannot match more than periods after its arrival; after units of time the vertex becomes critical and departs. It is helpful to think of as a service quality set by the platform and a passenger is assigned to a single ride after waiting for periods of time.

The goal is to find a weighted matching with a large total weight in an online manner. This means that the decision for every vertex has to be made no later than periods after its arrival (this differs from the classic online bipartite matching literature, in which ). There is no a priori information about weights or arrival times and the underlying graph may be arbitrary and hence non-bipartite.

Our first results are given in a setting, in which the vertices arrive in an adversarial order. We introduce for this setting a -competitive algorithm, termed Postponed Greedy (PG). We further show that no algorithm achieves a competitive ratio that is higher than .

The key idea behind PG is to look at a virtual bipartite graph, in which each vertex is duplicated into a “buyer” and a “seller” copy. We enforce that the seller copy does not match before the vertex becomes critical. This enables us to postpone the matching decision until we have more information about the graph structure and the likely matchings. We then proceed in a manner similar to Feldman et al. (2009a): tentatively match each new buyer copy to the seller that maximizes its margin, i.e., the difference between edge weight, and the value of the seller’s current match.

We extend the model to the case where the departure of vertices are determined stochastically. We show that when the departure distribution is memoryless and realized departure times are revealed to the algorithm just as becoming critical, one can adapt the PG algorithm to achieve a competitive ratio of . It is worth noting that when departure times are chosen in an adversarial manner no algorithm can achieve a constant competitive ratio.

Next we study the setting in which vertices arrive in a random order. We analyze a batching algorithm which, every time steps, computes a maximum weighted matching among the last arrivals. Vertices that are left unmatched are discarded forever. We show that when the number of vertices is sufficiently large, batching is -competitive.

The analysis proceeds in three steps. First, we show that the competitive ratio is bounded by the solution to a graph covering problem. Second, we show how a solution for small graphs can be extended to covers for larger graphs. Finally, we establish a reduction that allows us to consider only a finite set of values for . We conclude with a computer-aided argument for graphs in the finite family.

Related literature

There is a growing literature related to ride-sharing. Santi et al. (2014) finds that about of rides in Manhattan could be shared by two passengers. Many studies focus on rebalancing or dispatching problems without pooling, e.g., Pavone et al. (2012); Zhang and Pavone (2014); Santi et al. (2014); Spieser et al. (2016); Banerjee et al. (2018). Alonso-Mora et al. (2017) studies real-time high-capacity ride-sharing. It does not consider, however, a graph-theoretic online formulation for matching rides.

This paper is closely related to the online matching literature. In the classic problem, introduced in Karp et al. (1990), the graph is bipartite with vertices on one side waiting, while others are arriving sequentially and have to be matched immediately upon arrival. This work has numerous extensions, for example to stochastic arrivals and in the adwords context Mehta et al. (2007); Goel and Mehta (2008); Feldman et al. (2009b); Manshadi et al. (2011); Jaillet and Lu (2013). See Mehta (2013) for a detailed survey. Our contributes to this literature in three ways. First, we provide algorithms that perform well on edge-weighted graphs. Second, our graph can be non-bipartite, which is the case in ride-sharing and kidney exchange. Third, all vertices can arrive over time and may remain for some given time until they are matched. Closely related is Huang et al. (2018), which studies a similar model to ours in the non-weighted case, but allow departure times to be adversarial.

Several papers consider the problem of dynamic matching in the edge-weighted case. Feldman et al. (2009a) find that in the classic online bipartite setting, no algorithm achieves a constant approximation. They introduce a free disposal assumption, which allows to discard a matched vertex in favor of a new arriving vertex. They find, based on an algorithm by Lehmann et al. (2006), that a greedy algorithm that matches a vertex to the highest marginal vertex, is -competitive. We build on this result for a special classes of bipartite graphs. In the adversarial setting Emek et al. (2016); Ashlagi et al. (2017a) study the problem of minimizing the sum of distances between matched vertices and the sum of their waiting times. In their model no vertex leaves unmatched and our model does not account for vertices’ waiting times. Few papers consider the stochastic environment (Baccara et al., 2015; Ozkan and Ward, 2016; Hu and Zhou, 2016). These papers find that some waiting before matching is beneficial for improving efficiency.

Related to our work are some papers on job or packet scheduling. Jobs arrive over online to a buffer, and reveal upon arrival the deadline by which they need to be scheduled. The algorithm can schedule at most one job per time and the value of scheduling a job is independent from the time slot. Constant approximation algorithms are given by Chin et al. (2006) and Li et al. (2005).

Finally, there is a growing literature that focuses on dynamic matching motivated from kidney exchange (Ünver, 2010; Anderson et al., 2015; Dickerson et al., 2013; Ashlagi et al., 2017b). These papers focus mostly on random graphs with no weights. Closer to our paper is Akbarpour et al. (2017), which finds that in a sparse random graph, knowledge about the departure time of a vertex is beneficial and matching a vertex only when it becomes critical performs well. Our work differs from these papers in two ways: we consider the edge-weighted case, and, we make no assumption on the graph structure.

2 Model

Consider a weighted graph with vertices indexed by . Vertices arrive sequentially over periods and let denote the arrival time of vertex . Let denote the weight on the undirected edge between vertices and .

For vertices and with , the weight on the edge between and is observed only after vertex has arrived.

For , the online graph with deadline , denoted by , has the same vertices as , and the edge between and in exists if an only if . We say that becomes critical at period , at which time the online algorithm needs to either match it and collect the associated edge weight, or let it depart from the graph.

We will consider two settings regarding how arrivals are generated. In the Adversarial Order (AO) setting, we assume that . In the Random Order (RO) setting, we assume that is sampled uniformly at random among all possible permutations of .

The goal is to find an online algorithm that generates a matching with high total weight. More precisely, we seek to design a randomized online algorithm that obtains in expectation a high fraction of the expected maximum-weight of a matching over .

To illustrate a natural tradeoff, consider the example in Figure 1 for . At period the planner can either match vertices and or let vertex remain unmatched. This simple example shows that no deterministic algorithm can obtain a constant competitive ratio. Furthermore, no algorithm can achieve a competitive ratio higher than .

Figure 1: Let . Therefore, there is no edge between vertices and . The algorithm needs to decide whether to match with and collect without knowing .

3 Adversarial arrival order

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 . We ensure this property by assigning every vertex to be either a seller or a buyer. We then prevent sellers from matching before they become critical, while we allow buyers to be matched at any time.

It will be useful to first study a special case, in which the underlying graph is bipartite, with sellers on one side and buyers and in the online graph a buyer and a seller cannot match if the buyer arrives before the seller. For such online graphs we show that a greedy algorithm given by Feldman et al. (2009a) is 0.5-competitive. We then build on this algorithm to design a randomized -competitive algorithm for arbitrary graphs.

3.1 Bipartite constrained online graphs

Let be a bipartite graph and be the order of arrivals. The online graph is called constrained bipartite if for every seller and every buyer , there is no edge between and if , i.e. and cannot match if arrives before .

Consider the following greedy algorithm, which attempts to match buyers in their arriving order. An arriving buyer is matched to the seller with the highest marginal value if the marginal value is positive. If the seller is already matched to another buyer , becomes unmatched and never gets matched again. Formally:

  • Input: constrained bipartite graph, .

  • For each arrival :

    • If is a seller, initialize , and .

    • If is a buyer:

      • Set .

      • If , set and set .

  • When a seller becomes critical: match it to if .

Algorithm 1 Greedy algorithm (Feldman et al., 2009a)
Proposition 3.1 (Feldman et al. (2009a)).

The greedy algorithm is 0.5-competitive for online bipartite constrained graphs.

Feldman et al. (2009a) prove that this algorithm is 0.5-competitive for an online matching problem with free disposal. In their setting all seller exists and buyer arrive one at a time. The algorithm provides the same guarantees for constrained bipartite graph since, by construction, there is no harm in assuming that all sellers exist rather than arriving over time. The key behind the proof is that the value function for each seller is submodular. In fact the result is a special case of a result by Lehmann et al. (2006), who study combinatorial auctions with submodular valuations.

3.2 Arbitrary graphs

In this section we extend the greedy algorithm for constrained bipartite graphs to arbitrary graphs. A naive way to generate a online 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 only keep the edges between each buyer and all the sellers who arrived before her. Formally:

  • Input: an online graph with deadline , .

  • For each vertex :

    1. Toss a fair coin to decide whether is a seller or a buyer. Construct the online constrained bipartite graph by keeping only the edges between each buyer and the sellers who arrived before her.

  • Run the Greedy algorithm on .

Algorithm 2 Naive Greedy
Corollary 3.2.

The naive greedy algorithm is -competitive for arbitrary online graphs.

Observe that for vertices , with , edge in the original graph remains in the generated constrained bipartite graph with probability (if is a seller and is a buyer). We then use proposition 3.1 to prove that naive greedy is -competitive.

One source of inefficiency in the naive greedy algorithm is that the decision whether a vertex becomes a seller or a buyer is done independently at random and without taking the graph structure into consideration. We next introduce the Postponed Greedy algorithm that defers these decisions as long as possible in order to construct the constrained bipartite graph more carefully.

When a vertex arrives, we add two copies of to a virtual graph: a seller and a buyer . Let and be the set of sellers and buyers at arrival time . On arrival, seller does not have any edges, and buyer has edges towards any vertex with value . Then we run the greedy algorithm with the virtual graph as input. When a vertex becomes critical, becomes critical in the virtual graph, and we compute its matches generated by greedy.

Both and can be matched in this process. If we were to honor both matches, the outcome would correspond to a 2-matching, in which each vertex has degree at most 2. Now observe that because of the structure of the constrained bipartite graph, this 2-matching 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 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 2-matching: if is a seller then the next vertex will be a buyer and vice-versa. That ensures that assignments are correlated and saves a factor compared to uncorrelated assignments in the naive greedy algorithm.

  • Input: an online graph with deadline , .

  • Process events at time in the following way:

    1. Arrival of a vertex :

      1. Set ’s status to be undetermined.

      2. Add a virtual seller: , and .

      3. Add a virtual buyer: .

      4. Find a virtual seller for the virtual seller: .

      5. Match if marginal utility is positive: If , then tentatively match to by setting and .

    2. Vertex becomes critical:

      1. Proceed if no match found: If , do nothing.

      2. match in the virtual graph: If . Set , and .

      3. If ’s status is undetermined, w.p set it to be either seller or buyer.

        1. If is a seller: finalize the matching of to and collect the reward . Set ’s status to be a buyer.

        2. If is a buyer: Set ’s status to be a seller.

Algorithm 3 Postponed Greedy (PG)
Theorem 3.3.

The postponed greedy (PG) algorithm is -competitive for arbitrary online graphs.


Fix a vertex , and denote to be the final value of its virtual seller ’s match. If ’s status is a seller in step (2.c.i), then we collect . Note that this happens with probability exactly for every .

For a virtual buyer arriving at time , let be the margin for in step (1.d). Note that every increase in a virtual seller’s price corresponds to a virtual buyer’s margin. Using the notation and , this implies that .

The dual of the offline matching problem linear programs can be written as:

(Offline Dual)

Let and be two vertices with . When arrives, we have . Together with the fact that increases over time, this implies that is a feasible solution to (Offline Dual).

We can conclude that .

3.3 Alternative algorithm for Greedy: Dynamic Deferred Acceptance

Observe that the greedy algorithm discards a buyer that becomes unmatched and therefore does not attempt to rematch it. We introduce the Dynamic Deferred Acceptance (DDA) algorithm, which takes as input a constrained bipartite graph and returns a matching (formally presented below). The main idea is to maintain a tentative maximum-weight matching at all times during the run of the algorithm. This tentative 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 that already arrived and yet to become critical is associated with a profit margin which corresponds to the value of matching to their most preferred seller minus the price associated with that seller. Every time a new buyer arrives, she bids on her most preferred 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 realized (and the buyer and seller leave) only once the seller becomes critical, i.e., she has been present for time periods and is about to become critical. At that time, the seller and the buyer are considered matched and depart. This ensures that sellers never get matched before they become critical. A buyer is discarded only if she is unmatched and becomes critical.

At any point throughout the algorithm, we maintain a set of sellers , a set of buyers , as well as a matching , a price for every seller , and a marginal profit for every buyer .

  • Input: an online graph with deadline , .

  • Process each event in the following way:

    1. Arrival of a seller s: Initialize and .

    2. Arrival of a buyer : Start the following ascending auction.

      1. Let and .

      2. If then

        1. .

        2. (tentatively match to )

        3. Set to if was not matched before. Otherwise, let be the previous match of .

      Until or .

    3. Departure of a seller s: If seller becomes critical and , finalize the matching of and and collect the reward of .

Algorithm 4 Dynamic Deferred Acceptance

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 sellers and buyers that are present in the “market” form an optimum dual for the matching linear program (see Appendix A for more details).

In Appendix A, we show that DDA is -competitive on constrained bipartite graphs. We note that in the case of arbitrary graphs, we can adapt the methodology of Postponed Greedy to DDA to recover a factor .

Although the DDA provides the same theoretical guarantees as greedy, we present it here since it may lead to better results in practice. Loosely speaking it rationalizes a reoptimization-like algorithm by keeping a tentative maximum weighted matching.

3.4 Lower bounds

Claim 3.4.

When the input is a constrained bipartite graph:

  • No deterministic algorithm can obtain a competitive ratio above .

  • No randomized algorithm can obtain a competitive ratio above .


Figure 2: Bipartite graph where and , with : vertex becomes critical before arrives. The adversary is allowed to choose edge to be either or . Left: instance for the deterministic case. Right: instance for the randomized case.

Deterministic algorithm: Consider the example on the left of Figure 2. When seller becomes critical, the algorithm either matches her with buyer , or lets departs unmatched. The adversary then chooses accordingly. Thus the competitive ratio cannot exceed:

Randomized algorithm: Consider the example on the right of Figure 2. Similarly to the deterministic case, when seller becomes critical, the algorithm decides to match her with with probability . The adversary then chooses accordingly. Thus the competitive ratio cannot exceed:

Next we show that our analysis for PG is tight.

Claim 3.5.

There exists a constrained bipartite graph for which PG is -competitive.

Figure 3: Bipartite graph where and , with : vertex becomes critical before arrives. Dotted edges represent edges that are not know to the algorithm initially.

Consider the input graph in Figure 3. Vertex will be temporarily matched with , and vertex will depart unmatched. When becomes critical, with probability , she will be determined to be a buyer and will depart unmatched. Therefore the PG collects in expectation while the offline algorithm collects .

4 Random arrival order

In some cases, the vertices can be assumed to come from a distribution that is unknown to the online algorithm. One way to model this is to assume that the adversary chooses the underlying graph, but that the vertices arrive in random order.

4.1 The batching algorithm

The batching algorithm computes a maximum-weight matching every time steps. Every vertex in the matching is then matched, and all other vertices in the batch are discarded.

Theorem 4.1.

Batching is -competitive.

The proof of Theorem 4.1 works in three steps. In a first step, we reduce the analysis of the competitive ratio of Batching to a graph covering problem. More precisely, we show that it is enough to cover , the cycle with vertices to the power , with ensembles of cliques. Second, we show how a cover for small can be extended to any at the cost of a small rounding error. Finally, we establish a reduction that allows us to consider only a finite set of values for . We conclude with a computer-aided argument for graphs in the finite family.

Reducing to a graph theoretic problem

There is no harm in assuming that the underlying graph is a complete. Recall that is the set of all permutations over integers . For any deadline and any arrival sequence , we define the path graph with edge-weight if , and otherwise.333Note that corresponds to the path taken to the power .

Note that every batch in the algorithm has vertices except the last batch which may have fewer vertices. Let be the batch of vertex under permutation and batch size : is the unique integer such that We define the batched graph with edge-weight if and are in the same batch (i.e. ), and otherwise.444Note that is a collection of disjoint -cliques.

For any , denote to be the -cycle to the power .

Definition 4.2 (Graph operations).

For any two graphs and with vertices and respective edge weights , we define the following:

  • The linear combination denotes the graph with edge weights ,

  • The product denotes the graph with edge weights , and

  • We say that is a cover of if for all , , .

For any graph , let denote the value of a maximum-weight matching over . Observe that when the arrival sequence is , the graph and therefore the offline algorithm collects . Note that the online algorithm collects .

Remark 4.3.

Observe that for any graphs and any , we have:

  • .

  • If is a cover of , then, .

Definition 4.4 (Periodic permutation).

For such that divides , we say that a permutation is -periodic if for all , .

We say that a permutation is periodic if there exists such that is -periodic.

Definition 4.5 (-cover).

Let be an unweighted graph with vertices. We say that a set of permutations forms an -cover of if there exist values such that:

  • is a cover of .

  • .

We say that an -cover is -periodic if for all , is -periodic.

The next proposition will allow us to abstract away from the weights that are chosen by the adversary. For any graph , we denote by the weight in .

Proposition 4.6.

If there exists an -cover of , then batching is -competitive.


Let id be the identity permutation over vertices. Let be an -cover of . Fix an arrival sequence . We first claim that is an -cover of .

For any , let us denote and to be the weights of edge in and respectively. Consider : :

where the last inequality is implied by the fact that is an -cover of and therefore of . Therefore the claim holds using remark 4.3.

Denote by BAT the value collected by the batching algorithm and OFF the value collected by the offline algorithm. Observe that

where we used the change of variable and the fact that the application is a bijection.

We have reduced the analysis of Batching to a graph-theoretic problem without edge weights. In what follows, we will show that we can reduce the problem further to find covers of for only small values of and .

Reducing : periodic covers.

We now wish to find -covers for for every and . In Proposition 4.7, we show that it is sufficient to find periodic covers for small values of .

Proposition 4.7.

Let be a multiple of , and a multiple of . Any -periodic -cover of can be extended into an -cover of for any .

Proof when is a multiple of ..

Let be a -periodic -cover of . We will show that it can be extended into an -cover of .

Assume for now that is a multiple of . Let be the -periodic permutation over such that for all , . Take such that . Because is a multiple of , there exist such that , and . By -periodicity of and , we know that . Thus we can conclude that is an -cover of . ∎

In the case when is not a multiple of , the proof follows similar ideas and looses an additional factor due to rounding of to a lower multiple of . Details are provided in Appendix B.

Reducing : cycle contraction.

In Proposition 4.7, we show that it is enough to find periodic -covers of for small values of . Next, we provide a reduction that enables us to consider only a finite set of values for .

The key idea of the reduction is that we can contract vertices of into groups of vertices. The resulting graph also happens to be a cycle . In Proposition 4.10, we provide a way to expand an -cover on the contracted graph into an cover on the original graph.

Definition 4.8 (Cycle contraction).

For any and an integer which divides , we define the -contraction to be the graph with vertices for , and edges if and only if there exist and with an edge in .

Claim 4.9.

For any , if divides and divides , then .


We first prove that covers . Fix , and assume that . If , then let and . We have , thus and .

Conversely, we now prove that covers . If there exist and such that , then which implies that . ∎

Figure 4: Left: , with contraction for . Right: Contracted graph with vertices , , … .
Proposition 4.10.

Fix . For , suppose that there is a periodic -cover of .

  • For any integer , if divides then there exists a periodic -cover of .

  • In general, if is the remainder of the euclidian division of by , then there exists a periodic -cover of .

Proof of (i).

Suppose that and suppose that there exists multiple of such that we have a -periodic -cover of . For any permutation we can construct a permutation in the following way: if then . Because is a cover of , we can conclude that is an -cover of .

The proof for case (ii) follows a similar idea, with an additional randomization that chooses a subset vertices that we can group in every group of . The details are in Appendix B.

Final step: Computer-aided proof of factor

We will now apply Proposition 4.7 with and . Let be the set of -periodic permutations of . We can find covers for using the following linear program:

Proposition 4.11.

Let be the solution to LP. Let . Batching is -competitive.


Follows from Propositions 4.6 and 4.7. ∎

The Linear program (LP) has variables, and solving it may not be computationally possible when is large. Using Proposition 4.10, we now provide a way to find upper bounds on by solving a different LP on a smaller graph.

Recall that is the set of -periodic permutations of . We define the problem of finding an -cover of the cycle .


We denote by the solution to (LP’). Solving (LP’) numerically for yields . For all Proposition 4.10 therefore implies that, . 555We note that our methodology can be extended to obtain a better factor. For instance, being able to solve (LP) for values higher than would lead to a competitive ratio closer to . For , we either solve (LP) directly, or use Proposition 4.10 to show that (see Appendix C). Observing that , this concludes the proof for Theorem 4.1. ∎

4.2 Lower bound in random order.

Proposition 4.12.

No algorithm is more than -competitive even under the random arrival order.


Consider a graph with three vertices and , i.e. vertices can only be matched to the ones arriving just before or after them. After the first two arrivals, the online algorithm needs to decide whether to match them or let the first arrival leave. Furthermore, it has no information on how compares to the other edge weights. Therefore the decision of whether to match has to be a coin toss. Regardless of whether the algorithm matches the first two or the last two arrivals, its expected reward is . OFF however has an expected reward of . Taking , we get while which concludes the proof. ∎

5 Extensions

5.1 Stochastic departures in the adversarial order setting

We relax the assumption that all vertices depart after exactly time steps.

We therefore focus on the stochastic case, in which the departure time of vertex is sampled independently from a distribution . We assume that the realizations are only known at the time becomes critical.

Proposition 5.1.

Suppose that there exists such that satisfies the property that for all ,

Then PG is -competitive.


When a vertex becomes critical in the original graph, we match it if its status is determined to be seller. In that case, we need to ensure that its tentative match is still present. With probability at least , vertex is still present, and we collect . The rest of the proof follows similarly to that of Theorem 3.3

Corollary 5.2.

PG is -competitive when is memoryless.

5.2 Look-ahead under random arrival order

We assume now that the online algorithm knows vertices that will arrive in time steps (and their adjacent edges). We can update the Batching Algorithm in the following way: every time steps, compute a maximum-weight matching on both the current vertices and the next arrivals. Match vertices as they become critical according to the matching, and discard unmatched vertices. Note that this is the same as running Batching when the deadline is .

Proposition 5.3.

There exists an -cover of .


For , let . Let be such that , then for at least different values of . We can conclude that is a -cover by taking . ∎

Corollary 5.4.

Batching with -lookahead is -competitive when is large.

6 Conclusion

This paper introduces a model for dynamic matching in which all agents arrive and depart after some deadline. Match values are heterogeneous and the underlying graph is non-bipartite. We study online algorithms for two settings, where vertices arrive in an adversarial or random order.

In the adversarial arrival case, we introduce two new -competitive algorithms when departures are deterministic and known in advance. We also provide a -competitive algorithm when departures are stochastic, i.i.d, memoryless, and known at the time a vertex becomes critical. Finally we show that no online algorithm is more than -competitive.

In the random arrival case, we show that a batching algorithm is -competitive. We also show that with knowledge of future arrivals, its performance guarantee increases towards .

Importantly, our model imposes restrictions on the departure process and requires the algorithm to know when vertices become critical. Other than closing the gaps between the upper bound and the achievable competitive ratios, we point out a just a few interesting directions for future research. Our model imposes that matches retain the same value regardless of when they are conducted. An interesting direction is to account for agents’ waiting times. A different intersting objective is to achieve both a high total value and a large fraction of matched agents. Finally, it is interesting to consider the stochastic setting with prior infromation over weights and future arrivals.


  • Akbarpour et al. (2017) Akbarpour, M., Li, S., and Oveis Gharan, S. (2017). Thickness and information in dynamic matching markets.
  • Alonso-Mora et al. (2017) Alonso-Mora, J., Samaranayake, S., Wallar, A., Frazzoli, E., and Rus, D. (2017). On-demand high-capacity ride-sharing via dynamic trip-vehicle assignment. Proc Natl Acad Sci USA.
  • Anderson et al. (2015) Anderson, R., Ashlagi, I., Gamarnik, D., and Kanoria, Y. (2015). A dynamic model of barter exchange. In Proceedings of the twenty-sixth annual ACM-SIAM 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). Min-cost bipartite perfect matching with delays. In LIPIcs-Leibniz International Proceedings in Informatics, volume 81. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik.
  • Ashlagi et al. (2017b) Ashlagi, I., Burq, M., Jaillet, P., and Manshadi, V. (2017b). On matching and thickness in heterogeneous dynamic markets.
  • Baccara et al. (2015) Baccara, M., Lee, S., and Yariv, L. (2015). Optimal dynamic matching. Working paper.
  • Banerjee et al. (2018) Banerjee, S., Kanoria, Y., and Qian, P. (2018). State dependent control of closed queueing networks. In Abstracts of the 2018 ACM International Conference on Measurement and Modeling of Computer Systems, pages 2–4. ACM.
  • 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.
  • Chin et al. (2006) Chin, F. Y., Chrobak, M., Fung, S. P., Jawor, W., Sgall, J., and Tichỳ, T. (2006). Online competitive algorithms for maximizing weighted throughput of unit jobs. Journal of Discrete Algorithms, 4(2):255–276.
  • Dickerson et al. (2013) Dickerson, J. P., Procaccia, A. D., and Sandholm, T. (2013). Failure-aware kidney exchange. In Proceedings of the fourteenth ACM conference on Electronic commerce, pages 323–340. ACM.
  • Emek et al. (2016) Emek, Y., Kutten, S., and Wattenhofer, R. (2016). Online matching: haste makes waste! In

    Proceedings of the forty-eighth annual ACM symposium on Theory of Computing

    , pages 333–344. ACM.
  • Feldman et al. (2009a) Feldman, J., Korula, N., Mirrokni, V., Muthukrishnan, S., and Pál, M. (2009a). Online ad assignment with free disposal. In International Workshop on Internet and Network Economics, pages 374–385. Springer.
  • Feldman et al. (2009b) Feldman, J., Mehta, A., Mirrokni, V. S., and Muthukrishnan, S. (2009b). Online stochastic matching: Beating 1-1/e. In Proceedings of the 50th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 117–126.
  • 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 ACM-SIAM 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., Zhang, Y., and Zhu, X. (2018). How to match when all vertices arrive online. In Proceedings of the 50th Annual ACM SIGACT Symposium on Theory of Computing, pages 17–29. ACM.
  • 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 on-line bipartite matching. In Proceedings of the twenty-second 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(1-2):83–97.
  • Lehmann et al. (2006) Lehmann, B., Lehmann, D., and Nisan, N. (2006). Combinatorial auctions with decreasing marginal utilities. Games and Economic Behavior, 55(2):270–296.
  • Li et al. (2005) Li, F., Sethuraman, J., and Stein, C. (2005). An optimal online algorithm for packet scheduling with agreeable deadlines. In Proceedings of the sixteenth annual ACM-SIAM symposium on Discrete algorithms, pages 801–802. Society for Industrial and Applied Mathematics.
  • Manshadi et al. (2011) Manshadi, V. H., Oveis-Gharan, S., and Saberi, A. (2011). Online stochastic matching: online actions based on offline statistics. In Proceedings of the Twenty-Second Annual ACM-SIAM 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.
  • Ostrovsky and Schwarz (2018) Ostrovsky, M. and Schwarz, M. (2018). Carpooling and the economics of self-driving cars. Technical report, National Bureau of Economic Research.
  • Ozkan and Ward (2016) Ozkan, E. and Ward, A. R. (2016). Dynamic matching for real-time ridesharing.
  • Pavone et al. (2012) Pavone, M., Smith, S. L., Frazzoli, E., and Rus, D. (2012). Robotic load balancing for mobility-ondemand systems. Int J Rob Res.
  • Santi et al. (2014) Santi, P., Resta, G., Szell, M., Sobolevsky, S., Strogatz, S. H., and Ratti, C. (2014). Quantifying the benefits of vehicle pooling with shareability networks. In Proc Natl Acad Sci USA.
  • Spieser et al. (2016) Spieser, K., Samaranayake, S., Gruel, W., and Frazzoli, E. (2016). Shared-vehicle mobility-ondemand systems: A fleet operator’s guide to rebalancing empty vehicles. In Transportation Research Board 95th Annual Meeting.
  • Ünver (2010) Ünver, M. U. (2010). Dynamic Kidney Exchange. Review of Economic Studies, 77(1):372–414.
  • Vickrey (1965) Vickrey, W. (1965). Pricing as a tool in coordination of local transportation. In Transportation economics, pages 275–296. NBER.
  • Zhang and Pavone (2014) Zhang, R. and Pavone, M. (2014). Control of robotic mobility-on-demand systems: a queueing-theoretical perspective. In Proceedings of Robotics: Science and Systems Conference.

Appendix A Missing proofs for Dynamic Deferred Acceptance

Lemma A.1.

Consider the DDA algorithm on a constrained bipartite graph.

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

  2. 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 maximum-weight 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 A.2.

DDA is -competitive for constrained bipartite graphs.


The proof follows the primal-dual 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 A.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 A.3.

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:


By applying this equality iteratively after each arrival, we can relate the initial margins to the final margins and prices :

Claim A.4.


This completes the proof of Proposition 3.1 given that the offline algorithm achieves at most:

It remains to prove Claims A.3 and A.4.

Proof of Claim a.3.

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: