Online scheduling of car-sharing request pairs between two locations

We consider an online car-sharing problem between two locations with advance bookings. Each customer submits a pair of requests, where each request specifies the pick-up time and the pick-up location: one request from A to B, and the other request from B to A, not necessary in this order. The scheduler aims to maximize the number of satisfied customers, where the schedule has to decide whether or not to accept a request pair immediately at the time when the request pair is submitted. This problem is called OnlineTransfersForCommuting. We present lower bounds on the competitive ratio for this problem with both fixed booking times and variable booking times, and propose two algorithms, greedy algorithm and balanced greedy algorithm, that achieve the best possible competitive ratios.


Introduction
The sharing economy has become more close to everyone. The car-sharing, as a new form of transport, has already been in use in daily life. In a car-sharing system, customers can book a car to drive from one place to another, and the car-sharing company will provide a car to serve this customer. Once a request for booking a car is accepted, the customer can pick up a car at the origin, drive it to the destination and return it there. An optimization problem is denoted by car-sharing problem (C S − k in short), where the goal is to maximize the number of satisfied customers by k cars. A customer is satisfied if all his or her requests are fulfilled.
In this paper, we study an online car-sharing problem where each customer submits two rides in opposite directions. This variant of online car-sharing problem is denoted by OnlineTransfersForCommuting (OT FC − k in short, where k is the number of cars), and the goal is to maximize the number of satisfied customers. A scenario is as follows: There are two popular locations, which could be a business center and a residential area. Customers want to drive from the business center to the residential area and drive back later and vise versa.
Remark This work expanded the work of Luo et al. (2019b): we introduce the fixed booking time variant and variable booking time variant for this problem; we propose a balanced greedy algorithm for OT FC − k (k > 2) and prove that BGA is optimal.

Related work
Off-line car-sharing problem Böhmová et al. (2016) studied two off-line versions of the car-sharing problems. In one problem, OfflineTransfersForCommuting, there are two locations and each customer submits two requests (each request is specified by its pick-up time, pick-up location and drop-off location) that are between these two locations (in opposite directions). A customer is satisfied if and only if his or her two requests are fulfilled. The goal is to maximize the number of satisfied customers. If all customer requests for car bookings are known in advance, they proved that this problem is NP-hard and APX-hard even for one car. Following their works, we consider the online version of the problem. In the other problem, each customer submits one request, they showed that this problem can be solved in polynomial time using a minimum-cost network flow algorithm for both two different goals: To minimize the cars to serve all requests, or to maximize the number of accepted requests with k cars. Bei and Zhang (2018) studied another version of the car-sharing problem. There are n cars, and 2n requests and each request is specified only by pick-up location and drop-off location. Each car serves exactly two requests. The goal is to assign all requests to the cars with minimized total travel cost. They showed that this problem is NP-hard, and gave an 2.5-approximation algorithm.
Online car-sharing problem In the online model, each request is revealed when it is submitted. The scheduler has to decide whether or not to accept a request immediately when it is submitted. Luo et al. (2018a) considered the car-sharing problem for the special case of two locations and one car. For fixed booking time variant and variable booking time variant, they proposed an optimal algorithm that is 2-competitive for fixed booking times and 3-competitive for variable booking times, respectively. With the case of two locations and two cars, for fixed booking time variant, they proved tight results for the competitive ratio (Luo et al. 2018b). The competitive ratio was shown to be 2. With the case of two locations and k cars, for both fixed and variable booking times, they showed that the case with 3 cars for the fixed booking time variant and that with 5 cars for the variable booking time variant already allow us to get the best competitive ratio, and no improvement is possible with more cars (Luo et al. 2018c). In this paper, we consider the online car-sharing problem where each customer submits a pair of requests. For the online car-sharing problem with one car, the competitive ratio of the problem in which each customer submits a pair of requests is larger than the problem in which each customer submits one request. If each customer can submit one request or two requests, the competitive ratios are the same as the problem where each customer submits a pair of requests.
Furthermore, they dealt with the setting with m locations in a star network and k cars which is motivated by the transport between an airport and the nearby hotels (Luo et al. 2019a). They studied two star networks. In the unit star network, they gave a 2competitive algorithm. For the arbitrary star network where the travel time between the airport and a hotel may have an arbitrary length between t and Lt for L ≥ 1, they gave a O(log L)-competitive algorithm. For both networks, they proved the matching lower bounds on the competitive ratio of any deterministic online algorithm. Furthermore, in a metric graph, for both fixed booking time variant and variable booking time variant, Liu et al. (2019) gave an algorithm with competitive ratio O(L), where the L is known in advance. They also proved that no O(L α ) (any 0 < α < 1)-competitive deterministic algorithm exists for the fixed booking variant, and no O(L)-competitive deterministic algorithm exists for the variable booking variant.
Online matching problem The results of the special online car-sharing problem also can be viewed as a matching. Recently, Dutta and Sholley (2018) proposed a model of matching requests online. The requests are released when they are submitted and at the same time the profit of matching with other preceding d requests are revealed. The scheduler has to match each request within w time steps since it arrives and the objective is to construct a matching to maximize the sum of weights of the matched requests picked in the matching. They presented a randomized 1/4competitive algorithm for this problem with w = d. Raghvendra (2018) came up with the online bipartite matching problem for ride sharing. Given a set of car locations in a metric space, the requests arrive one by one, and the scheduler has to decide immediately to match it to a car at a cost (the distance between locations) with the aim of minimizing the total travel distance. They improved the analysis of the deterministic Robust Matching algorithm from O(log 2 n) (Nayyar and Raghvendra 2017) to O(log n) for the line metric, and established a bound of O(log n) on the competitive ratio.
Online interval scheduling problem For an online car-sharing problem, if all the pick-up and drop-off locations are the same, the problem becomes an online interval scheduling problem. Lipton (1994) considered the online interval scheduling problem, where the intervals are presented in order of their start times and each interval has a length. In the problem setting, the scheduler has to decide whether to accept each interval before the next interval is presented, and ensure that no pair of accepted intervals overlap. The objective of this problem is to maximize the total length of the accepted intervals. They showed that no algorithm can achieve competitive ratio smaller than O(log Δ) (where Δ denotes the ratio of the longest interval to the shortest interval, and Δ is unknown to the algorithm), and gave a randomized algorithm with competitive ratio O((log Δ) 1+ε ).
Another interval scheduling problem where two or multiple intervals have to be accepted together, is called multitrack interval problem (Golumbic 2004;Gyárfás and West 1995). Bar-Yehuda et al. (2006) considered a multitrack interval model, where each job consists at most two segments (or intervals). The object is to find a scheduling that maximize the number of accepted jobs. They presented a greedy algorithm with 3-competitive ratio for the proper 2-interval graph, and proved that no randomized algorithm can achieve a competitive ratio smaller than 2.5. For general instances, they gave a O(log 2 Δ)-competitive (resp. O((log Δ) 2+ε )-competitive) randomized algorithm, where Δ denotes the known (resp. unknown) ratio of the longest segment to the shortest segment.

