In design and analysis of algorithms, the model clearly plays an important role. A small modification of the model sometimes gives us a lot of gifts and stimulates subsequent research. Among many others, the removable online knapsack problem is such an example. A natural online model for knapsack is for each item coming in an online fashion, the online player has to decide whether to take or not irrevocably. However, it is easy to show that this model does not admit a finite competitive ratio. Iwama and Taketomi  introduced a model allowing to discard items in the knapsack once acquired, which allows them to design an competitive algorithm together with a simple but yet nontrivial analysis. The new model became popular immediately and has promoted a considerable amount of following research.
Our problem in this paper is the online car-sharing problem. In car-sharing (not only for cars, but also for other resources like bikes and shuttle-buses), there are several service stations in the city, for instance in residential areas and downtown, at popular sightseeing spots, and so on. Customers can make a request with a pick-up time and place and a drop-off time and place. The decision for accepting or rejecting a request should be made in an online fashion and we want to maximize the profit by accepting as many requests as possible. Relocation of the (unused) resource is usually possible with a much smaller or even negligible costs. (It is seen occasionally that a truck is carrying bikes for this purpose.)
Car-sharing problem. In the car-sharing problem, requests for car booking are submitted in an online fashion. While the company can get profits by serving customers within the requested duration, the goal of the car-sharing problem is to maximize the total profit. We mainly consider a setting with two locations (denoted by 0 and 1) and servers (i.e. cars), . The servers are initially located at location 0. The travel time from 0 to 1 and 1 to 0 is the same, denoted by . The problem for servers and two locations is called the S2L problem for short.
We denote the -th request by which is specified by the release time or the booking time , the start time , and the pick-up location (the drop-off location is , see Figure 1). If is accepted, the server must pick up the customer at at time and drop off the customer at at time . Suppose for each , is an integer multiple of the travel time between location 0 and 1, i.e., for some . We assume that is equal to a fixed value , where for all requests. Without loss of generality, we can assume that and then we are only interested in a discrete-time stage, denoted by 0, 1, 2, ….
Each server can only serve one request at a time. Serving a request yields a fixed positive profit . We allow empty movements, i.e., a server can be moved from one location to the other without serving any request. An empty movement spends time , but takes no cost. The goal of the S2L problem is to maximize the total profit by serving a set of online requests. Note that the performance of an online scheduling algorithm is typically evaluated by competitive analysis. More precisely, the quality of an online algorithm is measured by the worst case ratio, called competitive ratio, which is defined to be the fraction between the output of the algorithm and the result of the offline optimum that is aware of the whole sequence of requests in advance. The online algorithm is called -competitive, if for any instances, the outcome of the algorithm is at most times the offline optimum. So far the current model is exactly the same as S2L-F in [8, 9, 11, 10].
New online model. Recall the S2L model, discussed in . Suppose two (or more) requests, and , with the same booking time arrive. In S2L-F, the two requests still have an order, e.g., first and then , and we need to treat them in an online fashion. Namely, the player needs to make an online decision (accept or reject) for first and then for . Note that the adversary can change depending on the player’s decision for . Thus if are requests all having as their booking time, they come one by one, later than and before or at , each of which can get a decision immediately before the next request. Under the assumption of S2L-F, they proved that the competitive ratio of any deterministic algorithm is at least 1.5 and becomes as bad as 2 in the case when only two servers are available (i.e.
). This setting sounds reasonable as an online model, but the following question seems also natural; what if requests with the same booking time come exactly at the same time, and the player can see all of them and has to make decisions all together at the booking moment (equivalently the requests arrive in the same fashion as above but the player can delay his/her online decisions until the booking moment, as more elaborated at the end of this section)? In this study we consider this new model, denoted byS2L-S. We further extend the model and assume that the number of requests with the same booking time is at most for some constant , where is an integer. We call the generalized model S2L-S. Notice that having more than requests at the same location with the same booking time never helps. Therefore, we only need to study the case where and the model S2L-S corresponds to the case where .
Prior work. The car-sharing problem has received a considerable amount of attention in recent years. Luo et al.  studied the problem with one single server and two locations, and considered the problem for both fixed booking time and variable booking time. They showed the lower bounds on the competitive ratio for fixed booking time is , and for variable booking time if , where denotes the cost of the empty movement. They also proposed a greedy algorithm which achieves the best possible competitive ratio for both the variants of the problem. Later, Luo et al.  studied the car-sharing problem with two servers and two locations, i.e. 2S2L. They considered only the problem with fixed booking time and presented the lower bounds on the competitive ratio. They also proposed an online algorithm which can achieve the lower bound of two. Luo et al.  studied the car-sharing problem with servers and two locations, and showed the lower bounds for both fixed booking time and variable booking time. They proposed an algorithm which achieves the competitive ratio of 1.5 () when (). Very recently, Luo et al.  studied the car-sharing problem on a star network with servers, and considered only the problem with fixed booking time. Moreover, they considered two types of travel time: unit travel times and arbitrary travel time, and derived the competitive ratio of two () for unit travel time (arbitrary travel time). They also presented online algorithms which can meet the lower bounds.
In comparison with the online setting, Böhmová et al.  considered the offline car-sharing problem in which all input requests are known in advance. The objective is to minimize the number of vehicles while satisfying all the requests. The offline (i.e. static) problem can be solved in polynomial time. They also studied the problem with two locations and presented an algorithm which can offer two rides for each request. The problem model has been proved to be NP-hard and APX-hard. On the other hand, another closely related problem is the on-line dial-a-ride problem (OLDARP), where objects are transported between given points in a metric space. The problem has been studied widely. The goal is to minimize the total makespan [1, 2] or the maximum flow time .
In OLDARP, it is typically assumed that requests want to be finished as soon as possible. However, there are two variations of this problem. Christman et al.  studied a variation of OLDARP where each request yields a revenue and the goal of this variation is to maximize the total revenue within a time limit. Yi et al.  studied the other variation of OLDARP where each request has a deadline and the goal of this variation is to maximize the number of requests that are served before their deadlines. In , unsatisfied requests can be regarded as being called off and they are quite similar to the settings in the car-sharing problem.
|S2L-S ( is even)||Fixed||for||0||Deterministic||4/3||4/3||this paper|
|S2L-S ()||Fixed||for||0||Randomized||(2+)/3||(2+)/3||this paper|
Our contribution. In contrast with S2L-F, the best possible competitive ratio should be better, since the player has an obvious advantage in S2L-S and S2L-S. Indeed, we can prove that for any algorithms, the competitive ratio is at least for all . We also propose an online randomized algorithm (called Adaptive Greedy Balanced Algorithm (AGBA)) that optimally meets the bound on the competitive ratio for all . AGBA includes the case that , namely it works optimally for such inputs.
The performance of the proposed AGBA algorithm is pretty good if the number of requests does not exceed too much; for instance, if (at most excess than ), the competitive ratio becomes at most . That is, the profit of the algorithm is smaller than the offline optimum only by at most . For the case where (and the number of requests is unrestricted), we propose a simple deterministic algorithm called Greedy Balanced Algorithm (GBA) that optimally meets the bound on the competitve ratio for all even . For odd values of , the performance becomes worse, but the competitive ratio still approaches for a large value of .
Furthermore, we remark that both GBA and AGBA are designed in a different way from the concept of the Balanced Greedy Algorithm (BGA), reported in . The latter one partitions servers into several groups, and accepts online requests according to the partition rule. In contrast, our GBA algorithm attempts to balance the number of servers in two locations in every iteration, as far as possible. Moreover, this structure of our algorithm can even accommodate sequential inputs of S2L-F in  without losing the competitive ratio, as shown in Section 4 for a brief description.
Table 1 shows the comparison between the previous works and our results. The remainder of this paper is organized as follows. We first present the simple deterministic GBA algorithm as a warm-up in Section 2. Then we present our main algorithm AGBA with competitive analysis and show its expected upper bound in Section 3. Next we consider the lower bound of the S2L-S problem. We conclude with some discussions in Section 4.
2 The Basic Greedy Balanced Algorithm (GBA)
In this section, we introduce and analyze the deterministic GBA algorithm as a warm-up to the more general AGBA algorithm. Notice that the algorithm works in the S2L-S model (i.e., S2L-S model with ). The following table summarizes our notations which are used in the rest of the paper. In order to further discuss the competitive analysis of our algorithms, we use simple notation and to denote requests between location 0 and 1 at each moment.
|The number of total servers|
|:||Requests from location 0 to 1|
|:||Requests from location 1 to 0|
|:||The number of (0,1)’s requested in stage with start time|
|:||The number of (1,0)’s requested in stage with start time|
|:||The number of (0,1)’s accepted by the algorithm in stage|
|:||The number of (1,0)’s accepted by the algorithm in stage|
|:||The number of servers not accepted, i.e.,|
|:||The number of (0,1)’s accepted by OPT in stage|
|:||The number of (1,0)’s accepted by OPT in stage|
|:||The number of servers not accepted, i.e.,|
The idea of this greedy balanced algorithm can be illustrated as follows. All servers are at location 0 in stage 0. An arbitrary number of servers can be moved to location 1 if needed in stage 1. We can think of all servers as "floating", available at either location 0 or 1. Let and suppose requests in stage 1 are . Thanks to the floating servers, we can assign 100 servers freely to locations 0 and 1, such as (100,0), (75,25) or (0,100). (Recall is the number of accepted (0,1)’s and (1,0)’s.) However, if (100,0) is selected, then all the servers are at location 1 in stage 2, and the adversary would send , no servers available for the online player. Since the almighty adversary can select (0,100) in stage 1, the competitive ratio would be 2. Thus one can easily see that the best thing an algorithm can do is to accept in stage 1 to secure a competitive ratio of 1.5. This is the notion of "Balanced".
What if ? In this case, is the best, i.e., the strategy is a simple "Greedy" one. If , our selection is , namely "Greedy" but as "Balanced" as possible. Algorithm 1 realizes this idea almost as it is. This should help for the following introduction of our main algorithm.
In Algorithm 1, first notice that and are the maximum number of (0,1) and (1,0) requests that the algorithm can accept in stage . If , the algorithm first accepts as many (0,1) requests as possible (using at most half of all servers), then accepts as many (1,0) requests as possible. Therefore, the algorithm is greedy. Similar for the case where (as shown in Figure 2). If both and are large, the algorithm splits the servers as evenly as possible, which is what we call “balanced”. The following theorem shows that GBA achieves the optimal -competitive ratio for all even and approaches this value when is a large odd number. In the rest of this paper, we use ALG to denote any online algorithm and OPT an offline optimal scheduler.
GBA is -competitive, where .
In order to prove the theorem, we consider the following six key values:
Our goal is to bound by . To do so, it is popular to use a potential function for competitive analysis, which is typically the difference between configurations of ALG and OPT. In our present case, it may be the difference between server allocations of GBA and OPT. It turns out however that this configuration difference or a similar one is unlikely to work since we still have a freedom for server selection which is not controlled by this difference strongly. Instead we introduce four parameters, , , and , which play a key role in our proof. Note that and denote the total revenue of GBA and OPT respectively for the first stages assuming that the adversary tries to penalize the algorithm choice by introducing (1,0)-requests in stage ; the last two values, and , denote the total revenue of GBA and OPT respectively for the first stages assuming that the adversary tries to penalize the algorithm choice by introducing (0,1)-requests in stage . Intuitively, GBA balances the accepted requests in both directions and guarantees that the competitive ratios in these two instances ( and , respectively) are not too large. It turns out that taking care of these two extreme instances is sufficient to keep the competitive ratio low for all instances.
In order to prove that the algorithm is -competitive, we show that the set of inequalities:
hold for every by induction.
For the base case, , we have and . Thus the three inequalities hold obviously.
Now the main part of the proof is proving assuming that holds for all . Note that we can rewrite , , and so on as follows:
Since and , the following lemma is obvious, but will be used frequently. .
Now we are ready to take a look at each combination of the three cases given in lines 2, 5 and 7 in GBA and the three inequlities (i) to (iii), one by one. The first case is that and (iii). Suppose that . Using (line 3 of GBA) and in Lemma 2, we have
Thus (iii) is true since by the induction hypothesis on (i). The proof for is done by replacing by in and by in (Lemma 2) and using the induction on (ii).
We next prove (ii) under the same case of . Suppose first . Then and we further need to consider the two cases comparing and . However, one can see and look very similar to the above and in both cases and can use a similar analysis (omitted). Next assume . Then note and we have
Thus (ii) is also true by the hypothesis on (i) and . We are done.
Now what remains is (i) for . If then we are done since GBA accepts requests in total. Otherwise, we have
We need to consider four cases due to the two functions for , but it cannot happen that both and hold since if they do, , , and so , which contradicts .
GBA can also accept requests if both and hold. For each of the other two cases, we can use the corresponding bound of Lemma 2. For instance, for and , we can use and and the hypothesis on (ii). Similarly for the other. Thus we are done for .
The case where (line 5) is symmetric and may be omitted. So, we move on to the case that , , and . In this case, (i) is obvious since . For (ii) and (iii),
Since , by the induction hypothesis and , both inequalities hold. Thus the theorem is proved. ∎
The next theorem shows the tightness and therefore the GBA algorithm is optimal.
No deterministic online algorithms for the S2L-S problem can achieve a competitive ratio of less than .
Let be any deterministic algorithm. The adversary requests (0,1)’s and (1,0)’s in stage 1. accepts (0,1)’s and (1,0)’s. If , then the adversary requests (1,0)’s (and zero (0,1)’s) in stage 2. The profit of is in stage 1, and at most in stage 2. Therefore, the total profit of is at most The profit of OPT is and the theorem is proved. If , then . Now the adversary requests (0,1)’s in stage 2. The profit of and OPT are exactly the same as above and we may omit the rest of calculation. Thus the bound is tight. ∎
3 Adaptive Greedy Balanced Algorithm (AGBA)
Now we are ready to present Adaptive Greedy Balanced Algorithm (AGBA) in Algorithm 2
, which is probably the most general algorithm for our problem. It works as good as GBA for an evenand better for an odd thanks to randomization. Furthermore, if the number of requests is limited to at most at each iteration, for some such that and is an integer, it also works better than GBA. Note that we do not need to know in advance, namely AGBA automatically accommodates such a restricted input to provide the better performance, achieving the absolute tightness due to Theorem 3 later in this section. The basic idea is as follows:
Suppose . GBA accepts the same number, 50, of (0,1)’s and (1,0)’s in stage 1. Then the adversary sends , resulting in that only 50 (0,1)’s can be accepted by GBA in stage 2, but 100 ones by OPT which could accept 100 (1,0)’s in stage 1. Thus the competitive ratio in these two steps is 4/3. Our new AGBA, on the other hand, accepts roughly 28.57 (0,1)’s and 71.43 (1,0)’s in stage 1 (as expected numbers due to randomized rounding). Then the best the adversary can do is to provide or , in both of which the competitive ratio is , significantly better than 1.5 of GBA. Note that in AGBA, these key values 28.57 and 71.43 are denoted by and , respectively.,We also use a new parameter . The ultimate goal of AGBA is to accept exactly (0,1)’ and (1,0)’s as the ultimate goal of GBA was to accept (0,1)’s and (1,0)’s. If this goal is unachievable, both algorithms simply turn greedy. Note that, in each stage, at most one server needs to randomize between (0,1) and (1,0) requests. All other servers are deterministically assigned.
The competitive analysis is given by the following theorem. Note that if the input in stage includes more than (0,1)’s, we can select an arbitrary subset of size and similarly for (1,0)’s. This guarantees that and the case that is covered by . Thus the restriction of , , makes sense. Also, note that whenever . AGBA uses but not .
Suppose the number of requests is limited to at most in each stage for some such that and is an
integer. Then the competitive ratio of AGBA is at most
It is well known that due to the standard randomized rounding (line 12), the expected value of (, resp.) is (, resp.). Hence we can use the fractional values, and as and , for analysis, if they are set in lines 12 and 13.
We use the same notation as before and the goal is to prove the following set of inequalities.
by induction. For the base case, , we have and . Thus (i) – (iii) hold obviously. To prove assuming that holds for all , we use two lemmas; the first one is straightforward and the second one plays a key role. For any , and . Let . Then and .
Just a simple calculation:
Similarly for the other. ∎
We start with the case that (line 6) and prove (iii) first. Since (line 7) and by Lemma 2,
Thus (iii) is proved since by the induction hypothesis.
Due to and , combining with Lemma 3, it follows . Now the induction hypothesis, , implies (ii), as required.
For the remaining (i) again under , if , then AGBA accepts requests in total and so (i) is obviously true. Hence suppose . For OPT, by using and in Lemma 2, we have
Thus (i) is true by the induction hypothesis on (ii).
The case that (line 9) is very similar and may be omitted. So, we move on to the case that and . As mentioned in the beginning, we can set and , both maybe fractional. (i) is obvious since AGBA accepts requests. For (ii),
and is exactly the same as above, and we are done. For (iii) we have
and similarly it is proved using Lemma 3.
Next, we prove the lower bound on the competitive ratio of any online algorithm in the S2L-S problem. Note that randomization is used only for rounding in AGBA; in other words, the role of randomization is limited in this problem. Indeed, we can prove the lower bound for any randomized algorithms in a way similar to the deterministic case by referring to Theorem 2.
Recall that satisfies that and is an integer. No randomized online algorithms for the S2L-S problem can achieve a competitive ratio of less than .
Let be any randomized algorithm. The adversary requests (0,1)’s and (1,0)’s in stage 1 ( by the integrality condition). accepts (0,1)’s and (1,0)’s. Let and if (the adversary has a full information of , so it can compute ), then the adversary requests (1,0)’s (and zero (0,1)’s) in stage 2. The profit of is at most
The profit of OPT is and the theorem is proved. If then let and it is easy to see that . Hence we have because . Now the adversary requests (0,1)’s. The profit of and OPT are exactly the same as above by replacing by and we may omit the rest of calculation. ∎
4 Final Remarks
Recall that under the current setting of the proposed model, S2L-S, our algorithms can see all the requests (0,1)’s and (1,0)’s (for start time ) at booking time . However, as mentioned before, this setting is equivalent to the scenario in which those requests come sequentially before or at time but the online player can delay his/her decisions until time . That is, the player can still see all those requests before the decisions.
Note that in S2L-F in , such delays are not permitted. It would be better if we can modify our GBA to make immediate decisions even for a part of the requests. In fact, there is a common practice based on "first come first served for early bookings and call the office for late ones". We present three modifications of GBA in Appendix. The first Accept or wait GBA is basically the same as GBA, just accepting (early) requests immediately if it does not affect the final or . Its competitive ratio does not change at all. Its decisions can be delayed for at most requests in the worst case, but much less for non-extreme inputs. We can make a similar modification to AGBA.
By simply changing wait to reject, we obtain the next Accept or reject GBA() which includes no delay at all, and so completely accommodates S2L-F. Its downside is a worse competitive ratio, which is 2. Fortunately, however, we can improve the competitive ratio only by changing a parameter value as shown in the third Accept or reject GBA() to 1.5 for a large value of . Thus our GBA can achieve the same performance as the online algorithm reported in  without changing its basic structure.
The idea of combining greedy and balancing strategies appeared in . However, its implementation here is quite different and turned out to be powerful. In fact the main reason that we lose a competitive ratio in sequential inputs compared to simultaneous inputs as mentioned above is due to the fact that balancing is more difficult in the former. We believe that this fundamental idea and its specific implementation also play a key role in the future research for more general versions of car-sharing.
-  Norbert Ascheuer, Sven O. Krumke, and Jörg Rambau. Online dial-a-ride problems: Minimizing the completion time. In Proceedings of the 17th Annual Symposium on Theoretical Aspects of Computer Science (STACS’00), pages 639–650, 2000.
-  Antje Bjelde, Yann Disser, Jan Hackfeld, Christoph Hansknecht, Maarten Lipmann, Julie Meißner, Kevin Schewior, Miriam Schlöter, and Leen Stougie. Tight bounds for online tsp on the line. In Proceedings of the 2017 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA’17), pages 994–1005, 2017.
-  Kateřina Böhmová, Yann Disser, Matúš Mihalák, and Rastislav Šrámek. Scheduling transfers of resources over time: Towards car-sharing with flexible drop-offs. In Proceedings of the 12th Latin American Symposium on Theoretical Informatics (LATIN’16), volume 9644 of LNCS, pages 220–234, 2016.
-  Ananya Christman, William Forcier, and Aayam Poudel. From theory to practice: maximizing revenues for on-line dial-a-ride. Journal of Combinatorial Optimization, 35(2):512–529, 2018.
-  Esteban Feuerstein and Leen Stougie. On-line single-server dial-a-ride problems. Theoretical Computer Science, 268(1):91–105, 2001.
-  Kazuo Iwama and Shiro Taketomi. Removable online knapsack problems. In International Colloquium on Automata, Languages, and Programming (ICALP’02), pages 293–305. Springer, 2002.
-  Sven O. Krumke, Willem E. de Paepe, Diana Poensgen, Maarten Lipmann, Alberto Marchetti-Spaccamela, and Leen Stougie. On minimizing the maximum flow time in the online dial-a-ride problem. In Proceedings of the Third International Conference on Approximation and Online Algorithms (WAOA’05), page 258–269, 2005.
-  Kelin Luo, Thomas Erlebach, and Yinfeng Xu. Car-sharing between two locations: Online scheduling with flexible advance bookings. In 24th International Computing and Combinatorics Conference (COCOON’18), volume 10976 of LNCS, pages 242–254, 2018.
-  Kelin Luo, Thomas Erlebach, and Yinfeng Xu. Car-Sharing between Two Locations: Online Scheduling with Two Servers. In 43rd International Symposium on Mathematical Foundations of Computer Science (MFCS’18), volume 117 of LIPIcs, pages 50:1–50:14, 2018.
-  Kelin Luo, Thomas Erlebach, and Yinfeng Xu. Online Scheduling of Car-Sharing Requests Between Two Locations with Many Cars and Flexible Advance Bookings. In 29th International Symposium on Algorithms and Computation (ISAAC’18), volume 123 of LIPIcs, pages 64:1–64:13, 2018.
-  Kelin Luo, Thomas Erlebach, and Yinfeng Xu. Car-Sharing on a Star Network: On-Line Scheduling with Servers. In 36th International Symposium on Theoretical Aspects of Computer Science (STACS’19), volume 126 of LIPIcs, pages 51:1–51:14, 2019.
-  Andrew Chi-Chin Yao. Probabilistic computations: Toward a unified measure of complexity. In 18th Annual Symposium on Foundations of Computer Science (FOCS’77), pages 222–227. IEEE Computer Society, 1977.
-  Fanglei Yi and Lei Tian. On the online dial-a-ride problem with time-windows. In International Conference on Algorithmic Applications in Management (AAIM’05), pages 85–94. Springer, 2005.