Knapsack-like scheduling problems, the Moore-Hodgson algorithm and the ‘tower of sets’ property

Knapsack-like scheduling problems, the Moore-Hodgson algorithm and the ‘tower of sets’ property

Mathl. Comput. Pergamon 08957177(94)00107-3 Modelling Vol. 20, No. 2, pp. 91-106, 1994 Copyright@1994 Elsevier Science Ltd Printed in Great Britain...

1MB Sizes 0 Downloads 16 Views

Mathl. Comput.

Pergamon 08957177(94)00107-3

Modelling Vol. 20, No. 2, pp. 91-106, 1994 Copyright@1994 Elsevier Science Ltd Printed in Great Britain. All rights reserved 0895-7177/94 $7.00 + 0.00

Knapsack-Like Scheduling Problems, the Moore-Hodgson Algorithm and the ‘Tower of Sets’ Property E. L. LAWLER* Computer Science Division, University of California Berkeley, CA 94720, U.S.A. Abstract-Suppose there are n jobs, each with a specified processing time, release date, due date and weight. The objective is to schedule the jobs for processing by a single machine so that the total weight of the late jobs is minimized. A well-known algorithm of Moore and Hodgson solves this problem in O(n log n) time when all release dates are equal, provided processing times and job weights are, in a certain sense, ‘agreeable.’ In this paper, we show the Moore-Hodgson algorithm can be adapted to solve three other special cases of the general scheduling problem. Each of those special cases can be formulated BS a knapsack-like problem with nested inequality constraints. We show that optimal solutions to these knapsack-like problems exhibit a ‘tower of sets’ property, provided processing times, release dates, due dates and job weights satisfy certain order relations. We then show that the ‘tower of sets’ property enables dynamic programming recurrences to be solved by O(nlog n) time procedures, and that this property contributes to simple proofs of validity of the procedures. Keywords-Scheduling,

Dynamic programming, Tower of sets, Knapsack problem, Lateness.

1. INTRODUCTION In this paper, we consider are n jobs,

j = l,...,

and weight wj.

several variations

of the following

The objective

is to schedule

the jobs

as to minimize

the sum of the weights of the late jobs.

not permitted,

the problem

hard. When preemption preemptive

is styled

is permitted,

general scheduling

problem.

There

processing time pj, release date rj, due date dj,

n, each with a specified

for processing When

llrj 1c WjUj in the notation the problem is denoted

by a single machine

preemption

(‘job

splitting’)

of [l], and is strongly

so is NP-

llpmtn, rj 1C WjUj and an optimal

schedule can be found in 0(n3 W2) time [2], where W is the sum of the (integer) job

weights. A well-known

algorithm

of Moore

and Hodgson

[3] solves the problem

case in which

all release dates are zero and all job weights

that a simple

adaptation

same problem,

of the Moore-Hodgson

1 11C WjUj, when processing

algorithm

1 11C

are arbitrary.

Uj, the special

Lawler

solves the weighted

times and job weights are ‘agreeable’

[4] showed

version

of the

or oppositely

ordered, meaning that there is an indexing of the jobs such that WI 2 w2 2 .‘.

Pl
2 w,.

Much of the material in this paper will appear in the forthcoming book Scheduling, by E. L. Lawler, J. K. Lenstra, A. H. G. Rinnooy Kan and D. B. Shmoys. The author wishes to thank his co-authors, particularly David Shmoys, for their technical advice and editorial work. *Research supported by NSF Grant IRI-9120074.

Typeset by &+S-T&$ 91

E. L. LAWLER

92

Note that when all processing times are unity, but job weights are arbitrary, i.e., the problem is 1lPj = 11 CWjUj, Precessing times and job weights are necessarily oppositely ordered. In this paper, we shall show that the Moore-Hodgson algorithm can be adapted to solve one special case of 1 ]rj 1C Uj and two special cases of l(pmtn, rj] C wj Uj, as follows: (i) ilrjl C uj (i.e., nonpreemptive scheduling, unit job weights) with similar ordering of release dates and due dates. (ii) l]pmtn, rj ( C wj Uj (i.e., preemptive scheduling) with nested release date-due date intervals and opposite ordering of processing times and job weights. (iii) 1 Ipmtn, rj I c wj Uj with similar ordering of processing times and release dates and opposite ordering of processing times and job weights. The O(nlogn)

running time achieved for problem (i) improves on the O(n2) running time of

a dynamic programming algorithm due to Kise, Ibaraki and Mine [5]. When release dates are equal, there is no advantage to preemption, and problems (ii) and (iii) reduce to the special case originally solved by Moore-Hodgson and Lawler. Each of these special cases can be formulated as a knapsack-like problem with nested inequality constraints. Optimal solutions to these knapsack-like problems exhibit a ‘tower of sets’ property, provided processing times, release dates, due dates and job weights satisfy certain order relations. We show that the ‘tower of sets’ property enables dynamic programming recurrences to be solved by O(n log n) time procedures, and that this property contributes to simple proofs of validity of the procedures. 2.

SOME PRELIMINARIES

The processing of a job may not begin before its release date. If the processing of a job is completed by its due date, the job is said to be on time; otherwise it is late. We begin with a simple but fundamental observation that applies to the general problem in either its nonpreemptive or preemptive versions, i.e., llrjl C Wj Uj or lIpmhl,rjI C Wj Uj. If a job is late, it might as well be arbitrarily late. Hence, there exists an optimal schedule in which all jobs that are on time precede all the jobs that are late. Next, we observe that the on-time jobs can be assumed to be scheduled by the Earliest Due Date (EDD) rule. When all release dates are zero and preemption is not allowed (nor is of any advantage), the EDD rule simply means that jobs are sequenced in nondecreasing order of their due dates. When there are unequal release dates, the ‘preemptive’ version of the EDD rule is applied. This means that jobs are scheduled in time with a decision point each time a job is completed or new release date is encountered. At each decision point, a job with the smallest possible due date is next chosen for processing, from among all jobs that are currently available (in that their release dates have been met). A preemptive EDD schedule can be found in O(n log n) time.

IOn-TlmeJobsl

)LoleJobt Figure 1