Preliminaries
We consider a setting with two locations, one is denoted by 0 and the other is denoted by 1. Assume that the traveling time from 0 to 1 is the same as that from 1 to 0, and is denoted by t. We have k cars S = {s 1 , s 2 , . . . , s k }. All of these cars stay at location 0 initially.
Each customer submits one request pair, which consists of two requests, and the directions of these two requests are in opposite. Let R denote a sequence of request pairs that are released over time. For a given sequence R, the i-th request pair in R is denoted by Note that for any request pair {r i,1 , r i,2 }, the request r i,1 and request r i,2 are released at the same time, i.e., b i,1 = b i,2 . Request r i,1 (resp. r i,2 ) is specified by the booking time b i,1 (resp. b i,2 ), the start time/the pick-up time t i,1 (resp. t i,2 ) and the start location/the pick-up location p i,1 (resp. p i,2 ). Besides, the drop-off time of r i,1 is denoted byṫ i,1 , the drop-off location is denoted byṗ i,1 , whereṫ i,1 = t i,1 + t andṗ i,1 = 1 − p i,1 . In our problem setting, each customer submits a round-trip, that means the pick-up location of the request r i,2 and the drop-off location of the request r i,1 are the same, i.e., p i,2 =ṗ i,1 . And the pick-up time of r i,2 is not later than the drop-off time of r i,1 , i.e. t i,2 ≥ t i,1 + t.
We consider both the fixed booking time variant and the variable booking time variant. For fixed booking time variant, customers can submit a request pair at a specific time before the start time of the first request. t i,1 − b i,1 = a holds for all i. Correspondingly, for variable booking time variant, customers can submit a request pair at any time of an interval before the start time of the first request.
Each car can only serve one request at a time. We say that two requests are in conflict if they can not be served by one car. Note that t i,2 ≥ t i,1 + t and p i,2 =ṗ i,1 ensure that the two requests in one request pair are not in conflict. When a request pair is accepted, the car-sharing company will provide a car for this customer at time t i,1 at location p i,1 , and later provide a car at time t i,2 at location p i,2 . We do not require that the algorithm assigns the request to a car immediately or assigns the two requests in one pair to the same car, when the requests are accepted by the algorithm.
We forbid 'unprompted' empty moves, similar to Luo et al. (2018c). An empty move is to move a car from one location to another without serving a request. An algorithms is allowed to make an empty move if and only if the empty move is done to serve a request at the other location, which is accepted before the current time.
The performance of an algorithm for OT FC − k is measured using competitive analysis (Borodin and El-Yaniv 2005). For any sequence of request pairs R, let P R * denote the objective value produced by an optimal schedular O PT , where O PT has full information about R in advance, and P R A denote the objective value produced by an online deterministic algorithm A. The competitive ratio of A is defined by ρ A , which is shown by ρ A = sup R P R * P R A . An algorithm A is ρ-competitive if P R * ≤ ρ · P R A holds for all sequences R. For a problem, we say β is the lower bound on the best possible competitive ratio if ρ A ≥ β for all A ∈ ON, where ON is the set of all online deterministic algorithms. And we say an algorithm A is optimal if ρ A = β.

