Joint replenishment meets scheduling

In this paper, we consider a combination of the joint replenishment problem (JRP) and single-machine scheduling with release dates. There is a single machine and one or more item types. Each job has a release date, a positive processing time, and it requires a subset of items. A job can be started at time t only if all the required item types were replenished between the release date of the job and time point t. The ordering of item types for distinct jobs can be combined. The objective is to minimize the total ordering cost plus a scheduling criterion, such as total weighted completion time or maximum flow time, where the cost of ordering a subset of items simultaneously is the sum of a joint ordering cost, and an additional item ordering cost for each item type in the subset. We provide several complexity results for the offline problem, and competitive analysis for online variants with min–sum and min–max criteria, respectively.


Introduction
The Joint Replenishment Problem (JRP) is a classical problem of supply chain management with several practical applications.In this problem a number of demands emerge over the time horizon, where each demand has an arrival time, and an item type (commodity).To fulfill a demand, the required item must be ordered not sooner than the arrival time of the demand.Orders of different demands can be combined, and the cost of simultaneously ordering a subset of item types incurs a joint ordering cost and an additional item ordering cost for each item type in the order.None of these costs depends on the number of units ordered.Thus the total ordering cost can be reduced by combining the ordering of item types of distinct demands.However, delaying a replenishment of an item type delays the fulfillment of all the demands that require it.The objective function expresses a trade-off between the total ordering cost, and the cost incurred by delaying the fulfillment of some demands, see e.g., [13].There are other variants of this basic problem, see Section 2.
In the above variant of JRP a demand becomes ready as soon as the required item type has been replenished after its arrival time.However, in a make-toorder manufacturing environment the demands may need some processing by one or more machines before they become ready, or in other words, a scheduling problem emerges among the demands for which the required item types have been ordered.This paper initiates the systematic study of these variants.By adopting the common terminology of scheduling theory, from now on we call the demands and item types 'jobs' and 'resource types', respectively.
We consider the simplest scheduling environment, the single machine.It means that there is one machine, which can process at most one job at a time.Each job has a release date and a processing time, and it requires one or more resource types (this is a slight generalization of JRP, where each demand has only one item type).A job becomes ready to be started only if all the required resources are replenished after its release date.We only consider non-preemptive scheduling problems in this paper.The objective function is the sum of the replenishment costs and the scheduling cost (such as the total weighted completion time, the total weighted flow time, or the maximum flow time of the jobs).Observe that if we delay a replenishment of a resource type i, then all the jobs waiting for i will occupy the machine after i arrives, thus the processing of these jobs may delay the processing of some other jobs arriving later.In other words, at each time moment we have to take care of the jobs with release dates in the future, which is not easy in the offline case, and almost impossible in an online problem, where the jobs are not known in advance.
After a literature review in Section 2, we provide a formal problem statement along with a brief overview of the main results of the paper in Section 3. Some hardness results for min-sum, and min-max type criteria are presented in Section 4, and 5, respectively.Polynomial time algorithms are described for some variants of the problem in Sections 6 and 7.Then, in Sections 8 and 9 we provide online algorithms for min-sum type criteria, and for the F max objective function, respectively.We conclude the paper in Section 10.

