Efﬁcient Delivery Services Sharing with Time Windows

: Delivery service sharing ( DSS ) has made an important contribution in the optimization of daily order delivery applications. Existing DSS algorithms introduce two major limitations. First, due to computational reasons, most DSS algorithms focus on the ﬁxed pickup/drop-off time scenario, which is inconvenient for real-world scenarios where customers can choose the pickup/drop-off time ﬂexibly. On the other hand, to address the intractable DSS with the ﬂexible time windows ( DSS-Fle ), local search-based heuristics are widely employed; however, they have no theoretical results on the advantage of order sharing. Against this background, this paper designs a novel algorithm for DSS-Fle, which is efﬁcient on both time complexity and system throughput. Inspired by the efﬁciency of shareability network on the delivery service routing ( DSR ) variant where orders cannot be shared and have the ﬁxed time window, we ﬁrst consider the variant of DSR with ﬂexible time windows ( DSR-Fle ). For DSR-Fle, the order’s ﬂexible time windows are split into multiple virtual ﬁxed time windows, one of which is chosen by the shareability network as the order’s service time. On the other hand, inspired by efﬁciency of local search heuristics, we further consider the variant of DSS with ﬁxed time window ( DSS-Fix ). For DSS-Fix, the beneﬁcial sharing orders are searched and inserted to the shareability network. Finally, combining the spitting mechanism proposed in DSR-Fle and the inserting mechanism proposed in DSS-Fix together, an efﬁcient algorithm is proposed for DSS-Fle. Simulation results show that the proposed DSS-Fle variant algorithm can scale to city-scale scenarios with thousands of regions, orders and couriers, and has the signiﬁcant advantage on improving system throughput.


Introduction
The popularization of smartphones has made people increasingly connected, and has provided the great convenience for daily order delivery service. For example, by using the ride-ordering apps, such as DiDi Chuxing (www.didiglobal.com) and Uber (www.uber.com), customers can be picked up by the private car or taxi at any time, and, by using the food-ordering apps, such as Meituan (www.meituan.com), Eleme (www.ele.me), and Freshhema (www.freshhema.com), food can be delivered to customers' homes within a very short time. During July 2019, the average daily ride orders of DiDi Chuxing broke 24 million, and the average daily food orders of Meituan broke 30 million. Delivery service routing (DSR), which routes the cars/couriers to deliver orders, has made such an important contribution of serving these millions of orders. To improve customer experience, a significant characteristic of the ordering apps is to provide the flexible pickup or drop-off windows [1,2]. For example, in the food-ordering apps, the customer has the flexibility to choose the food drop-off time, e.g., during the lunch time, it is feasible to drop off the food from 11:30 a.m. to 12:30 p.m. Moreover, to improve the system throughput

Related Work
In this section, we categorize the related work into two groups: delivery service routing (DSR) and delivery service sharing (DSS). The latter is further categorized into vehicle-oriented sharing and customer-oriented sharing two subgroups.

Delivery Service Routing (DSR)
The DSR problem is a combinatorial optimization problem seeking to serve a number of customers with a fleet of vehicles [1,2]. Let G = V, C denote a graph, where V denotes the nodes, say customers that need service, c ij ∈ C denotes the time distance between nodes v i and v j . Each customer v i has a time window specified by an interval [e i , l i ], corresponding to the earliest and latest possible serving times, respectively. A vehicle route starts at the depot v 0 , serving some number of customers at most once within their windows. Solomon [1] proposes a heuristic of inserting a new un-routed customer into the current partial route, between two adjacent customers with the minimum insertion cost. To further improve routing efficiency, Potvin and Roussea [11] propose a 2-opt exchange heuristic where the initial route is improved by exchanging two existing route links for another two new route links-being aware that some lateness customers can be tolerated, and the soft time window is introduced and a tabu search heuristic of swapping sequences of consecutive customers between two routes is proposed in [12]. To minimize the number of vehicles and traveling cost, a two-stage hybrid algorithm is proposed in [13], in which the simulated annealing heuristic is used to minimize the number of vehicles, and the neighborhood search is used to minimize travel costs. Considering the necessity of visiting recharging stations in electric DSR problem, meta-heuristic search [14] and branch-price-and-cut-based exact algorithms [15] are proposed to minimize the route cost. To minimize the average distance traveled per customer, the weighted DSR is introduced [16]. For weighted DSR, the regret-insertion heuristic is proposed to construct the initial solution and iterative local link exchange heuristics is proposed to improve the routing efficiency. In the above DSR literature, customers have the same pickup location (i.e., the depot), and each drop-off location is modeled as a node, which can be served successfully once it is visited by a vehicle. In contrast to the existing DSR with the same pickup location, this paper studies the delivery service sharing (DSS) variant where the customer is specified by the origin, destination, and flexible pickup/drop-off time windows, and the customer can be served successfully if and only if he is picked up from its origin and delivered to its destination with the time window.