Paper outline
An overview of our results for OnlineTransfersForCommuting with one car is shown in Table 1. For OT FC − 1 with fixed booking times a ≥ t, no deterministic online algorithm can achieve a competitive ratio smaller than 5, and for OT FC − 1 with variable booking times b u > b l ≥ t, no deterministic online algorithm can achieve a competitive ratio smaller than 6. The Greedy Algorithm is optimal for both variants above. Compared with C S − 1 problem, the lower bounds and upper bounds for OT FC − 1 are larger.
An overview of our results for OnlineTransfersForCommuting with k (k ≥ 2) cars is shown in Table 2. The lower bound for OT FC −2 is 6, and the greedy algorithm is proved to be optimal. The lower bound for OT FC − k (k > 2) is 4. When the pickup time t i, j is an integer multiple of the travel time t, i.e., t i j = ν · t for some ν ∈ N, we propose a balanced greedy algorithm for OT FC − k (k > 2 and k = 2i, i ∈ N) which is optimal. When k = 2i, i ∈ N, the upper bound for OT FC − k (k > 2) with slotted pick-up times is 4 + 4 k−1 . The remaining of the paper is organized as follows. In Sect. 2, we prove the lower bounds. In Sect. 3, we propose the greedy algorithm for OT FC − k and prove the competitive ratios. Section 4 concludes the results of this work.

Lower bound
In this section, we present lower bounds for OT FC − 1, OT FC − 2 and OT FC − k (k > 2), respectively. We use ALG to denote any online algorithm, and O PT to denote the optimal scheduler. For a sequence of request pairs R, let R * denote the set of request pairs accepted by O PT , and R denote the set of request pairs accepted by ALG.
To illustrate whether two request pairs can be served by the same car or not, we have the following Observation 1.
Observation 1 (Conflicted condition) Any two requests r a,b and r g,h are in conflict if p a,b =ṗ g,h and |t a,b − t g,h | < t ( Fig. 1a shows an example), or if p a,b = p g,h and |t a,b − t g,h | < 2t ( Fig. 1b shows an example).

Table 1
Compare the competitive ratios between OT FC

Fig. 1 Illustration of conflicted requests
Note that the two requests of a request pair are not in conflict, that means for any request pair

ONLINETRANSFERSFORCOMMUTING with one car
In this section, we present lower bounds for OT FC − 1.
Observe that the ALG car stays at location 0 after serving r 1,2 and the O PT car stays at location 1 after serving r 5,2 . The adversary then releases request pairs can be arbitrarily large). Since we forbid 'unprompted' moves and a < t, a car does not have enough time to reach the pick-up location of the first request if the car stays at another location, ALG cannot accept all request pairs From the above analysis we have |R * | = G − 1 and |R | = 1, and hence lim G→∞ Case 2: ALG does not accept request pair {r 1,1 , r 1,2 }. In this case, O PT accepts {r 1,1 , r 1,2 }. We have |R * | = 1 and |R | = 0, and hence |R * | |R | = ∞.
Theorem 2 For a ≥ t, no deterministic online algorithm for O T FC − 1 with fixed booking times can achieve a competitive ratio smaller than 5.