Literature review
The first results on JRP are more than 50 years old, see e.g., Starr and Miller [33], for an overview of older results we refer the reader to Khouja and Goyal [26].Since then, several theoretical and practical results appeared, this review cites only the most relevant literature.
Over the years, a number of different variants of the JRP have been proposed and studied, some of which are mathematically equivalent.Originally, JRP was an inventory management problem, where demands have due dates, and to fulfill a demand, the required item type must be ordered before the due-date of the demand.However, keeping the units on stock incurs an inventory holding cost beyond the total ordering costs, and we call this variant JRP-INV.In another variant, demands have release dates and deadlines, and they can be fulfilled by ordering the corresponding items in the specified time intervals.The cost of a solution is determined solely by the total ordering costs.We will refer to this variant as JRP-D.In the last variant considered in this review, demands have a delay cost function instead of deadlines, which determines the cost incurred by the delay between the release date of the demand and the time point when it is fulfilled by an order.The objective function balances the total cost incurred by delaying the fulfillment of the demands and the total ordering costs.We call this variant JRP-W.In this paper we combine JRP-W with a scheduling problem.
The complexity of JRP-INV is studied by Arkin et al. [3], who proved strong NP-hardness.Levi et al. [29] give a 2-approximation algorithm, and the approximation ratio is reduced to 1.8 by Levi and Sviridenko [30], see also Levi et al. [28].Cheung et al. [17] describe approximation algorithms for several variants under the assumption that the ordering cost function is a monotonically increasing, submodular function over the item types, see also Bosman and Olver [12].
The JRP-D is shown NP-hard in the strong sense by Becchetti, et al. [9] as claimed by Bienkowski et al. [10], and APX-hardness is proved by Nonner and Souza [31], who also describe an 5/3-approximation algorithm.Bienkowski et al. [10] provide an 1.574 approximation algorithm, and new lower bounds for the best possible approximation ratio.For the special case when the demand periods are of equal length, they give an 1.5-approximation algorithm, and prove a lower bound of 1.2.In Bienkowski et al. [11], the online version of JRP-D is studied, and an optimal 2-competitive algorithm is described.
The NP-hardness of JRP-W with linear delay cost functions follows from that of JRP-INV (reverse the time line).This has been sharpened by Nonner and Souza [31] by showing that the problem is still NP-hard even if each item admits only three distinct demands over the time horizon.Buchbinder et al. [13] study the online variant of the problem providing a 3-competitive algorithm along with a lower bound of 2.64 for the best possible competitive ratio.Bienkowski et al. [11] provide a 1.791-approximation algorithm for the offline problem, and they also prove a lower bound of 2.754 for the best possible competitive ratio of an algorithm for the online variant of the problem with linear delay cost function.
For scheduling problems we use the well-known α|β|γ notation of Graham et al. [20].1|r j | C j is a known strongly NP-hard problem, see, e.g., Lenstra et al. [27].There is a polynomial time approximation scheme (PTAS) for this problem even in the case of general job weights and parallel machines (Afrati et al. [1]).However, there are other important approximation results for this problem.Chekuri et al. [15] provide an e/(e − 1) ≈ 1.5819-approximation algorithm based on the α-point method.For the weighted version of the same problem Goemans et al. [19] present an 1.7451-approximation algorithm.If each job has the same processing time then the weighted version of the problem is solvable in polynomial time even in case of constant number of parallel machines (Baptiste [8]).
Anderson and Potts [2] devise a 2-competitive algorithm for the online version of 1|r j | w j C j , i.e., each job j becomes known only at its due-date r j , and scheduling decisions cannot be reversed.This is the best possible algorithm for this problem, since Hoogeveen and Vestjens [21] proved that no online algorithm can have a competitive ratio less than 2, even if the weights of the jobs are identical.
Kellerer et al. [25] describe a O( √ n)-approximation algorithm for 1|r j | F j and proved that no polynomial time algorithm can have O(n 1/2−ε ) approximation ratio for any ε > 0 unless P = N P .It is also known that the best competitive ratio of the online problem with unit weights is Θ(n), and it is unbounded if the jobs have distinct weights [18].Due to these results, most of the research papers assume preemptive jobs, see e.g., [7,14,18].In one of the online variants of the problem we study in this paper the only unknown parameter is the number of consecutive time periods while the jobs arrive.The ski-rental problem, introduced by L. Rudolph according to Karp [24], is very much alike.A person would ski for an unknown number of d consecutive days, and she can either rent the equipment for unit cost every day, or buy it in some day for the remaining time for cost y.If she buys the equipment in day t ≤ d, the total cost is t + y, while the offline optimum is min{d, y}.One seeks a strategy to minimize the ratio of these two values in the worst case without knowing d.The best deterministic online algorithm has a competitive ratio of 2, while the best randomized online algorithm has e/(e − 1) ≈ 1.58, and both bounds are tight [23], [22].
While this paper is probably the first one to study the joint replenishment problem combined with production scheduling, there is a considerable literature on integrated production and outbound distribution scheduling.In such models, the production and the delivery of customer orders are scheduled simultaneously, while minimizing the total production and distribution costs.After the first paper by Potts [32], there appeared several models and approaches over the years, for an overview see e.g.[16].While most of the papers focus on the offline variants of the problem, there are a few results on the online version as well.In particular, Averbakh et al [4,5] propose online algorithms for single machine problems with linear competitive ratio in either ∆ or ρ, where ∆ and ρ denote the ratio of the maximum to minimum delivery costs, and job processing times, respectively.This is considerably improved by Azar et al. [6], who propose poly-logarithmic competitive online algorithms in ∆ and ρ in single as well as in parallel machine environments, and they also prove that their bounds are essentially best possible.
3 Problem statement and overview of the results We have a set J of n jobs that have to be scheduled on a single machine.Each job j has a processing time p j > 0, a release date r j ≥ 0, and possibly a weight w j > 0 (in case of min-sum type objective functions).In addition, there is a set of resources R = {R 1 , . . ., R s }, and each job j ∈ J requires a non-empty subset R(j) of R. Let J i ⊆ J be the set of those jobs that require resource R i .A job j can only be started if all the resources in R(j) are replenished after r j .Each time some resource R i is replenished, a fixed cost K i is incurred on top of a fixed cost K 0 , which must be paid each time moment when any replenishment occurs.These costs are independent of the amount replenished.Replenishment is instantaneous.
A solution of the problem is a pair (S, Q), where S is a schedule specifying a starting time for each job j ∈ J , and Q = {(R 1 , t 1 ), . . ., (R q , t q )} is a replenishment structure, which specifies time moments t ℓ along with subsets of resources R ℓ ⊆ R such that t 1 < • • • < t q .We say that job j is ready to be started at time moment t in replenishment structure Q, if each resource R ∈ R(j) is replenished at some time moment in [r j , t], i.e., R(j) ⊆ t ℓ ∈[rj,t] R ℓ .The solution is feasible if (i) the jobs do not overlap in time, i.e., S j + p j ≤ S k or S k + p k ≤ S j for each j = k, (ii) each job j ∈ J is ready to be started at S j in Q.
The cost of a solution is the sum of the scheduling cost c S , and the replenishment cost c Q .The former can be any optimization criteria know in scheduling theory, but in this paper we confine our discussion to the weighted sum of job completion times w j C j , the sum of flow times F j , where F j = C j − r j , and to the maximum flow time F max := max F j .Note that C j is the completion time of job j in a schedule.The replenishment cost is calculated as follows: In the offline problem the complete input is known in advance, and we seek a feasible solution of minimum cost over the set of all feasible solutions.In the online variant of the problem, where the jobs arrive over time, and the input becomes known only gradually, the solution is built step-by-step, however, decisions cannot be reversed, i.e., if a job is started, or some replenishment is made, then this cannot be altered later.
Note that w j F j = w j C j − w j r j , where the last sum is a constant, thus the complexity status (polynomial or NP-hard) is the same for the two problems.However, there can be differences in approximability and the best competitive ratio of algorithms for the online version of the problems.
This assumption is without loss of generality in offline problems, and can be handled by transforming the problem data in the online variants, see Section 8.1.We extend the notation of [20] by jrp in the β field to indicate the joint replenishment of the resources, thus we denote our problem by 1|jrp, r j |c S + c Q .In addition, s = 1 or s = const indicate that the number of resources is 1, and constant, respectively, and not part of the input.Further on, p j = 1 and p j = p imply that all the jobs have the same processing time 1 (unit-time jobs), and p, respectively.
The next example describe two feasible solutions for a one-resource problem.
Results of the paper .The main results of the paper fall in 3 categories: (i) NPhardness proofs, (ii) polynomial time algorithms, and (iii) competitive analysis of online variants of the problem, see Table 1 for an overview.We provide an almost complete complexity classification for the offline problems with both of the w j C j and F max objectives.Notice that the former results imply analogous ones for the w j F j criterion.While most of our polynomial time algorithms work only with unit-time jobs, a notable exception is the case with a single resource and the F max objective, where the job processing times are arbitrary positive integer numbers.We have devised online algorithms for some special cases of the problem for both min-sum and min-max criteria.In all variants for which we present an online algorithm with constant competitive ratio, we have to assume unit-time jobs.While we have a 2-competitive algorithm with unit time jobs for min-sum criteria, for the online problem with the F max objective we also have to assume that the input is regular, i.e., in every time unit a new job arrives, but in this case the competitive ratio is Observation 1.For any scheduling criterion, the problem 1|jrp, r j |c S + c Q admits an optimal solution in which all replenishments occur at the release dates of some jobs.
4 Hardness results for min-sum criteria In this section we prove results for 1|jrp, r j | w j C j +c Q .However, these results remain valid, if we replace w j C j to w j F j , since the difference between the two objective functions is a constant ( j∈J w j r j ).
We say that two optimization problems, A and B, are equivalent if we can get an optimal solution for problem A in polynomial time by using an oracle which solves B optimally in constant time, and vice versa.Of course, preparing the problem instance for the oracle takes time as well, and it must be polynomial in the size of the instance of problem A (B).
Recall the definition of R and T in Section 3.
Q is exactly the same as 1|r j | w j C j (each resource can be replenished no-cost at any time moment).
For the other direction consider an instance I of 1|jrp, r j | w j C j + c Q .We prove that we can get the optimal solution for I by solving a constant number of instances of 1|r j | w j C j .First, we define 2 |R| |T | replenishment structures for I: By Observation 1, there exists an optimal solution of 1|jrp, r j | w j C j + c Q with one of the above replenishment structures.
We define an instance I Q of 1|r j | w j C j for each Q ∈ W .The jobs have the same p j , and w j values as in I, the differences are only in their release dates.
For a given Q, let r ′ j := min{t ≥ r j : R(j) ⊆ ∪ τ ℓ ∈[rj ,t] R ℓ } be the release date of j in I Q .If this value is infinity for any job j, then there is no feasible schedule for I Q , because some resource in R(j) is not replenished at or after r j .Observe that, if S is a feasible solution of I Q , then (Q, S) is a feasible solution of I, and its objective function value is Thus, if (Q ⋆ , S ⋆ ) is an optimal solution of I then S ⋆ is an optimal solution for I Q ⋆ and the optimal solution of I Q ⋆ yields an optimal solution for I with Q ⋆ .Invoking the oracle for each I Q (Q ∈ W ), we can determine an optimal schedule S Q for each I Q .From these schedules we can determine the value Note that Theorem 1 remains valid even if we add restrictions on the processing times of the jobs, e.g., p j = p or p j = 1.
We need the following results of Lenstra et al. [27].
The next results is a direct corollary.
We have another negative result when p j = 1 and s is not a constant: Proof.We reduce the MAX CLIQUE problem to our scheduling problem.
MAX CLIQUE: Given a graph G = (V, E), and k ∈ Z.Does there exist a complete subgraph (clique) of G with k nodes?Consider an instance I of MAX CLIQUE, from which we create an instance where M is a sufficiently large number), and s = |E| resources in I ′ .There is a bijection between the edges in E and the resources, and likewise, there is a bijection between the nodes in V and the first |V | jobs.The release date of these jobs is r ′ = 0, and such a job j requires a resource r if and only if the node corresponding to job j is an endpoint of the edge associated with resource r.We define M further jobs with a release date r ′′ = |V | − k, which require every resource.
We claim that there is a solution for I, if and only if in G then we introduce two replenishments: at r ′ = 0 we replenish every resource that corresponds to an edge in E \ E ′ , and at r ′′ , we replenish every resource.Observe that the replenishment cost is 2|E| Then, consider the following schedule S: schedule the jobs that correspond to the nodes of V \ V ′ and have a release date 0 from t = 0 in arbitrary order, after that schedule the remaining jobs in arbitrary order.It is easy to see that S is feasible since the number of the jobs scheduled in the first step is The total completion time of the jobs is |V |+M+1