It follows from the preceding observations that there exists an optimal schedule like that shown in Figure 1, where the on-time jobs are scheduled in accordance with either the ordinary EDD rule or its preemptive version. It also follows that the scheduling problem reduces to that of finding a maximum weight feasible set of jobs, where by a feasible set we mean a set of jobs that are all completed on time when scheduled by the (preemptive) EDD rule. Throughout this paper, we shall normally assume that jobs are numbered in EDD order, i.e.,

Knapsack-Like

Scheduling

Problems

93

We shall also employ the following notation. For 5’ & N = (1,. . . ,n}, let p(S) = Cjes pj, r(S) = min{rj ] J’ E S}, and w(S) = Cjes wj; finally, let c(S) denote the completion time of the last job in an EDD schedule for the jobs indexed by S. 3.

DYNAMIC

PROGRAMMING

SOLUTION

OF 111 C 20~Uj

The problem of finding a maximum-weight feasible set for the 1 11 C formulated as an integer linear programming problem [6]: maximize C

wj Uj

problem can be

Wj Xj

subject to Pl Xl I dl ~1x1

+PZX~

I

d2

pl~l+p2~2+p3~3
and forj=1,2

Xj E (0~1)~

,...,

72.

Note that when all the dj’s are equal, the last inequality implies all the others and the problem reduces to the ordinary knapsack problem. The triangular form of the inequality constraints enables us to employ a dynamic programming procedure essentially like that for the ordinary knapsack problem. Let P(j)(w) denote the minimum total processing time for any feasible subset of jobs J1, . . . , Jj that has total weight exactly w. Then we have

P(O)(w)= p(j)(,)

=

ifw=O,

0,

+oo, otherwise. min { p(j-r) (W),

P(j-l)(W

-

Wj)

+ Pj}

if P(j-i)(w

7

@-l)(w),

- wj) + pj < dj,

(1)

otherwise.

There are O(W) equations to solve at each of n iterations, j = 1,2,. . . , n, where W = C wj. Each equation requires a constant number of arithmetic operations. It follows that the values Ptn)(w) can be computed in O(nW) time; the maximum weight of a feasible set is the largest value of w such that Pen)(w) is finite. The dynamic programming recurrence equations can be solved by computing lists of dominant pairs (w, P(j)(w)). At each iteration, a list of candidate pairs is formed from the list existing at the end of the previous iteration. This list is merged with the existing list, with dominated pairs discarded in the course of the merge. More specifically, a pair (w, P(j)(w)) is said to be dominant at iteration j if there is no value w’ > w such that P(j)(w’) 5 P(j)(w). G’iven an ordered list of dominant pairs existing at the end of iteration j - 1, one first forms an ordered list of candidate pairs (w + wj, P(j-l) (w) + pj), excluding any candidates for which P(j-l) (w) +Pj > dj. This list is merged with the existing list, with dominated pairs discarded in the course of the merge. Each list contains at most W pairs, so the merge can be carried out in O(W) time at each iteration, yielding an O(nW) time bound for n iterations. 4.

THE

MOORE-HODGSON

ALGORITHM

Let us now review the Moore-Hodgson algorithm for solving 1 11 C wj iYj when processing times and jobs weights are oppositely ordered, i.e., there is an indexing of the jobs such that Pl

I

Pz I

*. . I

Pn,

w12

w2 2

.‘.

> w,.

E. L. LAWLER

94

Note that opposite ordering necessarily case of opposite ordering of processing problems 1 Ipj = 11 C wj Uj and 1 11C The Moore-Hodgson algorithm is as