ONLINETRANSFERSFORCOMMUTING with two cars
In this section, we present lower bound for OT FC − 2. Recall that ALG denotes any online algorithm and O PT denotes the optimal scheduler, and R and R * denote the request pair set accepted by ALG and O PT , respectively. To show the lower bound, we introduce two conceptions: matched and unmatched.
Definition 1 For any two accepted requests r a,b and r g,h , we say that r a,b and r g,h are matched if and only if they satisfy |t a,b − t g,h | < 2t and p a,b = p g,h . Both r a,b and r g,h are called matched requests. If r i, j is not matched with any other accepted request, we say that r i, j is an unmatched request. Lemma 1 For O T FC − 2, if ALG accepts two matched requests r a,b and r g,h with t a,b ≤ t g,h , then the adversary can release six request pairs (see Fig. 5 for an illustration):

which can be accepted by O P T but can not be accepted by ALG
Proof Observe that r 1,1 is in conflict with r a,b because t a,b − t 1,1 < t (based on Observation 1). Similarly, r 2,1 (also r 3,1 , r 4,1 , r 5,1 , r 6,1 ) is in conflict with r a,b . Since r a,b and r g,h are matched by each other, by Definition 1 we have t g,h − t a,b < 2t. As ε < min{t g,h − t a,b , t}, we have t g,h − t 1,1 < t, thus r 1,1 is in conflict with r g,h (based on Observation 1). Similarly, r 2,1 (also r 3,1 , r 4,1 , r 5,1 , r 6,1 ) is in conflict with r g,h . Therefore, ALG can not accept any of the six request pairs because ALG have already accepted r a,b and r g,h .