Delivery Service Sharing (DSS)
For the DSS group, we mainly focus on vehicle-oriented DSS and two customer-oriented DSS subgroups. For vehicle-oriented DSS, some customers are served in sequence by the same vehicle, and for customer-oriented DSS some customers can be shared and served by the same vehicle at the same time.  [17]. In the vehicle-based DSS, each vehicle can only serve one customer at a time, and customers are served in sequence. For the special scenario with the fixed pickup/drop-off time, i.e., t e c = t l c = t j , the vehicle-shareability network is constructed in [18]. In the shareability network, each node represents a customer, and there is an directed edge between customers c and c if and only if c can be served immediately after c , i.e., t c + t cc ≤ t c , where t cc denotes the time distance of traveling from c's destination to the origin of c and delivering c to its destination. Given the constructed shareability network, the Hopcroft-Karp algorithm [19] is utilized to maximize the number of customers served with n vehicles [6]. Considering the flexible pickup windows [t e c , t l c ], Bertsimas et al. [7] propose an iterative Backbone algorithm, and, at each iteration, the fixed time is chosen randomly within the time window and the desirable edges are remained. The optimal mixed integer programming is used to return the optimal solution within the remained shareability network. Being aware of the soft constraints of minimizing the delay of the fixed time window, a linear programming-based approximation algorithm is proposed in [20], and a heuristic local search strategy with a diversification updating strategy is used to improve the solution quality iteratively [21]. Compared with existing heuristics for vehicle-oriented DSS with flexible time windows, we propose an approximation algorithm which has theoretical performance guarantee on system throughput. Moreover, we also systemically analyze the customer-oriented sharing scenarios, where multiple customers can be served by a vehicle at the same time.

Customer-Oriented DSS
Customer-oriented sharing has been proposed as a promising means for improving DSS applications (e.g., ridesharing), where multiple customer requests can be shared and severed by a vehicle simultaneously [3][4][5]. A mixed integer programming can be used to model the static customer-oriented DSS where the customer requests are known in advance, and a time-consuming Lagrangian decomposition approach is used to return the exact solution [8]. To scale up the customer-oriented DSS, Bei et al. [9] propose a bipartite matching-based approximation algorithm. By considering the advantage of tip sharing with partners locating in proximal locations, a community-based trip-sharing paradigm is proposed, where customers are first clustered into local communities and optimal intra community trip sharing can be found by the integer programming [22]. By utilizing the offline partial paths, online nearby customer requests can be constructed and inserted by a local search in a real-time manner [23][24][25]. On the other hand, in ridesharing, the sharing paths should also satisfy the monetary constraints where passengers will not pay more compared with the scenario without ridesharing and taxi drivers will also make money for all the detour distance due to ridesharing [10]. Compared to the above customer-oriented DSS scenarios where customers have the fixed pickup/drop-off window, we study the more practical and flexible DSS variant where customers have time windows. Moreover, we design customer-oriented DSS algorithms with the systemic understanding of the power of customer sharing.

Model and Algorithm Framework
In this section, we first model the problem of delivery service sharing with flexible time windows, and outline the algorithm framework. Table 1 summarizes the notations used throughout the paper.

Notation Description
A = {a 1 , a 2 , · · · , a n } the set of n couriers available for food delivery services V = {v 1 , v 2 , . . . , v m } the set of m regions of a city R = {r 1 , r 2 , · · · , r l } the set of l customer orders need in service

