Job Sequencing with Deadlines

13.3.1 Job Sequencing with Deadlines

is given to be processed on a single machine. The machine can execute one job at a time, and when it is assigned a job, it must complete it before the next job can

A set of n jobs J =

be processed. With each job is associated (i) a processing time and

(ii) a deadline by which it must be completed.

A schedule is a permutation of the jobs in J that determines the order of their execution.

A schedule is said to be if each job finishes by its deadline. The question is: Given n jobs

and deadlines

with processing times

does a feasible schedule exist? It turns out that this question can be answered in the affirmative if and only if any schedule where the jobs are executed in nondecreasing order of deadlines is feasible. Therefore, to solve the

problem, it suffices to arrange the jobs in order of nondecreasing deadlines and test whether this yields a feasible schedule. In case it does, we know that the answer to the question is yes, otherwise the answer is no. Sequentially, this algorithm requires O(n log n) time to sort the jobs and then

time to test whether each job can be completed by its deadline. We are now ready to present our parallel algorithm for solving the sequencing problem based on the preceding idea. The algorithm runs on a tree-connected parallel computer with leaf processors

We assume for notational simplicity that in the original statement of the problem, the jobs are already arranged in order of nondecreasing deadlines; in other words,

352 Decision and Optimization Chap. 13 Initially, leaf processor

The algorithm is given as procedure TREE SEQUENCING.

contains

and

procedure TREE SEQUENCING (J, answer) Step

1: Compute

the prefix sums of t,, t , , .. .,

Step 2: (i) leaf processor

if

then send "yes" to parent else send "no" to parent

end if (ii) intermediate processor

if inputs from both children are "yes" then send "yes" to parent

else send "no" to parent

end if

root processor if inputs from both children are "yes" then answer "feasible schedule exists" else answer "no feasible schedule"

end if.

Example 13.3

3, 3, 4) and {d,,

d,,

5, 7, 9). Thus

however, and a feasible schedule does not exist for this problem.

We have

and

operations. However, the running time of the algorithm is dominated by the time taken to initially sort the jobs in the leaves in order of nondecreasing deadlines. This time is known from section 4.8 to be

Analysis.

Both steps

and 2 require

13.3.2 The Knapsack Problem

We are given a knapsack that can carry a maximum weight of Wand a set of objects

A = (a,, a , , ... ,

whose respective weights are

Associated

with each object is a profit, the set of profits being denoted by {p,,

If we place in the knapsack a fraction of the object whose weight is

where 1, then a profit of

is gained. Our purpose is to fill the knapsack with objects (or fractions thereof) such that

(i) the total weight of the selected objects does not exceed W and (ii) the total profit gained is as large as possible.

13.3 Applications 353

Formally, given 2n + 1 positive numbers

it is required to maximize the quantity

subject to the two conditions

1. 0 1 for all i and

2. X

that maximizes Q while satisfying conditions 1 and 2. Such a solution is obtained if the objects are examined in nonincreasing order of the ratios

An optimal solution is a sequence =

z,, . .. ,

If an object whose turn has come to be considered fits in the remaining portion of the knapsack, then the object is included; otherwise only a fraction of the object is placed in the knapsack. Sequentially, this

requires O(n log n) time to sort the profits and weights and then time to examine all the objects one at a time. Our parallel algorithm for finding the optimal sequence

uses this approach. It runs on a tree-connected parallel computer with leaf processors

z,, ... ,

. . , . We assume for notational simplicity that in the original statement of the problem, the objects are already sorted in order of nonincreasing profit to weight ratios, in other words,

Initially, leaf processor

The algorithm is given in what follows as procedure TREE KNAPSACK. When the procedure terminates, the solution

contains

and

resides in the leaves. Let

2W

procedure TREE KNAPSACK (A,

Step

1: (1.1) Compute

the prefix sums of

w,, . .. ,

(1.2) for i = 1 to n - 1 do in parallel

computes

end for.

Step

2: for i = to n - 1 do in parallel

if

then

else if

W and

(W -

else end if

end if end for.

Decision and Optimization Chap. 13 Note that the total profit Q may be computed at the root as follows: (i) Each leaf processor computes

profit,

and sends profit, to its parent. (ii) Each intermediate processor adds the two inputs received from its children and

sends the result to its parent. (iii) The root adds the two inputs received from its children; this is Q.

Example 13.4 Let n = 4 with {w,,

and 15. Thus

W and hence = 0. Analysis. Steps 1 and

Wand therefore = (15 -

= 0.5. Finally,

steps, respectively. However, the running time of the algorithm is dominated by the time taken to initially sort the profits and weights in the leaves in order of their

2 require

and

ratios. This time is known from section

4.8 to be