Now we give Theorem 4:
Theorem 4 No deterministic online algorithm for O T FC − 2 with variable bookings b u > b l ≥ t can achieve competitive ratio smaller than 6.
Proof Recall that R * is the set of request pairs accepted by O PT , and R is the set of request pairs accepted by ALG. Let R denote the union of the requests in R .
Otherwise, r 1,1 and r 1,2 are accepted by ALG and they are unmatched (according to Definition 1). Let r a,b and r g,h be the unmatched requests in R . Note that r a,b = r 1,1 , r g,h = r 1,2 . Next the adversary releases request pairs according to the "If-else loop", shown in Algorithm 1: Algorithm 1 If-else Loop 1: Input: r a,b , r g,h .
2: i = 0; 3: While i < 2 do 4: If i = 0, 5: the adversary releases {r a 1 ,1 , r a 1 ,2 }, {r a 2 ,1 , r a 2 ,2 }, {r a 3 ,1 , r a 3 ,2 }, {r a 4 ,1 , r a 4 ,2 }; 6: If ALG accepts one request pair {r a t ,1 , r a t ,2 }, 7: then request r a,b and request r a t ,1 are matched. The adversary stops to release the rest request pairs, and releases 6 request pairs according to Lemma 1; 8: r a,b = r g,h , r g,h = r a t ,2 ; 9: Else 10: O PT accepts {r a 1 ,1 , r a 1 ,2 }, {r a 2 ,1 , r a 2 ,2 }, {r a 3 ,1 , r a 3 ,2 }, {r a 4 ,1 , r a 4 ,2 }; 11: i = i + 1; 12: Else if i = 1, 13: the adversary releases If ALG accepts one request pair {r b t ,1 , r b t ,2 }, 15: then request r g,h and request r b t ,1 are matched. The adversary stops to release the rest request pairs, and releases 6 request pairs according to Lemma 1; 16: Then we analyze the number of request pairs accepted by ALG and O PT . In each loop, there are two cases: The adversary releases four request pairs in order of the booking times: Once ALG accepts a request pair {r a t ,1 , r a t ,2 }, the adversary stops to release the rest request pairs. Note that the request r a,b is matched by r a t ,1 , there are still two unmatched requests in R : r a,b = r g,h and r g,h = r a t ,2 . The adversary releases six request pairs according to Lemma 1. O PT accepts all the six request pairs, while ALG can not accept either of these request pairs. In sum, ALG accepts one request pair and O PT accepts six request pairs in this loop (see Fig. 6 for an illustration). Once the four request pairs are not accepted by ALG, i = i + 1 and the algorithm switch to Case 2. In sum, ALG accepts no request pairs and O PT accepts four request pairs in this loop (see red lines in Fig. 7 for an illustration). These four request pairs are counted when the loop break. Case 2: i = 1.
The adversary releases four request pairs in order of the booking times: Similarly, once ALG accepts a request pair {r b t ,1 , r b t ,2 }, the adversary stops to release the rest request pairs. Note that the request r g,h is matched by r b t ,1 , there are still two unmatched requests in R : r a,b is unchanged and r g,h = r b t ,2 . The adversary releases six request pairs according to Lemma 1. O PT accepts all the six request pairs, while ALG can not accept either of these request pairs. In sum, ALG accepts one request pair and O PT accepts six request pairs in this loop. Once the four request pairs are not accepted by ALG, the loop breaks. In sum, ALG accepts no request pairs and O PT accepts four request pairs in this loop.
Next we will prove that any two requests accepted by OPT in two different loops are not in conflict. According to Algorithm 1, we have three circumstances: Both two loops x and y are in case 1, loop x in case 1 and loop y in case 2, or loops x, y are both in case 2.
For any two loops x and y (x < y) in case 1, we claim that t a,b in loop x + 1 is no less than t a,b + 8t in loop x. Observe that t g,h = t a,b + 12t in loop 1. Based on Line 8 in Algorithm 1, we know that t a,b in loop x + 1 is equal to t g,h in loop x, and t g,h in loop x + 1 is equal to t a t ,2 in loop x where t a t ,2 = t g,h + 8t or t a t ,2 = t g,h + 10t. Thus we know that t g,h − t a,b ≥ 8t in loop x + 1, and t a,b in loop x + 1 is no less than t a,b + 8t in loop x, the claim is proved. For any two loops x and y (x < y) in case 2, we claim that t g,h in loop x + 1 is no less than t g,h + 14t in loop x. Based on Line 16 in Algorithm 1, we know that t g,h in loop x + 1 is equal to t b t ,2 in loop x, which is later than t g,h + 14t in loop x. The above claim is proved.
Consider the circumstance that loop x and loop y are both in case 1. Since loop x and loop y are both in case 1, the requests accepted by OPT in loop x must have start time between (t a,b − t, t a,b + 5t] based on Lemma 1. If OPT accepts 6 pair pairs in loop y as shown in Line 7 in Algorithm 1, we know that the start time of the request accepted by OPT in loop y is not earlier than t a,b − t in loop y, which is not earlier than 2t plus the start time of the request accepted by OPT in loop x with the latest start time since t a,b in loop y is no less than t a,b + 8t in loop x. Similarly, if OPT accepts 4 request pairs in loop y as shown in Line 10 in Algorithm 1, we know that the start time of the request accepted by OPT in loop y is not earlier than t a,b − t in loop y, which is not earlier than 2t plus the start time of the request accepted by OPT in loop x with the latest start time. That means any two requests accepted by OPT in two different loop x and loop y are not in conflict.
Consider the circumstance that loop x and loop y are both in case 2. Since loop x and loop y are both in case 2, the requests accepted by OPT in loop x must have start time between (t g,h − t, t g,h + 5t] based on Lemma 1. If OPT accepts 6 request pairs in loop y as shown in Line 15 in Algorithm 1, we know that the start time of the request accepted by OPT in loop y is not earlier than t g,h − t in loop y, which is not earlier than 2t plus the start time of the request accepted by OPT in loop x with the latest start time since t g,h in loop y is no less than t g,h + 14t in loop x. Similarly, if OPT accepts 4 request pairs in loop y as shown in Line 18 in Algorithm 1, we know that the start time of the request accepted by OPT in loop y is not earlier than t g,h − t in loop y, which is not earlier than 2t plus the start time of the request accepted by OPT in loop x with the latest start time. That means any two requests accepted by OPT in two different loop x and loop y are not in conflict.
Consider the circumstance that loop x is the last case 1 loop and loop y is in case 2. As shown in Line 10 in Algorithm 1, the requests accepted in loop x starts between (t a,b − t, t a,b + 2t] or t g,h + 8t, or t g,h + 10t. If y is the first case 2 loop, y = x + 1, t a,b (resp.t g,h ) in both loops are the same. As shown in Line 15 and Line 18 in Algorithm 1, the requests accepted in loop y starts between (t g,h − t, t g,h + 5t] or t g,h + 14t, or t g,h + 16t. Since t g,h − t a,b ≥ 8t, we know that any request accepted in loop x and a request accepted in loop y are not in conflict as the interval of the two start times is at least 2t. If y ≥ x + 2, t g,h in loop y is greater than t g,h + 14t in loop x. As shown in Line 15 and Line 18 in Algorithm 1, the requests accepted in loop y starts between (t g,h − t, t g,h + 5t] or t g,h + 14t, or t g,h + 16t. Since t g,h − t a,b ≥ 8t in loop x, we know that any request accepted in loop x and a request accepted in loop y are not in conflict as the interval of the two start times is at least 3t. That means any two requests accepted by OPT in the last case 1 loop x and case 2 loop y are not in conflict.
Since all requests accepted in case 1 by OPT starts earlier than the requests in the last case 1 loop, we deduce that any two requests accepted by OPT in two different loops are not in conflict based on the above three circumstances analysis.
Finally, we bound the accepted requests by ALG and O PT . If the loop finally breaks, based on the analysis of Case 1 and Case 2, in each loop that ALG accepts one request pair, O PT accepts six request pairs that ALG could not accept; and whenever ALG accepts no request pairs, O PT accepts four request pairs. Notice that ALG accepts no request pairs in exactly two loops and the loop breaks. Suppose ALG accepts n request pairs (one is {r 1,1 , r 1,2 }), then O PT accepts 6(n − 1) + 8 request pairs. Therefore, we have |R * | |R | = 6i+8 i+1 > 6. If the loop does not break and works internally, based on the analysis of Case 1 and Case 2, for each loop that ALG accepts one request pair, O PT accepts six request pairs that ALG could not accept. Suppose ALG accepts n request pairs (one is {r 1,1 , r 1,2 }), then O PT accepts no less than 6(n − 1) request pairs. Since n → ∞, we have |R * | |R | = 6(n−1) n = 6.