The Model
Food-Ordering Delivery Applications. The model is mainly motivated by food-ordering applications, such as Meituan, Eleme, and Freshhema. There are a set of n couriers A = {a 1 , a 2 , · · · , a n } available for food delivery services. Each courier a i has a capacity c ∈ N + , indicating the maximum number of customer orders that can serve at a time (Here, we assume that each courier has the homogeneous delivery capacity, which can be easily extended to heterogeneous capacity scenario by making a match between the courier and delivery plans). Each day is discretized into periods; each period includes δ minutes (e.g., 5 min). The daily horizon T = {1, 2, · · · , T = 24 × 60 δ }, and the parameter δ can be tuned such that 24 × 60 δ is an integer. City Network. Let G = V, E, W, D denote the weighted city network, where V = {v 1 , v 2 , . . . , v m } indicates m regions in the city and each e ij ∈ E indicates the edge between regions v i and v j . The time distance on edges W = {w ij } e ij ∈E indicates that it will take w ij periods to travel from v i to v j , and w ii = 0, ∀v i . Let D = {d ij } v i ,v j ∈V denote the time distance of the shortest path from v i to v j . The time distance matrix D satisfies the triangle inequality, i.e., d ik ≤ d ij + d jk , ∀v i , v j and v k .
Customer Orders. Let R = {r 1 , r 2 , · · · , r l } be a collection of customer orders. Each r j ∈ R is defined as a tuple (v A delivery sharing plan P is a temporally-ordered route of pickup and drop-off regions of orders. Let R P ⊆ R denote the subset of orders served in P, and for each r j ∈ R P , v p j should precede v d j , and the drop-off time should be within its flexible windows [t e j , t l j ]. A courier is responsible for a plan, and for each plan, there are at most c orders in service at a time. DSS-Fle is formally defined as follows: given the set of n couriers A and the set of l customer orders R, find the n order-disjoint delivery sharing plans with the objective of optimizing order service rate, i.e., maximizing the number of orders served.

The Algorithm Framework
Before presenting the algorithm for DSS-Fle, we first study the following three special DSS-Fle variants: • Delivery service routing with the fixed window (DSR-Fix). We first consider the DSR-Fix variant where orders have the fixed drop-off window and there is no order sharing in routing plan. In terms of the fixed drop-off window, we mean that each order r j has a fixed drop-off time window, i.e., t e j = t l j = t j , and each order can only be finished at its fixed window t j . In terms of without order sharing, we mean that orders are served in sequence and each courier can only serve one order at a time.
• Delivery service routing with the flexible windows (DSR-Fle). In DSR-Fle, each order has a flexible drop-off time window [t e j , t l j ], but they are still cannot be shared by a courier in the same service time. • Delivery service sharing with the fixed window (DSS-Fix). In DSS-Fix, multiple orders can be shared and served at a time, but each order r j has the fixed drop-off time window t j .
Inspired by the efficiency of a shareability network (proposed in [6,18]) on addressing DSR-Fix, we propose an approximation algorithm and a time efficient heuristic algorithm for DSR-Fle and DSS-Fix, respectively. Combining DSR-Fle and DSS-Fix algorithms together, we finally propose the DSS-Fle algorithm, which is efficient on both computation complexity and order service rate. The algorithm framework for DSS-Fle is outlined in Figure 1.

The Algorithms
In this section, we propose four algorithms for DSR-Fix, DSR-Fle, DSS-Fix, and DSS-Fle variants, respectively, and theoretically analyze these algorithms' properties.

The DSR-Fix Variant Algorithm
In DSR-Fix, each order r j has the fixed drop-off window, i.e., t e j = t l j = t j , i.e., a courier must deliver r j to the drop-off region v d j before t j and wait until t j to drop off it. Moreover, orders cannot be shared and must be served in sequence. For any two orders r j and r k , they can be served consecutively if one courier can pick up the order r k immediately after finishing the order r j . There must be a long enough period of time between drop-off periods of r j and r k such that denotes the time distance of traveling from the drop-off region of r j to the pickup region of r k and delivering r k to its drop-off region v d k . For such a DSR-Fix problem, an efficient courier-shareability network (CSN)-based algorithm is proposed in [6].

Definition 1.
Courier-shareability network (CSN). The CSN is a directed network CSN=(V, E), where each node v j ∈ V corresponds to an order r j . The directed edge (v j , v k ) ∈ E if and only if r j and r k can be served consecutively, i.e., t j + τ jk ≤ t k .
The existence of an edge (v j , v j ) in the CSN indicates that the two orders r j and r k can be served consecutively, and a delivery plan in CSN corresponds to a sequence of orders that can be served by a courier. Solving the DSR-Fix problem is equivalent to finding n node-disjoint paths in such a way to maximize the cover of V in the constructed CSN [18]. The problem of finding the maximum n node-disjoint paths cover on directed acyclic graphs can be solved efficiently by using the Hopcroft-Karp maximum-matching algorithm [26]. Algorithm 1 describes the CSN-based DSR-Fix algorithm, in which the Hopcroft-Karp maximum matching algorithm is shown in Algorithm 2. In Algorithm 2, Steps 1-2, for each order r j , we create an in-order r j1 and an out-order r j2 in the bipartite graph G β . In Steps 3-5, for each directed edge (r j , r k ) in the CSN, we create an edge between the in-order r k1 and out-order r j2 in the bipartite graph G β . Given the bipartite graph G β , the Hopcroft-Karp algorithm is utilized to return the maximum matchings M. In Algorithm 1, top n node-disjoint delivery plans correspond to top n longest consecutive matchings. Figure 2 shows a toy example on how to construct the CSN and how the optimal delivery path can be found by the Hopcroft-Karp maximum-matching algorithm.  Create an in-order r j1 and an out-order r j2 in the bipartite graph G β ; 3 for r j , r k ∈ R do 4 if (r j , r k ) ∈ E then 5 Create an edge between the in-order r j1 and out-order r k2 in G β ; 6 Invoke Hopcroft-Karp algorithm [26] to return the maximum matchings M.

The DSR-Fle Variant Algorithm
In this section, we formulate the DSR-Fle problem where orders have flexible drop-off time windows, prove that the DSR-Fle problem is NP-hard, and propose an approximation algorithm for the DSR-Fle.

Problem Formulation
We use an integer programming (IP) to formulate the DSR-Fle problem where each order r j has flexible drop-off time windows [t e j , t l j ]. The following decision variables are necessary: • x ij ∈ {0, 1}, set to 1 if order r j is served by the courier a i as a first order; • y kj ∈ {0, 1}, set to 1 if order r j is served immediately after r k ; • z j ∈ {0, 1}, set to 1 if order r j is served by a courier; • θ j ∈ [t e j , t l j ], the drop-off period of order r j .
The following IP can be used to formulate the DSR-Fle.
Equation (1) is the object of maximizing the number of orders served. Constraint (2) ensures that the order r j is served (i.e., z j = 1) if and only if a courier a i serves him as the first customer order (i.e., x ij = 1) or after another order r k (i.e., y kj = 1). Constraint (3) ensures that the order r j that can be served after the order r k iff r k is served (i.e., z k = 1). Constraint (4) ensures that each courier can only serve one request as the first customer order. Finally, we enforce the drop-off time window constraints in Constraint (5): the first constraint ensures that the drop-off period θ j must lie in the window [t e j , t l j ]; the second constraint ensures that r j can be served immediately after r k iff there are long enough periods between θ j and θ k such that the courier can travel from the drop-off region of r k to the pickup region of r j and deliver r j to its drop-off region, the third constraint ensures that the courier a i can serve the order r j as the first order iff there are long enough periods for a i to travel from his region to the pickup and drop-off regions of r j and where v a i indicates the region where a i starts from.
Proof. We show a reduction from the three-dimensional perfect matching problem (3DM), which is known to be NP-hard [27]. Recall that 3DM is as follows: given three finite and disjoint sets I, J and K, each of size n, and a subset T ⊆ I × J × K with size m ≥ n (i.e., T consists of triples (i, j, k) such that i ∈ I, j ∈ J, and k ∈ K), the 3DM problem asks if there exists a perfect matching with a subset M ⊆ T with n triples, such that every element in I ∪ J ∪ K occurs in exactly one triple of M.
For any 3DM instance, I = I, J, K, T . We construct a corresponding DSR-Fle instance as follows: for each element i ∈ I, we create an order r i with the fixed drop-off window t i . For each element j ∈ J, we create an order r j , and, for each tuple (·, j, ·) ∈ T, we create an available drop-off time t(·, j, ·) for r j . For each element k ∈ K, we create an order r k with the fixed drop-off window t k . For each tuple (i, j, k) ∈ T, we create a directed edge from the order r i to the order r j , and a directed edge from r j to the order r k . The directed edge from r i to r j indicates that it is feasible to travel from r i 's drop-off region (at the period t i ) to r j 's pickup and drop-off region before the period t(i, j, k). The edge directed from r j to r k indicates that it is feasible to travel from r j 's drop-off region (at the period t(i, j, k)) to r k 's pickup and drop-off region before the period t k . The region of the orders r i , r j and r k and time distance among orders can be easily constructed to satisfy the shareability requirements. Moreover, there are n couriers in the DSR-Fle problem. The construction can be done in the polynomial time. We will show that the DSR-Fle can serve 3n orders iff 3DM has a perfect matching.

The 'if' direction:
Assume that 3DM has a perfect matching M ⊆ T with n triples. In the DSR-Fle, for each courier, it can serve three orders r i , r j , and r k consecutively, where (i, j, k) ∈ M. For each r i and r k , it is only served exactly once. This is because the drop-off windows of r i and r k are fixed, and, for r j , it is only served once since element j occurs exactly in one triple of M.
The 'only if' direction: Assume that these n couriers can serve 3n orders in the DSR-Fle problem, where each courier's delivery plan is r i , r j , r k . Then, in 3DM, the n delivery plans correspond to the n triples (i, j, k), which is a perfect matching. This is because each element in i ∈ I, j ∈ J, and k ∈ K occurs exactly once.

The Approximation Algorithm
The main idea behind the approximation algorithm is that, for the order r j , we split its flexible windows [t e j , t l j ] into κ j = t l j − t e j + 1 virtual ordersr j = {r j1 ,r j2 , · · · ,r jκ j }, each virtual orderr jh has the fixed drop-off window t e j + h − 1, 1 ≤ h ≤ κ j . For DSR-Fix with the set of virtual ordersR = {r 1 ,r 2 , · · · ,r m }, we can adopt Algorithm 1 to optimize the order service. LetR ⊆R denote the set of virtual orders served by Algorithm 1. For these virtual orders {r j1 ,r j2 , · · · ,r jκ j } that are served inR and belong to the same real order r j , randomly choosing one virtual orderr jh (1 ≤ h ≤ κ j ) as the real order r j 's drop-off period, i.e., t e j + h − 1. The details of the approximation algorithm are presented in Algorithm 3. In Steps 2-3, each real order r j ∈ R is split into κ j virtual orders, and the set of virtual orders is denoted byR. In Step 4, Algorithm 1 is utilized to return the served ordersR ∈R. Finally, in Steps 5-6, one of these virtual ordersr h j that belongs to the same real order r j is chosen such that r j is finished at the drop-off period t jh = t e j + h − 1.

Algorithm 3:
Splitting-Based Approximation Algorithm for DSR-Fle (Spl-DSR-Fle). Input : Customer Orders R. Output : Served orders R ⊆ R. 1 R = ∅; 2 for r j ∈ R do 3 Split r j into κ j = t l j − t e j + 1 virtual ordersr j = {r j1 ,r j2 , · · · ,r jκ j }; 4 Invoke Algorithm 1 to return the served ordersR =CSN-DSR-Fix(R); 5 for r j ∈ R : ∃r jh ∈R do 6 R = R ∪ r j and the drop-off period of r j is t e j + h − 1; Theorem 2. Let κ = max r j ∈R κ j denote the maximum window length of orders R, then the number of orders achieved from the Algorithm 3 at least 1 κ of the optimal value returned by Equations (1)-(5).

Proof. Let
Opt denote the optimal number of orders served in DSR-Fle, Opt spl denote the optimal number of orders served in the "split" DSR-Fle variant, where each order r j is split into κ j virtual orders, and Alg spl denotes the number of orders served by Algorithm 3. When no ambiguity is possible, we let Opt, Opt spl and Alg spl denote the number of orders served as well the order delivery plan. In the following, we will prove that Opt ≤ Opt spl and Alg spl ≥ Opt spl κ , respectively. Opt ≤ Opt spl . Let Opt = {Opt 1 , Opt 2 , · · · , Opt n }, where Opt i denotes the order delivery plan of the courier a i . It should be noted that Opt is also a feasible delivery plan in the "split" DSR-Fle variant. On the other hand, virtual orders served in Opt spl might belong to the same real orders, and a feasible delivery plan of Opt spl does not necessarily correspond to a feasible delivery plan of Opt. Therefore, we have Opt ≤ Opt spl .
Alg spl ≥ Opt spl κ . Let Opt spl = {Opt 1 spl , Opt 2 spl , · · · , Opt n spl }, where Opt i spl denotes the order delivery plan as well as the orders served by a i in the "split" DSR-Fle. For any delivery plan Opt i spl , and any consecutive three virtual ordersr jo ,r kp andr hq served by a i , it is feasible for a i to serve any two virtual orders ofr jo ,r kp andr hq . This is because the triangle inequality τ j o k p + τ k p h q ≤ τ j o h q , where j o , k p , and h q are the virtual orders with the drop-off period t e j + o − 1, t e k + p − 1 and t e h + q − 1, respectively. This indicates that, for any delivery plan Opt i spl , removing any number of virtual orders does not break the shareability of other remained virtual orders. Therefore, in Algorithm 3, for each real order r j (with κ j virtual orders) that are served in the "split" DSR-Fle variant, at least one of its virtual ordersr jh remains. Therefore, we have Alg spl = ∑ r j 1 r j ∈R ≥ ∑r j ∑r jh ∈r j 1r jh ∈R κ j ≥ Opt spl κ , where the function 1 f (·) returns value 1 when the function f (·) is true; otherwise, it returns zero,R is the set of orders served in Opt spl , and R is the set of orders served in Alg spl .
Combining the above two conclusions, we have that Theorem 2 generalizes the DSR-Fix variant (i.e., κ = 1) that Algorithm 1 can achieve the optimal solution [6].

Improvement on the Spl-DSR-Fle Algorithm
We extend Algorithm 3 and propose an iterative algorithm to further improve system throughput. At each iteration g, let R f ix g denote "fixed" orders, i.e., the set of orders whose drop-off period is determined and fixed, and R f le g denote the "flexible" orders, i.e., the set of orders whose drop-off period is flexible within windows [t e j , t l j ]. For each flexible order r j ∈ R f le g , we split its flexible time windows into κ j = t l j − t e j + 1 virtual ordersr j = {r j1 ,r j2 , · · · ,r jκ j }, and eachr jh has the fixed drop-off period t e j + h − 1, 1 ≤ h ≤ κ j . At each iteration g, letR f le g denote the virtual orders split from R f le g andR g = R f ix g R f le g denote all of the orders. GivenR g , we construct the corresponding CSN G(R g , E) and invoke Algorithm 3 to return the fixed orders R f ix g that are served at the current iteration g. The details of the iterative DSR-Fle are proposed in Algorithm 4. In Step 3, the set of ordersR g is constructed, which includes the set of fixed orders R f ix g whose drop-off period is fixed, and the set of virtual ordersR f le g split from R f le g . In Step 4, the CSN G = (R g , E) is constructed with respect toR g . In Step 5, Algorithm 3 is invoked to return the fixed orders served, R f ix g . In Step 6, the set of flexible orders R f le g is updated by removing the fixed orders R f ix g whose drop-off period has been determined. The iteration terminates until there is no improvement over previous iteration g − 1 on the number of orders served.

Lemma 1. Algorithm 4 can always converge within finite iterations.
Proof. Assume that, at the iteration g, if there is no improvement in the number of orders over that of the previous iteration g − 1, Algorithm 4 terminates and converges. Otherwise, it will always increase at least one order at each iteration; this is because each iteration generates a feasible solution of serving a set of real orders. On the other hand, there are at most |R| orders to be served, thus, Algorithm 4 can always converge within at most |R| iterations.
Construct the CSN G = (R g , E); 6 Invoke Algorithm 3 to return the "fixed" orders R f ix g ;

The DSS-Fix Variant Algorithm
In this section, we formulate the DSS-Fix problem, prove the DSS-Fix problem is NP-hard, and propose an efficient heuristic algorithm for DSS-Fix.

Problem Formulation and Complexity Analysis
In DSS-Fix, each order r j has the fixed drop-off time window t j , but multiple orders can be shared and served by a courier at a time. For example, orders r j and r k with proximal pickup regions can be picked up consecutively by a courier, and the sharing delivery plan can be v We say such a sharing plan is feasible if and only if (1) at any region, the number of orders in service is smaller than the courier capacity c, and (2) the courier can drop-off the order r j (resp. r k ) at v d j (resp. v d k ) no later than t j (resp. t k ), but can before t j (resp. t k ) while waiting until t j (resp. t k ). The DSS-Fix problem is to find the optimal n sharing delivery plans to maximize the order service rate.

Theorem 3. The DSS-Fix problem is NP-hard.
Proof. We show a reduction from the metric Traveling Salesman Problem (TSP), which is known to be NP-hard. Recall that a metric TSP problem is as follows: given a weighted complete graph G = (V, W), where v i ∈ V (|V| = n) is the vertex and w ij ∈ N + is the non-negative cost associated with the edge e ij between v i and v j , the TSP asks if there exists a Hamiltonian path (i.e., a path visiting each vertex exactly once) with a cost equal to K. For any metric TSP instance I = G, K , we construct a DSS-Fix instance as follows. For each vertex v i ∈ V, we create an order where v i indicates the pickup region, v − is the created auxiliary region indicating the drop-off region of r i , and K indicates the drop-off period. The weight of the edge w ij corresponds to the time distance between the pickup regions of r i and r j . Moreover, for each order r i , the time distance between its pickup region v i and its fixed drop-off region v − is zero. In DSS-Fix, there is only one courier with capacity n. The courier stats from the depot region v 0 and the time distance between v 0 and any other region is zero. This construction can be done in polynomial time. We can conclude that the DSS-Fix can serve n orders within the period horizon K iff TSP has a Hamiltonian path with cost K.

The Heuristic Algorithm
The main idea behind the heuristic algorithm for DSS-Fix is that we first search these orders that can be shared, then package the shared orders as a virtual order, and finally insert the virtual order into the DSR-Fix CSN.
Order Sharing Search. For two orders r j and r k whose pickup (resp. drop-off) regions that are proximal, it will be beneficial to pick up (resp. drop off) r j and r k consecutively. Imposing a bound of c implies that at most c orders can be shared and served by a courier at a time. In the following, we consider the case c = 2, i.e., search 2-order sharing where two orders can be served in a sharing manner. Definition 2. 2-order sharing r j , r k . Given two orders r j and r k with fixed time window t j and t k , and assuming that t j ≤ t k without loss of generality, it is beneficial for serving the two orders in a sharing manner if these two orders satisfy the following two properties: (1) it is not feasible to serve r j and r k consecutively, i.e., t j + τ jk > t k , and (2) it is feasible to execute one of the following two sharing delivery plans v Definition 3. CSN Update Rule. The solution R includes virtual sharing and real orders, which might involve the same order, and the CSN G s should be updated to delete the undesirable orders, such as

•
For the virtual order r s jk (resp. r s kj ), if it is not served in the solution R , r s jk (resp. r s kj ) will be deleted from the CSN G s .

•
For the virtual orders r s jk and r s kj that belong to the same 2-order sharing r j , r k , if they are both served in R , one of the them will be deleted from the CSN G s .

•
For the virtual order r s jk (resp. r s kj ), if it is served in R , and both of the real orders r j and r k are also served in R , r s jk (resp. r kj ) will be deleted from the CSN G s .

•
For the virtual order r s jk (resp. r s kj ), if it is served in R , however, only one of the real orders r j and r k is served in R , both r j and r k will be deleted from the CSN G s .
After updating the CSN, Algorithm 2 is invoked again to derive the orders served in the next iteration. The details of the iterative DSS-Fix algorithm are proposed in Algorithm 5. In Step 2, the set of virtual sharing ordersR s is constructed. Based on the constructedR s and the real orders R, the CSN graph G s is constructed in Step 3. Steps 4-8 are the iterative process of finding the set of orders R g and updating the CSN G s g at each iteration g. The iterative process terminates until there is no improvement over the previous iteration on the number of real orders served.

6
Invoke the Algorithm 2 to return the set of orders R g served on G s g−1 ; 7 Update the CSN G s g using the CSN update rule; 8 until |R g−1 | = |R g |; 9 Return R g .

Lemma 2. Algorithm 5 can always converge within finite iterations.
The proof is similar to that in Lemma 1 and is omitted here for space limitation.

Lemma 3.
Given the set of customer orders R, the number of orders served by the DSS-Fix algorithm (i.e., Algorithm 5) is not less than that served by the DSR-Fix algorithm (i.e., Algorithm 1).
Proof. In DSS-Fix, the CSN G s = (R ∪R s , E) not only includes the real orders R, but also includes the virtual shared ordersR s . Therefore, the number of orders served in the DSR-Fix variant CSN G = (R, E) must not be larger than that in the DSS-Fix variant CSN G s = (R ∪R s , E). Moreover, the CSN update rule always deletes the real order r j that has been served in the virtual shared orders r s jk (resp. r s kj ), which will not reduce the number of orders served in G = (R, E). In other words, for each served order r j in G = (R, E) that is not served in G s = (R ∪R s , E), there must be another one real order r k or virtual orders r s jk (resp. r s kj ) replacing r j in G s = (R ∪R s , E). Therefore, we have this conclusion.
Lemma 3 theoretically guarantees the advantage of delivery sharing plan over delivery routing plan.

The DSS-Fle Variant Algorithm
On one hand, the DSS-Fle problem, where the order has flexible drop-off time windows, is a general variant of the DSS-Fix problem. On the other hand, the DSS-Fle problem, where orders can be served in a sharing manner, is also a general variant of the DSR-Fle problem. To solve such an NP-hard DSS-Fle problem, we can combine the DSR-Fle variant algorithm (i.e., Algorithm 4) and the DSS-Fix variant algorithm (i.e., Algorithm 5).
The main idea of the DSS-Fle variant algorithm is that we first employ Ite-DSR-Fle algorithm (i.e., Algorithm 4) to return "fixed" orders whose drop-off periods are determined and fixed. Given the "fixed" orders, we then employ the Ite-DSS-Fix algorithm (i.e., Algorithm 5) to search the order-sharing and generate the sharing delivery plan. The details of the DSS-Fle algorithm are shown in Algorithm 6. In Step 2, the Ite-DSR-Fle algorithm is employed to determine the fixed drop-off period of each order (For the order whose drop-off period cannot determined, a greedy heuristic of choosing its latest drop-off period is employed). Let R f ix denote the set of "fix" orders. In Step 3, the Ite-DSS-Fix algorithm is employed to optimize the set of fixed orders R f ix .

Algorithm 6: The DSS-Fle Variant Algorithm (DSS-Fle).
Input : Customer orders R. Output : Served orders R ⊆ R. 1 Initialize R f ix = ∅; 2 Invoke the Ite-DSR-Fle algorithm (i.e., Algorithm 4) to generate "fixed" orders R f ix with fixed drop-off periods; This proof can be derived from the convergence results of Algorithms 4 and 5.

Experimental Evaluation
We generate synthetic datasets to validate the performance of proposed algorithms. All computations are performed on a 64-bit PC with 16 GB RAM and a Dual core 3.5 GHz processor. All records are averaged over 40 instances, and each record is statistically significant at a 95% confidence level. Existing public delivery datasets such as the New York City taxi-trip dataset (https://www1.nyc.gov/site/tlc/about/ tlc-trip-record-data.page) only includes the order's pick-up region, drop-off region, and request time, and does not include the flexible drop-off time windows. Thus, we use the synthetic data to validate the proposed algorithms.
Comparison Metrics. We mainly compare the running time and the order service rate (OSR) of the algorithms. The OSR is computed as follows: we compare the number of orders served with the total number of orders |R|, e.g., the OSR of the algorithm Alg is computed as NoS(Alg) |R| , where NoS(Alg) is the number of orders served by the algorithm Alg.

Validate the Ite-DSR-Fle Variant Algorithm
In this section, we mainly focus on the DSR variant without considering order sharing and validate the efficiency of the proposed Ite-DSR-Fle approximation algorithm. Experimental Setup. Each period consists of 5 min and the horizon T = 36, which might represent the food-delivery peak-hour at noon ranging from 10:30 a.m. to 1:30 p.m. The city network consists of 100 regions; each region has four neighbors, connected by a small-world network [28]. The traveling period between adjacent neighbors follows U (1, 4), where U(a, b) indicates the uniform distribution between a and b. The time distance between two regions can be computed by the shortest path. There are 200 couriers starting routing with uniformly distributed initial regions. Customer orders are randomly generated as a Poisson process P(λ) with a fixed arrival rate λ. The origin and destination of each order is uniformly drawn across the regions. By setting the arrival rate of the Poisson process so that the expectation of the total number of orders is 200, 500, 1000, respectively, these three levels of customer order demand correspond to the low, medium, and high demands. We give all customers a constant time window around their preferred drop-off period (that follows U(1, T)), from one to five periods.
Comparison Methods. We compare the proposed approximation Ite-DSR-Fle with the following two benchmarks.

•
The integer-programming-based optimal solution (IPopt): We use the CPLEX (version 12.6) to solve this IPopt (i.e., Equations (1)- (5)) to return the optimal solution. • Greedy: Each customer order r j is assigned with its latest drop-off period t * j = t l j as its fixed drop-off period, based on which the CSN-DSR-Fix (i.e., Algorithm 1) is employed to return the solution.
Experiment Results. Table 2 shows the OSR and running time of these algorithms with varying order demands and window lengths. From Table 2, we can observe that (1) the proposed Ite-DSR-Fle can perform close to the optimal IPopt with respect to maximizing OSR. For example, in the worst scenario with high order demand and the five periods flexible time window, Ite-DSR-Fle finishes ∼5% less OSRs than that of the optimal IPopt. This result is consistent with the theoretical approximation of the Ite-DSR-Fle algorithm.
(2) Ite-DSR-Fle achieves nearly ∼6% more OSRs than that of the greedy heuristic in average. The potential reason is that the orders' drop-off periods should be coordinated rather than chosen by their latest period independently. Considering that there are thousands of customer orders, such an improvement is desirable.
(3) Since IPopt needs to solve the IP Equations (1)-(5), the running time prevents it from scaling to large instances. For example, in the scenario with high demand, it will take a couple of minutes (e.g., 80.4 s) to return the routing plan. However, the Ite-DSR-Fle can generate the routing plan within about 1.4 s. (4) The more flexible time windows, the more OSR will be achieved by the Ite-DSR-Fle. For example, in the scenario of high order demand, the OSR of Ite-DSR-Fle(#1) is 0.435, while the OSR of Ite-DSR-Fle(#5) increases to 0.484, where #1 and #5 indicate that the lengths of time windows are 1 and 5, respectively. This can be explained by the fact that, the longer the time window, the more feasible routing plans can be generated, and the more orders can be finished.
In summary, in the DSR-Fle variant, the proposed Ite-DSR-Fle can achieve nearly the optimal OSR, while the running time is significantly reduced over the optimal solution.

Validate the DSS-Fle Variant Algorithm
In this section, we will validate the DSS-Fle variant algorithm, such as the advantage of order sharing over DSR variant algorithms, the advantage of flexible time selection mechanism over traditional fixed time selection heuristics, and the scalability on city-scale applications.
Experimental Setup. We consider that the city-scale network consists of 1000 regions, connected by a small-world like network, and each node has on average six neighbors. We consider that there are 1000 couriers with uniformly distributed depot regions. Each customer order has a fixed time window of three periods around their preferred drop-off period. The other settings are similar to that in Section 5.1.

Validate the Advantage of Order Sharing and Scalability
Comparison Methods and Metrics. We compare the proposed DSS-Fle, Ite-DSS-Fix, Ite-DSR-Fle and DSR-Fix algorithms on running time and OSR.
Experimental Results. Table 3 shows the OSR and running time of these algorithms with varying customer order demands. From Table 3, we can observe that (1) the DSS-Fle can always produce the highest OSR, which is followed by Ite-DSR-Fle, Ite-DSS-Fix, and DSR-Fix. This result is consistent with the theoretical analysis that DSS-Fle Ite-DSS-Fix, and Ite-DSR-Fix DSR-Fix. This can be explained by the fact that taking the flexible time windows and order sharing (though 2-order sharing) into consideration is beneficial for improving OSRs. The experimental order-sharing advantage is consistent with the theoretical results of Lemma 3. (2) For the large-scale instances with 10,000 orders, although DSS-Fle will take about 2 min to return the delivery plans, considering its benefit of improving ∼200 orders over DSR-Fix, DSS-Fle is still a good option for food ordering apps. In food-ordering apps, customers are more concerned with whether their food can be dropped off in time or not, and the response time is tolerable within several minutes [20]. (3) With the constant couriers (e.g., 1000 in this experiment), the more customer order demands, the more number orders that can be served. For example, in the case of 2000 orders, 1140 (= 2000 × 0.572) orders are served on average, while, in the case of 10,000 orders, nearly 1720 (= 10,000 × 0.172) orders will be served. This can be explained by the fact that more customers will generate more feasible delivery plans, thereby improving the number of orders served. • Greedy: Each customer order r j is assigned with its latest drop-off period t * j = t l j as its fixed drop-off period, based on which the CSN-DSR-Fix (i.e., Algorithm 1) is employed to return the solution.
• Insertion-based Heuristics (Insert-Heu): The Greedy algorithm is first employed to derive a solution of n delivery sharing plans P = {P 1 , P 2 , · · · , P n }. For any order r j ∈ R that is not served in P, a re-optimization of inserting r j into a sharing plan P i ∈ P is elaborated. Given the delivery plan P i = v p 1 , v d 1 , v p h , v d h of a temporally-ordered route of pickup and drop-off regions of h orders, the insertion heuristic attempts to insert r j pick-up region v p j and drop-off region v p j into these 2h regions. A feasible insertion of r j into P i must satisfy (1) without violating the order service in the rest of the plan P i , and (2) the number of on-board orders is smaller than the courier's capacity c (c = 2 in this experiment). There are O(l 2 ) possible ways of insertion for each order and each plan, where l is the number of orders. Given these n delivery plans and l orders in total, there are O(nl 3 ) insertion computations.
Experimental Results. Figure 3 shows the OSRs of these algorithms with varying customer order demands. From Figure 3, we can observe that DSS-Fle can always serve the most orders, which is followed by Insert-Heu and Greedy. This result can validate (1) the advantage of flexible drop-off time selection mechanism (i.e., Algorithm 3) over a fixed drop-off time selection mechanism (i.e., Insert-Heu and Greedy), and (2) the advantage of insertion mechanism (i.e., Insert-Heu) over the one-short Greedy solution on improving OSR. Moreover, inspired by the advantage of Insert-Heu, it is interesting for the future work to combine the proposed DSR-Fle with the insertion mechanism for the online delivery services' applications.  In summary, the proposed DSS-Fle can maximize system throughput in the tolerable time in the city-scale order delivery applications with thousands of couriers and customers. Moreover, the more computation time available, the larger system throughput that will be achieved.

Conclusions
This paper studies the practical DSS-Fle problem, where customer orders have flexible drop-off time windows and can be served in a sharing manner. To address such a NP-hard problem, we first study the special DSR-Fix variant, which can be addressed by the CSN and Hopcroft-Karp maximum matching algorithm. By extending the DSR-Fix variant algorithm, we further propose an approximation algorithm (i.e., Ite-DSR-Fle) for the DSR-Fle problem and a heuristic algorithm (i.e., Ite-DSS-Fix) for the DSS-Fix problem. The Ite-DSR-Fle algorithm splits the flexible time windows into multiple fixed time windows, and the DSR-Fix variant algorithm can then be employed to serve orders at the desirable drop-off period. The Ite-DSS-Fix algorithm searches and inserts the sharing orders, and the DSR-Fix variant algorithm then can be employed to generate the desirable sharing plan. Finally, using Ite-DSR-Fle to generate the "fixed" orders and using Ite-DSS-Fix to search order sharing together yield the polynomial time DSS-Fle algorithm for order service rate optimization. Simulation results show that the proposed DSS-Fle algorithm is efficient both on improving order service rate and applying to city-scale scenarios with thousands of regions and customer orders.

Conflicts of Interest:
The authors declare no conflict of interest.