An online joint replenishment problem combined with single machine scheduling

This paper considers a combination of the joint replenishment problem with single machine scheduling. There is a single resource, which is required by all the unit-time jobs, and a job can be started at time point t on the machine if and only if the machine does not process another job at t, and the resource is replenished between its release date and t. Each replenishment has a cost, which is independent of the amount replenished. The objective is to minimize the total replenishment cost plus the maximum flow time of the jobs. We consider the online variant of the problem, where the jobs are released over time, and once a job is inserted into the schedule, its starting time cannot be changed. We propose a deterministic 2-competitive online algorithm for the general input. Moreover, we show that for a certain class of inputs (so-called p-bounded input), the competitive ratio of the algorithm tends to 2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\sqrt{2}$$\end{document} as the number of jobs tends to infinity. We also derive several lower bounds for the best competitive ratio of any deterministic online algorithm under various assumptions.


Introduction
In this paper, we study a combination of the classical joint replenishment problem (JRP) with machine scheduling, proposed recently by Györgyi et al. (2021).The joint replenishment problem seeks an optimal replenishment policy of one or several items required to fulfill a sequence of demands over time.When combined with machine scheduling, a demand is fulfilled only after the required item is replenished, and, in addition, processed on a machine for a given amount of time.The machine processes the demands in some order that has to be determined.The cost to be minimized has two main components: one is related to the replenishment of the items, and another to the scheduling of the demands on the machine.An example for the former one is a fixed cost due each time some item is replenished, while a possible scheduling related cost is the maximum flow time, which is the maximum difference between the completion time of a demand on the machine and its arrival time.The processing of the demands on the machine adds an extra twist to the problem, and it may delay the fulfillment of the demands.NP-hard even in case of linear delay cost functions, which follows from the NP-hardness of another variant examined by Arkin et al. (1989) (called JRP-INV), by reversing the time line.Later, Nonner and Souza (2009) proved the NP-hardness of a more restricted variant, where each item admits only three distinct demands over the time horizon.Buchbinder et al. (2013) described a 3-competitive algorithm for the online problem with linear delay function, and they gave a lower bound of 2.64 for the best competitive ratio of any online algorithm.The latter was strengthened in Bienkowski et al. (2014) to 2.754, and the authors also proposed a 1.791-approximation algorithm for the offline problem.
There are a lot of results for offline and online single machine scheduling problems for different optimization criteria such as C j (Lenstra et al., 1977;Afrati et al., 1999;Chekuri et al., 2001), w j C j (Anderson and Potts, 2004;Hoogeveen and Vestjens, 1996;Goemans et al., 2002) or F j (Kellerer et al., 1999;Epstein and Van Stee, 2001).The F max objective is a special case of the L max objective, where the goal is to minimize maximum lateness (Lageweg et al., 1976).Jackson (1955) showed that the optimal solution for the problem 1||L max can be obtained by scheduling the jobs in non-decreasing order of their due dates, called the EDD rule.On the other hand, Lenstra et al. (1977) showed that the problem 1|r j |L max is strongly NP-hard.
For 1|r j |L max , Hall and Shmoys (1992) proposed an O(n 2 log n) algorithm with a worst-case ratio of 4/3, and they also described two Polynomial Time Approximation Schemes.The online variant is analyzed by Hoogeveen and Vestjens (1996).They showed that no online algorithm can obtain a competitive ratio better than ( √ 5 + 1)/2.Using the EDD rule whenever the machine becomes idle leads to a 2-competitive algorithm, and by introducing a clever waiting strategy, the competitive ratio reaches the lower bound of ( √ 5 + 1)/2.Györgyi et al. (2021) analyzed the combination of the joint replenishment problem (JRP-W) and the single machine scheduling with different scheduling objective such as C j , w j C j , F j and F max .For the latter, the authors showed that if there are two resources, the problem is NP-hard even under very strong assumptions.For 1|jrp, s = 1, r j |F max and 1|jrp, s = const, p j = p, r j |F max , polynomial algorithms based on dynamic programming were proposed.The paper also considered some online variants of the problem with the w j C j , F j , and F max objectives.For the former two objectives, deterministic 2-competitive online algorithms were proposed, while for the F max objective, only a special case was considered where a job arrives every time unit till an unknown time moment, so-called regular input.For the latter online problem, a deterministic √ 2-competitive algorithm was described, and it was shown that there is no deterministic (4/3 − ε)-competitive algorithm for any ε > 0. For the general input, it was shown that no deterministic online algorithm can achieve a competitive ratio better than ( √ 5 + 1)/2.Organization of the paper .We provide the problem formulation and an overview of our results in Section 2. In Section 3, we present some properties of the offline optimum for later use.In Section 4, we propose a deterministic 2-competitive online algorithm for the general input, and also prove that for p-bounded input, the competitive ratio of the same algorithm tends to √ 2. In Section 5 we present numerical results regarding to the algorithm proposed in Section 4. In Section 6, we derive lower bounds for the best competitive ratio for the general and p-regular input, respectively.We conclude the paper in Section 7.