2
, thus the total cost is O. Now suppose that there is a solution of 1|jrp, p j = 1, r j | C j + c Q with an objective function value of O. Observe that each resource must be replenished at r ′′ , since the jobs with a release date r ′′ require every resource.The cost of this replenishment is |E|.If there is a gap in the schedule before r ′′ , then the total completion time of the jobs is at least Proof.We will reduce the NP-hard PARTITION problem to our scheduling problem.
PARTITION: Given a set A of n items with positive integer sizes a 1 , a 2 , . . ., a n such that B = j∈A a j /2 is integral.Is there a subset A 1 of A such that j∈A1 a j = B?
Consider an instance I of PARTITION, and we define the corresponding instance I ′ of 1|r j , jrp|F max + c Q as follows.There are n + 2 jobs: n partition jobs, such that p j = a j , r j = B, and R(j) = R 1 (j = 1, . . ., n).The other two jobs require resource R 2 , they have unit processing times, r n+1 := 0, and r n+2 := 2B.Further on, let K 0 = K 1 := 0, and We prove that PARTITION instance I has a solution if and only if I ′ admits a solution with an objective function value of at most O := B 2 + 2B + 1.
If I has a solution, then consider the following solution (S, Q) of I ′ .There are two replenishments: Let the partition jobs correspond to the items in A 1 be scheduled in S in arbitrary order in [B, 2B], while the remaining partition jobs in [2B + 1, 3B + 1].Let S n+1 := 2B, and S n+2 := 3B + 1 (see Figure 2 for illustration), therefore Observe that (S, Q) is feasible, and its objective function value is exactly O. Now suppose that there is a solution (S, Q) of 1|jrp, Observe that there is only one replenishment from R 2 , since two replenishments would have higher cost than O.It means the flow time of every job is at most 2B + 1.Since j n+2 requires R 2 , the replenishment time of R 2 cannot be earlier than r n+2 = 2B.However, j n+1 has to be completed until 2B+ 1, which means it requires R 2 not later than 2B, therefore the replenishment of R 2 is at 2B, and S n+1 = 2B.Since the partition jobs has a flow time of at most 2B + 1, thus these jobs are scheduled in the interval [B, 3B + 1].Due to the position of j n+1 , the machine cannot be idle in this interval, which means the partition jobs are scheduled in [B, 2B], and in [2B + 1, 3B + 1] without idle times (j n+1 separates the two intervals).Hence, we get a solution for the PARTITION instance I.