holds if either all pj = 1 or all wj = 1. Hence, the special times and job weights is a common generalization of the Uj. follows: Starting with S’(O) = 0, process the jobs in EDD feasible sets S(j), j = 1,2 , . . . , n, by the recurrence relations

order, constructing

u {j),

if p (s(j-l)

&gPl) u {j} - {l},

otherwise,

s(j-l)

u {j}) 5 dj, (2)

where 1 = argmax = argmin

pi ) i E S(j-‘)

U {j}}

wi 1 i E S(j-l)

U

1 1

Y

{j)) .

The set 5’cn) is then a maximum-weight feasible set. The Moore-Hodgson algorithm is efficiently implemented with a priority queue S supporting the operations of insert and deletemax, as indicated below: moora-hodgsono : s:=0; p(S) := 0; for j = 1,2,...,n insert(S, j> ; P(S)

if

:=P(S)+Pj;

p(S) > dj then 1 := deletemaa:(S); P(S)

:= P(S)

- Pli

return S. Each of the n insertions and each of the at most n deletions takes at most O(logn) time. Hence, the overall running time required to generate a maximum-weight feasible set Scn) is bounded by O(n logn). Although the Moore-Hodgson algorithm seems quite unrelated to the dynamic programming algorithm of Section 3, the two are actually closely related. We shall demonstrate this by deriving the Moore-Hodgson algorithm from the list-making version of the dynamic programming algorithm. Recall that the input to iteration j of the dynamic programming algorithm is the list of dominant pairs generated at iteration j - 1: (

w(O), #j-l)

(w(0)))

) (w(l),

@j-l)

(w(l)))

). . . ) (w(k),

w-l)

(w(k)))

,

where 0 = w(0) < w(1) < f.. < w(k), < P’j-l’(w(1))

0 = P’j-“(W(0)) Each

pair (w(i),

S(j-l)(w(i))

G {1,2,.

< ..* < P’j-“(W(k))

in the list of dominant

P(j-“(w(i)))

. . , j - l}, with

(W(w(i))) = w(i), p(&w’)(w(i)))= P'j-"(W(i)).

w

<

dj_1.

pairs is realized by a feasible set

Knapsack-Like

Scheduling Problems

95

Ordinarily, we could not expect these feasible sets to be related in any special way. But when the processing times and job weights’are oppositely ordered, a happy thing occurs: the feasible sets form a tower. Specifically, each set N-i) contained in the set S(j-‘)

(w(i)) contains exactly one job Jjci) that is not

(w(i - 1)) that is immediately below it in the tower. That is,

s(j-i)&(O))

= 0 G s(+l)(w(l))

= {j(l)}

c - S(9w(2))

= {j(l),j(2)}

c- s(j-l)(w(k))

= {j(l),j(2),

c ...

(3)

. . . ,j(k)},

from which it follows that P’j-“(w(i))

- P(j-l)(~(i

- 1)) = pj(i),

and w(i) - ~(i - 1) = Wj(i),

i = 1,2,.

,k.

Furthermore, Pj(1) I Pj(Z) 5

"'

(4)

I Pj(k)

and wj(l) > wj(2) >

(5)

.*' > Wj(k).

We shall refer to relations (3)-(5) as the tower-of-sets property At this point, we may gain some insight from an example.

of feasible sets. Consider the following

problem

data. j

12345

pj

21543

-t-wj

45123

Assume that all due dates are very large, so that they are of no consequence. Iteration 4, we have the following list of dominant pairs,

At the end of

(O,O), (5, I), (%3), (11,7), (12, i2), which are plotted as dots in Figure 2. With reference to the Gantt charts shown in Figure 3, we see that these pairs are realized by a tower of feasible sets: s@)(O) = 0 G S(4)(5) = (2) c &!e(9) c S@)(ll)

= (2,l) = {2,1,4}

c S(4)(12) = {2,1,4,3}.

From the existing list of dominant pairs, we form a list of candidates (3,3), (3,4), (12,6), (14,10), (15,15), which are plotted as f’s in Figure 2. When the two lists are merged, and dominated pairs discarded, the surviving pairs are (O,O), (5, I), (%3), (12,6), (14, lo), (15,15). Again, with reference to Figure 3, we find that these pairs are realized by a tower of feasible sets: S@)(O) = S@)(O) = 0 c S(5)(5) = S(4)(5) = (2) G S@)(9) = S@)(9) = (2,l) c S(5)(12) = H(9)

u (5) = {2,1,5}

c S(5)(14) = s(4)(11) u (5) = {2,1,5,4} c S(5)(15) = S(4)(12) u (5) = {2,1,5,4,3}.

E. L. LAWLER

96

P

(15.15)

/ (12.12)

A

/

(14;10)