Problem formulation and overview of main results
There is a set of n jobs J , one resource, and a single machine.Each job j has a processing time p j = 1, and a release date r j .The release dates are distinct i.e. r j = r k if j = k.A job can be processed on the machine from time t only if there is a replenishment from the resource in [r j , t].Each replenishment incurs a cost of K.All data is integral.
A solution of the problem is a pair (S, Q), where S = {S j , j ∈ J } is a schedule specifying the starting times of the jobs, and Q = {τ i , 1 ≤ i ≤ q} is the set of replenishment times of the resource such that τ i is the i th replenishment time, and τ i < τ i+1 for each i = 1, . . ., q − 1.The solution is feasible, if the jobs do not overlap in time, i.e. S j + 1 ≤ S k or S k + 1 ≤ S j holds for each j = k, and for each job j ∈ J there exists some τ i ∈ Q such that τ i ∈ [r j , S j ].The completion of job j in schedule S is C j = S j + 1, and its flow time is F j = C j − r j .The replenishment cost of a solution is c Q := Kq, while the maximum flow time is F max = max j∈J F j .The cost of a solution is cost(S, Q) = c Q + F max .We seek a feasible solution of minimum cost.
In the online problem, the jobs arrive over time, and there is no information about them before their release date.The solution is constructed step-by-step, the starting time of a job and the replenishment times, once fixed, cannot be reversed.However, upon arrival of the last job, the scheduler is notified immediately that there will be no more jobs.
An input is called p-regular , if r j = (j − 1)p for j ≥ 1, for a given integer p ≥ 1.It is regular if it is 1-regular.We will also consider p-bounded input, where the only known information about the input is that the difference of two consecutive release dates is upper bounded by some number p, i.e., r j+1 − r j ≤ p for j ≥ 1.
We illustrate the problem and its possible solutions in Example 2.
Example Consider an input consisting of two jobs, with release dates r 1 = 0 and r 2 = t for some t ≥ 1.If an algorithm makes two replenishments in τ 1 < t and τ 2 = t, then the cost of this solution is cost(S, Q) = 2K + τ 1 + 1.However, if we postpone the replenishment and the starting time of the first job, then the objective is cost(S , Q ) = K + t + 1.We have saved K at the replenishment cost, but the maximum flow time has increased by t − τ 1 .Depending on whether K or t − τ 1 is bigger, the first or the second solution has a smaller cost.See Figure 1 for an illustration.Of course, in an online setting we do not know when the second job is released, therefore, we have to make the decision about the first replenishment time τ 1 before time t.
Figure 1: Two feasible solutions.The arrows below the axis denote the replenishments.
In this article, we focus on the online problem 1|jrp, s = 1, p j = 1, distinct r j |F max + c Q .First, we present some preliminary results regarding the offline optimal solution.Although Györgyi et al. (2021) already covered the offline variant of the problem, these results help in the analysis of the proposed online algorithm.We show that if the release dates of the jobs are not necessary distinct, then the problem 1|jrp, s = 1, , when the jobs can have arbitrary processing times), see Proposition 1.This justifies our assumption that the jobs have distinct release dates.
We devise a deterministic 2-competitive online algorithm for the problem 1|jrp, s = 1, p j = 1, distinct r j |F max +c Q .For the so-called sparse input, where the difference between two consecutive release dates r j and r j+1 is lower bounded by Kj, this analysis is tight.On the other hand, we show that for the p-bounded input, the competitive ratio of the algorithm tends to √ 2 as the number of jobs tends to infinity.This result generalizes the one of Györgyi et al. (2021) for the regular input, and although it does not reach the √ 2-competitive ratio for short sequences of jobs, in the long run it gets arbitrarily close to it.
Lastly, we provide new lower bounds for the best competitive ratio.For the general input, there is no online algorithm with competitive ratio of 3/2, even if there are only two jobs in the input.In the case of three jobs, this lower bound is 4/3.We also provide a lower bound for the best competitive ratio in the case of the p-regular input.For long sequences of jobs (i.e., where the last job arrives at some large time point t > t 0 ), there is no algorithm with a competitive ratio better than 1.015.
We mention that our online model is slightly different from that of Györgyi et al. (2021).While in this paper, upon the arrival of the last job we get the information that there will be no further jobs, in Györgyi et al. (2021) this information is not available at once.Therefore, the presented lower bounds cannot be directly compared with each other.In fact, we receive a smaller lower bound for the general case (3/2 instead of ( √ 5 + 1)/2).We summarize our new results, along with some previous ones in Table 1. 3 Properties of the offline optimum In this section we are going to present some properties of the offline optimal solution regarding the general, p-regular and p-bounded input.Denote with OP T (I) the offline optimum for input I.
First we make some easy observations: Observation 1.It is enough to consider solutions for which the jobs are scheduled in increasing order of their release date.
Observation 2. It suffices to replenish the resource only at the release dates of some jobs (Györgyi et al., 2021).
In this article, we only consider inputs where the release dates are distinct.If this condition does not hold, the problem is equivalent to a more general problem: Proposition 1.If the release dates are not distinct, then the problem 1|jrp, s = 1, p j = 1, r j |F max is equivalent to the problem 1|jrp, s = 1, r j |F max , i.e., when the jobs have arbitrary processing time.
Proof.Consider an optimal solution (S , Q ) for the input I of the problem 1|jrp, s = 1, p j = 1, r j |F max .Let I t be the set of jobs released at time t in I.By Observation 1, the jobs are ordered in non-decreasing order of their release dates in (S , Q ), hence, jobs in I t are scheduled consecutively after each other.Let I be the following input for the problem 1|jrp, s = 1, r j |F max : for each t, for which I t = ∅, define a job j such that r j = t and p j = |I t |.Observe that the solution (S , Q ) is feasible for I .
For the other direction, consider an input I for the problem 1|jrp, s = 1, r j |F max , and let (S , Q ) be an optimal solution.Now let the input I for the problem 1|jrp, s = 1, p j = 1, r j |F max be the following: for each j ∈ I , define p j unit-length jobs with release date r j .Similarly, (S , Q ) is a feasible solution for I. Therefore, the two problems are equivalent, hence the statement is proved.
From now on, we only consider the problem 1|jrp, s = 1, p j = 1, distinct r j |F max .
Observation 4. For any feasible schedule, consider any pair of two jobs, j and k (for which r j < r k ), scheduled consecutively, i.e., S j + 1 = S k , on the machine.Then F j ≥ F k .
From this observation, we can conclude the following: Observation 5.For any feasible solution, the maximum flow time is given by the first job scheduled in some τ i , such that the machine is idle before τ i .
Following Observations 1 and 2, we only consider offline solutions where the replenishments occur at the job release dates, and the jobs are scheduled in increasing release date order as soon as possible (i.e., after each of the earlier jobs are scheduled and after the first replenishment following their release date).
Next, we derive some properties of the p-regular input consisting of n jobs, which we denote by R n .Observation 6.Consider the p-regular input R n .
i) If there is a replenishment which provides resource for at least n jobs in a feasible solution, then the maximum flow time is at least (n − 1)p + 1.
ii) For any feasible solution with q replenishments, there exists a job which has a flow time of at least ( n/q − 1)p + 1.
iii) The cost of any feasible solution with q replenishments is at least qK + ( n/q − 1)p + 1.
Proof.Let τ be the time of the replenishment, and denote with f and the first and the last job in the schedule for which the replenishment is in τ .Then, τ ≥ r = r f + (n − 1)p, from which i) follows.
If there are n jobs, then by pigeonhole principle, there is a replenishment which provides resources for at least n/q jobs.Then, ii) follows from i).
iii) follows directly from ii).
Proposition 2. For the p-regular input, the minimum cost of any solution with q replenishments is qK + ( n/q − 1)p + 1.
Proof.We construct a feasible solution with q replenishments and total cost as claimed.
Let r be such that n = q n/q + r.Let and schedule the jobs in increasing release date order as soon as possible.Let j be the k th job (k ≥ 1) arriving after τ i , but not later than τ i+1 for i = 0, . . ., q − 1.Then τ i < r j = τ i + kp ≤ τ i+1 , and . By Observation 4, this expression is maximal if k = 1.Therefore, F max ≤ ( n/q − 1)p + 1 and the cost of this solution is at most qK + ( n/q − 1)p + 1. Equality follows from Observation 6.Now it follows immediately that Lemma 1.For p-regular input, the offline optimum is (Kq + ( n/q − 1)p + 1) .
The q * giving the minimum value is the number of replenishments in an optimal solution.
Next we derive lower and upper bounds on the optimum for p-regular input.To this end, we define the function f (q): f (q) = Kq + (n/q − 1)p + 1.
Note that f (q) is quite similar to the expression for OP T (R n ) in Lemma 1.
Proof.By Lemma 1, we can derive This expression is minimal if q = np/K, for which we obtain the minimum value of 2 Proof.By Lemma 1, there exists some q * ∈ Z ≥1 such that It is easy to see that f (q ) ≤ OP T (R n ) ≤ f (q ) + p.Let q = np/K be the point minimizing f (q) on the positive orthant.Observe that f (q) is a convex function, hence |q − q | < 1 holds.We distinguish two cases.
First assume q ≤ q < q + 1.Then Second, assume q < q ≤ q + 1, and we verify that from which the statement follows.To see this, we compute f (q) = K q + (n/q − 1)p + 1 ≥ Kq + (n/(q + 1) − 1)p + 1 where the first inequality follows from q < q ≤ q +1 by assumption, the second from the properties of integer rounding, and the last from the definition of q .
Let I be an p-bounded input, where the first job arrives in t min , and the last job arrives in t (this means that the last job can be completed earliest in t + 1).Consider the regular input and the p-regular input between t min and t denoted by D I and R I , respectively.See Figure 2 for an illustration of these three different inputs in the case of p = 3.

