# realtime_driverrequest_assignment_in_ridesourcing__d4cc3438.pdf Real-Time Driver-Request Assignment in Ridesourcing Hao Wang, Xiaohui Bei School of Physical and Mathematical Sciences, Nanyang Technological University wang1242@e.ntu.edu.sg, xhbei@ntu.edu.sg Online on-demand ridesourcing service has played a huge role in transforming urban transportation. A central function in most on-demand ridesourcing platforms is to dynamically assign drivers to rider requests that could balance the request waiting times and the driver pick-up distances. To deal with the online nature of this problem, existing literature either divides the time horizon into short windows and applies a static offline assignment algorithm within each window or assumes a fully online setting that makes decisions for each request immediately upon its arrival. In this paper, we propose a more realistic model for the driver-request assignment that bridges the above two settings together. Our model allows the requests to wait after their arrival but assumes that they may leave at any time following a quitting function. Under this model, we design an efficient algorithm for assigning available drivers to requests in real-time. Our algorithm is able to incorporate future estimated driver arrivals into consideration and make strategic waiting and matching decisions that could balance the waiting time and pick-up distance of the assignment. We prove that our algorithm is optimal ex-ante in the single-request setting, and demonstrate its effectiveness in the general multirequest setting through experiments on both synthetic and real-world datasets. Introduction On-demand ridesourcing has become a pillar in urban transportation due to its efficiency and flexibility in connecting available drivers with on-demand riders. One of the essential components for a successful ridesourcing service is the real-time assignment of drivers to riding requests. However, the dynamic nature of on-demand ridesourcing brings several major challenges. More specifically, on a ridesourcing platform, drivers and riding requests are constantly arriving at unpredictable times. Upon the arrival of a riding request, its driver assignment needs to be computed in a very short time while considering the often conflicting objectives of minimizing request s waiting time, minimizing the driver s pick-up distance, as well as maximizing the number of served requests. The research community has only recently started to look at these problems, and many issues have not been addressed in satisfactory by existing works. Copyright 2022, Association for the Advancement of Artificial Intelligence (www.aaai.org). All rights reserved. In the literature, there are mainly two approaches for solving the driver-request assignment problem. The first line of works (Cordeau and Laporte 2007; Bei and Zhang 2018) adopts a static and offline approach. That is, they focus on a single snapshot of the system and aims to find an optimal matching between all available drivers and the active requests in the snapshot. When dealing with real-time assignments, a common approach is then to divide the whole time horizon into small intervals (say one minute per interval) and apply the offline algorithm at the end of each interval (Anshelevich et al. 2013; Alonso-Mora et al. 2017; Lesmana, Zhang, and Bei 2019; Ke et al. 2020). With the information of all the drivers and requests at hand, the algorithm is usually able to find very efficient assignments through methods like maximum weight matching. However, in order to accumulate a sufficiently large pool of drivers and requests, the platform needs to set a long enough interval length, which will in turn incur a large waiting cost for the requests. In addition, because all assignments are being made at the end of an interval, requests that arrived at the beginning and at the end of an interval will experience a significantly different amount of waiting time. For example, a request arriving at the beginning of a one-minute interval needs to wait for a whole minute before it can be assigned, even if there is a nearby driver waiting at the very start. This will create significant inefficiency to the assignment, as well as a very unbalanced user experience for different riders, which will in turn harm the sustainability of the platform in the long run. A second approach applies a fully online model that requires each request to be assigned (or rejected) immediately after its arrival. This approach has the advantage of reducing a request s waiting time to essentially zero. There is also a large body of literature on online matching from other domains, such as online bipartite matching (Karp, Vazirani, and Vazirani 1990; Mehta et al. 2007) and Ad Words display (Aggarwal et al. 2011), from which the ridesourcing algorithm could draw inspirations. On the other hand, by completely removing the waiting time, the algorithm has to make haste and local decisions which will compromise the efficiency of the assignment, which we define as the distance between the request and the assigned driver in the assignment. In particular, a request that is assigned right upon its arrival loses the opportunity to be matched to closer drivers that might arrive in the near future. The Thirty-Sixth AAAI Conference on Artificial Intelligence (AAAI-22) From these two approaches, we can see a clear trade-off between the request waiting time and the assignment quality. In order to balance these two objectives, an ideal assignment algorithm should sit in the middle of these two approaches. That is, it should find the appropriate assignment time of a request that could strike a right balance between waiting for new drivers to emerge nearby and matching the request to existing drivers. This calls for a new driver-request assignment model that could capture the trade-off between request waiting time and assignment quality, together with an efficient assignment algorithm that could assign requests to the right drivers at the right time. These are the main objectives of this paper. Our Contribution In this paper, we propose a new driver-request real-time assignment model. In this model, both drivers and riding requests arrive in an online fashion, and the algorithm is allowed to make driver-request assignments at any time. To capture the waiting time and assignment quality trade-off, we assume the cost of an assignment consists of two components: the waiting cost, which is the time the request has waited before it gets assigned, and the matching cost, which is the pick-up distance between the request and its assigned driver. In addition, we will also assume that while waiting, a request might also quit and leave the platform at any time according to a quitting probability function. If the request leaves the platform unassigned, it will incur a quitting penalty. This assumption captures the impatient nature of the riding requests and makes the model more realistic. We also take a data-aware view and assume the algorithm knows the arrival distribution of the available drivers, which in practice can be estimated from historical data. Based on this model, our second contribution is an efficient algorithm for assigning drivers to requests in real-time. At the heart of our algorithm, we want to answer the following question of a typical scenario: When there is an active request and some drivers waiting, how long should the algorithm wait in the hope of a better (i.e. closer) driver arriving soon before assigning this request to the currently available driver? To answer this question, we start from the simple case with only a single request and show how to compute the optimal waiting time thresholds when there are multiple types of drivers with different arrival rates. Next, we use the single-request algorithm as a building block to construct an efficient algorithm for the general case with multiple heterogeneous requests and drivers. Our algorithm is efficient and only requires a small polynomial update time for each arrival event. We also demonstrate the effectiveness of our algorithm through experiments on both synthetic and real-world datasets. Related Works Driver-request assignment in ridesourcing has been studied extensively in the literature across multiple disciplines. As discussed above, most works can be categorized into the offline static assignment setting and the online dynamic assignment setting. On the offline front, in operation research, the problem is under the name of dial-a-ride problem (DARP) and has been studied in several works (Colorni and Righini 2001; Coslovich, Pesenti, and Ukovich 2006; Cordeau and Laporte 2007). In computer science, the offline assignment problem has been considered in the context of ride-sharing (Bei and Zhang 2018), efficiency and fairness balance (Lesmana, Zhang, and Bei 2019), route optimization (Alonso-Mora et al. 2017). Many of these works also use the batch approach (i.e. divide the time horizon into short intervals) to convert the offline algorithm to solve the real-time assignment problem. On the online front, several works have investigated the online ridesourcing assignment problem (Lee et al. 2004; Caramia et al. 2001; Bertsimas, Jaillet, and Martin 2019; Ma, Zheng, and Wolfson 2013; Xu et al. 2018; Miao et al. 2016; Dickerson et al. 2018b,a; Nanda et al. 2020). This problem is also closely related to online bipartite matching (Karp, Vazirani, and Vazirani 1990; Mehta et al. 2007; Aggarwal et al. 2011) in which one side of the vertices arrive online. All of these works require the request to be assigned immediately upon its arrival. That is, there is no waiting time involved. There are also works that allow vertices to quit during the matching process. Huang et al. (2018, 2019) study an online general graph matching model in which every arrival vertex has a fixed deadline to be matched before it leaves the system. Collina et al. (2020); Aouad and Saritac (2020) consider a general graph matching problem in which vertices arrive and depart following given processes. A major difference between these works and ours is they do not consider request waiting time as part of the matching cost. Ke et al. (2020); Xu et al. (2018); Feng, Gluzman, and Dai (2021); Lowalekar, Varakantham, and Jaillet (2021) use reinforcement learning to solve different ridesourcing problems. (Ke et al. 2020) consider a model which is similar to our settings. However, their model still uses fixed time intervals and can only make matches at the end of each interval, while our model focuses on the real-time assignment. Another related problem is the min-cost perfect matching with delays (MCMD) model studied in (Emek, Kutten, and Wattenhofer 2016; Azar, Chiplunkar, and Kaplan 2017; Azar and Fanani 2020; Ashlagi et al. 2017). Similar to our model, these works consider both waiting cost and matching cost as part of their objectives. The main difference is that in our model, only the request waiting time is counted while they consider the waiting cost of all vertices. They also do not allow vertices leaving the system voluntarily, which is different from our assumption. Finally, queueing model is another related model that has been used for ridesourcing assignment problems before (Zhang and Pavone 2016; Zukerman 2013; Banerjee, Johari, and Riquelme 2015). Model We consider a bipartite graph G0 = (R, D, E) that is known to the algorithm. Here R = {r|1 r N} and D = {d|1 d M} are the type spaces of requests and drivers, respectively, with |R| = N and |D| = M. E denotes the set of allowed matches between requests and drivers. In other words, a request of type r can be matched to a driver of type d if (r, d) E. We do not put any restrictions on the structure of the graph and allow E to encode any physical or performance-related constraints. In practice, usually requests can only be matched to nearby drivers due to pick-up distance constraints. This means G0 is usually a sparse graph. Each edge (r, d) E is also associated with a cost crd. This cost represents the time for the driver to pick up the request. We consider an infinite time horizon starting from time 0, and a fully online setting where vertices from both sides arrive at different times. Driver and Request Arrival. For each driver type d D, the arrival of a driver of this type is independent of arrivals of other types and follows a known random process. In this paper, we limit our focus to the Poisson process with process rate λd. This is a standard assumption for driver arrivals that has been considered in many works (Collina et al. 2020; Aouad and Saritac 2020). After its arrival, the driver will stay in the system until it is matched. For each request type r R, we do not make any assumptions on its arriving process and allow it to be arbitrary. However, when a request of type r arrives, this request will only be available for a period of time before it quits and leaves the system. The length of time t that this request stays in the system follows a quitting distribution F(t). More specifically, if a request arrives at time t0, then F(t) denote the probability that this request quits before time t0 + t. Let f(t) = d F (t) dt be the probability density function of F(t). We make a natural assumption that F(t) is continuous and f(t) is non-decreasing. That is, the requests are more likely to quit the longer they have been waiting. Matching and Matching Cost. Our goal is to design an online algorithm that matches the requests and drivers in real time as they arrive. Note that our setting differs from the traditional online matching setting in that when a request or a drive arrives, we are not required to immediately find a match for it. Instead, we are allowed to match a request and a driver at any time as long as they are both still in the system. For every request i arrived in the system, it will either be matched by the algorithm to some driver j at some time t, or it will quit at some time t Q i unmatched. In either case, this request will incur two types of costs: a waiting cost and a matching cost. The waiting cost is the waiting time of a request before it is matched, or it quits. That is, if request i arrives at time ti and is matched at time t, then the waiting cost is t ti. If the request i quits at time t Q i without being matched to any drivers, the waiting cost is t Q i ti. The matching cost is crd when the request i (of type r) is matched to some driver j of type d. If the request i quits without being matched to any drivers, it will incur a fixed matching cost of c Q r . We assume c Q r > crd for all (r, d) E. The cost of a request is the sum of the waiting cost and the matching cost. The goal of the algorithm is to minimize the total cost of the matching, which is the sum of the costs of all requests. Single Request We start off by considering a simplified model with the following assumption. Assumption 0.1. There is a single request of type r arriving at time 0 in the whole time horizon. The reason for starting from this simplified setting is twofold: first, it can provide us useful intuitions about what should an optimal matching strategy look like, even in the general case; second, the solution of this simple case can also be used as a building block for the algorithms for the general, multi-request case. In the following we will also call this request r when the context is clear. Assume there are M types of drivers, and type i driver has a matching cost cri = bi. We assume without loss of generality that b1 < b2 < < b M < cq, where cq is the quit cost of request r. We also assume the arrival rate of type i driver is λi, and we denote the vector λ = (λ1, λ2, . . . , λM). First, observe that at any time when there are multiple drivers of different types waiting, only the driver with the smallest matching cost should be considered. Therefore, throughout the process, we only needs to maintain two pieces of information: the current time t and the best driver type m that is currently available. We denote this state as s(t, m). At state s(t, m), intuitively, the algorithm faces two choices: wait or match. If the time is still early or the available driver m is far away, we may want to wait a bit to see if a closer driver can arrive soon (unless m = 1 is already the closest driver type, in which case the algorithm should match r to this driver immediately). On the other hand, as time grows, the probability of the request quitting will increase, until it becomes large enough such that the chance of receiving a quitting cost cq will outweigh the potential benefits of waiting for a better driver. Then the algorithm should simply match r to the type m driver. Based on this intuition, we can see that the optimal algorithm in this setting should be in the form of a parameterized threshold algorithm SINGLE-REQr(λ, T = (T1, T2, . . . , TM+1)) described as below.1 Here Tm is the threshold waiting time for state s(t, m), such that when t < Tm, the algorithm should wait, and when the time reaches Tm with no better driver arrived, the algorithm would match the request to this type m driver. Note that if there is better driver m < m arrived at time t before Tm, the algorithm does not necessarily have to match r to this driver m immediately. Rather, it will transit to a new state s(t , m ) and use the new threshold waiting time Tm to decide whether to continue waiting or not. 2 The pseudocode can be found in Algorithm 1. The remaining question boils down to how to choose the threshold waiting times (T1, . . . , TM) that is optimal for the algorithm. 1Without loss of generality, we only focus on deterministic algorithms here. 2For notational convenience, we define a new type M + 1 driver with cr(M+1) = to represent the state of no available drivers. Clearly we would have TM+1 = because without any available drivers, the request has no other options except waiting. Algorithm 1: Single Request and Multi Driver Types SINGLE-REQr(λ, T ) Input: a single request r arrives at time 0; M driver types with arrival rates λ = (λ1, . . . , λM); Threshold T = (T1 = 0, T2, T3, . . . , TM, TM+1 = ). 1: m M + 1 // m represents the best available driver type so far 2: while time t grows continuously starting from 0 do 3: if A type di driver arrives with i < m then 4: m i 5: end if 6: if t Tm then 7: match request r to the dm driver 8: return 9: end if 10: end while Finding the optimal threshold times T . Next we provide a characterization of the optimal thresholds in algorithm SINGLE-REQ for the case of a single request and multiple driver types. Theorem 1. With a single request r and M types of drivers, the optimal algorithm is the threshold algorithm SINGLE-REQr(λ, T = (T 1 , . . . , T M+1)), where T j is the smallest nonnegative value satisfies q(T j ) Pj 1 i=1 λi(bj bi) 1 where q(t) = f(t) 1 F (t) is the probability density function that the request quits conditioning on the request still being alive at time t. If no such T j exists, then we set T j = which means the algorithm will always wait no matter how long the request has waited. Proof. Consider the scenario in which j is currently the best available driver type, and we are at time t = T j . Consider the following two options. Option (1): assign request r to currently the best driver, which will generate a cost of bj + t. Option (2): wait for a short time , match r to any driver with type i < j that arrives during time (t, t + ), and assign r to the type j driver at time t + otherwise. For this option, there are j events could happen in the [t, t + ] time interval: the request quits (with probability q(t) + o( )) or a type di(i < j) driver arrives (with probability λi +o( )). Again we ignore the probability that two or more such events happen within this short time interval. If a driver of type i < j arrives, the algorithm will assign r to this driver with a total cost of bi + t + O( ). In summary, the expected cost of this option is i T rd(β) From here we can then derive the expected cost function U rd(β) = Z 0 β