("*7112,6) +

54' / (9.3)

($3)

/*, aJ)

, 1

2

3

/",,*,, (5.1)

4

5

6

7

a

9

;*W

10

11

12

13

14

Figure 2.

---._.--__ r( -_.

2

5

..__.d___.______'

P,(9)

P,(O) P,(5)

P,(l

Ps(%

p,

P,il

1)

il2)

P5

4)

Figure 3

We shall prove by induction that the tower-of-sets property holds at each iteration. For the base case of the induction, note that the property holds at the end of iteration 0 when the only dominant pair, (O,O), is realized by the empty set. Assume, by inductive hypothesis, that the property holds at the end of iteration j - 1. At iteration j, the candidate pairs that are formed are W(0)

+

Wj,

P(j-l) Cw(0))+ Pj)

7

(W(l)+Wlr P’j-l’(W(l)) +

Pj)

(w(k)

).

.3

+ wg,

N--l) (w(k)) + Pj).

Let h be the largest index, 1 5 h 5 k, if any, such that pj(h) 5 pj and (The case in which there is no such h can be handled easily; details are omitted.) Recall that the existing pairs wj(h)

(

w(l),

P’j-“(w(l)))

, . . . , (w(h),

2

w3.

‘P(+‘)(w(h)))

can be rewritten as W(0) + “j(l),

P(j-I) (W(0)) + Pj(r))

>. . .T (w(h

-

1) + wj(h),

P(j-‘)(w(h

-

1))

f

Pj(h))

.

Knapsack-Like

Scheduling

Problems

97

Opposite ordering of processing times and job weights implies that these pairs, respectively, dominate the candidate pairs (

w(0) + Wj, @j-l)

Furthermore, (

w(h) +

(W(0)) +pj)

7s*. 1 (W(h - 1) + Wj, P(j-l)(W(h

-

1)) +_Dj)

.

by rewriting the other existing pairs as

Wj(h+l)r

p(j-l)(w(h>)

+Pj(h+l)

>

Y*"Y

(

W(k - l)

+ Wj(/c)~ p(j-l)(w(k

-I))

+Pj(/c)

>

7

we see that they are, respectively, dominated by the candidate pairs (

W(h)

+ Wj, P(j-l)

(w(h))

+ pj)

7e.. ) (w(k

1) + Wj, P(j-l)(W(k

-

- 1)) + p.j> .

Hence, the merged list at the end of iteration j contains the pairs (

w(O), P’j-i’(W(0)))

, . . . , (w(h),

P’qw(h)))

)

followed by the pairs (

W(h)

+ Wj, P(j-l)

(w(h))+

p’j-“(W(k))

pj) ). ..Y (W(k)+Wjy

tpj)

.

These pairs are realized by a new tower of feasible sets S(j)(w(O))

= s(j-i)(w(O))

= 8 C S(j)(w(l))

= s(j-i)(w(l))

c S(jj(w(2))

= s(+l)(w(2))

= {j(l),j(2)}

2 S(j)(w(h))

= s(j-‘)(w(h))

= {j(l),

c Sqw(h) C S(‘)(W(k

+ Wj) = s(j-‘)(w(h)) -

1) + Wj) = S(j-l)(W(k

= {j(l)}

. . . ,j(h)} = {j(l),

u {j} -

. . . ,j(h),j}

1)) U {j}

= {j(l),... ,j(h),j,j(h+l),..',j(k - 1)) C S(j)((W(k)+Wj) = S(jel)(W(k))U{j} Ofcourse thisIsthe caseo~~~~l)..j(ii).'.j(ai l),...,j(k-l)TAk)). . . 1 P'j-"(W(k)) +pj =p(S(jel) U {j)) 5 dj. If not, the pair (w(k) either

+ wj,

P(j-“(w(k))

s(j-l)(w(k

+ pj)

is d iscarded and the last set in the new tower is

- 1)) u {j},

ifh
or S(j-‘)(w(k)),

if h = k.

In either case, it follows that the relation (3) holds at the end of iteration j. Since Properties (4) and (5) follow directly from the definition of h, we see that at the end of iteration j, the towerof-sets property holds. It is now evident that list-making and list-merging is quite unnecessary. If we know the largest set in the tower at any given iteration, then we know everything about the tower. Furthermore, it is now a small step to verify that the Moore-Hodgson recurrence relations are designed to compute the largest set S(j) at iteration j from the largest set S(j-l) at iteration j - 1. Thus, the Moore-Hodgson algorithm is, in effect, a much more streamlined version of the dynamic programming computation for the problem 1 11C wj l_Jj. As a final note, observe that the algorithm does not require that either processing times or job weights be integers. Furthermore, the maximum-weight feasible set that is computed is invariant under changes in job weights, provided the relative ordering of the weights is unchanged.

E. L. LAWLER

98

5. SIMILARLY

ORDERED

RELEASE

DATES

AND

DUE DATES

In this section, we shall assume that release dates and due dates are similarly ordered and that the jobs have been given an EDD numbering such that rl

5

‘l-2

dl 2 d2 5 . . . 5 d,.

5 ... 5 T,,

Under this condition, there is no advantage to preemption and the problems llrj ( C Uj and 1 Jpmtn, rj ) C U, are equivalent. Furthermore, the preemptive EDD rule produces schedules with no preemptions. Let C(j)(w) denote the earliest completion time of a feasible subset of jobs Jr, Jz, . . . , Jj having total weight exactly w. Generalizing the recurrences (l), we have C(O)(w) =

t-y(w)

if w =O, OY otherwise, { f=% min {N-l)(w), max {rj,

C(j-l)(w

- WJ)} +pj}

if max { rj, C(j-l) (w-Wj)}+pj

= { N-i)(w),

,
or

(6)

otherwise.

As in the case of (l), there are O(W) equations to solve at each of n iterations, and each equation requires a constant number of arithmetic operations. Hence, the values C(“)(w) can be computed in O(nW) time. The maximum weight of a feasible set is given by the largest value of w such that Ccn)(w) is finite. The dynamic programming recurrences we have described are essentially the same as those of Kise, et al. [I]. It happens that when job weights are equal, a variation of the Moore-Hodgson algorithm computes a maximum-cardinality feasible set in O(nlogn) time. Let qj 5 pj be an effective processing time that is imputed to Jj, as we shall describe later, and define

n}. Starting with S(O) = 0, we process the jobs in EDD order, constructing .I feasible sets S(J), j = 1,2, . . . , n, by the recurrence relations

foranysetSs{l,.

.

3

s(j-1) u {j},

if q (S(j-l)

gel)

otherwise,

u {j} - {l},

U {j})

<

dj - ~j,

(7)

where

The set Scn) is then a maximum-cardinality feasible set. The inductive proof argument that we shall make to justify the above recurrence relations for 1 (rj I C Uj, under the condition of similarly ordered release dates and due dates, parallels that of the previous section. Before proceeding with this argument, let us try to gain some insight from a numerical example with the following problem data: j

12345

Tj

12356

Pj --I--

37533

Assume that all due dates are very large and hence, are of no consequence. The dominant pairs existing at the end of Iteration 4 are of the form (i, Ct4)(i)), i = 0, 1, . . . ,4. These dominant pairs, plotted as dots in Figure 4, are as follows: (0, O), (1>4), (27%

(3,12),

(4,W

Knapsack-Like

Scheduling Problems

99

@.a .

Wi

1

5

4

3

2

Figure 4. With

reference

to Figure 5, we observe that these existing dominant pairs are realized by a tower

of feasible sets:

S@)(O) =0c

S@)(l)

= (1)

& S(4)(2) = {1,4} G S(4)(3) = {1,4,3} c S(4)(4) = {1,4,3,2}. Candidate pairs (i + 1, max{n,, C(4)(i)}

+ps),

i = O,l,. . . ,4, are formed from the existing list.

These are plotted as +‘s in Figure 4, and are as follows: (kg),

(2,9), (3,11), (4,15), (5,22).

The candidate pairs (1,9) and (2,9) are each dominated by the existing pair (2,8). The existing pairs (3,12) and (4,19) are, respectively, dominated by the candidate pairs (3,ll) and (4,15). Hence, when the two lists of pairs are merged, the surviving dominant pairs are (9, O), (1,4), (2,8), (3, ll),

(4715) (5722).

With reference to Figure 5, we see that these pairs are again realized by a tower of feasible sets: S(5)(0) = $4)(O)

= 0 c S@)(l) s $572)

= S@)(l)

= (1)

= S(4)(2) = {1,4}

c S(5)(3) = S(4)(2) u (5) = {1,4,5} c S(5)(4) = SC4)(3) u (5) = (1,4,5,3}

c S(5)(5) = s(4)(4) u (5) = {1,4,5,3,2}.

E. L. LAWLER

100 , I

2 I I

4

6

8

10 I

I

16 12 14 I I I I

2

18 al ; L__+_+ 4

3

5 .._.___-_..

C, (4)

Figure 5.

In general, the input to iteration j is a list of dominant pairs,

(0,c’j-“(0))) where each pair (i, C (j-l)(i))

(1, &-‘,(I))

)...)

(k, c’+“(k)))

is realized by a feasible set S(j-l)(i),

1p-l)(i)l = i,

.

c(j-l)(q

=

c

with

(SW(i))

(Recall that, by definition, c(S) is the time of completion of the last job in an EDD schedule for S.) We assert that the feasible sets form a tower:

s(qo)

= {j(l)}

= 0 c s(-)(l)

5 &s(j-i)(2) = {j(l),j(Z)}

(8) c s(j-i#) For each j(i)

E S(j-l)(k), qjci)

= {j(l),

j(2), . . . ,j(k)}.

i = 1,2,. . . , lc, define =

max {rj,

C(j-‘j(i)}

- max {rj,

C(j-i)(i

- l)} .

(9)

We assert that !?j(l) 5

qj(2)

5

“.

5

@(k),

(10)

and refer to (8) and (10) as the tower-of-sets property for this problem. It is useful to point out that (9) is equivalent to the following less compact way to determine the effective processing time:

Q(i) = (

0, CW)(i)

- rj,

C(j-l)(i)

_ C(?-l)(i

_ I),

if 0-‘(i)

5 rj,

if C(j-l)(i

- 1) < rj < @-l)(i),

if rj < C(Pl)(i

_ 1).

The second condition holds for at most one of qj(i), i = 1,. . . , lc. It is not hard to verify that in each of the three cases, qj(i) < pj(,): the additional processing of Jj(i) cannot delay the completion

Knapsack-Like

Scheduling Problems

101

of the EDD schedule by more than pj(i) time units beyond the maximum of the completion and its release date. time for Jj(r), . . . , Jj(i-l) We next show how the effective processing times are used in determining the dominating pairs

time

after iteration j of the dynamic programming algorithm. To perform iteration j, we form a list of candidate pairs (

i + 1, max

1

rj, C(j-l) (Z)}f&)’

i=0,1,...,

k.

Let h be the largest index, 1 5 h 5 k, if any, such that qj(h) <_ pj. (As in Section 4, the case in which there is no such h is omitted.) For i = 1,. . . , h, pj 2

C&(i)

=

mELX

1

c(‘-‘)

Tj,

2 &-r)(i)

(i)} -

max {

_ max

T.j, &-qi

-

1)}

(i - I)},

and so it follows that the existing pairs (1, C(j-‘j(1))

,... , (h, C+‘)(h)),

respectively, dominate the candidate pairs C (‘-l’(O)}

(1, max (9, Furthermore, when

i

mZU { Tj,

l)}.

c(j-‘)(i

-

fpj)

,. . . , (h, max {rj,

- l)}

C(j-‘)(h

+pj)

.

h, we have qj(i) > pj > 0, which implies that qj(i) = C(j-l)(i)

>

As a result, pj < Qj(i) = C(j-l)(i)

- max

1

Tj, C(j-l)(i

- l)} ,

and so the candidate pairs

respectively, dominate the existing pairs (h + 1, C(j-‘)(h

+ 1)) , . . . , (k, C’j-l’(k))

.

Hence, the merged list at the end of iteration j contains the pairs

(0,d-"(O))

,.. , (h,

d-“(h)),

followed by the pairs (

h+l,max

i

~~,C~~~1~(h)}+~~),...,(k+1,~~{~~,C~~~1~(F;)}+p~).

These pairs are realized by a new tower of feasible sets S(j)(O) = S(j-r)(O)

= 0 2 S(j)(l)

= @r)(l)

= {j(l)}

c P(2)

= S(92)

= {j(l),j(2)}

c S(j)(h)

= A+-‘)(h)

= {j(l),

L S(j)(h + 1) = S (j-‘)(h) c S’j’(k) = {j(l),

c sqlc = {j(l), MCM 20:2-H

= N-l)@ . . . ,j(h),Lj(h + 1) = s(j-l# .

U {j}

& . ‘.

. . . ,j(h)} = {j(l),

. . ,j(h),j}

- 1) u {j} + 11,. . ,j(k - 1)) u {j}

*.,j(h),j,j(h+l),...,j(k:-l),j(lc)).

C ...

-

E. L. LAWLER

102

That is, this is the case if max

{

rj, Cc’-l’(k)}

If not, the pair (k + 1, max {rj, C(j-‘j(k)} tower is either

s(3-l)(k -

+pj

5 dj.

+ pj) is discarded and the largest set in the new 1) u {j},

if h < k,

or @-l)(k),

if h = k.

This shows that Property (8) holds at the end of iteration j. Property (10) holds as well, as we indicate below. It would be inefficient to compute the qj(i) values at each iteration directly from the definition (9). Instead, we shall derive a more efficient procedure. Let j(l),j(Z), . . . ,j(k) be the elements of S(j-l)(k) ordered to indicate the inclusions (8). Suppose that h is the index computed above, so that the jobs in the tower at the end of iteration j are j(l),j(2), . . . ,j(h),j, j(h + l), . . , j( k). (Of course, j(k) might be deleted, but assume that it is not. An identical argument proves the other case.) Let j’(i), i = 1,. . . , k + 1, denote the ith element of this sequence. At the start of iteration j, each job Jk in this tower has effective processing time qk. (For Jj, let qj = pj.) We have already seen that C(j)(i)

=

C(H(i), { max{rj,C(j-‘)(i-l)}+pj,

This recurrence for C(j)(i) tion j, qjt(i)

ifi=l,...,h, ifi=h+l,...,

k+l.

can be used to show that the effective processing times used in itera-

=

max {Tj, C(j)(i)}

- max{rj,

C(‘)(i

- l)}

,

(11)

by applying the recurrence separately in each of the three cases: (a) i = 1,. . . , h; (b) i = h + 1; and (c) i = h + 2,. . . , k + 1. Therefore, to update these values for the next iteration, we need only update them to reflect the new release date rj+i. If the release date is increased by one unit, the effect is to decrease by one the effective processing time of the first job in the tower that currently has a positive effective processing time. The same idea can be used to update the release date from rj to rj+l in (ll), by repeating this rj+i - rj times; this can clearly be made efficient by making the maximum allowed reduction to qj/(i) at once, for each i = 1,. . . , k, in that order. We can now show that (10) is maintained by the algorithm. In iteration j, j is inserted into the tower between j(h) and j(h + 1) according qj’s place in the sorted order of effective processing times. Furthermore, after the update just described, the modified effective processing times are still sorted in nondecreasing order. In order to implement the algorithm, we propose to maintain two sets, 5’ and S’, where S contains jobs whose effective processing times are strictly positive and S’ contains jobs with zero effective processing times. At the end of iteration j, the maximum feasible set in the tower is then S’(j) = S U S’. We propose to implement the set S by a priority queue that supports the operations of insert, deletemin, and deletemax. For the set S’, we need only support the operation insert. At iteration j, the following subroutine is performed to modify the effective processing times. modify0 : r := 7-j - 7-j-1 ; while (r > 0 and S # 8) i := deletemin (S);

Knapsack-Like Scheduling Problems

103

Q(S) := q(S) = 4i; if

(qi I r) then inseti(S’,

i) ;

I- := r - qi; else I.&:=Qi-T: insert q(S)

(S, i) :=

Q(S)

; + 4i;

r := 0; return; We can now implement similar(

the recurrence relations

(7) as follows.

>:

s:=0; S’ := 0; q(S) := 0; for

j = 1 to call

72 modify0

;

qj :=pj; insert( S, j) ; q(S) := C?(S)+ qj; if (q(S) > dj - rj) then 1 := deletemax( return(S

q(S) := Q(S) - a; U S’) ;

At most O(n) of each of the operations insert, deletemin, and deletemax are performed in the course of the computation. Each of these operations takes O(logn) time. Hence, the overall running time of the algorithm is bounded by O(n log n).

6. NESTED

RELEASE

DATE-DUE

DATE INTERVALS

Let us begin by considering the special case of 1 Ipmtn, rj ( C wj Uj in which release dates and due dates are oppositely ordered. That is, there is an indexing of the jobs such that 7-l L

7-g

2 ... > r,,

dl 5 da 5 ... 5 d,.

Equivalently, [rl,dl] c [ra,d2] C ... c [r,, d,]. Note that if all release dates are zero, there is no advantage to preemption and this special case reduces to exactly the same special case considered in Section 4. This problem can be formulated as an integer linear programming problem: maximize C subject to

Wj

xj

~1x1 PI XI+ PI 21 +P~XZ

PI x1 +p2x2

tp3x3

+

Id1 -n,

~2 22 5 & - r2,

+p3x3

... +P,G

5 d3 - r3,

5 &

-in,

104

E. L. LAWLER

and for j = 1,2, . . . , n.

“j E {O,l),

Let P(j)(w) be defined as in Section 3. We now need simply modify the recurrence relations (1) so that the condition “if Pj-’ (w - wj) +pj 5 dj” is replaced by “if Pj-’ (m -wj) +pj 5 dj - rj .” It follows that the problem can be solved in O(nIV) time by a simple generalization of the dynamic programming procedure we used for 1 (1c wj Uj. When processing times and job weights are oppositely ordered, independently of the opposite ordering of release dates and due dates, we assert that the problem can be solved in O(n log n) time by a simple generalization of the Moore-Hodgson algorithm:

$0) = 0, $3

=

if p (S(j-l)

s(j-1) u {j}, S(j - 1) U {j}

-

{1},

U pj)

5

dj - rj,

otherwise,

where, as before, 1 = argmax = argmin

{ 1

pi 1 i E S(j-l)

u w}

Wi ( i 6 s(j-1)

u {A}.

Let us now consider a generalization of oppositely ordered release dates and due dates. We say that release date-due date intervals [rj, dj] are nested if each pair [ri, di], [rj, dj] is such that either the two intervals are disjoint (except possibly at end points) or one interval is contained within the other. The problem lJpmtn, rj 1c wj Uj with nested intervals and opposite ordering of processing times and job weights can be solved in O(nlogn) time as follows. If ties between equal [rJ, dj] intervals are broken arbitrarily, the intervals are partially ordered by the relation of containment. The transitive reduction of this partial order is represented by a forest of rooted trees, and the problem can be decomposed into rooted trees, each of which is considered separately. Our procedure works from the bottom of the rooted tree upward. For each job j we compute a maximal feasible set S(J). If j is at a leaf of the tree, then S(j) = {j}. If j has children j(i), . . f ,j(k), we compute S(j) from the sets S(j(‘)), . . , S(j(‘)), by letting S(J(l)) U . . . U S(j(lc)) play the role of S(j-l) in the recurrence (7). To implement this procedure, we need priority queues supporting the operation of merge in addition to insert and deletemax, Initially, we create a queue at each leaf of the rooted tree. When an internal node j is processed, we merge the queues of its children, insert j, and, if necessary, remove 1 with a deletemax operation. The single queue remaining after the root node is processed contains a maximum-weight feasible set of jobs. Since each queue operation requires at most O(logn) time, the overall time bound is O(nlogn).

7. ANOTHER SPECIAL THE TOWER-OF-SETS

CASE FOR WHICH PROPERTY HOLDS

We now consider the special case of llpmtn, r3 1c wj Uj in which there exists an indexing of the jobs such that ri 5 r2 <... Pl I P2 5..

5 r,, . 5 P,?

w12w2>...Lw71.

Once again, as we noted in the previous section, if all release dates are zero, then there is no advantage to preemption and this special case reduces to exactly the same special case considered in Section 4.

Knapsack-Like

Scheduling

Problems

105

We assert that the problem can be solved in O(n log n) time by computing a maximum-weight feasible set Scn) as follows. Process the jobs in EDD order. At iteration j, compute a maximumweight feasible set S’(j) using the familiar recurrences: $0) zz 0 $1

=

if c (S(j-l)

’ SG-1) u {j}, { S(j - 1) U {j}

-

U {j})

I

dj ,

otherwise,

{l},

where 1 =argmax

{

ri ) i E s(j-1)

= arg max pi ( i E S(j-l) 1 = argmin wi 1i E #-I) { The set S(j) = (j(l),

j(2), . . . , j(k)},

0 C {j(l)}

C {j(l),

+ j} +j} fj}.

induces a tower of sets

j(2)) ... C {jO),j(%.

. . , j(k))

= S(j),

where Tj(l)

I

Tj(2)

5

“’

Pj(1)

I

Pj(2)

5

. . . I Pj(k),

5

Wj(2)

Wj(l)

5

I

...

Tj(k),

I

Wj(k).

It is not hard to prove that the sets in the tower have the property that for any feasible set s c {1,2,.. . , j} there is a set S’ in the tower dominating S, according to the following definitions. For any S and t, let p(S, t) denote the amount of processing that is done after time t in an EDD schedule for S. A feasible set S’ is said to dominate a feasible set S if w(S’) 2 w(S) and p(S’, t) 5 p(S, t), for all t. In order to implement the recurrence relations (i’), we need to be able to test the set S(j-‘)U{j} for feasibility. Our task is complicated by the block structure of the EDD schedule for S(J-‘)u{j}. We propose to use a set of priority queues supporting the operations merge, insert and deletemax, as in the previous section, and in addition, a disjoint set structure supporting the operations find and link. Initially, we create a linked list of n empty priority queues, with a queue corresponding to each of the n jobs. The queues are linked in order of job release dates. We also create a singleton set for each job. The representative of each set in our disjoint set structure provides a pointer to the priority queue for jobs in that set. At each iteration j we find the priority queue for j. This priority queue is either empty or it corresponds to a block of the EDD schedule for S(j-l), namely the block processing jobs at time rj. We then insert j into the queue. If the total processing time for all jobs in the queue is such that the block overlaps the block on the right, we perform a merge with that block, and continue merging until there is no further overlap. We then check the total processing time of all jobs in the queue, and if infeasible use deletemax to remove job 1. Since there are at most O(n) of each of the set operations to be performed, each of which requires no more than O(logn) time, the total running time of the algorithm is bounded by O(nlogn). Finally, we note that by symmetry of release dates and due dates, we can also solve the special case in which dl < d2 5 ...


Pl I

L

WlI

p2

I

w2 I

...

Pn,

.*. I w,.

106

E. L. LAWLER

REFERENCES 1. E.L. Lawler, J.K. Lenstra, A.H.G. Rinnooy Kan and D.B. Shmoys, Sequencing and scheduling: Algorithms and complexity, In Handbooks in Operations Research and Management Science, Vol. 4, (Edited by S.C. Graves et al.), pp. 445-570, North-Holland, (1994). 2. E.L. Lawler, A dynamic programming algorithm for preemptive scheduling of a single machine to minimize the number of late jobs, Annals of Operations Research 26, 125-133 (1990). 3. J.M. Moore, An n job, one machine sequencing algorithm for minimizing the number of late jobs, Management Science 15, 102-109 (1968). 4. E.L. Lawler, Sequencing to minimize the weighted number of late jobs, RAIRO Rech. Oper. 10 (5 Suppl.), 27-33 (1976). 5. H. Kise, T. Ibaraki and H. Mine, A solvable csse of the one-machine scheduling problem with ready and due times, Operations Research 26, 121-126 (1978). 6. E.L. Lawler and J.M. Moore, A functional equation and its application to resource allocation and sequencing problems, Management Science 16, 77-84 (1969).