Necessary and sufficient optimality conditions for scheduling unit time jobs on identical parallel machines

In this paper we characterize optimal schedules for scheduling problems with parallel machines and unit processing times by providing necessary and sufficient conditions of optimality. We show that the optimality conditions for parallel machine scheduling are equivalent to detecting negative cycles in a specially defined graph. For a range of the objective functions, we give an insight into the underlying structure of the graph and specify the simplest types of cycles involved in the optimality conditions. Using our results we demonstrate that the optimality check can be performed by faster algorithms in comparison with existing approaches based on sufficient conditions.


Introduction
Finding optimal schedules is the primary goal of scheduling and therefore the main stream of research often deals with sufficient conditions of optimality that play the key role in the design of solution algorithms and in proving their correctness. The new trend is the study of the structural properties of optimal solutions. The practical aspects of this research Peter Brucker tragically passed away on July 24, 2013. This paper is the outcome of our collaborative research and is dedicated to his memory. B Natalia V. Shakhlevich N. Shakhlevich@leeds.ac.uk 1 Fachbereich Mathematik/Informatik, Universität Osnabrück, 49069 Osnabrück, Germany 2 School of Computing, University of Leeds, Leeds LS2 9JT, UK direction are discussed in the recent paper by Lin and Wang (2007) which presents necessary and sufficient conditions of optimality for some classes of scheduling problems. As stated in Lin and Wang (2007), the optimality conditions may be useful for • developing efficient algorithms that verify whether a given solution is optimal (such algorithms may be faster than the algorithms which construct optimal solutions); • finding several (or all) optimal solutions; • multi-objective hierarchical optimization (finding a characterization of all optimal solutions for the primary criterion and then optimizing the other one); • developing new solution algorithms.
The most recent application of optimality conditions is related to solving inverse scheduling problems, which has become an important research area (see surveys Ahuja and Orlin 2001;Heuberger 2004). In an inverse scheduling problem, there is given a target solution, which may be non-optimal for initial values of problem parameters. The objective is to adjust problem parameters (e.g., to modify job weights) to make the target solution optimal. A typical approach for solving inverse problems is based on necessary and sufficient conditions of optimality which are used to produce a mathematical programming formulation of the inverse problem.
In this paper, we study a range of scheduling models with unit time operations. Given are m identical parallel machines and a set J = {1, 2, . . . , n} of n jobs with processing times p j = 1, j ∈ J . Each job j has to be processed by one machine; it cannot start before some integer time r j ≥ 0 and it is desirable to complete it before a given due date d j . A schedule C = (C j ) n j=1 assigns to each job j a finishing time C j (or starting time S j = C j − 1). C is feasible if r j ≤ C j − 1 for each job j and the number of jobs processed simultaneously at any time is at most m. We assume that all data are integer. The objective is to find a feasible schedule C which minimizes a given non-decreasing function F (C, w) depending on job completion times and job weights w = (w j ) n j=1 , which are assumed to be positive. The objective functions considered in this paper are (a) total weighted completion time n j=1 w j C j ; (b) the weighted number of late jobs w j U j C j , where U j C j is the unit penalty for completing job j after its due date d j , U j C j = 1 if C j > d j and U j C j = 0, otherwise; (c) the weighted tardiness w j T j C j , where T j C j = max{C j − d j , 0} is the tardiness of job j.
The first function is strictly increasing while the last two functions are non-decreasing. In the last two cases we classify all jobs as early or late. Early jobs satisfy condition C j ≤ d j and they incur a zero cost.
Using standard three field notation, the scheduling problems we consider are denoted as P|r j , p j = 1|F (C, w), where the first field represents identical parallel machines, the second field specifies job requirements and the third field is the objective function of type (a), (b) or (c). We replace P by 1 in the first field if there is a single machine (m = 1). We drop r j from the second field if all jobs are available simultaneously (r j = 0 for all j ∈ J ) and drop w from the third field if all jobs have the same weight (w j = 1 for all j ∈ J ).
Our primary objective is to produce the necessary and sufficient conditions of optimality for versions (a)-(c) of problem P|r j , p j = 1|F (C, w). Our study complements the earlier results for the following problems: 1||L max , 1|| w j C j , F2||C max , 1|| U j (Lin and Wang 2007), and P|r j , p j = 1| w j U j (Dourado et al. 2009). Notice that in the first problem L max denotes the maximum lateness objective function, L max = max j∈J {C j −d j }; in the third problem, F2 in the first field denotes the two-machine flow shop problem.
In this paper we study the problems with unit time jobs. We give a characterization of the block structure of optimal schedules (Sect. 2) and derive the necessary and sufficient conditions of optimality for the general problem P|r j , p j = 1|F (C, w). We show in Sect. 2.3 that verifying these conditions results in detecting negative cycles in a specially defined network N (C) of the transportation problem. The number of nodes of that network is ν = n m and the network can be constructed in O mν 2 = O n 2 m time. In the subsequent sections, we explore the properties of network N (C) for the following problems: • P|r j , p j = 1| w j C j (Sect. 3), • P|r j , p j = 1| w j U j (Sect. 4) and its special case P| p j = 1| w j U j (Sect. 5), • P|r j , p j = 1| w j T j (Sect. 6) and its special cases P|r j , p j = 1| T j (Sect. 7) and P| p j = 1| T j (Sect. 8).
Taking into account special features of the above problems, we derive stronger conditions than those known for a general transportation problem. For each problem we also give an insight into the underlying structure of the graph N (C) and specify the simplest types of cycles which are sufficient to consider in the optimality conditions: two-node cycles for problems P|r j , p j = 1| w j C j and P| p j = 1| T j , chain cycles for problems P| p j = 1| w j U j and P|r j , p j = 1| T j , spiral cycles for problem P|r j , p j = 1| w j U j and for its unweighted case P|r j , p j = 1| U j , see Sect. 2.3 for the definitions of special cycles. Conclusions and possible directions for future research are presented in Sect. 9. Notice that conditions we formulate for problem P|r j , p j = 1| w j U j are different from the previously known, e.g., those presented in Dourado et al. (2009). In particular, we give a precise characterization of spiral cycles that should be examined in the underlying network. As the new conditions are more explicit and precise, they allow us to develop a fast algorithm for verifying optimality of a given solution (see Appendix 3).
Verifying the optimality of a given schedule C is one of the important application areas of our study. Instead of finding an optimal solution C * by using a traditional scheduling algorithm and comparing F (C, w) and F (C * , w), the necessary and sufficient conditions can be applied directly to C without constructing an optimal solution C * . We discuss the computational aspects of the optimality check for the problems under study at the end of the corresponding section, providing technical details in appendices. As we show, the new algorithms based on the necessary and sufficient conditions outperform those that find optimal schedules.