ONLINETRANSFERSFORCOMMUTING with k cars
Theorem 5 For b u > b l ≥ t and b u ≥ b t + t, no deterministic online algorithm for OT FC − k with variable booking times can achieve a competitive ratio smaller than 4.
Proof Without loss of generality, suppose t = 1. Consider a sequence of request pairs that consists of 8 phases where phase i, 1 ≤ i ≤ 8, consists of l i groups of request pairs. l i = 1 for i = 1, 4, 6, 8. Let R i, j denote the set of request pairs in phase i group j. Each group consists of k copies of a request pair. If l i =1, let {r i,1 , r i,2 } denote the request pair in R i,1 ; otherwise, let {r i j,1 , r i j,2 } denote the request pair in R i, j . Suppose ALG accepts k i, j request pairs in phase i group j, R i, j . Let k i denote the number of request pairs that ALG accepted in phase i, j R i, j . Note that k i = j k i, j . At first, the adversary releases R 1,1 , consisting of k copies of the request pair {r 1,1 , r 1,2 } = {(0, b u , 0), (0, b u + 4, 1)}. We distinguish two cases based on the value of k 1,1 . Case 1: ALG accepts no more than k 4 request pairs in phase 1, i.e., k 1 = k 1,1 ≤ k 4 . O PT accepts all the request pairs in R 1,1 . We have P R * = k and P R ≤ k 4 , and hence Case 2: ALG accepts more than k 4 request pairs in phase 1, i.e., k 1 > k 4 . Then the adversary releases request pairs in phase 2 and phase 3 based on the releasing rule Algorithm 2. For all 1 ≤ j ≤ k, R 2, j consists of k copies of request pair Observe that r 2 j,1 with 1 ≤ j ≤ l 2 and r 1,1 are in conflict because t 1,1 − t 2 j,1 < 1, and r 3 j,1 with 1 ≤ j ≤ l 3 and r 1,1 are in conflict because t 3 j,1 − t 1,1 < 2 and Algorithm 2 Releasing rule for phase i 1: Input: j = 1 and the adversary releases R i, j .
We distinguish two sub-cases based on the value of k 1 + k 2 + k 3 + k 4 . Case 2.2.1: ALG accepts no more than 3k 4 request pairs in the first four phases, i.e., k 1 + k 2 + k 3 + k 4 ≤ 3k 4 . Recall that the request pairs in R 2,l 2 , R 3,l 3 and R 4,1 are not in