Polynomial time algorithms for min-sum criteria
In this section we describe polynomial time algorithms, based on dynamic programming, for solving special cases of 1|jrp, r j | w j C j + c Q .Again, the same methods work for the w j F j + c Q objective function.Throughout this section we assume that each job j requires a single resource only, and with a slight abuse of notation, let R(j) be this resource.Recall the definition of T in the end of Section 3.
Proof.We describe a dynamic program for computing an optimal solution of the problem.The states of the dynamic program are arranged in |T | + 1 layers, L(τ 1 ), . . ., L(τ |T |+1 ), where L(τ k ) is the k th layer (k = 1, . . ., |T | + 1).A state N ∈ L(τ k ) is a tuple encoding some properties of a partial solution of the problem.Each state has has a corresponding partial schedule S N such that the last job scheduled completes not later than τ k , and also a replenishment structure Q N such that replenishments occur only at {τ 1 , . . ., τ k−1 }.
α i -number of the jobs from J i (jobs that require resource R i ) that are scheduled in S N , δ -total number of replenishments in Q N , i.e., the number of (R ℓ , τ ℓ ) pairs in See Figure 3 for an easy example.
The schedule S N associated with N is specified by n numbers that describe the completion time of the jobs, or −1, if the corresponding job is not scheduled in S N .
Let J i ( βi ) be the subset of those jobs from J i that have a release date at most βi .
The first layer of the dynamic program has only one state N 0 where all parameters are 0 or ′ − ′ , and the corresponding schedule and replenishment structure is empty.The algorithm builds the states of L(τ k+1 ) from those of L(τ k ), and each state has a 'parent state' in the previous layer (except N 0 in L(τ 1 )).We compute the states by Algorithm DynProg wjCj.When processing state N ∈ L(τ k ), the algorithm goes through all the subsets of the resources, and for each subset it generates a tuple N by selecting jobs unscheduled in S N .The number of jobs selected is at most τ k+1 − τ k , so that they can fit into the interval [τ k , τ k+1 ].From each set J i we consider only those unscheduled jobs that are ready to be started while taking into account the latest replenishment time of resource R i , see step 1c.Then, S N is extended with the selected jobs to obtain a new schedule S new , and also a new replenishment structure Q new is obtained in step 1f.There are two cases to consider: f.Construct the schedule S new from S N by scheduling the jobs of J k in nonincreasing wj order from τ k without idle times.Analogously, Q new is obtained from Q N by extending it with ( R, τ ).