General structural properties of feasible schedules
In this section we discuss the general structural properties of feasible schedules. Depending on the objective function, it might be necessary to start jobs as early as possible if the function is strictly increasing, or the jobs can be postponed within some limits if the function is non-decreasing. For example, in any optimal schedule for problem P|r j , p j = 1| w j C j the maximum number of available jobs is allocated to each unit time interval [t, t + 1[ starting with t = min j∈J {r j }. In the case of problems P|r j , p j = 1| w j U j and P|r j , p j = 1| w j T j , an optimal schedule can often be modified by reshuffling and postponing early jobs without changing their "early" status; the resulting schedule still has the same value of the objective function.
In order to develop a uniform approach, we propose in Sect. 2.1 the concept of an earliest start schedule, which provides a convenient framework for formulating the necessary and sufficient conditions of optimality. Then in Sect. 2.2 we demonstrate how an arbitrary schedule with postponed jobs can be modified into an earliest start schedule.

Earliest start schedules
For non-decreasing objective functions, we are particularly interested in so-called earliest start schedules which contain the maximum number of jobs in each unit time interval [t, t +1[, t ≥ min j∈J {r j }. For such a schedule C, there exists a partition of the job set J into disjoint sets B 1 , B 2 , . . . , B κ , called block sets, and a partition of the time line into corresponding block intervals T 1 , T 2 , . . . , T κ (i) its starting time t i is equal to a minimum release date among all jobs from B i , t i = min{r j | j ∈ B i }; (ii) it includes all jobs j with t i ≤ r j ≤ t i + l i − 1 and none of such jobs is included in any subsequent block; (iii) each time interval [t, t + 1[, t ∈ T i , with the exception of the last one, contains exactly m jobs, while the last unit time interval contains at most m jobs.
The first condition implies that block (B i , T i ) starts at the earliest possible start time t i . Moreover, all jobs j scheduled The second condition is the separating rule for two consecutive blocks. It ensures that the jobs that follow (B i , T i ) cannot be moved to time intervals T i . The third condition characterizes the structure of a block; it states that each unit time slot should be saturated. The blocks are numbered in the order they appear in the schedule: t 1 < t 2 < · · · < t κ . For a block set B i , its length is l i = |B i | m . An earliest start schedule can be constructed by Algorithm 'Calculate Blocks' presented in Appendix 1. At the beginning the algorithm considers the time slot [t, t + 1[ defined by the minimal release time t. If the number z of jobs which can be scheduled in this time slot is at most m, then these jobs define the first block (B i , T i ) , i = 1, with T 1 = {t}. Otherwise the block contains more than m jobs and it is obtained by considering the subsequent time intervals [t, t +1[ one by one, adding each time to the block set B i those jobs which are released at time t and assigning the maximum number of jobs to [t, t +1[. Whenever the number of available jobs is m or less, the block (B i , T i ) is finalized and the new block is started. In addition to the schedule, the algorithm also calculates a function h : T → {1, . . . , m}, where T is the union of all sets T i and h(t) is the number of jobs scheduled in [t, t +1[ for each t ∈ T . The algorithm can be implemented in O(n log n) time by sorting the jobs in non-decreasing order of their release dates in the beginning. Clearly schedule C constructed by Algorithm 'Calculate Blocks' is an earliest start schedule since the number of jobs h(t) scheduled at time t is equal to m except for, probably, the last time interval of a block, which may contain less jobs.
The following example illustrates the algorithm. A feasible earliest start schedule C with block sets B 1 , B 2 , B 3 and B 4 is shown in Fig. 1. The jobs which start exactly at their release dates are dashed; the remaining jobs start after their release dates.
If a schedule C is given by a list of unit time intervals and a list of jobs allocated to them, then conditions (i)-(iii) can 123 be verified for all time slots in O (n) time by scanning the time slots of C three times.
In the first scan, the algorithm identifies time-values τ 1 , τ 2 , . . . , τ k with the property: all jobs that start at τ u , 1 ≤ u ≤ k, have their release times equal to τ u . Clearly, the identified τ values satisfy property (i) of the block definition, and therefore they get a label of a 't-candidate. ' In the second scan, the algorithm removes from the list of 't-candidates' those values which do not satisfy property (ii): a 't-candidate' τ u cannot define the starting time of a block if there is a job j starting after τ u (S j > τ u ) which is related to an earlier block (r j < τ u ). To check condition (ii) efficiently, the 't-candidates' are scanned right to left updating ρ accordingly.
The third scan is performed to verify property (iii) for the remaining 't-candidates. ' The formal description of this approach is presented in Appendix 1 as Algorithm 'Earliest Start Schedule Verification.' Its time complexity is O(n): there are no more than n unit time slots and they are scanned three times. The first two scans each consider n values of r j ; the third scan counts the number of jobs assigned to each time slot, which total number is n. Notice that as a by-product, the algorithm returns the t values, which define the decomposition of an earliest start schedule into the blocks.

Transforming an arbitrary schedule into an earliest start schedule
In this section we show that if a given schedule C for problem P|r j , p j = 1|F does not belong to the class of earliest start schedules, it can be transformed into an earliest start schedule C without increasing any of the completion times: This can be achieved as follows. Algorithm 'Calculate Blocks' is applied first in order to define the structure of the earliest start schedule, namely the time intervals T and the number of jobs allocated to them h(t), t ∈ T . Time intervals [t, t + 1[, t ∈ T , are considered one by one, starting with the earliest one. All jobs allocated in the original schedule to those time intervals are kept. If their number is less than h(t), the required number of additional jobs is moved from later time intervals to [t, t + 1[; the preference is given to the jobs with the smallest release dates. The formal description of such an algorithm (entitled as 'Left Shift(C)') and its analysis are presented in Appendix 1. We also discuss implementation details which result in the O(n log n) time complexity.
The following proposition establishes a link between a given optimal schedule and the earliest start optimal schedule.
Proposition 1 A schedule C is optimal for problem P|r j , p j = 1|F (C, w) with a non-decreasing objective function F, if and only if it can be transformed by Algorithm 'Left Shift (C)' into an optimal earliest start schedule C = C 1 , . . . , C n without changing the value of the objective function.
Proof Due to the properties of Algorithm 'Left Shift (C),' schedules C and C satisfy inequalities (1). This implies that for a non-decreasing objective function F, If C is optimal, then condition (2) should hold as equality since a strict inequality contradicts optimality of C. On the other hand, if C can be transformed into an optimal earliest start schedule C without changing the objective function value, then clearly C must be optimal.
Due to the described relationship between an arbitrary schedule C and an earliest start schedule C , in the subsequent sections we deal with earliest start schedules only. The optimality conditions which we formulate can be applied to each block separately, since no job from a block can be moved to a previous block.
Notice that if a given schedule does not belong to the class of earliest start schedules, then one can first apply Algorithm 'Left Shift (C)' checking condition (2) for the resulting schedule C . If F C , w < F (C, w), then schedule C cannot be optimal; if F C , w = F (C, w) then one needs to verify the optimality of the earliest start schedule C applying the necessary and sufficient conditions to it.

Earliest start schedule and associated compressed network
Consider problem P|r j , p j = 1|F (C, w) with a separable objective function F = w j f j (C j ), where each function f j (C j ) is non-decreasing. For a given earliest start schedule C consisting of a single block, the total number of time intervals is ν = n m , so that T = {0, 1, . . . , ν − 1}, and for each time t ∈ T there are exactly h(t) jobs allocated to [t, t + 1[: It is well known that a scheduling problem with unit time jobs can be reformulated as a transportation problem. Any feasible schedule corresponds to a feasible flow in the associated network and the objective value of the schedule equals the cost of delivering the flow. This implies that the necessary and sufficient conditions of optimality of a given schedule are equivalent to non-existence of a negative cycle in the corresponding residual network.
Formally, the transportation problem is defined by network N (C) = (V, A(C), η), Here, the vertex set V consists of job nodes {1, . . . , n}, each of which has a supply of 1, and interval nodes {I t | t ∈ T } with demand h(t). The arc set A(C) consists of the arcs ( j, I t ) defined for each feasible allocation of job j to interval [t, t + 1[, t ≥ r j . The cost of an arc ( j, I t ) represents the cost of allocating job j to time interval [t, t + 1[: and its capacity is 1. Depending on the type of the objective function, For a given solution C, a residual network N r (C) = (V, A r (C), ξ ) has the same vertex set V , while the arc set A r (C) and the costs ξ are defined as follows: Example 2 Consider problem P|r j , p j = 1| w j T j with m = 2 machines and n = 5 jobs with release dates, due dates and weights presented in the table: Observe that the release dates are the same as those of the first 5 jobs of Example 1 processed as one block. The transportation network N (C) is shown in Fig. 2a and the residual network corresponding to the schedule given by the first block of Fig. 1 is presented in Fig. 2b. The numbers at the arcs indicate the arc costs. Reformulating the well-known network flow theorem (see, e.g., Ahuja et al. 1993) we conclude that an earliest start schedule C is optimal for problem P|r j , p j = 1| w j f j (C j ) if and only if the corresponding residual network N r (C) = (V, A r (C), ξ ) constructed for each block of C contains no negative cycle.
A cycle in the residual network N r (C) is of the form The arcs are alternating between an arc from an interval node I t to a job node j and from a job node to an interval node.
It is convenient to compress the residual network N r (C) into a network N (C) by eliminating the job nodes; this results in multiple arcs connecting the interval nodes. We denote the nodes in N (C) by t ∈ {0, 1, . . . , ν − 1}. For any two nodes t and t we have an arc from t to t with length ξ t j + ξ jt , where ξ t j +ξ jt is the change of the objective function w j f j (C j ) when job j is moved from [t, t + 1[ to [t , t + 1[. Such an arc replaces the two alternating arcs I t → j → I t in N r (C). It is important to notice that the length (t,t ) of the arc from t to t depends not only on t and t , but on job j allocated For the three objective functions we consider, the cost of the arc (t, t ), associated with job j allocated to [t, t + 1[, is given by Example 3 Consider again the instance from Example 2. The corresponding residual network is presented in Fig. 2b and it contains a negative cycle I 0 , 1, This negative cycle characterizes that the series of the following moves leads to a schedule with a smaller value of w j T j : The compressed residual network is shown in Fig. 3a, and the corresponding negative cycle (marked by bold arcs) is 0, 1, 2, 0.
We distinguish between right and left arcs in N (C). Arc (t, t ) is a left arc if it is directed from t to a vertex corresponding to an earlier time slot t , t < t; for a right arc Consider a pair of time-nodes t and t , corresponding to time intervals [t, t + 1[ and [t , t + 1[. Since our aim is to detect negative cycles or to prove that none exists, we can compress network N (C) further by eliminating multiple arcs of larger costs. Instead of keeping multiple arcs (t, t ) and multiple arcs (t , t), we can keep just one arc in each direction that has the smallest cost.
Denote the resulting network by N (C). For Example 2, the corresponding network N (C) is shown in Fig. 3b. Let J t be the set of jobs assigned in C to time interval [t, t + 1[. Then the cost (or the length) of the right arc (t, t ), t < t , originating from t is defined as Considering left arcs (t, t ), t > t , originating from t, we need to take into account the release dates of the jobs from J t since not all of them can be moved to an earlier time slot [t , t + 1 [. Let J (t,t ) denote a subset of jobs from J t , which can be re-allocated to [t , t + 1[ without violating their release dates: Then the left arc t, t exists if J (t,t ) = ∅ and its length is defined as It is easy to make sure that if residual network N r (C) and the corresponding compressed network N (C) contain a negative cycle with repeated node t, then the cycle can be decomposed into two cycles and at least one of them is negative. Clearly, it is sufficient to consider the cycles without repeated time-values. Thus the necessary and sufficient optimality conditions can be formulated as follows.

Theorem 1 A schedule C for a given instance of P|r j
is optimal if and only if 1. transforming C into an earliest start schedule does not change the objective value; 2. for each block of the resulting earliest start schedule, the corresponding compressed network N (C) contains no negative cycle.
We estimate the size of the compressed network N (C) and the time complexity of constructing it assuming that a given earliest start schedule C has n jobs assigned to m machines and it consists of a single block. The number of nodes of N (C) is ν = n m . Each pair of nodes t and t are connected by at most two arcs (t, t ) and (t , t), so that the total number of arcs is O ν 2 . For each right arc (t, t ), its cost can be found in O(m) time since |J t | ≤ m, and for each left arc (t, t ), its cost can also be found in In the subsequent sections we show that, depending on the type of the problem, Condition 2 of Theorem 1 can be reformulated so that instead of checking the non-negative condition for all possible cycles only special types of cycles can be considered, namely two-node cycles, chain cycles and spiral cycles. Each of these cycles has exactly one arc of negative length denoted by (t, τ ); it originates in the rightmost node t of the cycle and contains no more than one positive arc; all other arcs have zero lengths. If the cycle contains a positive arc, that arc has end-node t.
A two-node cycle consists of two arcs (t, τ ) and (τ, t), see starts with the negative left arc (t, τ ) and then proceeds with a chain R of right arcs from τ to t, see Fig. 5a. A left-chain cycle starts with the negative left arc (t, τ ), proceeds then with a chain L of left arcs to the left-most node of the cycle and returns to the origin t via one right arc, see Fig. 5b.
A spiral cycle is defined as the one satisfying the following five properties.

Property 1:
The cycle contains exactly one negative arc (t, τ ), all other left arcs have zero length. Property 2: No left arc, except for possibly (t, τ ), spans over a node which appears in the remaining part of the cycle after that arc. Property 3: No right arc spans over a node which appears in the remaining part of the cycle after that arc. Property 4: The right-most node of the cycle is t. Property 5: All right arcs have zero length except for the last right arc terminating in t which may be of positive length or of zero length.
An example of a spiral cycle is shown in Fig. 6. In general, a spiral cycle contains alternating left chains L 1 , L 2 , . . . , L s and right chains R 1 , R 2 , . . . , R s 6. L 1 is a left chain originating in τ ; the first arc of R 1 spans over all nodes of L 1 ; the first arc of L 2 spans over all nodes of L 1 ∪ R 1 . For each k = 2, . . . , s, the first arc of L k spans over all nodes of Table 1 The simplest cycles which are sufficient to consider in optimality conditions

Problem
Simplest negative cycles Reference P|r j , p j = 1| w j T j Cycles with more than one negative arc (even if r j = 0) Example 8 P| p j = 1| T j Two-node cycles Theorem 8 and the first arc of R k spans over all nodes of The last chain R s consists of right arcs terminating in the origin t.
Notice that a two-node cycle is a special case of a chain cycle, which in its turn is a special case of a spiral cycle.
The main outcomes of our study are summarized in Table 1, where we list the types of cycles that should be examined in a compressed residual network N (C), representing a one-block earliest start schedule. Notice that for problem P|r j , p j = 1| w j T j and its special case P| p j = 1| w j T j there exist instances for which even the simplest negative cycles have several negative arcs so that they do not fall in any of the above three categories of cycles. We do not give a characterization of negative cycles for these two problems since the usage of such a result is likely to be very limited. For example, using those conditions in the optimality check would incur cycles with one negative arc, cycles with pairs of negative arcs and even more complex cycles with various combinations of negative arcs.
For all other problems and their special cases, we first prove the result establishing the type of a simplest negative cycle. Then we show that the result cannot be improved by providing an example that there exists an instance of the problem with only one negative cycle and it is of the type established in the corresponding theorem. Such instances are not needed for two-node cycles indeed.
In what follows we consider the three objective functions w j C j , w j U j and T j and prove the relevant statement about the type of the cycle for each problem. We then explore how the identified types of cycles can be used in order to speed up the optimality check.

Problem P|r j , p j = 1| w j C j
In this section we consider the problem P|r j , p j = 1| w j C j with the weighted completion time objective. We show that the optimality conditions for this problem can be simplified by limiting consideration to two-node cycles only. Moreover, the reduced network N (C) can be compressed further by eliminating transitive arcs, so that the resulting network N TransRem (C) contains no more than 2 (ν − 1) arcs; its left arcs form an out-tree and the right arcs form an in-tree. As a result, the optimality check problem can be solved in O(n) time, an improvement in comparison with the O(n log n) time algorithm for finding an optimal schedule. Theorem 2 A compressed residual network N (C), representing a one-block earliest start schedule for a given instance of problem P|r j , p j = 1| w j C j , contains a negative cycle if and only if it contains a negative two-node cycle.
Proof Clearly, the formulated condition is sufficient. In order to prove that it is also necessary, assume that there exists an instance of problem P|r j , p j = 1| w j C j such that all two-node cycles are non-negative while there exists a negative cycle with three or more nodes. Let this cycle additionally have the smallest number of nodes. We show that there exists a negative cycle with a smaller number of nodes.
Denote by t 1 the left-most node of the cycle. The cycle starts with a positive arc (t 1 , t 2 ), proceeds with a series of arcs, which we denote by α, leading to node t 3 and terminates at the origin t 1 with a negative arc (t 3 , t 1 ). The length of the Thus the length of the original cycle is where α is the length of fragment α.
First we derive an auxiliary inequality for w j 1 and w j 3 . Due to the assumption, the cycle consisting of two arcs Consider the following two cases, depending on the location of t 2 and t 3 is also non-empty for t 2 > t 1 . Hence we can introduce the arc (t 3 , t 2 ) and consider a cycle with less nodes, namely (α, (t 3 , t 2 )), see Fig. 7b. The length of (t 3 , t 2 ) is associated with some job j 3 , w j 3 = max j∈J (t 3 ,t 2 ) w j , and due Comparing the length of the original cycle given by (7) with the length of the new cycle = α − w j 3 (t 3 − t 2 ) we conclude that if < 0, the new cycle is also negative: In the above formula, the first inequality is due to (9), while the second inequality follows from (8). Thus we have detected a negative cycle with a less number of nodes which contradicts the assumption that the initial negative cycle has the smallest number of nodes.
If t 2 > t 3 , as shown in Fig. 8a, introduce the positive arc (t 3 , t 2 ) and consider a cycle with less nodes, namely ((t 3 , t 2 ) , α), see Fig. 8b. The length of (t 3 , t 2 ) is associated with some job j 3 , w j 3 = min j∈J t 3 w j , see (3). Comparing the latter formula with (6) we conclude that (notice that J t 3 ⊇ J (t 3 ,t 1 ) and the last equality corresponds to (6)).
Denoting by the length of the cycle shown in Fig. 8b, we obtain so that < 0 for < 0. In the above formula, the first inequality is due to (10), while the second inequality follows (a) (8). Again we have detected a negative cycle with a less number of nodes which contradicts the assumption that the initial negative cycle has the smallest number of nodes.
Notice that due to the definition of N (C), a right arc exists for any pair of nodes, while left arc (t, τ ) exists only if J (t,τ ) = ∅. Therefore in order to enumerate all two-node cycles one can consider left arcs one by one, complementing each left arc with its right arc counterpart. Moreover, we prove that transitive left arcs in N (C) are not needed.

Theorem 3 Consider network N TransRem (C) obtained from N (C) by removing transitive left arcs and removing all right arcs which do not have a left counterpart. Denote the set of left arcs in N TransRem (C) by A left (C). Then N (C) does not contain a negative cycle if and only if inequality
is satisfied for each (t, τ ) ∈ A left (C), τ < t.
Proof Necessity Clearly, relation (11) formulated for a left arc (t, τ ) is an equivalent representation of the condition that the cycle defined by nodes t and τ is non-negative, see formulae (3) and (5).

Sufficiency
To prove that conditions (11) defined for (t, τ ) ∈ A left (C), are sufficient, consider t 1 < t 2 < t 3 assuming that the left arcs (t 2 , t 1 ) , (t 3 , t 2 ) exist together with the transitive left arc (t 3 , t 1 ). The associated positive arcs are (t 1 , t 2 ) , (t 2 , t 3 ) and (t 1 , t 3 ). We show that if (11) holds for the pair of nodes t 1 , t 2 and for the pair t 2 , t 3 , then (11) also holds for the pair of nodes t 1 , t 3 . Indeed, conditions (11) for t 1 , t 2 and for t 2 , t 3 are of the form: The right-hand side of the first inequality is greater than or equal to the left-hand side of the second inequality since The right-hand side of the second inequality can be bounded as We conclude that which implies that condition (11) also holds for the pair of nodes t 1 , t 3 .

Proposition 2 The set of left arcs A left (C) in N TransRem (C)
is an out-tree.
Proof Suppose the proposition does not hold, i.e., there exists in A left (C) a pair of left arcs (t 2 , t 1 ) and (t 3 , t 1 ) with the same end-node, t 1 < t 2 < t 3 . This implies that J (t 2 ,t 1 ) = ∅ and J (t 3 ,t 1 ) = ∅. It follows from the latter condition that J (t 3 ,t 2 ) = ∅ since the jobs that can be re-allocated from [t 3 , t 3 + 1[ to [t 1 , t 1 + 1[ can also be re-allocated to [t 2 , t 2 + 1[. Then there exists arc (t 3 , t 2 ) in N (C) and therefore the set of arcs A left (C) in network N TransRem (C) (without transitive arcs) cannot contain (t 3 , t 1 ), a contradiction.

Example 4
The following table describes an instance of problem P|r j , p j = 1| w j C j with n = 18 jobs and m = 2 machines: A feasible schedule C for this problem is shown in Fig. 9. The jobs which start exactly at their release dates are dashed; the remaining jobs start after their release dates. The left arcs A left (C) of graph N TransRem (C) with transitive arcs removed are shown in Fig. 10. The set A left (C) consists of (8, 7) , (7, 6) , (6,5) , (6,4) , (4,3) , (3,2) , (3,1) , (1,0), which form an out-tree.
The proof of Proposition 2 justifies the following O(n)time algorithm for constructing left arcs A left (C) of network We provide the details of this approach in Appendix 2.

Problem P|r j , p j = 1| w j U j
This section explores the most general, spiral cycles.

Theorem 4 A compressed residual network N (C)
, representing a one-block earliest start schedule for problem P|r j , p j = 1| w j U j , contains a negative cycle if and only if it contains a negative spiral cycle.
Proof Consider an arbitrary negative cycle that starts with a negative arc (t, τ ). We show that then there exists a negative cycle such that the five properties formulated in the definition of a spiral cycle are satisfied.
In order to prove Property 1 (the cycle contains exactly one negative arc (t, τ )) we demonstrate that a negative cycle with the smallest number of nodes cannot contain more than one negative arc. Suppose a negative cycle has several negative arcs (t 1 , τ 1 ), (t 2 , τ 2 ), . . . , (t y , τ y ), y ≥ 2. Without loss of generality we assume that arc (t 1 , τ 1 ) has the right-most origin t 1 among all negative arcs, i.e., t 1 > max t 2 , . . . , t y . Notice that no nodes are repeated in the cycle. Denoting the path from τ 1 to t y by α and the path from τ y to t 1 by β, the cycle can be represented in the form (t 1 , τ 1 ) , α, t y , τ y , β , where fragment α can be empty. The three possible types of that cycle are illustrated in Fig. 11a-c depending on the relationship between τ 1 , t y and τ y . Let the lengths of arcs (t 1 , τ 1 ) and t y , τ y be −w j 1 and −w j y , where j 1 and j y are late jobs allocated to [t 1 , t 1 + 1[ and [t y , t y + 1[, respectively.
Since the cycle passes through t y before it returns to t 1 and t y < t 1 , there should be an arc (e, f ) belonging to fragment β that straddles node t y , so that e < t y < f, and we can represent fragment β as β , (e, f ) , β , see Fig. 12. Notice that the case e = τ y implies β = ∅ and the case f = t 1 implies β = ∅. Let the job corresponding to arc (e, f ) be q so that the length of the arc is Since fragment β does not contain negative arcs, all its three components are non-negative: Here β , (e, f ) and β denote the lengths of β , (e, f ) , β , respectively.
Consider instead of the original cycle two new cycles: Cycle I = t y , τ y , β , e, t y and Cycle I I = ((t 1 , τ 1 ) , Denoting the length of the original cycle by O and the lengths of the two new cycles by I and I I we obtain: Thus at least one of the new cycles is negative. This contradicts the assumption that the initial negative cycle has the smallest number of nodes.
We turn now to Property 2: no left arc, except for possibly (t, τ ), spans over a node which appears in the remaining part of the cycle after that arc. Suppose for a negative cycle satisfying Property 1 there exists a 0-length left arc ( f, g) which spans over node h that appears on the path from g to t, so that g < h < f , see Fig. 13. If there are several nodes of type h we select the right-most one. In that figure, solid lines represent arcs and dotted lines represent the fragments of the cycle which may consists of several arcs. Introduce new left arc ( f, h), which length is zero since there is only one negative left arc (t, τ ). Replacing the fragment of the cycle from f to h by the arc ( f, h), we remove 0-length left arcs and non-negative right arcs. Hence the resulting cycle is negative, but with less left arcs spanning over other nodes on the path to t. Repeating this transformation we eventually obtain a cycle satisfying Property 2.
The proof of Property 3 (no right arc spans over a node which appears in the remaining part of the cycle after that arc) is similar to the proof of Property 2: consider a right arc ( f, g) which spans over node h that appears on the path from Negative cycle with left arc ( f, g) spanning over node h on the path from g to t g to t, so that f < h < g, and replace the fragment of the cycle from f to h by the arc The same idea can be used to prove Property 4 (t is the right-most node of the cycle) using t instead of h in the above arguments.
Finally Thus replacing the fragment from e to t by arc (e, t) results in a negative cycle with less nodes and no more than one positive arc (e, t).
Clearly, spiral cycles have a more complex structure in comparison with two-node cycles and chain cycles. We demonstrate by means of Example 5 below that the result of Theorem 4 cannot be strengthened for problem P|r j , p j = 1| w j U j , and spiral cycles cannot be replaced by simpler counterparts. Since the instance below deals with the case of unit weights, w j = 1 for all j ∈ J , the result of Theorem 4 cannot be strengthened for problem P|r j , p j = 1| U j .

Example 5
Consider an instance of the problem P|r j , p j = 1| U j for which a negative spiral cycle exists but there are no negative cycles of simpler types. In that example, there is one machine and n = 8 jobs with job characteristics given by the   Figure 14 represents a spiral negative cycle for this instance. Notice that (7, 3) is the unique negative arc in the graph and its length is −1. In order to construct a negative cycle with that arc we need to find a 0-length path from 3 to 7. Due to the release date and due date restrictions, there is only one path with that property shown in Fig. 14. Thus there is only one negative cycle and that cycle belongs to the spiral category.
Notice that for problem P|r j , p j = 1| w j U j with nonunit weights, the last arc terminating in t = 7 may have a positive weight. In particular, if in Example 5, condition 1 < w 7 < w 8 holds and d 7 = 8 is replaced by d 7 = 7, then the spiral cycle shown in Fig. 14 has positive arc (6, 7) of length w 7 . The cycle, however, is still negative; its length is −w 8 + w 7 .
The algorithm for optimality check is presented in Appendix 3. Although the algorithm does not limit its search to spiral cycles, still it outperforms the fastest algorithm for finding the optimal solution for P|r j , p j = 1| w j U j .

Problem P| p j = 1| w j U j
We consider now the special case when all jobs are available simultaneously (r j = 0 for j ∈ J ) and show that for this case it is sufficient to consider simpler cycles of chain type.

Theorem 5 A compressed residual network N (C), representing a one-block earliest start schedule for problem P| p j = 1| w j U j , contains a negative cycle if and only if it contains a negative right-chain cycle.
Proof Since problem P| p j = 1| w j U j is a special case of P|r j , p j = 1| w j U j , we can use the result of Theorem 4 and consider only negative spiral cycles. Let z be the leftmost node of such a cycle. Consider a negative arc (t, τ ) of the cycle, which corresponds to moving some job j ∈ J (t,τ ) to time interval [τ, τ + 1[. Since all release dates are zero, arc (t, τ ) can be replaced by arc (t, z) which corresponds to moving the same job j to time interval [z, z + 1[, the  Fig. 15 A unique negative cycle for Example 6 belonging to the rightchain category length of the new arc being no larger than that of (t, τ ). Since the remaining part of the spiral cycle from z to t is a right chain with 0-length arcs except for the last arc, which can be positive, the new cycle with the shortcut (t, z) is a right-chain cycle t, z, . . . , t of negative length.
The result formulated in Theorem 5 cannot be strengthened for the unweighted version P| p j = 1| U j , as the following example illustrates.

Example 6
Consider an instance of the problem P| p j = 1| U j with one machine and three jobs with due dates d 1 = 2, d 2 = 3, d 3 = 1, and a schedule given by job sequence (1, 2, 3). The corresponding graph, shown in Fig. 15, contains a unique negative cycle (2, 0, 1, 2) of length −1; it is a right-chain cycle; all two-node cycles are non-negative.
In what follows we show that network N (C) can be reduced by removing some nodes and arcs. Recall that the network reduction has been performed in Sect. 3 for problem P|r j , p j = 1| w j C j where it has been shown that transitive arcs are not needed.
We start with decomposing N (C) into so called zerocomponents. A zero-component Z i , 1 ≤ i ≤ γ , consists of consecutive nodes τ i , τ i + 1, . . . , τ i , each of which can be reached from the start-node τ i via a chain of 0-length right arcs. For two zero-components Z i and Z j , i < j, there is no 0-length right arc (τ , τ ) connecting τ ∈ Z i and τ ∈ Z j . Notice that Z i may consist of a single node, i.e., τ i = τ i .
one of the jobs of Z i has a due date no smaller than ν or if Z i contains a late job; in both cases such a job can be moved to any later time slot at a zero cost, so that all right arcs originating from the corresponding node are of zero length. • Zero-component Z i is not the last one (i.e., τ i < ν − 1), if all jobs scheduled in the time-slots τ i , τ i + 1, …, τ i are early and their maximum due date is equal to τ i + 1.
The following example illustrates the decomposition of N (C) into zero-components.  1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 In the table we separate job triples, which are processed in the same unit time slot, by vertical lines. A schedule with four zero-components marked by rectangles is shown in Fig. 16; the start-and end-nodes of the components are as follows: Decomposition of a schedule into zero-components can be performed by scanning the nodes τ = 0, 1, . . . , ν − 1 left to right, identifying for a current zero-component Z i the furthest node from the start-node reachable by a chain of 0-length right arcs. We provide a formal description of procedure 'Decomposition' in Appendix 4 and show that its time complexity is O(n).
Based on zero-components Z 1 , Z 2 , . . . , Z γ , we define the notion of an essential cycle and prove that only essential cycles need to be considered in the optimality conditions. For all zero-components Z i except for the last one (1 ≤ i ≤ γ − 1) introduce characteristic w * i as the smallest w value among the jobs of that component: Let τ * i be the node associated with . . . , τ * i , t and consists of -a negative arc (t, τ i ) with t belonging to the last component Z γ and τ i being a start-node of the zero-component Z i , 1 ≤ i ≤ γ , -a chain of right arcs of zero length from τ i to τ * i , all belonging to Z i , -a final arc (τ * i , t) terminating at t.
Notice that if 1 ≤ i < γ , then the final arc (τ * i , t) is of positive length and if i = γ , then that arc is of zero length. Essential cycles of Example 7 are shown in Fig. 17.

Theorem 6 Network N (C) contains a negative cycle if and only if it contains a negative essential cycle.
Proof Due to Theorem 5 we can consider only negative rightchain cycles. Let t be the right-most node of such cycle and (t, τ ) be its negative arc. This implies that time interval [t, t + 1[ contains a late job and therefore t belongs to the last zero-component Z γ .
By the definition of a zero-component, any right arc from a node of one component to a node of another component is of positive length. Since there is no more than one positive arc in a right-chain cycle, the origin t is followed by the nodes of one zero-component only, say Z i , 1 ≤ i ≤ γ . Thus a negative right-chain cycle can be represented as t, τ i , . . . , τ i , t, where the zero length path τ i , . . . , τ i consists of right arcs within Z i . Notice that for a special case with τ i = τ i we get a twonode cycle. We show that the length of the essential cycle t, τ i , . . . , τ * i , t is no larger than that of an arbitrary negative right-chain cycle t, τ i , . . . , τ i , t with τ i , . . . , τ i belonging to Z i . Indeed, the left arcs of the two cycles satisfy (t,τ i ) ≤ (t,τ i ) since τ i < τ i ; the internal paths within Z i are of zero length for both cycles, i.e., (τ i ,. ..,τ t) holds due to the definition (14) of w * i . We illustrate how the formulated optimality condition can be used for the optimality check in Appendix 4; the resulting algorithm has time complexity O(n), an improvement in comparison with the O(n log n)-time algorithm for finding an optimal schedule for problem P| p j = 1| w j U j (Brucker and Kravchenko 2006;Dessouky et al. 1990). Example 8 Consider an instance of the problem P|r j , p j = 1| w j T j with one machine and n = 4 jobs given by the table Figure 18 represents the corresponding graph; the unique negative cycle (3,2,0,3) is marked by bold arcs and it contains two negative arcs (3,2) and (2,0).
Notice that the instance presented in Example 8 has zero release dates for all jobs, which implies that for problem P| p j = 1| w j T j we also cannot limit our consideration to the three types of cycles defined above. In this paper we do not introduce new cycle types with several negative arcs; it is likely that the resulting rather complicated optimality conditions would have limited application.
In what follows we discuss how solution optimality can be checked using Theorem 1. Recall that Theorem 1 provides the necessary and sufficient optimality conditions for the most general problem P|r j , p j = 1| w j f j (C j ) with an arbitrary separable objective function. In order to verify the optimality of a given solution C, we first apply the O(n log n)-time Algorithm 'Left Shift(C).' Then the reduced graph N (C) is constructed in O n 2 m time, as described in Sect. 2.3. It has ν = n m nodes and a arcs, a < ν 2 . Since the fastest algorithms for negative cycle detection are of time complexity O (νa) (Cherkassky and Goldberg 1999), which is O n 3 m 3 in our case, schedule optimality can be verified in O n 3 m 3 + n 2 m time -an improvement in comparison with the straightforward O(n 3 ) approach based on finding an optimal solution to problem P|r j , p j = 1| w j T j via solving the associated assignment problem.

Problem P|r j , p j = 1| T j
We consider now the equal weight special case (w j = 1 for j ∈ J ) and show that for this case it is sufficient to consider simpler cycles of chain type. The proof of Properties 1-4 follows the same ideas as the proof of Theorem 4 for problem P|r j , p j = 1| w j U j ; we present that proof in Appendix 5. Consider now Property 5 .
Let (e, f ) be the first right arc with f < t. We denote the fragment of cycle O from τ to e by α and the fragment of the schedule from f to t by β, see Fig. 19. Notice that by the definition of the spiral cycle see also Fig. 6.
Let j be a job in J (t,τ ) with the smallest due date, so that the length of arc (t, τ ) is defined via that job, (t,τ ) Notice that otherwise the length of the arc (t, τ ) is not negative. Similarly, let k be a job in J e with the largest due date, so that the length of arc (e, f ) is defined via that job, Introduce an artificial right arc (e, t) and replace the fragment (e, f ), β of cycle O by a single arc (e, t). The length of the new cycle is Clearly, if d k > t + 1, then the last term in the above expression is 0, so that the resulting cycle is negative and it satisfies Property 5 . Also, if max d j , τ + 1 < d k ≤ t + 1, then the resulting cycle is negative and it satisfies Property 5 as well: Thus in what follows we assume We show that introducing an artificial left arc (t, f ) and replacing in the original cycle O the fragment (t, τ ), α, (e, f ) by that arc we obtain a modified cycle M with less nodes which length M is negative. To this end, we calculate the difference M − O using the formula Let i be a job in J (t, f ) with the smallest due date, so that the length of arc (t, f ) is defined via that job, Notice that J (t,τ ) ⊆ J (t, f ) and, as defined earlier for J (t,τ ) , j is the job with the smallest due date among J (t,τ ) . It follows that d i ≤ d j so that We consider the following cases with respect to d j .
(1) The case of d j ≥ t + 1 is eliminated due to (16). ( where we first use inequality (17), then (15), while the last equality holds due to the assumption of case (3). Hence We conclude that (4) Finally, if d j ≤ τ + 1, then d k ≤ τ + 1 by (17) and Here we use (15) for max {τ + 1, e + 1}. It follows that Thus Property 5 is proved which, together with Properties 1-4 implies that the negative cycle with the smallest number of nodes belongs to the class of left-chain cycles.
The algorithm to check the optimality of a given schedule is presented in Appendix 6. Its time complexity is O(n log n) provided that an earliest start schedule is given, and it reduces to O(n) if all jobs are available simultaneously (r j = 0 for all j ∈ J ).
We now demonstrate that there are instances of problem P|r j , p j = 1| T j for which negative left-chain cycles exist but there are no negative cycles of a simpler type, namely, two-node cycles.
Example 9 Consider an instance of the problem P|r j , p j = 1| T j with m = 1 and n = 4 given by the table Figure 20 represents a unique negative cycle for this instance which is a left-chain cycle. It is easy to verify that all twonode cycles are non-negative. In problem P| p j = 1| T j all jobs are available simultaneously (r j = 0, j ∈ J ) and have unit weights. We first show that the necessary and sufficient conditions for problem P|r j , p j = 1| T j can be simplified so that only two-node cycles are considered. Proof Due to Theorem 7, if the graph for problem P|r j , p j = 1| T j contains a negative cycle, it also contains a negative left-chain cycle. Given an arbitrary negative left-chain cycle we replace the whole left chain by a single arc. Since the length of that arc is no larger than that of the initial negative arc and the remaining removed left arcs are of zero lengths, we obtain a negative two-node cycle.
Notice that unlike problem P|r j , p j = 1| w j C j , the transitive arcs cannot be eliminated, as the following example shows.
Observe that the algorithm for optimality check for problem P| p j = 1| T j follows from the algorithm for the more general problem P|r j , p j = 1| T j presented in Appendix 6. The time complexity of the latter algorithm is O(n) for an earliest start schedule. Since in the case of r j = 0 for all j ∈ J , Algorithm 'Left Shift(C)' transforms a given schedule into an earliest start schedule in O(n) time, the optimality check for problem P| p j = 1| T j can be performed in O(n) time for an arbitrary schedule.

Conclusions
In this paper we have studied the necessary and sufficient optimality conditions for various problems with parallel identical machines and unit job processing times. The formulated conditions deal with a specially defined network N (C) and they are based on detecting negative cycles. For each problem we give an insight into the underlying structure of the graph N (C) and specify the simplest types of cycles which need to be considered in the optimality conditions: two-node cycles, chain cycles and spiral cycles. The summary of the cycle types for different versions of problem P|r j , p j = 1|F (C, w) is provided in Table 1 in Sect. 2.3. The special features of the cycles allow us to develop efficient algorithms for verifying optimality of a given schedule. We describe the ideas of the optimality check algorithms after formulating the optimality conditions for each problem and present all technical details in the appendices. The summary of the results is presented in Table 2 where we compare the time complexity of traditional algorithms for finding optimal schedules with the complexity of our optimality check algorithms.
In the table we assume that an earliest start schedule consisting of a single block is given (which can be verified in O(n) time by the algorithm from Appendix 1). Otherwise an initial schedule can be converted into an earliest start schedule by Algorithm 'Left Shift' from Appendix 1; after that the optimality check can be performed for each block considered separately. Notice that Algorithm 'Left Shift' requires O(n log n) time if release dates are arbitrary and O(n) time if all jobs are available simultaneously (r j = 0 for all j ∈ J ). This implies that 'Left Shift' does not affect the O(n) time complexity of the algorithms for problems P| p j = 1| w j U j and P| p j = 1| T j ; for other problems the time complexity should be increased by O(n log n) if the initial schedule does not belong to the class of earliest start schedules.
While we have illustrated only one application of the necessary and sufficient optimality conditions, they might be beneficial for solving other problems as well. Further applications of the optimality conditions may involve the development of new algorithms for finding alternative optimal solutions different from those produced by the known algorithms or algorithms for finding several optimal schedules. Another application area is hierarchical optimization, where it is required to select among solutions optimal for one criterion those solutions which minimize the secondary criterion. Finally, the optimality conditions play an important role in inverse scheduling (Heuberger 2004) where a target schedule is given and it is required to modify the problem parameters to make the target solution optimal. Developing optimality conditions for other scheduling problems and Given an earliest start schedule, construct left arcs A left (C) of network N TransRem (C) without transitive arcs, to complement them with the corresponding right arcs and to verify conditions (11) for ν − 1 pairs of nodes t and τ . We first provide the details of the algorithm for constructing A left (C) and then analyze it, together with the remaining steps of the optimality check. As before, we assume that C consists of one block of ν = n m unit time intervals.

Algorithm 'Construct Left Arcs
Define J (t+1,t) as the set of jobs allocated to For each separate chain of left arcs, except for the last one, 6. Consider its right end-node τ and find the earliest time t from the next chain such that Introduce left arc (t, τ ) of length (t,τ ) = − max Clearly, each for-loop of the algorithm scans the nodes of N TransRem (C) once performing for each time slot t at most m operations on the jobs allocated to it. Thus the above algorithm can be implemented in O (νm) = O (n) time.
For each left arc of the constructed out-tree, the length of its right arc counterpart can be found by (3). Since the number of left arcs in the out-tree is ν − 1, the lengths of all right arcs of N TransRem (C) can be found in O (νm) = O (n) time as well.
Verifying conditions (11) for ν − 1 pairs of nodes t and τ requires O(ν) time, if the lengths of arcs (t, τ ) and (τ, t) have been determined. Thus the overall time complexity of the optimality check for problem P|r j , p j = 1| w j C j is O(n). Notice that for problem P|r j , p j = 1| w j C j , an optimal solution can be found in O (n log n) time by scheduling at each decision point an available job with the largest w j value.

Appendix 3: Verifying solution optimality for
The fastest algorithm for solving problem P|r j , p j = 1| w j U j is due to Dourado et al. (2009) and it is of time complexity O n 2 log m m + n log n . We show that the optimality check can be performed by a slightly faster algorithm of time complexity O n 2 m + n . By Theorem 4, it is sufficient to explore whether there exists a negative spiral cycle for a given earliest start schedule. Our approach consists of three stages, where the first two stages deal with pre-processing. We assume that graph N (C) is constructed and its set of nodes corresponds to time intervals T ={0, 1, . . . , ν − 1}. Stage 1. Determine for each τ ∈ T the left-most node λ(τ ) reachable from τ via a 0-length left chain, and the rightmost node μ(τ ) reachable from τ via a 0-length right chain. Stage 2. Determine for each τ ∈ T the left-most node a(τ ) and the right-most node b(τ ) reachable from τ via a 0length path consisting of alternating left chains and right chains. Stage 3. The negative arcs are considered one by one. For each arc (t, τ ) of length (t,τ ) < 0, one of the two conditions happen: In the former case there exists a negative cycle consisting of (t, τ ) and a 0-length path from τ to t. In the latter case the algorithm finds the shortest path from τ to t as the smallest w value of one of the jobs processed in If ( Graph N (C) can be constructed in O n 2 m time, see Sect. 2.3. As we show below, the complexities of the subsequent three stages are O n 2 m 2 + n , O n 2 m 2 and O n 2 m 2 + n , respectively, so that the overall time complexity is n 2 m + n . We start with the formal description of the procedure of Stage 1. It first determines for each τ ∈ T the set of nodes L(τ ) to the left of τ connected with τ by 0-length left arcs. The values λ(τ ) are defined one by one for τ = 0, 1, . . . ,, λ(1), . . . , λ(τ − 1) are known, then λ(τ ) is the smallest value among λ(τ ), where τ ∈ L(τ ), or λ(τ ) = τ if there are no 0-length left arcs originating from τ .
Finding μ values is similar, but there is one point of difference: the 0-length right arcs originating from τ are defined via early jobs from J τ that can be moved to the right to the time slots no later than their due dates; however, if there is at least one late job J τ , then all right arcs originating from τ are of 0 length. Formally, this procedure is described as follows. Step 1 incurs O(n) time, while the loops of Steps 3-5 and 7-9 require O(ν 2 ) = O n 2 m 2 time. The procedure for Stage 2 is based on the definition of a spiral cycle, see Sect. 2.3. The origin t of the negative left arc (t, τ ) is not fixed, but node τ is fixed. The output for a given τ is the widest possible range of nodes a(τ ), a(τ )+1, . . . , b(τ ) reachable via 0-length paths. Stage 2: 'Calculate a(τ ) and b(τ ) for all τ ∈ T ' 1. For each τ from T ={0, 1, . . . , ν − 1} 2. Set a(τ ) := τ and b(τ ) := τ ; 3.
If d q ≥ t y + 1, then (e,t y ) = 0 and we obtain a two-node negative cycle consisting of arcs (t y , e) and (e, t y ). Notice that (t y ,e) < 0 since there is a late job in J t y . Alternatively, if d q < t y + 1, then (e,t y ) = t y + 1 − max d q , e + 1 , where the last condition may hold as inequality since there may exist a job in J t y with a due date larger than t y + 1. Thus (e,t y ) + (t y , f ) ≤ f + 1 − max d q , e + 1 = (e, f ) , so that condition (13) holds and Property 1 is proved.
The proof of Properties 2-4 is the same as in Theorem 4.
Set W j * = U j * ∪ V j * and T := T \W j * ; 13. endfor Notice that the set U j * may be empty; then condition (25) is not checked in Step 5. We introduce and analyze the O(n) Procedure 'Calculate d [a(τ ),τ ] values' later on. Here we explain how Steps 3-13 can be implemented in O(n log n m ) time assuming that the initial schedule is the earliest start schedule. We also show that the time complexity reduces to O(n) if all jobs are available simultaneously (r j = 0 for all j ∈ J ). In Step 3 all values d j | j ∈ J late belong to set T = {0, 1, . . . , ν −1} due to assumption (21); therefore algorithm 'Distribution Counting' (Knuth 1998) can be used to sort the numbers in O(n) time.
For efficient implementation of Steps 4-13 we maintain disjoint sets of prohibited τ -nodes which have already been eliminated, specifying each such set by its first and last nodes. Eliminating nodes W 1 for job j * = 1 results in the first prohibited set I 1 = W 1 . Eliminating nodes W 2 for job j * = 2 results in another prohibited set I 2 = W 2 located to the right of I 1 , if the left node of W 2 is larger than the right node of I 1 , or in an extended set I 1 , otherwise. Notice that the case that the right node of W 2 is smaller than the left node of I 1 does not happen: if it was a case, then the whole set W 2 would be located to the left of W 1 , and hence two elements of those sets could not satisfy d 1 ≤ d 2 , d 1 ∈ W 1 and d 2 ∈ W 2 .
Suppose that after j iterations jobs 1, 2, . . . , j have been examined and h disjoint prohibited intervals I 1 , I 2 , . . . , I h have been produced, h ≤ j. It can be shown by induction that the most recent job j with the largest due date d j belongs to I h . Consider the next job j + 1 and the nodes W j+1 that should be eliminated. Eliminating nodes W j+1 results in (i) another prohibited set I h+1 = W j+1 located to the right of I h , (ii) or in an extended set I h .
The case that the right node of W j+1 is smaller than the left node of I h could not happen: if it was a case, then elements d j+1 ∈ W j+1 and d j ∈ I h of those sets could not satisfy d j ≤ d j+1 .
During the course of the algorithm, no more than ν new disjoint sets I h are created (in accordance with (i))