Greedy algorithm
In this section, we propose a Greedy algorithm (GA) for OnlineTransfersFor-Commuting, shown in Algorithm 3.
At first, we analysis the performance of GA for OT FC −1 with fixed booking times a ≥ t. Obviously, in the fixed booking times, the requests in R * and R are indexed Algorithm 3 Greedy algorithm (GA) 1: Input: k cars, request pairs arrive over time.
2: When request pair {r i,1 , r i,2 } arrives, 3: If {r i,1 , r i,2 } is acceptable, 4: accept {r i,1 , r i,2 }; 5: Otherwise, reject it. * Request pair {r i,1 , r i,2 } is acceptable to a car if and only if there is a schedule that no more than k cars can serve all request pairs R ∪ {r i,1 , r i,2 } without conflict. Proof We bound the competitive ratio of GA by analyzing each set R * i (obtained by the partition rule in Algorithm 4) independently. As Observe that for a request pair {r i,1 , r i,2 }, there are at most five request pairs whose first request starts later than t i,1 , which are in conflict with {r i,1 , r i,2 } (see Fig. 11 shows an example). Thus α = 5 and we have |R * i | ≤ 5, and the theorem follows.
Now we analyze the competitive ratio of OT FC − k with k ≥ 1 for both fixed booking time variant and variable booking time variant. Without loss of generality, let R denote the request pairs accepted by GA exactly before a new request pair arrives. Denote the union of the accepted requests in R and the requests in {r i,1 , r i,2 } by R = {r 1 , r 2 , ..., r 2|R |+2 } indexed in order of non-decreasing request start times. The requests with same start time are ordered according to their releasing times.
We say that a request pair {r i,1 , r i,2 } is acceptable if and only if there is a schedule that no more than k cars can serve all request pairs R ∪ {r i,1 , r i,2 } without conflict. To determine whether a request pair is acceptable or not immediately, we have the following property, see Lemma 2.
Lemma 2 When a request pair {r i,1 , r i,2 } arrives, {r i,1 , r i,2 } is acceptable if and only if the size of the maximum subset Sub is not greater than k, where Sub is a subset of R that any two requests in Sub are in conflict.
Proof Recall that a request pair {r i,1 , r i,2 } is acceptable if and only if there is a schedule that no more than k cars can serve all request pairs in R ∪{{r i,1 , r i,2 }} without conflict. Sufficient condition We claim that if the size of the maximum subset Sub is not greater than k, then there is a schedule that no more than k cars can serve all requests in R without conflict. If this claim holds, we get that {r i,1 , r i,2 } is acceptable, proving the lemma. Suppose the maximum subset of R that any two requests in this subset are in conflict is R sub . Note that |R sub | ≤ k. We schedule all requests in R one by one in order of request start times. For the simplification of analysis, we suppose that the cars are ordered. If a request r i, j is acceptable to some cars (r i, j and every request that assigned to these cars are not in conflict), we assign r i, j to the available car that comes first in that order. Since |R sub | ≤ k, no more than k consecutive requests are assigned to k different cars. There always exists a car whose every accepted request and a new request are not in conflict, and hence we can always schedule a request in R to that car. This establishes the claim, proving the sufficient condition. Necessary condition If {r i,1 , r i,2 } is acceptable, then there is a schedule that no more than k cars can serve all request pairs R ∪ {r i,1 , r i,2 } without conflict. Therefore the size of the maximum subset Sub is not greater than k. Otherwise, we get a contradiction because k cars could not serve all requests in subset Sub without conflict.
We refer to the car set of GA as S = {s 1 , s 2 , . . . , s k }, and the car set of O PT as S * = {s * 1 , s * 2 , . . . , s * k }. Let O PT j be the request pairs accepted by car s * j , and let G A j be the request pairs accepted by car s j .
Theorem 7 For b u > b l ≥ t, GA is 6-competitive for O T FC −k (k ≥ 1) with variable booking times. And for a ≥ t, GA is 6-competitive for O T FC − k (k ≥ 2) with fixed booking times.
Proof For car s * j , letR * j be the set of request pairs accepted by s * j that are not in R , and let R j be the set of request pairs accepted by s j that are not in R * . If the claim that | jR * j | ≤ α| k R j | for constant α holds and α = 6, we have |R * | |R | ≤ 6, proving the lemma.
It remains to prove the claim. Consider any request pair {r h,1 , r h,2 } inR * j . As s j for all s j ∈ S did not accept request pair {r h,1 , r h,2 }, according to Algorithm 3 and Lemma 2, s j must have been scheduled another request pair {r c,1 , r c,2 } in R j where one of the two requests is in conflict with request r h,1 ; otherwise, it would have been sufficient for s j to serve the scheduled request pairs and {r h,1 , r h,2 }. We charge {r h,1 , r h,2 } to {r c,1 , r c,2 }. In this way, every request pair inR * j is charged to a request pair in R j .
Then we bound the number of request pairs that can be charged to a single request pair {r c,1 , r c,2 } in R j . By the above charging scheme and recall Observation 1, every request that is served by s * j and charges to r c,1 (resp. r c,2 ) has a start time in (t c,1 − 2t, t c,1 + 2t) (resp. (t c,2 − 2t, t c,2 + 2t)) and pick-up location p c,1 (resp. p c,2 ), or has a start time in (t c,1 − t, t c,1 + t) resp. (t c,2 − t, t c,2 + t)) and pick-up locationṗ c,1 (resp. p c,2 ). As all requests have travel time at least t, the start times of consecutive requests (with the same pick-up location) accepted by s * j differ by at least 2t. Therefore,R * j contain at most (2 + 1) × 2 = 6 request pairs that charges to {r c,1 , r c,2 }. Hence {r c,1 , r c,2 } is charged by at most 6 request pairs fromR * j . This establishes the claim, with α = 6.

