Approximate Ridesharing of Personal Vehicles Problem
AApproximate Ridesharing of Personal Vehicles Problem
Qian-Ping Gu ∗ , Jiajian Leo Liang ∗ and Guochuan Zhang ∗ School of Computing Science, Simon Fraser University, [email protected], leo [email protected]
College of Computer Science and Technology, Zhejiang University, [email protected]
Abstract.
The ridesharing problem is that given a set of trips, each trip consists of anindividual, a vehicle of the individual and some requirements, select a subset of trips anduse the vehicles of selected trips to deliver all individuals to their destinations satisfying therequirements. Requirements of trips are specified by parameters including source, destination,vehicle capacity, preferred paths of a driver, detour distance and number of stops a driver iswilling to make, and time constraints. We analyze the relations between the time complexityand parameters for two optimization problems: minimizing the number of selected vehiclesand minimizing total travel distance of the vehicles. We consider the following conditions:(1) all trips have the same source or same destination, (2) no detour is allowed, (3) eachparticipant has one preferred path, (4) no limit on the number of stops, and (5) all trips havethe same departure and same arrival time. It is known that both minimization problems areNP-hard if one of Conditions (1), (2) and (3) is not satisfied. We prove that both problems areNP-hard and further show that it is NP-hard to approximate both problems within a constantfactor if Conditions (4) or (5) is not satisfied. We give K +22 -approximation algorithms forminimizing the number of selected vehicles when condition (4) is not satisfied, where K isthe largest capacity of all vehicles. Key words:
Ridesharing problem, optimization problems, approximation algorithms, algo-rithmic analysis
As the population grows in urban areas, the number of cars on the road also increases. Asshown in [20], personal vehicles are still the main transportation mode in 218 European citiesbetween 2001 and 2011. In the United States, the estimated cost of congestion is around$121 billion per year [3]. Based on reports in 2011 [6, 18], occupancy rate of personal vehiclesin the United States is 1.6 persons per vehicle, which can be a cause for congestion. Sharedmobility (carpooling or ridesharing) can be an effective way to increase occupancy rate [5].Caulfield [4] estimated that ridesharing to work in Dublin, Ireland can reduce 12,674 tons ofCO emissions annually. Ma et al. [14] showed taxi-ridesharing in Beijing has the potential1 a r X i v : . [ c s . D S ] J u l o save 120 million liter of gasoline per year. Systems that provide ridesharing services areknown as mobility-on-demand (MoD) systems, such as Uber, Lyft and DiDi. These systemsare cable of supporting dynamic ridesharing, meaning the ridesharing requests enter andleave the system in real-time. Although the analysis and algorithms discussed in this paperare for static ridesharing, one can view a dynamic ridesharing instance as a sequence of staticridesharing instances (computing a solution for a fixed interval, e.g. [19]).We consider the following ridesharing problem: given a set of trips (requests) in a roadnetwork, where each trip consists of an individual, a vehicle of the individual and somerequirements, select a subset of trips and use the vehicles of the selected trips to deliver theindividuals of all trips to their destinations satisfying the requirements. An individual of aselected trip is called a driver and an individual other than a driver is called a passenger .The requirements of a trip are specified by parameters including: the source and destinationof the trip, the vehicle capacity (number of seats to serve passengers), the preferred pathsof the individual when selected as a driver, the detour distance and number of stops thedriver is willing to make to serve passengers, and time constraints (e.g., departure/arrivaltime). There are different benefits of shared mobility [5], but the main goal considered in thispaper is to reduce the number of cars on the roads. This can be achieved by the followingoptimization goals: minimize the number of vehicles (or equivalently drivers) and minimizethe total travel distance of vehicles (or equivalently drivers) to serve all trips.In general, the ridesharing problem is NP-hard as it is a generalization of the vehiclerouting problem (VRP) and Dial-A-Ride problem (DARP) [17]. A common approach forsolving the ridesharing problem is to use a Mixed Integer Programming (MIP) formulationand solve it by an exact method or heuristics [3, 10, 11]. MIP based exact algorithms aretime consuming and not practical for large-scale ridesharing, so most previous studies relyon (meat)heuristics or focus on simplified ridesharing for large instances [1, 12, 19]. Theoptimization goals of the ridesharing problem are typically classified into two categories: op-erational objectives and quality-related objectives [17]. Operational objectives are system-wideoptimizing goals, such as maximizing the number of matched (served) trips and minimizingthe total travel time of all vehicles. whereas quality-related objectives focus on the perfor-mance from the individual (driver/passenger) perspective, such as minimizing the waitingtime of each individual passenger and maximizing the cost saving of the passengers. Somevariants and mathematical formulation of ridesharing problem come from the well studiedDARP. A literature review on DARP can be found in [16]. For the ridesharing problem, werefer readers to literature surveys and reviews [2, 5, 17].Most previous works focus on computational studies of the ridesharing problems anddo not have a clear model for analyzing the relations between the time complexity of theridesharing problem and its parameters. A recent model was introduced in [7] for analyzing2he computational complexity of simplified ridesharing problem with parameters of source,destination, vehicle capacity, detour distance limit, and preferred paths only. The work in [7]gives an algorithmic analysis on the simplified ridesharing problems based on the followingconditions: (1) all trips have the same destination or all trips have the same source; (2) nodetour is allowed; (3) each trip has a unique preferred path. It was shown in [7] that ifany one of the three conditions is not satisfied, both minimization problems (minimizing thenumber of drivers and travel distance of vehicles) are NP-hard. When all three conditionsare satisfied, Gu et al. [8] developed a dynamic programming algorithm that finds an exactsolution for each minimization problem in O ( M + l ) time, where M is the size of the roadnetwork and l is the number of trips. In [8], a greedy algorithm was also proposed that findsa solution with minimum number of drivers in O ( M + l · log l ) time.A closely related problem was studied by Kutiel and Rawitz [13], called the maximumcarpool matching problem (MCMP). An instance of MCMP consists of a directed graph H ( V, E ), where the vertices of V represent the individuals and an arc ( u, v ) ∈ E denotes v can serve u . Every v ∈ V is flexible to be a driver or passenger. The goal of MCMP is to finda set of drivers S ⊆ V to serve all trips of V such that the number of passengers is maximized.It was shown MCMP is NP-hard [9]. Algorithms are proposed in [13] with -approximationratio, that is, the number of passengers found by the algorithms is at least half of that for theoptimal solution. The algorithms in [13] can be modified to K +22 -approximation algorithmsfor the ridesharing problem with minimizing the number of drivers, where K is the largestcapacity of all vehicles.In this paper, we extend the time complexity analysis of simplified ridesharing problemsin [7] to more generalized ridesharing problems with three additional parameters considered:number of stops a driver willing to make to serve passengers, arrival time and departure timeof each trip. We introduce two more conditions: (4) Each driver is willing to stop to pick-uppassengers as many times as its vehicle capacity. (5) All trips have the same arrival timeand departure time. We call Condition (4) the stop constraint condition and (5) the timeconstraint condition . Our results in this paper are:1. We prove that both ridesharing minimization problems are NP-hard and further showthat it is NP-hard to approximate both problems within a constant factor if stop con-straint or time constraint condition is not satisfied.2. We present two K +22 -approximation algorithms for minimizing the number of driverswhen the input instances satisfy all conditions except stop constraint condition, where K is the largest capacity of all vehicles. For a ridesharing instance containing a roadnetwork of size M and l trips, our first algorithm, which is a modification of a -approximation algorithm (StarImprove) in [13], runs in O ( M + K · l ) time. Our second3lgorithm is more practical and runs in O ( M + K · l ) time.The rest of the paper is organized as follows. Section 2 gives the preliminaries of the paper.In Section 3, we prove the NP-hardness results for stop constraint condition. In Section 4, weprove the NP-hardness results for time constraint condition. Section 5 presents the approxi-mation algorithms based on MCMP for minimizing the number of drivers for stop constraintcondition. Section 6 presents our new algorithm for minimizing the number of drivers forstop constraint. The final section concludes the paper. A (undirected) graph G consists of a set V ( G ) of vertices and a set E ( G ) of edges, whereeach edge { u, v } of E ( G ) is a (unordered) pair of vertices in V ( G ). A digraph H consists ofa set V ( H ) of vertices and a set E ( H ) of arcs, where each arc ( u, v ) of E ( H ) is an orderedpair of vertices in V ( H ). A graph G (digraph H ) is weighted if every edge of G (arc of H ) isassigned a real number as the edge length. A path between vertex v and vertex v k in graph G is a sequence e , .., e k of edges, where e i = { v i − , v i } ∈ E ( G ) for 1 ≤ i ≤ k and v i (cid:54) = v j for i (cid:54) = j and 0 ≤ i, j ≤ k . A path from vertex v to vertex v k in a digraph H is defined similarlywith each e i = ( v i − , v i ) an arc in H . The length of a path P is the sum of the lengths ofedges (arcs) in P . For simplicity, we express a road network by a weighted undirected graph G ( V, E ) with non-negative edge length: V ( G ) is the set of locations in the network, an edge { u, v } represents the road segment between u and v .In the ridesharing problem, we assume that the individual of every trip can be assignedas a driver or passenger. In general, in addition to a vehicle and individual, each trip hasa source, a destination, a capacity of the vehicle, a set of preferred (optional) paths (e.g.,shortest paths) to reach the destination, a limit (optional) on the detour distance/time fromthe preferred path to serve other individuals, a limit (optional) on the number of stops adriver wants to make to pick-up passengers, an earliest departure time, and a latest arrivaltime. Each trip in the ridesharing problem is expressed by an integer label i and specified byparameters ( s i , t i , n i , d i , P i , δ i , α i , β i ), which are defined in Table 1.When the individual of trip i delivers (using i ’s vehicle) the individual of a trip j , wesay trip i serves trip j and call i a driver and j a passenger . The serve relation between adriver i and a passenger j is defined as follows. A trip i can serve i itself and can serve atrip j (cid:54) = i if i and j can arrive at their destinations by time β i and β j respectively such that j is a passenger of i , the detour of i is at most d i , and the number of stops i has to make toserve j is at most δ i . When a trip i can serve another trip j , it means that i - j is a feasibleassignment of a driver-passenger pair. We extend this notion to a set σ ( i ) of passenger trips4 arameter Definition s i The source (start location) of i (a vertex in G ) t i The destination of i (a vertex in G ) n i The number of seats (capacity) of i available for passengers d i The detour distance limit i willing to make for offering services P i The set of preferred paths of i from s i to t i in Gδ i The maximum number of stops i willing to make to pick-up passengers α i The earliest departure time of iβ i The latest arrival time of i Table 1: Parameters for a trip i .that can be served by a driver i ( i ∈ σ ( i )). A driver i can serve all trips of σ ( i ) if the totaldetour of i is at most d i , the number of stops i have to make to pick-up σ ( i ) is at most δ i ,and every j ∈ σ ( i ) arrives at t i before β j . At any specific time point, a trip i can serve atmost n i + 1 trips. If trip i serves some trips after serving some other trips (known as re-takepassengers in previous studies), trip i may serve more than n i + 1 trips. In this paper, westudy the ridesharing problem in which no re-taking passenger is allowed. A serve relationis transitive if i can serve j and j can serve k imply i can serve k . Let ( G, R ) be an instanceof the ridesharing problem, where G is a road network (weighted graph) and R = { , .., l } isa set of trips. ( S, σ ), where S ⊆ R is a set of trips assigned as drivers and σ is a mapping S → R , is a partial solution to ( G, R ) if • for each i ∈ S , i can serve σ ( i ), • for each pair i, j ∈ S with i (cid:54) = j , σ ( i ) ∩ σ ( j ) = ∅ , and • σ ( S ) = ∪ i ∈ S σ ( i ) ⊆ R .When σ ( S ) = R , ( S, σ ) is called a solution of (
G, R ). For a (partial) solution (
S, σ ) wesometimes simply call S a (partial) solution when σ is clear from the context or not relatedto the discussion.We consider the problem of minimizing | S | (the number of drivers) and the problem ofminimizing the total travel distance of the drivers in S . To investigate the relations betweenthe computational complexity and problem parameters, Gu et al. [7] introduced the simplifiedminimization (ridesharing) problems with parameters ( s i , t i , n i , d i , P i ) only and the followingconditions:(1) All trips have the same destination or all trips have the same source, that is, t i = D for every i ∈ R or s i = χ for every i ∈ R .52) Zero detour: each trip can only serve others on his/her preferred path, that is, d i = 0for every i ∈ R .(3) Fixed path: P i has a unique preferred path P i .It is shown in [7] that if any one of Conditions (1), (2) and (3) is not satisfied, both mini-mization problems are NP-hard. Polynomial time exact algorithms are given in [8] for thesimplified minimization problems if all of Conditions (1-3) and transitive serve relation aresatisfied. In this paper, we study more generalized minimization problems with all parame-ters in Table 1 considered. To analyze the computational complexity of the more generalizedminimization problems, we introduce two more conditions:(4) The number of stops each driver is willing to make to pick-up passengers is at least itscapacity, that is, δ i ≥ n i for every i ∈ R .(5) All trips have the same arrival time and departure time, that is, for every i ∈ R , α i = α and β i = β for some α < β .The polynomial-time exact algorithms in [8] can still apply to any ridesharing instance whenall of Conditions (1-5) and transitive serve relation are satisfied. We first show the NP-hardness results for the stop constraint condition, that is, when Con-ditions (1)-(3) and (5) are satisfied but Condition (4) is not. When Condition (1) is satisfied,we assume all trips have the same destination (since it is symmetric to prove the case that alltrips have the same source). If all trips have distinct sources, one can solve both minimizationproblems by using the polynomial-time exact algorithms in [8]: when Conditions (1-3) aresatisfied and each trip has a distinct source s i , each trip is represented by a distinct vertex i in the serve relation graph in [8]. Each time a driver i serves a trip j , i must stop at s j (cid:54) = s i to pick-up j . When Condition (4) is not satisfied ( δ i < n i ), i can serve at most δ i passengers.Therefore, we can set the capacity n i to min { n i , δ i } and apply the exact algorithms to solvethe minimization problems. In what follows, we assume trips have arbitrary sources (multipletrips may have a same source). We prove both minimization problems are NP-hard. The proof is a reduction from the 3-partition problem. The decision problem of 3-partition is that given a set A = { a , a , ..., a r }
6f 3 r positive integers, where r ≥ (cid:80) ri =1 a i = rM and M/ < a i < M/
2, whether A can bepartitioned into r disjoint subsets A , A , ...., A r such that each subset has three elements of A and the sum of integers in each subset is M . Given a 3-partition instance A = { a , ..., a r } ,construct a ridesharing problem instance ( G, R A ) as follows (also see Figure 1). • G is a graph with V ( G ) = { D, u , ..., u r , v , ..., v r } and E ( G ) having edges { u i , v } for1 ≤ i ≤ r , edges { v i , v i +1 } for 1 ≤ i ≤ r − { v r , D } . Each edge { u, v } hasweight of 1, representing the travel distance from u to v . It takes r + 1 units of distancetraveling from u i to D for 1 ≤ i ≤ r . • R A = { , ..., r + rM } has 3 r + rM trips. Let α and β be valid constants representingtime. – Each trip i , 1 ≤ i ≤ r , has source s i = u i , destination t i = D, n i = a i , d i = 0 , δ i =1, α i = α and β i = β . Each trip i has a preferred path { u i , v } , { v , v } , ..., { v r , D } in G . – Each trip i , 3 r + 1 ≤ i ≤ r + rM , has source s i = v j , j = (cid:100) ( i − r ) /M (cid:101) ,destination t i = D , n i = 0, δ i = 0, d i = 0, α i = α , β i = β and a unique preferredpath { v j , v j +1 } , { v j +1 , v j +2 } , ..., { v r , D } in G .Figure 1: Ridesharing instance based on a given 3-partition problem instance. Lemma 3.1.
Any solution for the instance ( G, R A ) has every trip i , ≤ i ≤ r , as a driverand total travel distance at least r · ( r + 1) .Proof. Since condition (2) is satisfied (detour is not allowed), every trip i , 1 ≤ i ≤ r , mustbe a driver in any solution. A solution with exactly 3 r drivers has total travel distance3 r · ( r + 1), and any solution with a trip i , 3 r + 1 ≤ i ≤ r + rM , as a driver has total traveldistance greater than 3 r · ( r + 1). Theorem 3.1.
Minimizing the number of drivers in the ridesharing problem is NP-hard whenConditions (1-3) and (5) are satisfied, but Condition (4) is not. roof. We prove the theorem by showing that an instance A = { a , ..., a r } of the 3-partitionproblem has a solution if and only if the ridesharing problem instance ( G, R A ) has a solutionof 3 r drivers.Assume that instance A has a solution A , ..., A r where the sum of elements in each A j is M . For each A j = { a j , a j , a j } , 1 ≤ j ≤ r , assign the three trips whose n j = a j , n j = a j and n j = a j as drivers to serve the M trips with sources at vertex v j . Hence, we have asolution of 3 r drivers for ( G, R A ).Assume that ( G, R A ) has a solution of 3 r drivers. By Lemma 3.1, every trip i , 1 ≤ i ≤ r ,is a driver in the solution. Then, each trip j for 3 r + 1 ≤ j ≤ r + rM must be a passengerin the solution, total of rM passengers. Since (cid:80) ≤ i ≤ r a i = rM , each driver i , 1 ≤ i ≤ r ,serves exactly n i = a i passengers. Since a i < M/ a i ∈ A , at least three driversare required to serve the M passengers with sources at each vertex v j , 1 ≤ j ≤ r . Due to δ i = 1, each driver i , 1 ≤ i ≤ r , can only serve passengers with the same source. Therefore,the solution of 3 r drivers has exactly three drivers j , j , j to serve the M passengers withsources at vertex v j , implying a j + a j + a j = M . Let A j = { a j , a j , a j } , 1 ≤ j ≤ r , we geta solution for the 3-partition instance.The size of ( G, R A ) is polynomial in r . It takes a polynomial time to convert a solutionof ( G, R A ) to a solution of the 3-partition instance and vice versa. Theorem 3.2.
Minimizing the total travel distance of drivers in the ridesharing problem isNP-hard when Conditions (1-3) and (5) are satisfied but Condition (4) is not.Proof.
Let d sum be the sum of travel distances of all trips i with 1 ≤ i ≤ r . Then thetotal travel distances of drivers in any solution for ( G, R A ) is at least d sum = 3 r ( r + 1) byLemma 3.1. We show that an instance A = { a , ..., a r } of the 3-partition problem has asolution if and only if instance ( G, R A ) has a solution with travel distance d sum .Assume that the 3-partition instance has a solution. Then there is a solution of 3 r driversfor ( G, R A ) as shown in the proof of Theorem 3.1. The total travel distance of this solutionis d sum .Assume that ( G, R A ) has a solution with total travel distance d sum . Trips i with 1 ≤ i ≤ r must be drivers. From this, there is a solution for the 3-partition instance as shown in theproof of Theorem 3.1. Based on the results in Section 3.1, we extent our reduction to further show that it is NP-hard to approximate both minimization problems within a constant factor if Condition (4) isnot satisfied. Let (
G, R A ) be the ridesharing problem instance constructed based on a given8-partition instance A as described above for Theorem 3.1. We modify ( G, R A ) to get a newridesharing instance ( G, R (cid:48) ) as follows. For every trip i , 1 ≤ i ≤ r , we multiply n i with rM ,that is, n i = a i · rM , where r and M are given in instance A . There are now rM trips withsources at vertex v j for 1 ≤ j ≤ r , and all such trips have the same destination, capacity,detour, stop limit, earlier departure time, latest arrival time, and preferred path as before.The size of ( G, R (cid:48) ) is polynomial in r and M . Note that Lemma 3.1 holds for ( G, R (cid:48) ) and (cid:80) ri =1 n i = rM (cid:80) ri =1 a i = ( rM ) . Lemma 3.2.
Let ( G, R (cid:48) ) be a ridesharing problem instance constructed above from a 3-partition problem instance A = { a , . . . , a r } . The 3-partition problem instance A has asolution if and only if the ridesharing problem instance ( G, R (cid:48) ) has a solution ( σ, S ) s.t. r ≤ | S | < r + rM , where S is the set of drivers.Proof. Assume that instance A has a solution A , . . . , A r where the sum of elements in each A j is rM . For each A j = { a j , a j , a j } , 1 ≤ j ≤ r , we assign the three trips whose n j = a j · rM , n j = a j · rM and n j = a j · rM as drivers to serve the rM trips withsources at vertex v j . Hence, we have a solution of 3 r drivers for ( G, R (cid:48) ).Assume that (
G, R (cid:48) ) has a solution with 3 r ≤ | S | < r + rM drivers. Let R (cid:48) (1 , r ) be theset of trips in R (cid:48) with labels from 1 to 3 r . By Lemma 3.1, every trip i ∈ R (cid:48) (1 , r ) is a driverin S . Since a i < M/ a i ∈ A , n i < rM · M/ i ∈ R (cid:48) (1 , r ). Fromthis, it requires at least three drivers in R (cid:48) (1 , r ) to serve the rM trips with sources at eachvertex v j , 1 ≤ j ≤ r . For every trip i ∈ R (cid:48) (1 , r ), i can only serve passengers with the samesource due to δ i = 1. There are two cases: (1) | S | = 3 r and (2) 3 r < | S | < r + rM .(1) It follows from the proof of Theorem 3.1 that every three drivers j , j , j of the 3 r drivers serve exactly rM passengers with sources at vertex v j . Then similar, let A j = { a j , a j , a j } , 1 ≤ j ≤ r , we get a solution for the 3-partition problem instance.(2) For every vertex v j , let X j be the set of trips with source v j not served by driversin R (cid:48) (1 , r ). Then 0 ≤ | X j | < rM due to | S | < r + rM . For every trip i ∈ R (cid:48) (1 , r ), n i = a i · rM is a multiple of rM . Hence, the sum of capacity for any trips in R (cid:48) (1 , r ) isalso a multiple of rM , and further, n i + n i (cid:48) = ( a i + a i (cid:48) ) · rM < rM · ( M −
1) for every i, i (cid:48) ∈ R (cid:48) (1 , r ) because a i < M/ a i (cid:48) < M/
2. From these and | X j | < rM , there are 3drivers j , j , j ∈ R (cid:48) (1 , r ) to serve trips with source v j and n j + n j + n j ≥ rM . Because n j + n j + n j ≥ rM for every 1 ≤ j ≤ r and (cid:80) ≤ i ≤ r n i = ( rM ) , n j + n j + n j = rM for every j . Thus, we get a solution with A j = { a j , a j , a j } , 1 ≤ j ≤ r , for the 3-partitionproblem.It takes a polynomial time to convert a solution of ( G, R (cid:48) ) to a solution of the 3-partitioninstance and vice versa.
Theorem 3.3.
Let ( G, R (cid:48) ) be the ridesharing instance stated above based on a 3-partition nstance. Approximating the minimum number of drivers for ( G, R (cid:48) ) within a constant factoris NP-hard. This implies that it is NP-hard to approximate the minimum number of driverswithin a constant factor for a ridesharing instance when Conditions (1-3) and (5) are satisfiedand Condition (4) is not.Proof. Assume that there is a polynomial time c -approximation algorithm C for instance( G, R (cid:48) ) for any constant c >
1. This means that C will output a solution ( σ C , S C ) for ( G, R (cid:48) )such that
OP T ( R (cid:48) ) ≤ | S C | ≤ c · OP T ( R (cid:48) ), where OP T ( R (cid:48) ) is the minimum number ofdrivers for ( G, R (cid:48) ). When the 3-partition instance is a “No” instance, the optimal value for(
G, R (cid:48) ) is
OP T ( R (cid:48) ) ≥ r + rM by Lemma 3.2. Hence, algorithm C must output a value | S C | ≥ r + rM . When the 3-partition instance is a “Yes” instance, the optimal value for( G, R (cid:48) ) is
OP T ( R (cid:48) ) = 3 r . For any constant c >
1, taking M such that c < M/ | S C | from algorithm C on ( G, R (cid:48) ) is 3 r ≤ | S C | ≤ rc < r + rM for a 3-partition“Yes” instance. Therefore, by running the c -approximation algorithm C on any ridesharinginstance ( G, R (cid:48) ) and checking the output value | S C | of C , we can answer the 3-partitionproblem in polynomial time, which contradicts that the 3-partition problem is NP-hardunless P = N P . Theorem 3.4.
It is NP-hard to approximate the total travel distance of drivers within anyconstant factor for a ridesharing instance when Conditions (1-3) and (5) are satisfied andCondition (4) is not.Proof.
Let (
G, R (cid:48) ) be the ridesharing problem instance used in Theorem 3.3, based on a given3-partition instance A = { a , ..., a r } . Let d ( S ) be the sum of travel distances for a set S ofdrivers. Let R (cid:48) (1 , r ) be the set of trips in R (cid:48) with labels from 1 to 3 r . By Lemma 3.1, all of R (cid:48) (1 , r ) must be drivers in any solution for ( G, R (cid:48) ) and d ( R (cid:48) (1 , r )) = 3 r ( r +1). Assume thatthere is a polynomial time c -approximation algorithm C for the ridesharing problem ( G, R (cid:48) )for any constant c >
1. This means that C will output a solution ( σ C , S C ) for ( G, R (cid:48) ) suchthat
OP T ( R (cid:48) ) ≤ d ( S C ) ≤ c · OP T ( R (cid:48) ), where OP T ( R (cid:48) ) is the minimum total travel distanceof drivers for ( G, R (cid:48) ). By Lemma 3.2, when the 3-partition instance is a “No” instance, thenumber of drivers in any solution for (
G, R (cid:48) ) is at least 3 r + rM . All of the rM trips can havesource at vertex v r , so d ( S C ) ≥ r ( r + 1) + rM . When the 3-partition instance is a “Yes”instance, the optimal value for ( G, R (cid:48) ) is
OP T ( R (cid:48) ) = 3 r ( r + 1). For any constant c > M and r such that c < M r +1) + 1. The output d ( S C ) from algorithm C on ( G, R (cid:48) ) is3 r ( r +1) ≤ d ( S C ) ≤ r ( r +1) c < r ( r +1)+ rM for a 3-partition “Yes” instance. Therefore, byrunning the c -approximation algorithm C on any ridesharing instance ( G, R (cid:48) ) and checkingthe output value d ( S C ) of C , we can answer the 3-partition problem in polynomial time,which contradicts that the 3-partition problem is NP-hard unless P = N P .10
NP-hardness result for time constraint condition
Assume that Conditions (1-4) are satisfied but Condition (5) is not, that is, trips can havearbitrary arrival time and departure time. In this case, the ridesharing minimization problemsare NP-hard. The proof is a reduction from the 3-partition problem, which is similar to theone used in Theorem 3.1. Recall that we assume all trips have the same destination whenCondition (1) is satisfied (the same reduction with simple modifications can also be appliedto all trips have the same source).Given a 3-partition minimization problem instance, construct a ridesharing instance(
G, R A ) with G shown in Figure 1. The only differences are the values of α i , β i and δ i . • For trips i , 1 ≤ i ≤ r , source s i = u i , destination t i = D , n i = a i , d i = 0, δ i = n i , α i = 0, β i = 2 r . Each trip i has a preferred path { u i , v } , { v , v } , ..., { v r , D } in G . • For trips i , 3 r + 1 ≤ i ≤ r + rM , source s i = v j , j = (cid:100) ( i − r ) /M (cid:101) , destina-tion t i = D , n i = 0, d i = 0, δ i = 0. Each trip i has a unique preferred path { v j , v j +1 } , { v j +1 , v j +2 } , . . . , { v r , D } in G , α i = r and β i = 2 r − j + 1, where j = (cid:100) ( i − r ) /M (cid:101) .Note that every trip i ∈ R A has the same travel distance from s i to t i as previous constructionin Section 3. Since they have the same construction, Lemma 3.1 also holds for this ridesharinginstance ( G, R A ). Lemma 4.1.
In any solution for the instance ( G, R A ) , all trips served by a driver i ∈ R A (other than i itself ), must have the same source v j , for some j ∈ [1 , . . . , r ] .Proof. By Lemma 3.1, every trip i , 1 ≤ i ≤ r , is a driver in any solution. Thus, only tripswith source v j , 1 ≤ j ≤ r , can be passengers. Let j be a trip with source v j . The traveltime from v j to D is r − j + 1. Since β j = 2 r − j + 1, j must be picked-up no later thantime r . Otherwise, j cannot arrive at t j = D by time β j . From this and the fact that α j = r , j must be picked-up at time r exactly. Suppose that driver i serves trip j . The travel timefrom s i to s j = v j is j ≤ r . i can arrive at D (after delivering j ) no later than time 2 r = β i .Let j and j be two trips with s j = v j , s j = v j and j < j . Then any trip i with1 ≤ i ≤ r can serve only one of j and j due to the following reasons. Suppose i picks-up j first. By the time i reaches v j after picking-up j , it will pass time r , and from above, i can no longer serve j . Otherwise, j will not be arrive on time. Suppose i picks-up j first.When i reaches v j by going back, it will also pass time r . Hence, i cannot serve j in thiscase. Therefore, if i decides to serve a trip j with source v j , the only other trips i can servemust also have source v j . 11emma 4.1 actual implies that every driver i (1 ≤ i ≤ r ) in any solution for ( G, R A ) willonly make at most one stop, effectively making δ i = 1. Theorem 4.1.
Minimizing the number of drivers in the ridesharing problem is NP-hard whenConditions (1-4) are satisfied but Condition (5) is not.Proof.
Assume that the 3-partition instance has a solution A , ..., A r where the sum of ele-ments in each A j is M . For each A j = { a j , a j , a j } , 1 ≤ j ≤ r , we assign the three tripswhose n j = a j , n j = a j and n j = a j as drivers to serve the M trips with sources at vertex v j . Hence, we have a solution of 3 r drivers for ( G, R A ).Assume that ( G, R A ) has a solution of 3 r drivers. By Lemma 3.1, every trip i , 1 ≤ i ≤ r ,is a driver in the solution. Similarly, each driver i serves exactly n i = a i passengers, andat least three drivers are required to serve the M passengers with sources at each vertex v j , 1 ≤ j ≤ r . By Lemma 4.1, each driver i , 1 ≤ i ≤ r , can only serve passengers withthe same source. Therefore, the solution of 3 r drivers has exactly three drivers j , j , j toserve the M passengers with sources at the vertex v j , implying a j + a j + a j = M . Let A j = { a j , a j , a j } , 1 ≤ j ≤ r , we get a solution for the 3-partition problem instance.The size of ( G, R A ) is polynomial in r . It takes a polynomial time to convert a solutionof ( G, R A ) to a solution of the 3-partition instance and vice versa.With a similar argument to that of Theorem 3.2, we have the following theorem. Theorem 4.2.
Minimizing the total travel distance of drivers in the ridesharing problem isNP-hard when Conditions (1-4) are satisfied but Condition (5) is not.
It is NP-hard to approximate the minimum number of drivers and total travel distanceof drivers within a constant factor for the ridesharing problem when Conditions (1-4) aresatisfied but condition (5) is not. The proofs are identical to the inapproximability proofof Theorem 3.3 and Theorem 3.4 respectively for each minimization problem. Let (
G, R A )be the ridesharing problem instance constructed based on a given 3-partition instance asdescribed above for Theorem 4.1. Construct a ridesharing instance ( G, R (cid:48) ) from (
G, R A ) asdescribed in Section 3.2. Then Lemma 3.2 and Lemma 4.1 can be applied to ( G, R (cid:48) ). Fromthis, the analysis of Theorem 3.3 and Theorem 3.4 can be applied to (
G, R (cid:48) ), and we havethe following theorems.
Theorem 4.3.
It is NP-hard to approximate the minimum number of drivers within anyconstant factor for a ridesharing instance satisfying Conditions (1-4) but not Condition (5). heorem 4.4. It is NP-hard to approximate the minimum total travel distance of driverswithin any constant factor for a ridesharing instance satisfying Conditions (1-4) but notCondition (5).
For short, we call the ridesharing problem with all conditions satisfied except Condition (4)as ridesharing problem with stop constraint . Let K = max i ∈ R n i be the largest capacityof all vehicles. Kutiel and Rawitz [13] proposed two -approximation algorithms for themaximum carpool matching problem. We show in this section that the algorithms in [13]can be modified to K +22 -approximation algorithms for minimizing the number of drivers inthe ridesharing problem with stop constraint. Then in the next section, we propose a morepractical K +22 -approximation algorithm for the minimization problem.An instance of the maximum carpool matching problem (MCMP) consists of a directedgraph H ( V, E ), a capacity function c : V → N , and a weight function w : E → R + , wherethe vertices of V represent the individuals and there is an arc ( u, v ) ∈ E if v can serve u . Weare only interested in the unweighted case, that is, w ( u, v ) = 1 for every ( u, v ) ∈ E . Every v ∈ V can be assigned as a driver or passenger. The goal of MCMP is to find a set of drivers S ⊆ V to serve all V such that the number of passengers is maximized. A solution to MCMPis a set S of vertex-disjoint stars in H . Let S v be a star in S rooted at center vertex v , andleaves of S v is denoted by P v = V ( S v ) \ { v } . For each star S v ∈ S , vertex v has out-degreeof 0 and every leave in P v has only one out-edge towards v . The center vertex of each star S v is assigned as a driver and the leaves are assigned as passengers. The set of edges in S iscalled a matching M . An edge in M is called a matched edge. Notice that | M | equals to thenumber of passengers. For an arc e = ( u, v ) in H , vertices u and v are said to be incidentto e . For a matching M and a set V (cid:48) ⊆ V of vertices, let M ( V (cid:48) ) be the set of edges in M incident to V (cid:48) . The in-neighbors of a vertex v is defined as N in ( v ) = { u | ( u, v ) ∈ E } , andthe set of arcs entering v is defined as in-arcs E in ( v ) = { ( u, v ) | ( u, v ) ∈ E } . Table 2 liststhe basic notation and definition for this section.Two approximation algorithms (StarImprove and EdgeSwap) are presented in [13]; bothcan achieve -approximation ratio, that is, the number of passengers found by the algorithmis at least half of that for the optimal solution. EdgeSwap
The EdgeSwap algorithm requires the input instance to have a bounded degreegraph (or the largest capacity K is bound by a constant) to have a polynomial running time.The idea of EdgeSwap is to swap i matched edges in M with i +1 edges in E \ M for 1 ≤ i ≤ k and k is a constant integer. The running time of EdgeSwap is in the order of O ( | E | k +1 ).13 otation Definition S A set of vertex-disjoint stars in H (solution to MCMP) S v and P v Star S v rooted at center vertex v with leaves P v = V ( S v ) \ { v } c ( v ) Capacity of vertex v (equivalent to n v in Table 1)Matching M The set of edges in S M ( V (cid:48) ) The set of edges in M incident to a set V (cid:48) of vertices N in ( v ) The set of in-neighbors of v , N in ( v ) = { u | ( u, v ) ∈ E } E in ( v ) The set of arcs entering v , in-arcs E in ( v ) = { ( u, v ) | ( u, v ) ∈ E } δP v The number of stops required for v to pick-up P v Table 2: Common notation and definition used in this section.EdgeSwap can directly apply to the minimization problem to achieve K +22 -approximationratio in O ( l K ) time, which may not be practical even if K is a small constant. StarImprove
Let ( H ( V, E ) , c, w ) be an instance of MCMP. Let S be the current set ofstars found by StarImprove and M be the set of matched edges. The idea of the StarImprovealgorithm is to iteratively check in a for-loop for every vertex v ∈ V ( G ): • check if there exists a star S v with E ( S v ) ∩ M = ∅ such that the resulting set of stars S\ M ( V ( S v )) ∪ S v gives a larger matching.Such a star S v is called an improvement and | P v | ≤ c ( v ). Given a ridesharing instance( G, R ) satisfying all conditions, except Condition (4). The StarImprove algorithm cannotapply to (
G, R ) directly because the algorithm assumes a driver v can serve any combinationof passengers corresponding to vertices adjacent to v up to c ( v ). This is not the case for( G, R ) in general. For example, suppose v can serve u and u with n v = 2 and δ v = 1.The StarImprove assigns v as a driver to serve both u and u . However, if u and u havedifferent sources ( s v (cid:54) = s u (cid:54) = s u ), this assignment is not valid for ( G, R ). Hence, we needto modify StarImprove for computing a star. For a vertex v and star S v , let N in - M ( v ) = { i | i ∈ N in \ V ( M ) } and δP v be the number of stops required for v to pick-up P v . Suppose thein-neighbors N in - M ( v ) are partitioned into g ( v ) , . . . , g m ( v ) groups such that trips with samesource are grouped together. When stop constraint is considered, finding a star S v withmaximum | P v | is similar to solving a fractional knapsack instance using a greedy approachas shown in Figure 2. Lemma 5.1.
Let v be the trip being processed and S v be the star found by Algorithm 1 w.r.t.current matching M . Then | P v | ≥ | P (cid:48) v | for any star S (cid:48) v s.t. P (cid:48) v ∩ M = ∅ . lgorithm 1 Greedy algorithm P v = ∅ ; c = c ( v ); δP v = 0; if ∃ a group g j ( v ) s.t. s u = s v for any u ∈ g j ( v ) then if | g j ( v ) | ≤ c then P v = P v ∪ g j ( v ); c = c − | g j ( v ) | ; else P v = P v ∪ g (cid:48) j ( v ), where g (cid:48) j ( v ) ⊆ g j ( v ) with | g (cid:48) j ( v ) | = c . c = 0; end if while c > δP v < δ v do Select g i ( v ) = max ≤ i ≤ m {| g i ( v ) \ P v |} ; if | g i ( v ) | ≤ c then P v = P v ∪ g i ( v ); c = c − | g i ( v ) | ; δP v = δP v + 1; else P v = P v ∪ g (cid:48) i ( v ), where g (cid:48) i ( v ) ⊆ g i ( v ) with | g (cid:48) i ( v ) | = c . c = 0; δP v = δP v + 1; end while return the star S v induced by P v ∪ { v } ; Figure 2: Greedy algorithm for computing S v . Proof.
Assume for contradiction, | P (cid:48) v | > | P v | for some star S (cid:48) v s.t. P (cid:48) v ∩ M = ∅ . Since | P (cid:48) v | > | P v | , c ( v ) > | P v | . For any trip u ∈ N in - M ( v ), let g i u ( v ) be the group s.t. u ∈ g i u ( v ). Let u ∈ P (cid:48) v \ P v . Note that s u (cid:54) = s v ; otherwise, u would have been included in P v by the greedyalgorithm, and hence, δ v >
0. From c ( v ) > | P v | and δ v >
0, the greedy algorithm musthave executed the while-loop and checked all the groups in decreasing order of their size,and δP v = δ v at the end of the while-loop. Because c ( v ) > | P v | , | P v ∩ g i w ( v ) | = | g i w ( v ) | ≥| P (cid:48) v ∩ g i w ( v ) | for any w ∈ P (cid:48) v ∩ P v . Since groups are checked in decreasing order of their size, | P v ∩ g i ( v ) | ≥ | P (cid:48) v ∩ g i u ( v ) | for every group g i ( v ) and every u ∈ P (cid:48) v \ P v . Recall that δP v = δ v .Hence, | P v | ≥ | P (cid:48) v | , which is a contradiction. Definition 5.1.
A star S v rooted at v is an improvement with respect to matching M if | P v | ≤ c ( v ) , δP v ≤ δ v and | S v | − (cid:80) ( u,v ) ∈ E ( S v ) | M ( u ) | > | M ( v ) | . Definition 5.1 is equivalent to the original definition in [13], except the former is for theunweighted case and stop constraint. When an improvement is found, the current matching M is increased by exactly | S v | − (cid:80) ( u,v ) ∈ E ( S v ) | M ( u ) | edges. For a vertex v and a subset S ⊆ E in ( v ), let N inS ( v ) = { u | ( u, v ) ∈ S } . Lemma 5.2.
Let M be the current matching and v be a vertex with no improvement. Let S v ⊆ E in ( v ) s.t. | S v | ≤ c ( v ) and δP v ≤ δ v , then | S v | ≤ | M ( v ) | + | M ( N inS v ( v )) | . Further, ifthe star S v found by Algorithm 1 w.r.t. M is not an improvement, then no other S (cid:48) v is animprovement.Proof. When no improvement exists for a vertex v , we get | S v | − | M ( N inS v ( v )) | = | S v | − (cid:80) ( u,v ) ∈ S v | M ( u ) | ≤ | M ( v ) | by Definition 5.1. 15o maximize | S v | , we need to maximize | S v | − (cid:80) ( u,v ) ∈ S v | M ( u ) | , which can be done byselecting only in-neighbors of v that are not in matching M . This is because for any ( u, v ) ∈ S v s.t. u is incident to a matched edge, | M ( u ) | ≥
1. In other words, including such avertex u cannot increase | S v | − (cid:80) ( u,v ) ∈ S v | M ( u ) | . Algorithm 1 considers only in-neighbors N in - M ( v ) = { i | i ∈ N in \ V ( M ) } . By Lemma 5.1, | P v | is maximized among all stars rooted at v w.r.t. M . Hence, lemma holds.Lemma 5.2 is equivalent to Lemma 5 of [13], except the former is for the unweighted caseand stop constraint. By Lemma 5.2 and the same argument of Lemma 6 in [13], we have thefollowing lemma. Lemma 5.3.
The modified StarImprove algorithm computes a solution to an instance ofridesharing problem with stop constraint with -approximation. Theorem 5.1.
Let ( G, R ) be a ridesharing instance satisfying all conditions, except condition(4). Let | S ∗ | be the minimum number of drivers for ( G, R ) , l = | R | and K = max i ∈ R n i .Then, • The EdgeSwap algorithm computes a solution ( σ, S ) for ( G, R ) s.t. | S ∗ | ≤ | S | ≤ K +22 | S ∗ | with running time O ( M + l K ) . • The modified StarImprove algorithm computes a solution ( σ, S ) for ( G, R ) s.t. | S ∗ | ≤| S | ≤ K +22 | S ∗ | with running time O ( M + K · l ) , where M is the size of a ridesharinginstance which contains a road network and l trips.Proof. First, we need to construct a directed graph H R to represent the serve relation of thetrips in R as described in [8], which takes O ( M ) time. Then reverse the direction of all arcsin H R , and this gives an instance can be solved by the EdgeSwap and modified StarImprovealgorithms. Then, the first bullet point of the Lemma is due to the EdgeSwap paragraphstated above. The rest of the proof is for the second bullet point.By Lemma 5.3, the modified StarImprove algorithm finds a solution to ( G, R ) with atleast ( l − | S ∗ | ) / | S | ≤ l − ( l − | S ∗ | ) / l + | S ∗ | ) / l −| S ∗ | passengers in the optimal solution, implying | S ∗ | ≥ ( l −| S ∗ | ) /K = l/ ( K +1),so l ≤ ( K + 1) | S ∗ | . Therefore, | S | ≤ ( l + | S ∗ | ) / ≤ (( K + 1) | S ∗ | + | S ∗ | ) / K + 2) | S ∗ | / v to see if an im-provement can be found, that is, it takes O ( l ) time to check all in-neighbors of v to see if astar S v that can increase | M | exists, where M is the current matching. In total, the for-loop16akes O ( l ) time. Then for the modified StarImprove, it takes O ( K · l ) time; O ( K · l ) timefor computing S v if it exists. After an improvement is made each time, StarImprove scansevery vertex again to check for another improvement until no improvement can be found,and this takes O ( l ) time due to at most O ( l ) improvements can be made for the unweightedcase. Thus, in total, the modified StarImprove has a running time of O ( M + K · l ). In this section, we present our new approximation algorithm, which has a better runningtime than the approximation algorithms based on MCMP. For our proposed algorithm, weassume the serve relation is transitive, that is, trip i can serve trip j and j can serve trip k imply i can serve k . In general, if each trip has a unique preferred path and trip i can servetrip j implies j ’s preferred path is a subpath of i ’s preferred path, then the serve relation istransitive. Given a ridesharing instance (
G, R ), we construct a directed meta graph Γ(
V, E ) to expressthe serve relation, where V (Γ) represents the start locations of all trips in ( G, R ). Each node µ of V (Γ) contains all trips with the same start location µ . There is an arc ( µ, ν ) in E (Γ)if a trip in µ can serve a trip in ν . Since Conditions (1-3) are satisfied, if one trip in µ canserve a trip in ν , any trip in µ can serve any trip in ν . We say node µ can serve node ν .An arc ( µ, ν ) in Γ is called a short cut if after removing ( µ, ν ) from Γ, there is a path from µ to ν in Γ. We simplify Γ by removing all short cuts from Γ. In what follows, we use Γfor the simplified meta graph. Notice that Γ is an inverse tree and for every pair of nodes µ and ν in Γ, if there is a path from µ to ν then µ can serve ν . We label the nodes of Γ as V (Γ) = { µ p , µ p − , ..., µ } , where p = | V (Γ) | , in such a way that for every arc ( µ b , µ a ) of Γ, b > a , and we say µ b has a larger label than µ a . The labeling is done by the procedure in [8](see Figure 5, Appendix). Figure 3 shows an example of a graph Γ( V, E ). Each node in Γwithout an incoming arc is called an origin , and µ is the unique sink. Table 3 contains thebasic notation and definition for this section.We divide all trips of R into two sets W and X as follows. Let W = { i ∈ R | n i =0 } ∪ { i ∈ R ( µ ) | δ i = 0 and | R ( µ ) = 1 | for every node µ ∈ V (Γ) } and X = R \ W . For anode µ in Γ, let X ( µ ) = X ∩ R ( µ ) and W ( µ ) = W ∩ R ( µ ). Our algorithm tries to minimize thenumber of drivers that only serve itself. There are three phases in the algorithm. In Phase-I,it serves all trips of W and tries to minimize the number of trips in W that are assigned as17igure 3: (a) a set R of 10 trips with same destination D in the road network graph G . (b)The directed meta graph expressing the serve relation of these trips with shortcuts in dashedarcs. (c) The simplified meta graph, which is an inverse tree. Notation Definition Γ( V, E ) A directed graph expressing the serve relation and p = | V (Γ) | µ is an ancestor of ν If ∃ a nonempty path from µ to ν in Γ ( ν is a descendant of µ ) A µ and A ∗ µ Set of ancestors of µ and A ∗ µ = A µ ∪ { µ } respectively D µ and D ∗ µ Set of descendants of µ and D ∗ µ = D µ ∪ { µ } respectively R ( µ ) and R ( U ) Set of trips in a node µ and in a set U of nodes respectively S ( µ ) and S ( U ) Set of drivers in a node µ and in nodes U respectivelynode( i ) The node that contains trip i (if i ∈ R ( µ ) then node( i ) = µ )Table 3: Basic notation and definition used in this section.drivers since each trip of W can serve only itself. Let Z be the set of unserved trips afterPhase-I such that for every i ∈ Z , δ i = 0. In Phase-II, it serves all trips of Z and tries tominimize the number of such drivers of Z , each only serves itself. In Phase III, it serves allremaining trips. Let ( S, σ ) be the current partial solution and i ∈ R be a driver. Denoted byfree( i ) = n i − | σ ( i ) | + 1 is the remaining seats (capacity) of i with respect to solution ( S, σ ).Denoted by stop( i ) is the number of stops i has to made in order to serve all trips in σ ( i ) w.r.t.( S, σ ). Initially, free( i ) = n i and stop( i ) = 0 for all i ∈ R for initial solution ( S, σ ) = ( ∅ , ∅ ).For a driver i and node µ , we define R ( i, µ, S ) as the set of min { free( i ) , | R ( µ ) \ σ ( S ) |} tripsin R ( µ ) \ σ ( S ) and W ( i, µ, S ) as the set of min { free( i ) , | W ( µ ) \ σ ( S ) |} trips in W ( µ ) \ σ ( S ),and similarly for Z ( i, µ, S ). The three phases of the approximation algorithm (Algorithm 2)are described in following, and the pseudo code is given in Figure 4.18 Phase-I)
In this phase, the algorithm assigns a set of drivers to serve all trips of W . LetΓ( W ) = { µ ∈ V (Γ) | W ( µ ) \ σ ( S ) (cid:54) = ∅} , and each node of Γ( W ) is processed. In eachiteration, the node µ = argmax µ ∈ Γ( W ) | W ( µ ) \ σ ( S ) | is selected and a subset of trips in W ( µ ) \ σ ( S ) is served by a driver as follows: • Let ˆ X = { i ∈ S ( A µ ) | free( i ) > ∧ stop( i ) < δ i } and ¯ X = { i ∈ X ∩ R ( A ∗ µ ) \ σ ( S ) | stop( i ) < δ i ∨ i ∈ R ( µ ) } . The algorithm finds and assigns a trip x as a driver to serve W ( x, µ, S ) s.t. x = argmin x ∈ ˆ X ∪ ¯ X : n x ≥| W ( µ ) \ σ ( S ) | δ x − stop( x ). – If such a trip x does not exist, it means that n x < | W ( µ ) \ σ ( S ) | for every x ∈ ˆ X ∪ ¯ X assuming ˆ X ∪ ¯ X (cid:54) = ∅ . Then, x = argmax x ∈ ˆ X ∪ ¯ X free( x ) is assigned as a driverto serve W ( x, µ, S ). If there is more than one x with same free( x ), the trip withsmallest δ x − stop( x ) is selected. • When ˆ X ∪ ¯ X = ∅ , assign every w ∈ W ( µ ) \ σ ( S ) as a driver to serve itself. (Phase-II) In the second phase, all trips of Z = { i ∈ R \ σ ( S ) | δ i = 0 } will be served.Let Γ( Z ) = { µ ∈ Γ | Z ( µ ) = ( Z ∩ R ( µ )) (cid:54) = ∅} . Each node µ of Γ( Z ) is processed in thedecreasing order of their node labels. • If | Z ( µ ) | ≥
2, trip x = argmax x ∈ Z ( µ ) n x is assigned as a driver and serves Z ( x, µ, S )consists of trips with smallest capacity among trips in Z ( µ ) \ σ ( S ). • This repeats until | Z ( µ ) | ≤
1. Then next node in Γ( Z ) is processed.After all nodes of Γ( Z ) are processed, if Z is still non-empty, each node µ of Γ( Z ) is processedagain; note that every µ contains exactly one z ∈ Z ( µ ) now. • A driver x ∈ ˆ X = { i ∈ S ( A ∗ µ ) | free( i ) > ∧ (stop( i ) < δ i ∨ i ∈ R ( µ )) } with largestfree( x ) is selected to serve z = Z ( µ ) if ˆ X (cid:54) = ∅ . • If ˆ X = ∅ , a trip x ∈ ¯ X = { i ∈ X ∩ R ( A ∗ µ ) \ σ ( S ) | stop( i ) < δ i ∨ i ∈ R ( µ ) } with largest δ x is selected to serve z = Z ( µ ). (Phase-III) To serve all remaining trips, the algorithm processes each node of Γ in decreasingorder of node labels from µ p to µ . Let µ j be the node being processed by the algorithm.Suppose there are trips in R ( µ j ) that have not be served, that is, R ( µ j ) (cid:42) σ ( S ). • A driver x ∈ ˆ X = { i ∈ S ( A ∗ µ j ) | free( i ) > ∧ (stop( i ) < δ i ∨ i ∈ R ( µ j )) } with largestfree( x ) is selected if ˆ X (cid:54) = ∅ . • If ˆ X = ∅ , a trip x = argmax x ∈ X ( µ j ) \ σ ( S ) n x is assigned as a driver. If the largest n x isnot unique, the trip with the smallest δ x is selected. • In either case, x is assigned to serve R ( x, µ j , S ). This repeats until all of R ( µ j ) areserved. Then, next node µ j − is processed.19 lgorithm 2 Practical approximation algorithm
Input:
A ridesharing instance (
G, R ) and the meta graph Γ (inverse tree) for (
G, R ). Output:
A solution (
S, σ ) for (
G, R ) with K +22 -approximation ratio. Label every node of Γ as V (Γ) = { µ p , µ p − , ..., µ } , p = | V (Γ) | , by the label procedure. ( S, σ ) = ( ∅ , ∅ ). Let Γ( W ) = { µ ∈ V (Γ) | W ( µ ) \ σ ( S ) (cid:54) = ∅} . while Γ( W ) (cid:54) = ∅ do /* Beginning of Phase-I */ Compute µ = argmax µ ∈ Γ( W ) | W ( µ ) \ σ ( S ) | . Let ˆ X = { i ∈ S ( A µ ) | free( i ) > ∧ stop( i ) < δ i } and ¯ X = { i ∈ X ∩ R ( A ∗ µ ) \ σ ( S ) | stop( i ) < δ i ∨ i ∈ R ( µ ) } . if ˆ X ∪ ¯ X (cid:54) = ∅ then Compute x = argmin x ∈ ˆ X ∪ ¯ X : n x ≥| W ( µ ) \ σ ( S ) | δ x − stop( x ). if x == ∅ then x = argmax x ∈ ˆ X ∪ ¯ X free( x ) with the smallest δ x − stop( x ). if x / ∈ S then S = S ∪ { x } ; σ ( x ) = { x } ; σ ( x ) = σ ( x ) ∪ W ( x, µ, S ); update free( x ) and stop( x ); else for each w ∈ W ( µ ) \ σ ( S ), S = S ∪ { w } , σ ( w ) = { w } ; update free( w ); end if end while /* End of Phase-I. Below is Phase-II */ Let Z = { i ∈ R \ σ ( S ) | δ i = 0 } and Γ( Z ) be the set of nodes containing Z . for each node µ ∈ Γ( Z ) in decreasing order of the node labels do while | Z ( µ ) | ≥ do Compute x = argmax x ∈ Z ( µ ) n x . S = S ∪ { x } ; σ ( x ) = { x } ; σ ( x ) = σ ( x ) ∪ Z ( x, µ, S ) where Z ( x, µ, S ) consists of trips with smallest capacity; update free( x ) and stop( x ); update Z . end while end for for each node µ ∈ Γ( Z ) in decreasing order of node labels do /* implying | Z ( x, µ, S ) | = 1 */ Let ˆ X = { i ∈ S ( A ∗ µ ) | free( i ) > ∧ (stop( i ) < δ i ∨ i ∈ R ( µ )) } . if ˆ X (cid:54) = ∅ then Compute x = argmax x ∈ ˆ X free( x ). else Let ¯ X = { i ∈ X ∩ R ( A ∗ µ ) \ σ ( S ) | stop( i ) < δ i ∨ i ∈ R ( µ ) } . Compute x = argmax x ∈ ¯ X δ x . if x / ∈ S then S = S ∪ { x } ; σ ( x ) = { x } ; σ ( x ) = σ ( x ) ∪ Z ( x, µ, S ); update free( x ) and stop( x ); end for /* End of Phase-II. Below is Phase-III */ for each node µ from µ p to µ do while R ( µ ) (cid:42) σ ( S ) do Let ˆ X = { i ∈ S ( A ∗ µ ) | free( i ) > ∧ (stop( i ) < δ i ∨ i ∈ R ( µ )) } . if ˆ X (cid:54) = ∅ then Compute x = argmax x ∈ ˆ X free( x ). else Compute x = argmax x ∈ X ( µ ) \ σ ( S ) n x (with smallest δ x as a tiebreaker) if x / ∈ S then S = S ∪ { x } ; σ ( x ) = { x } ; σ ( x ) = σ ( x ) ∪ R ( x, µ, S ); update free( x ) and stop( x ); end while end for Figure 4: Algorithm for approximating the minimum number of drivers.20 .2 Analysis of new approximation algorithm
A driver in a solution is called a solo driver if it serves only itself. Algorithm 2 tries tominimize the number of solo drivers. Recall that W is the set of trips, each of which canserve only itself. The algorithm, in Phase-I, computes a partial solution to serve all trips of W and tries to assign as few trips of W to be drivers as possible. In Phase-II, the set Z ofunserved trips after Phase-I (every i ∈ Z has δ i = 0) is served. The rationale to serve suchset of trips is that many trips of Z can become solo drivers if all trips of R (node( i )) \ { i } for i ∈ Z are served before i is processed or considered. This can cause Z to have thesame characteristic as W , so we need to treat Z separately. Let λ be the number of solodrivers in a solution computed by Algorithm 2 and λ ∗ be the number of solo drivers in anyoptimal solution. Then there are at most ( | R | − λ ) / λ drivers in the solution computed byAlgorithm 2 and at least ( | R | − λ ∗ ) / ( K + 1) + λ ∗ drivers in the optimal solution. A centralline of the analysis is to show that λ ∗ is close to λ which guarantees the approximation ratioof Algorithm 2We now introduce some notation used in our analysis. Denoted by ( S, σ ) is the completesolution computed by Algorithm 2. Denoted by ( S I , σ I ) is the partial solution computed atthe end of Phase-I, so all trips of W are served by drivers in S I . For every driver i ∈ S I ,( σ I ( i ) \ { i } ) ∩ ( R \ W ) = ∅ . Let S I ( X ) = S I ∩ X and S I ( W ) = S I ∩ W = S I \ S I ( X ). Notethat each driver i ∈ S I ( X ) must serve at least one trip from W and σ I ( S I ( X )) \ S I ( X ) ⊆ W if S I ( X ) (cid:54) = ∅ . Let W = { W , . . . , W e } such that each W j (1 ≤ j ≤ e ) is the set of tripsserved by a driver (or drivers) in S I for iteration j . For each W j , W j is a subset of W ( µ a j )for some node µ a j (indexed at a j ), and let ( S j , σ j ) be the partial solution just after serving W j , 1 ≤ j ≤ e . For a driver i ∈ S j , free j ( i ) = n i − | σ j ( i ) | + 1 is the remaining available seats(capacity) of i w.r.t. ( S j , σ j ). Similarly for stop j ( i ), which is the number of stops i has tomade in order to serve all trips in σ j ( i ) w.r.t. ( S j , σ j ). Property 6.1.
Every trip i that is assigned as a driver, i remains a driver until the algorithmterminates and free( i ) is non-increasing throughout the algorithm. Notice that each set W j of trips either are served by one driver or W j ⊆ S I ( W ). For clarity,we denote each set W j ⊆ S I ( W ) by ˜ W j . When trips of ˜ W j are assigned as drivers to servethemselves, all other trips W ( µ a j ) \ ˜ W j must have been served by drivers in S j − such that nodriver in S j − or trip in X \ σ j − ( S j − ) can serve ˜ W j . In other words, ˜ W j = W ( µ a j ) \ σ j − ( S j − )and ¯ X ∪ ˆ X = ∅ w.r.t. ( S j − , σ j − ), so the algorithm has the following property. Property 6.2.
For every pair ˜ W i and ˜ W j ( i (cid:54) = j ), µ a i (cid:54) = µ a j . Suppose ( S ∗ , σ ∗ ) is an optimal solution for ( G, R ) with | S ∗ | minimized. We first show, inLemma 6.1, that the number of trips in S I ( W ) served by S ∗ is at most that of the passengers21erved by σ I ( S I ( X )). The proof idea is as follows. Let U ⊆ S ∗ be the set of drivers such thatfor every u ∈ U , σ ∗ ( u ) ∩ S I ( W ) (cid:54) = ∅ and U ∩ W = ∅ . We prove that U are also drivers in S I (specifically, U ⊆ S I ( X )) and σ I ( u ) serves at least | σ ∗ ( u ) ∩ S I ( W ) | passengers for each u ∈ U . Lemma 6.1.
Let ( S ∗ , σ ∗ ) be an optimal solution for ( G, R ) and S ∗ ( W ) = W ∩ S ∗ . Let U ⊆ S ∗ be the set of drivers that serve all trips of W \ S ∗ ( W ) . Then | σ I ( S I ( X )) \ S I ( X ) | ≥| σ ∗ ( U ) ∩ S I ( W ) | .Proof. Let U j be the set of drivers in S ∗ that serve ( W ∪ . . . ∪ W j ) \ S ∗ ( W ) for 1 ≤ j ≤ e .Note that W = W ∪ . . . ∪ W e and U e = U . Let ˜ W a , . . . , ˜ W a d be the sets computed by thealgorithm such that ˜ W a b ⊆ S I ( W ) , ≤ b ≤ d , and for 1 ≤ b < c ≤ d , ˜ W a b is computedbefore ˜ W a c . For each ˜ W a b , the drivers of U a b that serve ˜ W a b \ S ∗ ( W ) can be partitioned intotwo sets: (1) U (cid:48) a b = { u ∈ U a b | σ ∗ ( u ) ∩ ˜ W a b (cid:54) = ∅ and u ∈ R ( µ a b ) } and (2) U (cid:48)(cid:48) a b = { u ∈ U a b | σ ∗ ( u ) ∩ ˜ W a b (cid:54) = ∅ and u ∈ R ( A µ ab ) } . We consider them separately.(1) Due to W ( µ a b ) (cid:54) = ∅ ( µ a b ∈ Γ( W )), the algorithm must have already assigned every u ∈ U (cid:48) a b as a driver in S a b − when µ a b is processed since such a trip u must be includedin ¯ X w.r.t. the partial solution just before µ a b is processed. Further, it must be thatfree a b − ( u ) = 0. Otherwise, σ a b − ( u ) would have served trips from ˜ W a b , a contradiction tothe algorithm. From free a b − ( u ) = 0, | σ a b ( u ) ∩ W | ≥ | σ ∗ ( u ) ∩ W | for every u ∈ U (cid:48) a b , that is, | (cid:83) u ∈ U (cid:48) ab σ a b ( u ) ∩ W | ≥ | (cid:83) u ∈ U (cid:48) ab σ ∗ ( u ) ∩ W | .(2) Every u ∈ U (cid:48)(cid:48) a b must also be a driver in S a b − with free a b ( u ) < n u . Otherwise, u wouldhave been assigned (from unassigned) as a driver in S a b to serve trips from ˜ W a b . We furtherdivide U (cid:48)(cid:48) a b into two subsets: U (cid:48)(cid:48) a b (0) = { u ∈ U a b | free a b ( u ) = 0 } and U (cid:48)(cid:48) a b (1) = { u ∈ U a b | free a b ( u ) ≥ } . We consider U (cid:48)(cid:48) a b (0) in case (2.1) and U (cid:48)(cid:48) a b (1) in case (2.2).(2.1) For every u ∈ U (cid:48)(cid:48) a b (0), | σ a b ( u ) ∩ W | ≥ | σ ∗ ( u ) ∩ W | since free a b ( u ) = 0. This implies that | (cid:83) u ∈ U (cid:48)(cid:48) ab (0) σ a b ( u ) ∩ W | ≥ | (cid:83) u ∈ U (cid:48)(cid:48) ab (0) σ ∗ ( u ) ∩ W | . (2.2) Consider any driver u ∈ U (cid:48)(cid:48) a b (1). Let W j be a non-empty set of passengers served by σ a b ( u ). Notice that W j is computed before ˜ W a b .Recall that W j ⊆ W ( µ a j ), W j are the only passengers in W ( µ a j ) served by u , and ( S j − , σ j − )is the partial solution just before trips of W j are served. From free j − ( u ) > free a b ( u ) > W j = W ( µ a j ) \ σ j − ( S j − ) must be served by σ j ( u ), implying | W j | < free j − ( u ). Since W j iscomputed before ˜ W a b , | ˜ W a b | ≤ | W ( µ a b ) \ σ j − ( S j − ) | ≤ | W ( µ a j ) \ σ j − ( S j − ) | < free j − ( u ),meaning | W j | ≥ | ˜ W a b | for every set W j of passengers served by σ a b ( u ).From the proofs of cases (1) and (2), U ⊆ S I ( X ). If U (cid:48)(cid:48) a b (1) ∩ U (cid:48)(cid:48) a c (1) = ∅ for any 1 ≤ b < c ≤ d , then for each u b ∈ U (cid:48)(cid:48) a b (1) and each u c ∈ U (cid:48)(cid:48) a c (1), u b (cid:54) = u c ; and for every set W j b of passengers served by σ j b ( u b ), | W j b | ≥ | ˜ W a b | , and for every set W j c served by σ j c ( u c ), | W j c | ≥ | ˜ W a c | . Assume that U (cid:48)(cid:48) a b (1) ∩ U (cid:48)(cid:48) a c (1) (cid:54) = ∅ for some 1 ≤ b < c ≤ d . Consider any driver u ∈ U (cid:48)(cid:48) a b (1) ∩ U (cid:48)(cid:48) a c (1). By definition, u serves trips from both ˜ W a b and ˜ W a c . Since free a c ( u ) > a c ( u ) = δ u . It must be that free a b ( u ) ≥ free a c ( u ) > a b ( u ) = δ u (otherwise,22 a b ( u ) would have served trips from ˜ W a b ). From this and µ a b (cid:54) = µ a c (by Property 6.2), σ a c ( u ) serves at least two sets W j b and W j c of passengers before ˜ W a b is computed. Similarto case (2.2) above, | W j b | ≥ | ˜ W a b | and | W j c | ≥ | ˜ W a c | . This can be generalized to all sets˜ W a , . . . , ˜ W a d ⊆ S I ( W ) such that trips of ˜ W a b \ S ∗ ( W ) are served by U a b for 1 ≤ b ≤ d . We get | (cid:83) u ∈ U (cid:48) ab ∪ U (cid:48)(cid:48) ab , ≤ b ≤ d σ a b ( u ) ∩ W | ≥ | (cid:83) u ∈ U (cid:48) ab ∪ U (cid:48)(cid:48) ab , ≤ b ≤ d σ ∗ ( u ) ∩ ˜ W a b | . By definition, (cid:83) u ∈ U (cid:48) ab ∪ U (cid:48)(cid:48) ab , ≤ b ≤ d σ ∗ ( u ) ∩ ˜ W a b = S I ( W ) \ S ∗ ( W ) = (cid:83) u ∈ U σ ∗ ( u ) ∩ S I ( W ). Since U ⊆ S I ( X ) and | σ I ( U ) \ U | = | (cid:83) u ∈ U (cid:48) ab ∪ U (cid:48)(cid:48) ab , ≤ b ≤ d σ a b ( u ) ∩ W | , | σ I ( S I ( X )) \ S I ( X ) | ≥ | σ I ( U ) \ U | ≥ | σ ∗ ( U ) ∩ S I ( W ) | . Lemma 6.2.
Let ( S ∗ , σ ∗ ) be any optimal solution for ( G, R ) . Let F I be the set of drivers in S ∗ that serve all of σ I ( S I ) . Then, | F I | ≥ | S I ∪ F I | K +2 .Proof. Three sets
U, B , B of drivers in S ∗ are considered, each of which serves a portion oftrips in σ I ( S I ), and altogether σ ∗ ( U ∪ B ∪ B ) ∪ S ∗ ( W ) ⊇ σ I ( S I ), where S ∗ ( W ) = S ∗ ∩ W . Let U be the set of drivers in S ∗ that serve all of S I ( W ) \ S ∗ ( W ). By Lemma 6.1 and the proof ofit, all of U must be drivers in S I ( X ) and | σ I ( U ) \ U | ≥ | σ ∗ ( U ) ∩ S I ( W ) | . It requires anotherset B of drivers in S ∗ to serve all trips of ( σ I ( U ) \ U ) ⊆ W since σ I ( U ) ∩ S I ( W ) = ∅ . From | σ I ( U ) \ U | ≥ | σ ∗ ( U ) ∩ S I ( W ) | , σ I ( U ) ∩ S I ( W ) = ∅ and σ ∗ ( U ) ∩ S I ( W ) = S I ( W ) \ S ∗ ( W ), | ( S I ( W ) \ S ∗ ( W )) ∪ ( σ I ( U ) \ U ) | ≥ | S I ( W ) \ S ∗ ( W ) | . Therefore, | U ∪ B | ≥ | S I ( W ) \ S ∗ ( W ) | /K . In the worst case, each trip v ∈ B can be assigned as a driver in S \ S I suchthat v serves only itself.Consider the drivers in S X = S I \ ( S I ( W ) ∪ U ) ( S X ⊆ S I ( X )). For each driver x ∈ S X , σ I ( x ) must serve at least one trip from W , meaning | σ I ( x ) | ≥ | σ I ( S X ) | ≥ | S X | . Let B be the set of drivers in S ∗ that serve all of σ I ( S X ). We now consider the size of B . Notethat B ∩ S X may or may not be empty. In the worst case, each trip v ∈ B \ S X can beassigned as a driver in S s.t. v serves itself only. Hence, the ratio between the total number ofdrivers in S to serve σ I ( S X ) ∪ B and B is ( | S X | + | B \ S X | ) / | B | . This function is monotoneincreasing in | B \ S X | . Hence, B ∩ S X = ∅ gives the worst case. From this and each v ∈ B \ S X can serve at most K trips of σ I ( S X ), | B | ≥ | S X | /K . Since σ I ( S X ) ∩ σ I ( U ) = ∅ and σ I ( S X ) ∩ σ I ( W ) = ∅ , | ( S I ( W ) \ S ∗ ( W )) ∪ ( σ I ( U ) \ U ) ∪ σ I ( S X ) | ≥ | S I ( W ) \ S ∗ ( W ) | +2 | S X | .Thus, | U ∪ B ∪ B | ≥ | S I ( W ) \ S ∗ ( W ) | + | S X | ) /K .Let F I = U ∪ B ∪ B ∪ S ∗ ( W ), which is the set of drivers in S ∗ required to serve σ I ( S I ).Then | F I | = | U ∪ B ∪ B | + | S ∗ ( W ) | ≥ | S I ( W ) \ S ∗ ( W ) | + | S X | ) /K + | S ∗ ( W ) | . Recall that S I = S I ( W ) ∪ U ∪ S X . The ratio between the number of drivers in S to serve σ I ( S I ) ∪ B ∪ B and F I is 23 S I ∪ B ∪ B || F I | ≤ | S I ∪ F I || F I | ≤ | S I ( W ) \ S ∗ ( W ) | + | S X | + | U ∪ B ∪ B ∪ S ∗ ( W ) || U ∪ B ∪ B ∪ S ∗ ( W ) | (5.1) ≤ | S I ( W ) \ S ∗ ( W ) | + | S X | | S I ( W ) \ S ∗ ( W ) | + | S X | ) /K + | S ∗ ( W ) | + 1 ≤ K | F I | ≥ | S I ∪ F I | / ( K + 2) drivers in S ∗ to serve all of σ I ( S I ).Next, we consider the minimum number of drivers in S ∗ that is required to serve all of σ II ( S II ), where ( S II , σ II ) is the partial solution computed at the end of Phase-II. Recall that Z = { i ∈ R \ σ I ( S I ) | δ i = 0 } and all of Z are served in σ II ( S II ). Lemma 6.3.
Let ( S ∗ , σ ∗ ) be any optimal solution for ( G, R ) . Let F II be the set of drivers in S ∗ that serve all of σ II ( S II ) . Then, | F II | ≥ | S II ∪ F II | K +2 .Proof. Consider the set S (cid:48) = { x ∈ S II \ S I | | σ II ( x ) | = 1 } of drivers in S II \ S I . For everypair x, x (cid:48) ∈ S (cid:48) , node( x ) (cid:54) = node( x (cid:48) ) since otherwise, one of them can serve the other. Inother words, each x ∈ S (cid:48) belongs to a distinct node. Let C (cid:48) = C (cid:48) ∪ C (cid:48) be the set ofdrivers in S ∗ that serve all of S (cid:48) , where C (cid:48) = { v ∈ S ∗ | σ ∗ ( v ) ∩ S (cid:48) (cid:54) = ∅ and δ v = 0 } and C (cid:48) = { v ∈ S ∗ | σ ∗ ( v ) ∩ S (cid:48) (cid:54) = ∅ and δ v ≥ } . By definition, C (cid:48) ⊆ X . Let S (cid:48) = S (cid:48) ∪ S (cid:48) , where S (cid:48) is served by C (cid:48) and S (cid:48) is served by C (cid:48) . Then | C | = | S (cid:48) | because each x ∈ S (cid:48) belongs to adistinct node. Consider a driver x ∈ S (cid:48) . Let ( S x , σ x ) be the partial solution just before x isprocessed by the algorithm. All trips in C (cid:48) ∩ R ( A ∗ node( x ) ) must have been assigned as driversin S x . Otherwise, any v ∈ C (cid:48) ∩ R ( A ∗ node( x ) ) would have been assigned as a driver in S II toserve x . Hence, C (cid:48) ⊆ S II . For each driver v ∈ C (cid:48) ∩ R ( A ∗ node( x ) ), free x ( v ) = 0 or free x ( v ) > x ( v ) = δ v . Since each x ∈ S (cid:48) belongs to a distinct node, σ x ( v ) must serve at least | σ ∗ ( v ) ∩ S (cid:48) | passengers, implying | (cid:83) v ∈ C (cid:48) σ x ( v ) \ { v }| ≥ | (cid:83) v ∈ C (cid:48) σ ∗ ( v ) ∩ S (cid:48) | . The passengersserved by σ x ( v ) are either in W or Z . Each passenger z in σ x ( v ) ∩ Z belongs to a differentnode as z is the only trip in Z (node( z )) \ σ x ( S x ), and further, node( z ) (cid:54) = node( x ) for every x ∈ S (cid:48) . This means that no passenger in σ x ( v ) ∩ ( W ∪ Z ) can serve other passengers of σ x ( v ) for all v ∈ C (cid:48) . Thus, it requires at leasts | C (cid:48) | ≥ | S (cid:48) | /K drivers to serve all of S (cid:48) and (cid:83) v ∈ C (cid:48) σ II ( v ) \ { v } since C (cid:48) ∩ ( σ II ( v ) \ { v } ) = ∅ for every v ∈ C (cid:48) . From | S (cid:48) | = | C (cid:48) | , the ratiobetween | S (cid:48) ∪ C (cid:48) | and | C (cid:48) | is | S (cid:48) ∪ C (cid:48) || C (cid:48) | ≤ | S (cid:48) | + | C (cid:48) || C (cid:48) | = | S (cid:48) || C (cid:48) | + 1 = | S (cid:48) | + | S (cid:48) || C (cid:48) | + | C (cid:48) | + 1 = | C (cid:48) | + | S (cid:48) || C (cid:48) | + | C (cid:48) | + 1 . (5.2)24ince | S (cid:48) | ≥ | C (cid:48) | , ( | C (cid:48) | + | S (cid:48) | ) / ( | C (cid:48) | + | C (cid:48) | ) is monotone decreasing in | C (cid:48) | . Therefore, | S (cid:48) ∪ C (cid:48) || C (cid:48) | ≤ | C (cid:48) | + | S (cid:48) || C (cid:48) | + | C (cid:48) | + 1 ≤ | S (cid:48) || C (cid:48) | + 1 ≤ | S (cid:48) | | S (cid:48) | /K + 1 = K K + 22 (5.3)Since C (cid:48) ⊆ S II belong to X , C (cid:48) ∩ S I may not be empty. We need to consider C (cid:48) ∩ U ,where U ⊆ S ∗ serve all of S I ( W ) \ S ∗ ( W ) (defined in Lemma 6.2). More precisely, we showthe following statement: for every v ∈ C (cid:48) ∩ U , | σ II ( v ) \ { v }| ≥ | σ ∗ ( v ) ∩ ( S I ( W ) ∪ S (cid:48) ) | . Forevery v ∈ U ∩ C (cid:48) , σ ∗ ( v ) serves trip from both S I ( W ) and S (cid:48) . The nodes containing S I ( W )are different from nodes containing S (cid:48) . Otherwise, S (cid:48) would have served trips from S I ( W ).From this, | C (cid:48) | = | S (cid:48) | and C (cid:48) can only serve trips from S (cid:48) . Consider any driver v ∈ C (cid:48) ∩ U .Recall that free II ( v ) = 0 or free II ( v ) > II ( v ) = δ v ≥ stop ∗ ( v ). If free II ( v ) = 0,statement is true. Suppose free II ( v ) >
0. It was shown (in Lemma 6.1) that for each set ˜ W a c in σ ∗ ( v ) ∩ S I ( W ), σ I ( v ) serves a set W j c of passengers such that | W j c | ≥ | ˜ W a c | . From this, S I ( W ) and S (cid:48) belong to different nodes, and stop II ( v ) ≥ stop ∗ ( v ), σ II ( v ) must serve additionaltrips if stop I ( v ) < stop ∗ ( v ). This implies that | σ II ( v ) \ { v }| ≥ | σ ∗ ( v ) ∩ ( S I ( W ) ∪ S (cid:48) ) | sinceeach trip in S (cid:48) belongs to a distinct node. Thus, the statement is true, and equation 5.1 andequation 5.3 hold.Consider the remaining drivers in S (cid:48)(cid:48) = S II \ ( S I ∪ S (cid:48) ∪ C (cid:48) ). Since each driver x ∈ S (cid:48)(cid:48) serves at least one passenger, | σ II ( S (cid:48)(cid:48) ) | ≥ | S (cid:48)(cid:48) | . Let C (cid:48)(cid:48) = C (cid:48)(cid:48) ∪ C (cid:48)(cid:48) be the set of driversin S ∗ that serve all of σ II ( S (cid:48)(cid:48) ), where C (cid:48)(cid:48) = { v ∈ S ∗ | σ ∗ ( v ) ∩ σ II ( S (cid:48)(cid:48) ) (cid:54) = ∅ and v ∈ Z } and C (cid:48)(cid:48) = { v ∈ S ∗ | σ II ( S (cid:48)(cid:48) ) (cid:54) = ∅ and v / ∈ Z } . Note that σ II ( S (cid:48)(cid:48) ) ⊆ X , C (cid:48)(cid:48) ⊆ X and C (cid:48)(cid:48) ⊆ σ II ( S II ).In the worst case, each trip v ∈ C (cid:48)(cid:48) can be assigned as a driver in S s.t. v serves itself only.Hence, the ratio between the total number of drivers in S to serve σ II ( S (cid:48)(cid:48) ) ∪ C (cid:48)(cid:48) and C (cid:48)(cid:48) is( | S (cid:48)(cid:48) | + | C (cid:48)(cid:48) | ) / | C (cid:48)(cid:48) | = ( | S (cid:48)(cid:48) | + | C (cid:48)(cid:48) | ) / ( | C (cid:48)(cid:48) | + | C (cid:48)(cid:48) | ). This function is monotone increasing in | C (cid:48)(cid:48) | .From this, C (cid:48)(cid:48) = C (cid:48)(cid:48) ∪ C (cid:48)(cid:48) and every v ∈ C (cid:48)(cid:48) can serve at most K trips of σ II ( S (cid:48)(cid:48) ), | S (cid:48)(cid:48) ∪ C (cid:48)(cid:48) || C (cid:48)(cid:48) | ≤ | S (cid:48)(cid:48) ∪ C (cid:48)(cid:48) || C (cid:48)(cid:48) | ≤ | S (cid:48)(cid:48) | + | C (cid:48)(cid:48) || C (cid:48)(cid:48) | ≤ | S (cid:48)(cid:48) | | S (cid:48)(cid:48) | /K + 1 ≤ K K + 22 (5.4)Next, we combine equations 5.3 and 5.4 with equation 5.1. As mentioned, C (cid:48) ∩ S I maynot be empty, or more specifically C (cid:48) ∩ S X (cid:54) = ∅ ( S X is defined in Lemma 6.2). We make aslight adjustment when calculating | F I | to not include C (cid:48) , that is, | F I | ≥ | S I ( W ) \ S ∗ ( W ) | + | S X \ C (cid:48) | ) /K + | S ∗ ( W ) | and equation 5.1 becomes | S I ∪ F I \ C (cid:48) | / | F I | ≤ ( K + 2) /
2. Let F II = F I ∪ C (cid:48) ∪ C (cid:48)(cid:48) , which is the set of drivers in S ∗ required to serve σ II ( S II ). Since σ I ( S I \ C (cid:48) ) ∩ σ II ( S (cid:48) ∪ C (cid:48) ) = ∅ , σ I ( S I ) ∩ σ II ( S (cid:48)(cid:48) ) = ∅ and σ II ( S (cid:48) ) ∩ σ II ( S (cid:48)(cid:48) ) = ∅ , | F II | ≥ | S I ∪ F I \ C (cid:48) | / ( K + 2) + 2 | S (cid:48) ∪ C (cid:48) | / ( K + 2) + 2 | S (cid:48)(cid:48) ∪ C (cid:48)(cid:48) | / ( K + 2). The ratio between S II ∪ B ∪ B ∪ C (cid:48)(cid:48) and F II is 25 S II ∪ F II || F II | = | S I ∪ S (cid:48) ∪ S (cid:48)(cid:48) ∪ C (cid:48) ∪ C (cid:48)(cid:48) ∪ F I || F I ∪ C (cid:48) ∪ C (cid:48)(cid:48) | (5.5) ≤ | S I ∪ F I \ C (cid:48) | + | S (cid:48) ∪ C (cid:48) | + | S (cid:48)(cid:48) ∪ C (cid:48)(cid:48) || F I ∪ C (cid:48) ∪ C (cid:48)(cid:48) |≤ | S I ∪ F I \ C (cid:48) | + | S (cid:48) ∪ C (cid:48) | + | S (cid:48)(cid:48) ∪ C (cid:48)(cid:48) | | S I ∪ F I \ C (cid:48) | + | S (cid:48) ∪ C (cid:48) | + | S (cid:48)(cid:48) ∪ C (cid:48)(cid:48) | ) / ( K + 2) = K + 22Therefore, it requires at least | F II | ≥ | S II ∪ F II | / ( K + 2) ≥ | S II | / ( K + 2) drivers in S ∗ toserve all of σ II ( S II ).Notice that the ratio stated in equation 5.5 is tight. By that, we mean every driver u ∈ F II serves K trips of σ II ( S II ) assuming n u = K . Each trip v in B ∪ B ∪ C (cid:48)(cid:48) (defined in theproofs of Lemma 6.2 and Lemma 6.3) can be a driver in S that serves itself only. This canhappen if before v ∈ B ∪ B ∪ C (cid:48)(cid:48) is processed, R ( D ∗ node( v ) ) \ { v } ⊆ σ v ( S v ) for δ v > R (node( v )) \ { v } ⊆ σ v ( S v ) for δ v = 0, where ( S v , σ v ) is the partial solution just before v isprocessed. Remark 6.1.
Let B and B the set of trips defined in the proof of Lemma 6.3. Let S (cid:48) and S (cid:48)(cid:48) be the set of drivers defined in the proof of Lemma 2.3. Trips of B ∪ B can be assignedas drivers in Phase-II or Phase-III. Suppose v ∈ B ∪ B is assigned as a driver in Phase-II.If σ ( v ) serves only itself, v is included in S (cid:48) . If σ ( v ) serves more than one trip, v is includedin S (cid:48)(cid:48) . For either case, equation 5.5 holds. From Remark 6.1, let B (cid:48) ∪ B (cid:48) ⊆ B ∪ B be the trips assigned as drivers in Phase-III. Let ˆ S = S \ S II be the set of drivers found during Phase-III of the algorithm and¯ S = ˆ S \ ( B (cid:48) ∪ B (cid:48) ∪ C (cid:48)(cid:48) ). Lemma 6.4.
It requires at least | S | K +2 drivers in S ∗ to serve all of σ ( S ) .Proof. Any trip x in R \ σ II ( S II ) has n x > δ x > W and Z are servedin σ II ( S II ). Consider the moment a trip x ∈ ¯ S is assigned as a driver. Let ( S x , σ x ) bethe partial solution just before x is processed by the algorithm. Since n x > δ x > x will serve at least one passenger ( | σ ( x ) | ≥
2) if there exists an un-assigned trip in R ( D ∗ node( x ) ) \ { x } , that is, R ( D ∗ node( x ) ) \ { x } (cid:42) σ x ( S x ). Let X (1) = { x ∈ ¯ S | | σ ( x ) | =1 } . For every pair x, x (cid:48) ∈ X (1), x / ∈ R ( D ∗ node( x (cid:48) ) ) ∪ R ( A ∗ node( x (cid:48) ) ). Otherwise, one of themcan serve the other. For every x ∈ X (1), any driver x (cid:48) ∈ ¯ S ( A ∗ node( x ) ) \ { x } must serve atleast two trips, where ¯ S ( A ∗ node( x ) ) = ¯ S ∩ R ( A ∗ node( x ) ). | ¯ S ( A ∗ node( x ) ) | ≤ (cid:100)| σ ( ¯ S ( A ∗ node( x ) )) | / (cid:101) = (cid:98) ( | σ ( ¯ S ( A ∗ node( x ) )) | − / (cid:99) + 1 ≤ ( | σ ( ¯ S ( A ∗ node( x ) )) | − / | σ ( ¯ S ( A ∗ node( x ) )) | + 1) /
2. Let26 x be the set of drivers in S ∗ that serve all of (cid:83) x (cid:48) ∈ ¯ S ( A ∗ node( x ) ) σ ( x (cid:48) ), where x ∈ X (1). Then | (cid:83) x (cid:48) ∈ ¯ S ( A ∗ node( x ) ) σ ( x (cid:48) ) | ≥ | ¯ S ( A ∗ node( x ) ) | −
1. For different x, x (cid:48) ∈ X (1), since drivers in Y x cannot serve any trip from (cid:83) x (cid:48)(cid:48) ∈ ¯ S ( A ∗ node( x (cid:48) ) ) σ ( x (cid:48)(cid:48) ), Y x ∩ Y x (cid:48) = ∅ . Let Y = (cid:83) x ∈ X (1) Y x and¯ S X = (cid:83) x ∈ X (1) ¯ S ( A ∗ node( x ) ).For the remaining drivers in ¯ S ¯ X = ¯ S \ ¯ S X , each driver x ∈ ¯ S ¯ X serves at least two trips,implying | σ ( ¯ S ¯ X ) | ≥ | ¯ S ¯ X | . Let Y (cid:48) be the set of drivers in S ∗ that serve all of (cid:83) x ∈ ¯ S ¯ X σ ( x ).For every y (cid:48) ∈ Y (cid:48) , y (cid:48) / ∈ R ( D ∗ node( x ) ) ∪ R ( A ∗ node( x ) ) for all x ∈ ¯ S X since any trip of σ ( ¯ S ¯ X )is neither a descendant nor an ancestor of every x ∈ ¯ S X . We divide Y ∪ Y (cid:48) into two sets Y = { y ∈ Y ∪ Y (cid:48) | y ∈ σ ( ¯ S ) } and Y = { y ∈ Y ∪ Y (cid:48) | y / ∈ σ ( ¯ S ) } . Each y ∈ Y can serve atmost K + 1 trips in σ ( ¯ S ), whereas each y ∈ Y can serve at most K trips in σ ( ¯ S ). In the worstcase, each y ∈ Y can be a trip in σ II ( S II ). By definition, every y ∈ Y ∩ σ II ( S II ) is a driverin F II since y is a driver serves at least one trip ( y ∈ σ II ( S II ) itself). From the assumptionthat the ratio in equation 5.5 is tight, it does not matter whether y serves K trips of σ II ( S II )or σ ( ¯ S ). Since if y serves K trips of σ ( ¯ S ), y does not serve any of σ II ( S II ) \ { y } , and y stillneeds to be counted in F II ⊆ S ∗ . Effectively, Y and Y can serve at most the same amountof trips in σ ( S ). From this, we assume for simplicity Y = ∅ , and | Y | = | Y ∪ Y (cid:48) | = | Y | + | Y (cid:48) | .The ratio between | ¯ S X | and | Y | is | ¯ S X || Y | = (cid:80) x ∈ X (1) | ¯ S ( A ∗ node( x ) ) | (cid:80) x ∈ X (1) | Y x | ≤ (cid:88) x ∈ X (1) ( | σ ( ¯ S ( A ∗ node( x ) )) | + 1) / | σ ( ¯ S ( A ∗ node( x ) )) | / ( K + 1) (5.6)= ( K + 1)( | σ ( ¯ S ( A ∗ node( x ) )) | + 1)2 | σ ( ¯ S ( A ∗ node( x ) )) | = K + 12 + 12 | σ ( ¯ S ( A ∗ node( x ) )) | ≤ K + 22Then the ratio between | ¯ S | and | Y ∪ Y (cid:48) | is | ¯ S || Y ∪ Y (cid:48) | = | ¯ S X | + | ¯ S ¯ X || Y | + | Y (cid:48) | ≤ | ¯ S X | + | ¯ S ¯ X | | ¯ S X | / ( K + 2) + 2 | ¯ S ¯ X | / ( K + 1) ≤ K + 22 (5.7)Notice that for every v ∈ B (cid:48) ∪ B (cid:48) ∪ C (cid:48)(cid:48) , v / ∈ ¯ S and hence, equation 5.7 holds regardless B (cid:48) ∪ B (cid:48) ∪ C (cid:48)(cid:48) is empty or not. Finally, we calculate the ratio between S and S ∗ ⊇ Y ∪ Y (cid:48) ∪ F II .Recall that S = ¯ S ∪ S II ∪ B (cid:48) ∪ B (cid:48) ∪ C (cid:48)(cid:48) , so S = ¯ S ∪ S II ∪ F II . From equation 5.5, | F II | ≥ | S II ∪ F II | / ( K + 2). The ratio between S and S ∗ is at least27 S || Y ∪ Y (cid:48) ∪ F II | = | ¯ S ∪ S II ∪ F II || Y ∪ Y (cid:48) | + | F II | ≤ | ¯ S X ∪ ¯ S ¯ X | + | S II ∪ F II || Y ∪ Y (cid:48) | + | F II | (5.8) ≤ | ¯ S X ∪ ¯ S ¯ X | + | S II ∪ F II | | ¯ S X ∪ ¯ S ¯ X | / ( K + 2) + 2 | S II ∪ F II | / ( K + 2)= | ¯ S X ∪ ¯ S ¯ X | + | S II ∪ F II | | ¯ S X ∪ ¯ S ¯ X | + | S II ∪ F II | ) / ( K + 2)= K + 22Equivalently, it requires at least | S | K +2 drivers in S ∗ to serve all of σ ( S ).Let ( S (cid:48) , σ (cid:48) ) be the partial solution computed by Algorithm 2 for a given time point. Lemma 6.5.
Let ( S, σ ) be a solution found by Algorithm 2 after processing all trips in R .Then for each pair i, j ∈ S , σ ( i ) ∩ σ ( j ) = ∅ and σ ( S ) = R , implying ( S, σ ) is indeed a validsolution to the ridesharing instance ( G, R ) .Proof. Phase-I of the algorithm ends until all trips of W are served, i.e. Γ( W ) = ∅ . In eachiteration of Phase-I, a node µ ∈ Γ( W ) containing trips of W is chosen w.r.t. ( S (cid:48) , σ (cid:48) ). A trip x is selected from ˆ X ∪ ¯ X , where ˆ X = { i ∈ S (cid:48) ∩ R ( A µ ) | free (cid:48) ( i ) > (cid:48) ( i ) < δ i } and¯ X = { i ∈ X ∩ R ( A ∗ µ ) \ σ (cid:48) ( S (cid:48) ) | stop (cid:48) ( i ) < δ i or i ∈ R ( µ ) } . By the definition of ˆ X and ¯ X , x is either a driver or an un-assigned trip that can still serve other trips in R ( D ∗ µ ). From this, x is a valid assignment for serving W ( x, µ, S (cid:48) ). If ˆ X ∪ ¯ X = ∅ , all trips of W ( µ ) \ σ (cid:48) ( S (cid:48) ) areassigned as drivers to serve themselves.Phase-II of the algorithm ends until all trips of Z are served, where Z = { i ∈ R \ σ (cid:48) ( S (cid:48) ) | δ i = 0 } . Since all of W are served before Phase-II starts, n i ≥ i ∈ R \ σ (cid:48) ( S (cid:48) ),that is Z ⊆ X . From this, every x ∈ Z \ σ (cid:48) ( S (cid:48) ) that is assigned as a driver to serve othertrips in Z ( x, node( x ) , S (cid:48) ) is valid, as described in the first part (first for-loop) of Phase-II.The second part of Phase-II is similar to Phase-I. A node µ ∈ Γ( Z ) is chosen, where Γ( Z )is the set of nodes containing the rest of Z w.r.t. ( S (cid:48) , σ (cid:48) ). Either a driver x ∈ ˆ X or anunassigned trip x ∈ ¯ X is selected to serve Z ( x, µ, S (cid:48) ), where ˆ X = { i ∈ S ∩ R ( A ∗ µ ) | free( i ) > i ) < δ i or i ∈ R ( µ )) } and ¯ X is the same as defined above. The assignment of x is valid as mentioned above.In Phase-III of the algorithm, the rest of X \ Z are served. The algorithm processes eachnode from µ p to µ . All trips in R ( µ j ) must be served before µ j − is processed. In eachiteration, either a driver x ∈ ˆ X (as defined above) or an unassigned trip x ∈ X ( µ ) \ σ (cid:48) ( S (cid:48) )is selected to serve R ( x, µ, S (cid:48) ). The assignment of x is valid as mentioned above. Therefore,Algorithm 2 produces a valid solution after all trips in R are processed.28 heorem 6.1. Given a ridesharing instance ( G, R ) of size M and l trips satisfying Con-ditions (1-3) and (5). Algorithm 2 computes a solution ( S, σ ) for ( G, R ) such that | S ∗ | ≤| S | ≤ K +22 | S ∗ | , where ( S ∗ , σ ∗ ) is any optimal solution and K = max i ∈ R n i , with running time O ( M + l ) .Proof. By Lemma 6.4 and Lemma 6.5, Algorithm 2 computes a solution (
S, σ ) for R withapproximation ratio K +22 . It takes O ( M ) time to construct the meta graph Γ( V, E ) using thepreprocessing described in [8]. The labeling of nodes in Γ takes O ( l ) time. For Phase-I, thereare at most O ( l ) iterations (in the while-loop). In each iteration, it takes O ( l ) time to pickthe required node µ from Γ( W ) and O ( l ) time to select a trip x from ˆ X ∪ ¯ X . To serve allof W ( x, µ, S (cid:48) ) or W ( µ ), | W ( µ ) | ≤ O ( l ) is required. Hence, Phase-I runs in time O ( l ). ForPhase-II, we can first scan the tree Γ following the node labels in decreasing order, whichtakes O ( l ) time. Whenever a node µ with | Z ( µ ) | ≥ x ∈ Z ( µ ) \ σ (cid:48) ( S (cid:48) )is selected to serve Z ( x, µ, S (cid:48) ) repeated until | Z ( µ ) | ≤
1. This takes O ( l ) time since the tripsin R ( µ ) are sorted. Hence, it takes O ( l ) time for the first for-loop in Phase-II. The secondfor-loop in Phase-II is similar to Phase-I, which requires O ( l ) time for each iteration. Thus,it requires O ( l ) time for Phase-II. For Phase-III, in each iteration when processing a node µ , it takes O ( l ) time to select a trip x from ˆ X or X ( µ ) \ σ (cid:48) ( S (cid:48) ). Then in total, it requires O ( l + K ) time to serve R ( x, µ, S (cid:48) ). Collectively, Phase-III may require O ( l ) iterations toprocess all trips in V (Γ). Thus, it requires O ( l ) time for Phase-III. Therefore, the runningtime of Algorithm 2 is O ( M + l ). We proved that the problems of minimizing the number of vehicles and minimizing the totaldistance of vehicles are NP-hard, and further it is NP-hard to approximate these two problemswithin a constant factor if one of Condition (4) or (5) is not satisfied. Combining these withthe results of [7, 8], both minimization problems are NP-hard if one of Conditions (1)-(5)is not satisfied. We also presented K +22 -approximation algorithms for minimizing number ofdrivers for problem instances satisfying all conditions except Condition (4), where K is thelargest capacity of all vehicles. It is worth developing approximation algorithms for other NP-hard cases; for example, two or more of the five conditions are not satisfied. It is interestingto study applications of the approximation algorithms for other related problems, such asmultimodal transportation with ridesharing (integrating public and private transportation).29 eferences [1] N. Agatz, A. Erera, M. Savelsbergh and X. Wang. Dynamic ride-sharing: A simulationstudy in metro atlanta. Trans. Research Part B, 45(9):1450-1464, 2011.[2] N. Agatz, A. Erera, M. Savelsbergh, and X. Wang. Optimization for dynamic ride-sharing: A review. European Journal of Operational Research, 223:295-303, 2012.[3] J. Alonso-Mora, S. Samaranayake, A. Wallar, E. Frazzoli and D. Rus. On-demandhigh-capacity ride-sharing via dynamic trip-vehicle assignment. Proc. of the NationalAcademy of Sciences (PNAS), 114(3):462-467, 2017.[4] B. Caulfield. Estimating the environmental benefits of ride-sharing: A case study ofDublin. Transportation Research Part D, 14(7):527-531, 2009.[5] M. Furuhata, M. Dessouky, F. Ord´o˜nez, M. Brunet, X. Wang and S. Koenig. Rideshar-ing: The state-of-the-art and future directions. Transportation Research Part B, 57:28-46, 2013.[6] K. Ghoseiri, A. Haghani, and M. Hamedi. Real-time rideshare matching problem. FinalReport of UMD-2009-05, U.S. Department of Transportation, 2011.[7] Q. Gu, J. L. Liang and G. Zhang. Algorithmic analysis for ridesharing of personalvehicles. Proc. of the 2016 International COCOA, LNCS 10043:438-452, 2016.[8] Q. Gu, J. L. Liang and G. Zhang. Efficient algorithms for ridesharing of personal vehicles.Theoretical Computer Science, 788:79-94, 2019.[9] I. B.-A. Hartman, D. Keren, A. A. Dbai, E. Cohen, and L. Knapen, A.-U.-H. Yasar,and D. Janssens. Theory and practice in large carpooling problems. Proc. of the 5thInternational Conf. on ANT, pages 339-347, 2014.[10] W. Herbawi and M. Weber. The ridematching problem with time windows in dynamicridesharing: A model and a genetic algorithm. Proc. of ACM Genetic and EvolutionaryComputation Conference (GECCO), pp 1-8, 2012.[11] Y. Huang, F. Bastani, R. Jin and X. S. Wang. Large scale real-time ridesharing withservice guarantee on road networks. Proc. of the VLDB Endowment, 7(14):2017-2028,2014. 3012] J. Jung, R. Jayakrishnan, J. Y. Park. Dynamic shared-Taxi dispatch algorithm withhybrid-Simulated annealing. Computer-Aided Civil and Infrastructure Engineering,31(4):275-291, 2016.[13] G. Kutiel and D. Rawitz Local Search Algorithms for Maximum Carpool Matching.Proc. of 25th Annual European Symposium on Algorithms, pp 55:1-55:14, 2017.[14] S. Ma, Y. Zheng and O. Wolfson. Real-time city-scale taxi ridesharing. IEEE Transac-tions on Knowledge and Data Engineering. 27(7):1782-1795, 2015.[15] T. Ma, S. Rasulkhani, J.Y.J. Chow and S. Klein. A dynamic ridesharing dispatch and idlevehicle repositioning strategy with integrated transit transfers. Transportation ResearchPart E, 128:417-442, 2019.[16] Y. Molenbruch, K. Braekers and A. Caris. Typology and literature review for dial-a-rideproblems. Annals of Operations Research, 259:295-325, 2017.[17] A. Mourad, J. Puchinger and C. Chu. A survey of models and algorithms for optimizingshared mobility. Transportation Research Part B, 123:323-346, 2019.[18] A. Santos, N. McGuckin, H.Y. Nakamoto, D. Gray, and S. Liss. Summary of traveltrends: 2009 national household travel survey. Technical report, US Department ofTransportation Federal Highway Administration, 2011.[19] D.O. Santos and E.C. Xavier. Taxi and ride sharing: A dynamic dial-a-ride problemwith money as an incentive. Expert Systems with Apps., 42(19):6728-6737, 2015.[20] G. Sierpi´nski. Changes of the modal split of traffic in Europe. Archives of TransportSystem Telematics, 6(1):45-48, 2013. Appendix rocedure Label-Inverse-Tree
Input:
An inverse tree Γ of l trips and p nodes. Output:
Distinct integer labels µ p , . . . , µ for nodes in Γ. begin let ST be a stack and push the sink of Γ into ST; i := p and mark every arc in Γ un-visited; while ST (cid:54) = ∅ do let µ be the node at the top of ST; if there is an arc ( ν, µ ) in Γ un-visited then push ν into ST and mark ( ν, µ ) visited; else remove µ from ST; assign µ integer label µ i ; i := i − endifendwhileend.endifendwhileend.