I t min
t + 1 Proof.Consider an optimal solution for the input D I .Since I ⊆ D I , by removing the jobs in D I \ I from this optimal solution, we obtain a feasible solution for I. Therefore OP T (D I ) ≥ OP T (I).Now consider an optimal solution (S , Q ) for the input I, with maximum flow time of F max .Observe that the number of jobs in I is at least the number of jobs in R I (otherwise I would not be a p-bounded input).Let j i and j i be the i th job in R I and I, respectively.It is easy to see that r ji ≥ r j i for i ∈ {1, . . ., |R I |}.
We are going to create a feasible solution (S, Q) for R I from the optimal solution for I: let Q := Q , and S ji := S j i for i ∈ {1, . . ., |R I |}.Since r ji ≥ r j i ∀ i, this is indeed a feasible solution for R I , with maximum flow time of at most F max , and with the same replenishment cost.Therefore, OP T (I) ≥ OP T (R I ).

Online algorithm for the general input
Consider Algorithm 1: For an input I, denote the cost provided by Algorithm 1 with ALG(I), and let q be the total number of replenishments, and τ 1 , . . ., τ q the replenishment times.
We can also make an observation regarding the behaviour of Algorithm 1 for the sparse input.Theorem 3. On general input, if there are only two jobs released, there is no online algorithm with competitive ratio better than 3/2.
Proof.Consider an arbitrary online algorithm.Suppose that the first job is released at 0, and the algorithm replenishes and starts this job at t.Then, assume that the last job is released at t + 1, therefore the algorithm schedules that job immediately, and then stops.Hence, ALG = 2K + t + 1.
On the other hand, OP T = min{2K + 1, K + t + 2}, because it either replenishes the resource once at t + 1 or twice at 0 and at t + 1.There are two cases to consider: 2. If K > t, then OP T = K + t + 2, therefore, Therefore, no online algorithm can obtain a competitive ratio better than 3/2, even if there are only two jobs released.Theorem 4. On general input, if there are at least three jobs released, there is no online algorithm with competitive ratio better than 4/3.
Proof.Consider an arbitrary online algorithm.Suppose that the first job is released at 0 and the algorithm replenishes and starts this job at t 1 .Then, a second job is released at t 1 + 1, and the algorithm replenishes and starts this job at some t 2 ≥ t 1 .Finally, the third and last job is released at t 2 + 1 which is replenished and started immediately.
We can assume that the flow time of the second job is at least the flow time of the first job, i.e. t 1 + 1 ≤ t 2 − t 1 , since replenishing and starting the second job sooner would not decrease the maximum flow time of the algorithm.Hence, ALG = 3K + t 2 − t 1 .
Now we consider the p-regular input consisting of n jobs, denoted by R n .That is, r j = (j − 1)p for 1 ≤ j ≤ n.In Section 4 we have presented a 2-competitive online algorithm whose competitive ratio tends to √ 2 as the number of jobs tends to infinity.In this section we investigate the question whether the above limit of √ 2 could be decreased to 1 + ε for an arbitrary small ε > 0. So, we will consider only long sequences of jobs, i.e., where the number of jobs is larger than some number n 0 , which is independent of the input.Lemma 4. On p-regular input, there exists n 0 > 0 such that for any n ≥ n 0 , the number of the replenishments in any c-approximate solution for R n is in where ε n → 0 as n → +∞.
Proof.From Lemma 3, we have OP T (R n ) ≤ 2 √ npK + K + 1.Hence, the objective function value in any c-approximate solution is at most c( 2√ npK + K + 1).Since K ≥ 1, the upper bound on the number of the replenishments immediately follows.
On the other hand, we will prove that if the number of the replenishments is too small, then the flow time of the solution is larger than the upper bound for a c-approximate solution.Suppose for contradiction that we have q < 1/(2c + ε n ) • np/K, where ε n → 0 as n tends to +∞.After a small transformation, we get and then, np c(2 if n ≥ n 0 for some n 0 > 0. We can reduce the denominator on the left-hand-side by using Rearranging terms gives np/q − p + 1 > c • OP T (R n ).
Notice that the left hand side is smaller than qK + n/q • p − p + 1, which is the cost of a schedule with q replenishments by Observation 6.Therefore, q replenishments are not enough to obtain a c-approximate solution.
Lemma 5. On p-regular input, there exist a series ε n such that ε n → 0 as n → ∞, and some integer n 1 > 0 such that for any n ≥ n 1 , the maximum flow time in any c-approximate solution for R n is in Proof.The upper bound on the flow time follows immediately from the upper bound of Lemma 3 on OP T (R n ).
We proceed with the lower bound.Let F be the maximum flow time of a solution with q replenishments.By Proposition 2, we have After small transformations we get (F + p − 1)/p ≥ n/q ≥ n/q, from which it follows that the number of the replenishments q is at least np/(F + p − 1), thus the replenishment cost is at least npK/(F + p − 1).
Suppose the statement of the lemma does not hold, i.e., F < (K 3/2 (n − 1)p)/((2+ε n )c)−p+1, for every ε n → 0 as n → ∞.We will prove that then where the left hand side is a lower bound on the replenishment cost (see above), and the right hand side is an upper bound on the cost of a c-approximate solution (cf.Lemma 3), which is a contradiction, and the claimed lower bound on the maximum flow time follows.To this end, we rewrite our indirect assumption: Observe that for ε n = (K + 1)/ np/K, we have ε n → 0 as n → ∞, and which implies (1).
Theorem 5.For any n 0 > 0, there is no deterministic online algorithm which is 1.015 competitive on any p-regular input R n with n > n 0 even if K = 1.
Proof.Fix any n 0 > 0. Suppose there is a c-competitive deterministic online algorithm on pregular input with n ≥ n 0 jobs.For an arbitrary p-regular input R n , let (S(n), Q(n)) be the solution computed by the algorithm.Note that for any n, R n is unique, and thus (S(n), Q(n)) is also uniquely defined, since the algorithm is deterministic.
Let n 1 > n 0 be such that the algorithm replenishes the 2k th time when the n th 1 job is released at (n 1 − 1)p for some integer k > 0, independently whether the n th 1 job is the last job released or not.Since the algorithm is deterministic on a p-regular input, n 1 is well-defined, and for any input where n ≥ n 1 , it produces the same schedule until (n 1 − 1)p.That is, S(n 1 ) is a sub-schedule of S(n), and Q(n 1 ) ⊆ Q(n) for any n ≥ n 1 .
From Lemma 5, we know that the maximum flow time in (S(n 1 ), Q(n 1 )) is at most U (n 1 ) = c 2 √ n 1 p + 2 , and the maximum flow time in (S(n), Q(n)) is at least L(n) = (n − 1)p/((2 + ε n )c) − p + 1.We can choose n such that L(n) ≥ 2U (n 1 ).Now consider the following new feasible solution (S (n), Q (n)) for R n : starting with the first one, drop every second replenishment from Q(n) in [0, (n 1 − 1)p].The flow time of the jobs arriving before (n 1 − 1)p at most doubles (since (n 1 − 1)p is the time of the 2k th replenishment, it is not removed), and the flow time of the jobs released after n 1 does not change.Since L(n) ≥ 2U (n 1 ), the maximum flow time of (S (n), Q (n)) is not greater than of (S(n), Q(n)).

Conclusions
In this paper we provided a deterministic online 2-competitive algorithm for the online variant of the problem 1|jrp, s = 1, p j = 1, distinct r j |F max .The competitive ratio is even better for the case of p-regular input.Yet, there is a gap between the best upper and lower bound.The natural question arises whether it is possible to provide an online algorithm with better competitive ratio, or to derive a stronger lower bound for the best competitive ratio.There are other open questions to consider: what can we say when the jobs can have arbitrarily big processing time, or if there are multiple types of resources.These problems can be intriguing for further research.

Figure 2 :
Figure 2: The inputs I, D I and R I for p = 3.

Table 1 :
Old and new results for the online problem 1|jrp, s = 1, p j = 1, distinct r j |F max .