Balanced greedy algorithm
In this section, we propose a balanced greedy algorithm (BGA) for OnlineTrans-fersForCommuting with slotted pick-up times, shown in Algorithm 5. Recall that the pick-up time t i, j is an integer multiple of the travel time t, i.e., t i j = ν · t for some ν ∈ N. R i, j is the set of request pairs whose pick-up location is p(i, j) and pick-up time is t(i, j). If a car serves a request r i, j , we say that this car stops at locationṗ i, j at time t i, j + t.

6:
Step 2: Assign request r i, j at time t i, j − t.

7:
If |S i, j | ≥ 1, 8: assign it to a car in S i, j ; 9: Otherwise, assign it to a car who is not assigned to any requests starting at or after t i, j − t. * S i, j is the set of cars who stop at p i, j at time t i, j and has not be assigned to any requests starting at t i, j .

Lemma 3 In Algorithm 5, all requests accepted in
Step 1 could be assigned to a car in Step 2.
Proof Observe that all requests start no earlier than t since b l ≥ t. We claim that before assigning requests with pick-up time it (i ∈ N), at most k/2 cars stop at location 0 at time it and at most k/2 cars stop at location 1 at time it. If this claim holds, we could assign each accepted request with pick-up time it to a car by Step 2 in Algorithm 5 since the number of accepted requests with the same pick-up time and pick-up location is not greater than k/2, proving the lemma.
In the following, we will prove this claim by induction over the times it (i ∈ N). Base Case Initially, all cars stay at location 0. Consider base case i = 1 and i = 2. i = 1, consider the case of assigning requests with pick-up time t. Based on the problem setting that booking interval is greater than t, then no requests starts before t, and thus, no car stops at location 0 at time t and no car stops at location 1 at time t. i = 2, consider the case of assigning requests with pick-up time 2t. According to Step 1 in Algorithm 5, we know that BGA accepts no more than k/2 requests with pick-up time t and pick-up location 0 (resp. 1), thus, we know that at most k/2 cars stop at location 0 (resp. 1) at time 2t. Induction step We assume that at most k/2 cars stop at location 0 at time jt and at most k/2 cars stop at location 1 at time jt hold for all instances with j ≤ i and show that then at most k/2 cars stop at location 0 at time (i + 1)t and at most k/2 cars stop at location 1 at time (i + 1)t also hold for all instances.
Consider an instance of OT FC − k, R, where the pick-up time of the last request in R is it. Let R (i, 0) be the set of requests in R with pick-up time it and pickup location 0, R (i, 1) be the set of requests in R with pick-up time it and pick-up location 1. Since BGA accepts request pairs {r i,1 , r i,2 } if and only if |R i,1 | < k/2 and |R i,2 | < k/2 (see Step 1, GA at most accept k/2 requests with the same pick-up location and pick-up time), the number of accepted requests with pick-up time it and pick-up location 0 (resp. 1) is not greater than k/2. In other words, |R (i, 0)| ≤ k/2 and |R (i, 1)| ≤ k/2.
Theorem 8 For b u ≥ b l ≥ t, BGA is 4-competitive for O T FC − k (k = 2i, i ∈ N) with variable booking times and slotted pick-up times.
Proof For the purpose of the analysis, we partition the set of accepted request pairs R into a number of request sets R i with 1 ≤ i ≤ 2n, where n = t |R|,1 −t 1,1 t . R 2i−1 contains the requests with pick-up time t 1,1 + it and pick-up location 0, and R 2i contains the requests with pick-up time t 1,1 +it and pick-up location 1. The requests in set R i are indexed in order of non-decreasing pick-up times, and for the request with the same pick-up times, they are indexed by the time they are released. Note that each request r g,h has a unique mapping, defined by R f (r g,h ) (1 ≤ f (r g,h ) ≤ 2n), which contains all accepted requests with pick-up time t g,h and pick-up location p g,h . Observe that |R | = 1 2 2n i=1 |R i |. LetR * be the set of request pairs accepted by O PT , but did not accepted by BGA. By Step 1 in Algorithm 5, we know that BGA will reject a request pair {r i,1 , r i,2 } if and only if BGA has accepted k/2 request pairs which contains a request with pick-up location t i,1 and pick-up time p i,1 , or BGA has accepted k/2 request pairs which Open problems We studied the car-sharing problem with two locations, therefore, a natural direction is to explore it with many locations in different networks, such as a star network.