Algorithm DynProg wjCj
g.If N / ∈ L(τ ), then add N to L(τ ), set N to be its parent node, and associate (S new , Q new ) with N .h.If N ∈ L(τ ) and the total weighted completion time of S new is smaller than that of S N , then replace S N with S new , Q N with Q new , and set the parent node of N to N .Observe that the number of the states is at most n 3s+2 , because there are at most n different options in each coordinate of a state.This observation shows that the above procedure is polynomial in the size of the input parameters of the problem.
(i) Each job in S N completes not later than τ k .
(ii) The jobs do not overlap in S N .(iii) If β i is a number (i.e., β i = −), then there is a replenishment from R i at (iv) There are δ replenishments in Q N of which there are γ i replenishments from R i (i = 1, . . ., s).
(vi) The cost of the replenishments in Q N can be determined from N in polynomial time.
Proof.(i) Follows from the observation that (ii) Follows from (i).
(iii) Follows from the definition of β i .
(v) Each job is scheduled because α i = |J i | and the jobs do not overlap due to (ii).Observe that Algorithm DynProg wjCj cannot schedule a job before its release date.If it chooses a job j ∈ J i to process in [τ k , τ k+1 ] at step 1c, it has a release date at most βi , since j ∈ J i ( βi ), thus the statement follows from (iii) and the definition of βi in step 1a.
(vi) Follows from (iv).The cost of Consider the set J k at Step 1c, when the algorithm creates an arbitrary state N from its parent state N .
is the set of jobs ready to be started at τ k with respect to Q new that are unscheduled in S N .Otherwise, it is the τ k+1 − τ k elements of this set with the largest weights.
Proof.Follows from the definitions.
After determining the states, Algorithm DynProg wjCj chooses a state N ∈ L(τ |T |+1 ) representing a feasible solution of smallest objective function value, and later we prove that (Q N , S N ) is an optimal solution.For each state N ∈ L(τ |T |+1 ), we decide whether (Q N , S N ) is feasible or not (by Lemma 1 (v)), calculate the cost of Q N (by Lemma 1 (vi)), and the total weighted completion time of S N .We define N as the state such that (Q N , S N ) is feasible, and it has best objective function value among that of the states of the last layer with a feasible solution.Observe that this procedure requires polynomial time.Now we prove that there is a state of the last layer such that the corresponding solution of the problem is optimal, thus the solution (Q N , S N ) calculated by our method must be optimal.Let (Q ⋆ , S ⋆ ) be an optimal solution.Notice that the jobs scheduled in the interval [τ k , τ k+1 ] in S ⋆ are in non-increasing w j order, and replenishments occur only at the release dates of the jobs.Recall that N 0 is the only state of L(τ 1 ).Let N k ∈ L(τ k+1 ) be the state that we get from N k−1 ∈ L(τ k ), when R was set to R ⋆ k (the set of those resources replenished at τ k in Q ⋆ ) in Algorithm DynProg wjCj (k = 1, . . ., |T |).Due to the feasibility of the optimal solution, there is a replenishment from R i not earlier than max j∈Ji r j , thus Algorithm DynProg wjCj will schedule every job in S N |T | , i.e., each We prove that (Q Proof.Suppose for a contradiction that τ k ≤ t < τ k+1 is the first time point, when the machine becomes idle either in S ⋆ or in S N |T | , but not in the other. If the machine is idle from t only in S ⋆ , then there are more jobs scheduled until t + 1 in S N |T | than in S ⋆ .Hence, there exists a resource R i such that there are more jobs scheduled from J i (the set of jobs that require R i ) until t + 1 in S N |T | than in S ⋆ .This means there is at least one job j ∈ J i with a release date not later than the last replenishment before t + 1 from R i , which starts later than t in S ⋆ , otherwise, S N |T | would not be feasible.However, if we modify the starting time of j in S ⋆ to t (the starting time of other jobs does not change) then we would get a schedule S ′ such that (Q ⋆ , S ′ ) is better than (Q ⋆ , S ⋆ ), a contradiction.
On the other hand, if the machine is idle from t only in S N |T | , then there is a resource R i such that there are more jobs scheduled from J i until t + 1 in S ⋆ than in S N |T | .The machine is idle from t in S N |T | , thus when Algorithm DynProg wjCj creates N k , it chooses a set J k at step 1c such that |J k | < τ k+1 − τ k .Hence, we know from Claim 1 that each job from J k ∩ J i (τ k ) is scheduled until t in S N k at that step.Observe that these jobs are scheduled until t also in S N |T | , and all the other jobs from J i must be scheduled after τ k+1 in any feasible schedule for replenishment structure Q ⋆ .It is in a contradiction with the definition of J i .
From Claim 1 we know that Algorithm DynProg wjCj always starts a job with highest weight among the unscheduled jobs that are ready to be started at any time moment t, if any, during the construction of S N |T | .We claim that this property is even valid for S ⋆ , thus for every time moment t, the job started at t in S N |T | has the same weight as the job which starts at t in S ⋆ , therefore, the total weighted completion time of the two schedules is the same.
Suppose that the above property is not met by S ⋆ , that is, let j 1 be a job of minimum starting time in S ⋆ such that there is a job j 2 such that w j2 > w j1 , S ⋆ j2 > S ⋆ j1 , and j 2 is ready to be started at S ⋆ j1 in Q ⋆ .Let S ′ be the schedule such that S ′ j1 := S ⋆ j2 , S ′ j2 := S ⋆ j1 , and S ′ j := S ⋆ j for each j = j 1 , j 2 .Observe that (i) j 2 is ready to be started at S ′ j2 in Q ⋆ by assumption, (ii) j 1 is ready to be started at S ′ j1 in Q ⋆ , because r j1 ≤ S ⋆ j1 ≤ S ′ j1 , and (iii) each other job j / ∈ {j 1 , j 2 } is ready to be started at S ′ j in Q ⋆ , because S ′ j = S ⋆ j .Thus schedule S ′ is feasible for Q ⋆ .The total weighted completion time of S ′ is smaller than that of S ⋆ , which contradicts that (Q ⋆ , S ⋆ ) is optimal.This proves the theorem.
We can prove Theorem 6 with a slightly modified version of the previous algorithm.
Proof (sketch).We sketch a similar dynamic program to that of Theorem 5. Let ), and T ′ contains all the possible starting and completion times of the jobs in any schedule without unnecessary idle times.
Let N = [τ ′ ; α 1 , . . ., α s ; β 1 , . . ., β s ; γ 1 , . . ., γ s ; δ] ∈ L(τ ′ ) be the state chosen in Step 1 of the Algorithm DynProg wjCj.Steps 1a and 1b remain the same and we modify step 1c as follows.We define J k as the set of all unscheduled job from s i=1 J i ( βi ).In step 1d, we define ᾱi in the same way as in Algorithm DynProg wjCj.If In steps 1f, we schedule the jobs of J k in non-increasing release date order.In steps 1h and 3, we use unit weights.The remaining steps are the same.
The proof of soundness of the modified dynamic program is analogous to that of Theorem 5.
Remark 1.The results of Theorems 5 and 6 remain valid even if the jobs may require more than one resource.To this end, we consider all non-empty subsets of the s resources (there are 2 s − 1 of them), and let φ ℓ be the ℓ th subset in some arbitrary enumeration of them.Then we define J ℓ as the set of those jobs that require the subset of resources φ ℓ .Clearly, the J ℓ constitute a partitioning of the jobs.In the dynamic program, let α ℓ be the number of jobs scheduled from J ℓ , and this also means that each state has 2 s − 1 components α ℓ .In step 1c, J k is chosen from ∪ 2 s −1 ℓ=1 J ℓ (min i∈φ ℓ βi ) as the min{τ k+1 −τ k , unscheduled jobs of largest weight.With these modifications, the dynamic programs solve the problems, where the jobs may require more than one resource.
7 Polynomial time algorithms for 1|jrp, r j |F max + c Q In this section we obtain new complexity results for the maximum flow time objective.We start with a special case with a single resource.
Lemma 2. If s = 1, there is an optimal solution, where jobs are scheduled in non-decreasing r j order, all replenishments occur at the release dates of some jobs, and the machine is idle only before replenishments.
Proof.Let (S ⋆ , Q ⋆ ) be an optimal solution.Suppose there exist two jobs, i and j, such that r i < r j , and i is scheduled directly after j in S ⋆ .By swapping i and j, F i will decrease, and F j will not be bigger than F i before the swap.Hence, F max will not increase, and the replenishment structure Q ⋆ will be feasible for the updated schedule as well, since all replenishments occur at the release dates of some jobs (see Observation 1).Let τ 1 , τ 2 be two consecutive replenishment dates in the optimal solution, and assume the machine is idle in the time interval [t 1 , t 2 ] ⊂ [τ 1 , τ 2 ) such that it is busy throughout the interval [τ 1 , t 1 ], and let j 1 be the first job starting after t 2 .Shift j 1 to the left until t 1 .This yields a feasible schedule, since again, we may assume that all replenishments occur at the release dates of some jobs.Moreover, F max will not increase.Repeating this transformation, we can transform S ⋆ into the desired form.
Theorem 7. If s = 1, then the problem 1|jrp, r j |F max + c Q can be solved in polynomial time.
Proof.Note that if two or more jobs have the same release dates, then in every optimal solution they are replenished at the same time, and they can be scheduled consecutively in arbitrary order without any idle time.Therefore, we can assume that the release dates are distinct, i.e., r 1 < r 2 < . . .< r n .
Denote with K = K 0 + K 1 the cost of a replenishment.We define n layers in Algorithm DynProg Fmax, layer i corresponding to r i .In layer i, the resource is replenished at r i , and the jobs arriving before r i and having no replenishment yet are scheduled in increasing release date order.
Throughout the algorithm we maintain several states for each layer, where a state N is a 5-tuple, i.e., N = (α N , β N , γ N , F max (N ), u N ).
α N -release date of a job when the last replenishment occurs, β N -release date of a job from which the remaining jobs are scheduled consecutively without idle times, γ N -index of the first job scheduled from β N , F max (N ) -maximum flow time, u N -number of replenishments.
b. Let P := βN + i k=γ N p k (the completion time of jobs scheduled consecutively).c.Start the jobs between i + 1 and j in increasing release date order from max (P, rj ) consecutively, without idle times.
d. Calculate F k = C k − r k for each newly scheduled job.
g. Insert N ′ in Lj if it has no other state with the same (α, β, γ, u) attributes, or replace the state 2. Determine the state N ∈ Ln with the smallest Fmax(N )+KuN value and output the corresponding solution.
From Lemma 2 we know that there is an optimal solution, where the jobs are scheduled in increasing release date order.In the proposed algorithm we consider all of the replenishment structures, and the best schedule for each of them.Hence, the algorithm finds the optimal solution.
Since for each N ∈ L i , (α N , β N , γ N , u N ) ∈ {r 1 , . . ., r i } 2 × {1, . . ., i} 2 , there are at most n 4 states in the layer n.Therefore, our algorithm is of polynomial time complexity, and it finds an optimal state N ⋆ = (α ⋆ , β ⋆ , γ ⋆ , F ⋆ max , u ⋆ ) with objective F ⋆ max + Ku ⋆ .By recording the parent state of each state N in the algorithm, we can define a series of states leading to N ⋆ : {N 0 , N ⋆ 1 , . . ., N ⋆ k }, where N ⋆ k = N ⋆ .The replenishment times are defined by α ⋆ 1 , . . .α ⋆ k .The optimal schedule can be built in the following way: for i = k, . . ., 1, jobs with indices at least γ ⋆ i are scheduled from β ⋆ i .
Now we propose a more efficient algorithm for the case, where s = 1, p j = 1 for every job, and all the job release dates are distinct (denoted by 'distinct r j ').
Lemma 3. The problem 1|jrp, s = 1, p j = 1, distinct r j |F max + c Q admits an optimal solution, where every job has the same flow time.
Proof.Consider an optimal solution, where there is a job j with F j < F max , directly followed by a job k with F k = F max .Since r j < r k and F j < F k , we have C k − C j = r k − r j + ∆, where ∆ > 0. This also means that there is a gap of length r k − r j + ∆ − 1 > ∆ between j and k.By moving j to the right with ∆ time units, we obtain a feasible schedule such that F j = F k = F max .We can repeat this transformation until we obtain an optimal schedule of the desired structure.
Theorem 8.There is an O(n 2 ) time algorithm that finds the optimal solution for 1|jrp, s = 1, p j = 1, distinct r j |F max + c Q .
Proof.Using Lemma 3, if we try every possible flow time for scheduling the jobs, and then find the best replenishment structure for this fixed schedule, we obtain the optimal solution by picking the solution that gives the minimal objective function value.Consider the following algorithm: Algorithm Distinct rj Fmax 1.For each F ∈ {1, . . ., n}, do steps 1a-1c: a. Construct a feasible schedule, where every job has flow time of F , by starting every job j at rj + F − 1.Let uF := 0.
b.While there is a job without a resource ordered for it, let j be the last such job.Replenish the resource at rj, let uF := uF + 1, and repeat.
c.The solution for F has objective function value F + KuF .
2. Output the best solution obtained in the first step.
The running time of the algorithm is O(n 2 ).We only have to show that for a fixed F , the replenishment structure defined by the algorithm gives a solution with a minimal number of replenishments.We proceed by induction on the number of jobs.For n = 1 the statement clearly holds.Consider an input I with n jobs, and denote the optimal number of replenishments for I for the fixed flow time F with u F (I).
For the last job in the schedule, there must be a replenishment at r n .Delete the jobs which start at or after r n in the schedule, and let I ′ be the input obtained by deleting the same jobs from I. By the induction hypothesis, the algorithm determines the optimal number of replenishments for I ′ .Hence, u F (I) ≤ u F (I ′ ) + 1.On the other hand, by the construction of I ′ , for all j ∈ I ′ , r j + F ≤ r n .Hence, u F (I) ≥ u F (I ′ ) + 1, and thus u F (I) = u F (I ′ ) + 1.
Finally, we mention that it is easy to modify the dynamic program of Section 6 for the F max objective, so that we have: Proof (sketch).Use the same dynamic program as in the proof of Theorem 6, except that in steps 1h and 3, consider the maximum flow time instead of the total completion time.
The proof of soundness of this algorithm is analogous to those of Theorems 5 and 6.

Competitive analysis of the online problem with min-sum criteria
First, we provide a 2-competitive algorithm for the case where the scheduling cost is the total completion time ( C j ), then we improve this algorithm to achieve the same result for the case where the scheduling cost is the total flow time ( F j ).The proof of the second result requires more sophisticated analysis, but the main idea is the same as that of the proof of the first result.
8.1 Online algorithm for 1|jrp, s = 1, In the online version of the problem, we do not know the number of the jobs or anything about them before their release dates.
Since there is only one resource and the processing time and the weight of each job is one, we can suppose that the order of the jobs is the same in any schedule (a fixed non-decreasing release date order).To simplify the notation, we introduce K := K 0 + K 1 for the cost of a replenishment.At each time point t, first we can examine the jobs released at t, then we have to decide whether to replenish the resource or not, and finally we can start a job from t for which the resource is replenished.Note that if we have to decide about the replenishment at time point t before we get information about the newly released jobs, then the problem is the same as the previous one with each job release date increased by one, by assuming that ordering takes one time unit.
In the following algorithm, let B t ⊆ J denote the set of unscheduled jobs at time t.When we say that 'start the jobs of B t from time t', then it means that the jobs in B t are put on the machine from time t on without any delays between them in increasing release date order.Observe that their total completion time will be t

Algorithm Online SumCj
Initialization: t := 0 1.Determine the set Bt of unscheduled jobs at time t.
Let (S, Q) denote the solution created by Algorithm Online SumCj, while (S ⋆ , Q ⋆ ) an arbitrary optimal solution.Recall the notation v(sol) denoting the objective function value of a solution sol.Let t i be the time moment of the i th replenishment in Q and t 0 := 0. To simplify our notations, we will use B (i) := B ti for the set (block) of jobs that start in [t i , t i+1 ) in S, see Figure 5.
Clearly, the release date r j of a job j ∈ B (i) has to be in [t i−1 + 1, t i ].For technical reasons we introduce b i := |B (i) |, z i := |{j ∈ B (i) : r j = t i }|, and y i := b i − z i .The next observation follows from the condition of step 2 of Algorithm Online SumCj.
We divide v(S, Q) among the blocks B (i) in the following way: for i = 1, 2, . .., let i.e., the total completion time of the jobs of B (i) in S plus K, which is the cost of the replenishment at t i .Since the sets B (i) are disjoint, we have v(S, Q) = Proof.Suppose that there is only one job arriving at 0. If an algorithm starts it at some time point t, then that algorithm cannot be better than K+t+1 K+1competitive, because it is possible that no other jobs will arrive.However, if it starts the first job at t, then it is possible that another job arrives at t + 1.In this case starting the two jobs at time t + 1 and t + 2, respectively, with one replenishment yields a solution of value K + 2t + 5, while v(S, Q) = 2K + 2t + 3, thus the competitive ratio cannot be better than 2K+2t+3 K+2t+5 .Observe that if K is given, then the first ratio increases, while the second one decreases as t increases.This means that we have to find a time point t ≥ 0 such that K+ t+1 K+1 = 2K+2 t+3 K+2 t+5 , because then K+ t+1 K+1 is a lower bound on the best competitive ratio.Some algebraic calculations show that t ∈ [K/2−5/4, K/2−1], thus the lower bound is at least (3/2)K−1/4 K+1 .Therefore, for any ε > 0, there is a sufficiently large K, such that there is no (3/2 − ε)-competitive algorithm for the problem.
When the job weights are arbitrary, then a slightly stronger bound can be derived.
Theorem 12.There is no Proof.Suppose that job j 1 arrives at time 0 with weight w 1 = 1.If no other jobs arrive and the algorithm waits until time t before starting j 1 then it is at least c 1 (t)-competitive where c 1 (t) = K+t+1 K+1 .If another job j 2 arrives at time t + 1 with weight w 2 , then the algorithm is at least c 2 (t)-competitive where c 2 (t) = 2K+t+1+(t+2)w2 K+t+2+(t+3)w2 .To get a lower bound for an arbitrary online algorithm, we want to calculate the value of max K,w2 min t max(c 1 (t), c 2 (t)).
It is easy to see that c 1 (t) is an increasing function of t, and if K > w 2 + 1 then c 2 (t) is a decreasing function of t.The second part can be proved by the following simple calculation: .
Substituting t into c 1 (t) we get the following formula The release dates of the jobs of B (i) (k) are from the blue interval.
Proof.Analogously to the proof of Theorem 10, we prove ℓ µ=0 ALG i+µ ≤ 2 • ℓ µ=0 OP T i+µ for each i such that in the schedule constructed by the algorithm, the machine is idle in [t i − 1, t i ), and the next idle period starts in [t i+ℓ , t i+ℓ+1 ), from which the theorem follows.
Recall the definition of ℓ ′ from the proof of Theorem 10.Then, the next claim is analogous to Claim 3.
Otherwise, we have r j ≥ t i+ℓ ′ −1 + 1 =: t ′ for each job j ∈ ∪ ℓ µ=ℓ ′ B (i+µ) , hence they cannot be started before the first replenishment after t ′ .The first replenishment after t ′ in Q ⋆ is not earlier than t i+ℓ ′ in S ⋆ due to the definition of ℓ ′ .We have assumed that the order of the jobs is the same in every schedule, and there is no idle time among the jobs in ∪ ℓ µ=ℓ ′ B (i+µ) in S, thus, we have C ⋆ j ≥ C j and F ⋆ j ≥ F j for each j ∈ ∪ ℓ µ=ℓ ′ B (i+µ) .Since OP T i+µ ≥ j∈B (i+µ) F ⋆ j ≥ j∈B (i+µ) F j ≥ K for all µ ∈ [ℓ ′ , ℓ], where the last inequality follows from the condition of step 2 of Algorithm Online SumFj, we have ALG i+µ = K + j∈B (i+µ) F j ≤ 2 • OP T i+µ for all µ ∈ [ℓ ′ , ℓ].
Each job in B (i) (k) gets resource at τ i,k in Q ⋆ , if k ≤ s i , thus they cannot start earlier than τ i,k in S ⋆ .The earliest start time of a job from B (i) (s i +1) is t i .Since F j = (τ i,k −r j )+(C j −τ i,k ), thus we have j∈B (i) (k) F j ≥ j∈B (i) (k) (τ i,k − r j ) + G(b (i) (k)) for any 1 ≤ k ≤ s i + 1. Applying the previous inequality for since the order of the jobs is fixed.Since b (i) = y i + z i , we have C j ′ ≤ C ⋆ j ′ + y i and F j ′ ≤ F ⋆ j ′ + y i .Let h := b (i+µ) .Since j∈B (i+µ) F ⋆ j ≥ G(h), OP T i+µ ≥ K + j∈B (i+µ) F ⋆ j , and ALG i ≤ K + j∈B (i+µ) (F ⋆ j + y i ), we have 2 • OP T i+µ − ALG i+µ ≥ K + G(h) − hy i ≥ G(y i ) + G(h) − hy i ≥ 0, where the second inequality follows from Observation 3. Finally, observe that the problem instance used at the end of Theorem 10 (there is only one job j, with r j = 0) shows that the above analysis is tight, i.e., Algorithm Online SumFj is not α-competitive for any α < 2.
The next theorem gives a lower bound on the best possible competitive ratio.Theorem 14.There does not exist an online algorithm for 1|jrp, s = 1, p j = 1, r j | F j + c Q with competitive ratio better than 3  2 − ǫ for any constant ǫ > 0. Proof.Suppose that one job is released at 0, and some online algorithm ALG starts it at time t ≥ 0, then another job at time t + 1 is released.The offline optimum for this problem instance with 2 jobs is OP T = min(2K +2, K +t+2), while the online solution has a cost of 2K + t + 2.
3. If t ≤ K ≤ t + 1, then for any ε > 0 we have ALG OP T ≥ 3K+2 2K+2 > 3 2 − ε if K is sufficiently large.9 Competitive analysis for the online 1|jrp, r j |F max + c Q problem Throughout this section we assume p j = 1 for each job j, and there is a single resource only (s = 1).We will describe a √ 2-competitive algorithm for a semionline variant, which we call regular input, where r j = j for j ≥ 1.That is, the job release dates are known in advance, but we do not know how many jobs will arrive.We also provide lower bounds for the competitive ratio of any algorithm for regular as well as general input.
For the competitive analysis we need a lower bound for the offline optimum, which is the topic of the next section.
It is easy to see that c 1 (t, K) is an increasing function of t, while c 2 (t, K) is a decreasing function of t.Therefore, max(c 1 (t, K), c 2 (t, K)) is minimal for a t ≥ 0 if c 1 ( t, K) = c 2 ( t, K).Some algebraic calculations show that this happens . Substituting t into c 1 (t, K), we get lim K→∞ c 1 ( t, K) = √ 5+1 2 .Therefore, for any ε > 0, there is a sufficiently large K, such that there is no − ǫ -competitive algorithm for the problem.

Conclusions
In this paper we have combined single machine scheduling with the joint replenishment problem, where the processing of any job on the machine can only be started if the required item types are ordered after the release date of the job.
We have proved complexity results, and devised polynomial time algorithms both for the offline and the online variant of the problem.However, several open questions remained, and we list some of the most intriguing ones.Is the offline problem with the w j C j objective solvable in polynomial time when p j = p and s is constant, while the w j are arbitrary?What is the best competitive ratio for the considered online problems?In particular, for the online problem with regular input and maximum flow time objective, only the number of the jobs is unknown, yet, there is a gap between the best upper and lower bound.What can we say in case of more complex machine environments?

Figure 1 :
Figure 1: Two feasible solutions.The arrows below the axis denote the replenishments.

Theorem 4 .
which is greater than O for M sufficiently large.Hence, there is no gap in the schedule before r ′′ .It means the resources replenished at r ′ = 0 are sufficient for r ′′ = |V | − k jobs.The total completion time of a schedule without any gap is |V |+M+1 2 , thus at most |E| − k 2 resources can be replenished at r ′ = 0, otherwise, the objective function value would exceed O.This means at least |V |−k nodes have at most |E|− k 2 incident edges.Consider the remaining at most k nodes of the graph.According to the previous observation, there are at least k 2 edges among them, which means this subgraph is a k-clique.5Hardness of 1|jrp, r j |F max + c Q When the scheduling objective is F max , the problem with two resources is NPhard, even in a very special case: If s = 2, then the problem 1|jrp, r j |F max + c Q is NP-hard even if K 0 = K 1 = 0 and every job requires only one resource.

Figure 2 :
Figure 2: Illustration of the schedule.The arrows below the axis denote the replenishments (the replenished resources are in a bracket).

2 . 3 .
If k ≤ |T | then let k := k + 1 and go to the first step.Determine a state N ∈ L(τ |T |+1 ) with the smallest j∈J wj Cj(S N ) + K0δ + s i=1 Kiγi value and output the corresponding solution.

Claim 2 .
e., the Q ⋆ and Q N |T | consists of the same pairs of resource subsets and time points).It remains to prove that the total weighted completion time is the same for S ⋆ and S N |T | .The next claim describes an important observation on these schedules.The machine is working in the same periods in S ⋆ and in S N |T | .

Figure 4 :
Figure 4: Schedule and replenishment structure created by Algorithm Distinct rj Fmax for six jobs for F = 3.

Figure 5 :
Figure 5: Schedule S created by Algorithm Online SumCj.

Table 1 :
Results of the paper.