• No results found

Imprecise Computation Model:

Total Weighted Error

and Maximum

Weighted Error

Joseph Y-T. Leung New Jersey Institute of Technology

7.1 Introduction ... 7-1 7.2 Total Weighted Error ... 7-3

Single Processor • Parallel and Identical Processors • Uniform Processors

7.3 Maximum Weighted Error ... 7-9 7.4 Concluding Remarks ... 7-13

7.1 Introduction

Meeting deadline constraints is of paramount importance in real-time systems. Sometimes, it is not possible to schedule all the tasks to meet their deadlines, a situation that occurs quite often when the system is overloaded. In situations like this, it is often more desirable to complete some portions of every task rather than giving up completely the processing of some tasks. The Imprecise Computation Model was introduced [1–3] to allow for the trade-off of the quality of computations in favor of meeting the deadline constraints. In this model, a task is logically decomposed into two subtasks, mandatory and optional. The mandatory subtask of each task is required to be completed by its deadline, while the optional subtask can be left unfinished. If a task has an unfinished optional subtask, it incurs an error equal to the execution time of its unfinished portion. The Imprecise Computation Model is designed to model an iterative algorithm, where the task initially spends some time for initialization (the mandatory subtask) and then iterates to improve the quality of the solution (the optional subtask). Since the optional subtask corresponds to iterations to improve the quality of the solution, it can be left unfinished and still obtain a solution with a somewhat inferior quality. In this way, we can trade off the quality of the computation in favor of meeting the deadline constraints.

In the Imprecise Computation Model, each task Tiis represented by the quadruple Ti= (ri, ¯di, mi, oi), where ri, ¯di, mi, and oidenote its release time, deadline, mandatory subtask’s execution time, and optional subtask’s execution time, respectively. Let ei= mi+ oidenote its total execution time. A schedule for a given task system is said to be feasible if each mandatory subtask is executed fully in the time interval between its release time and deadline; a task system is said to be feasible if there is a feasible schedule for it. Feasibility of a task system can be determined in at most O(n2log2n) time for parallel and identical

processors [4], and O(n log n) time for a single processor [5]. In this chapter, we assume that all task systems are feasible and all task parameters are rational numbers. Furthermore, we will be concerned with preemptive scheduling only.

Let S be a feasible schedule for a task system TS with n tasks. For each task Ti, let α(Ti, S) denote the amount of time Tiis executed in S. The error of Ti, denoted by (Ti, S), is defined to be ei− α(Ti, S). The total error of S, denoted by (S), is defined to beni=1(Ti, S). The maximum error of S, denoted by ϒ(S), is defined to be maxn

i=1{(Ti, S)}. The minimum of total error of TS, denoted by (TS), is defined to be min{(S) : S is a feasible schedule for TS}. The minimum of maximum error of TS, denoted by ϒ(TS), is defined to be min{ϒ(S) : S is a feasible schedule for TS}. If the importance of the tasks are not identical, we can assign two weights wiand wito each task Ti, and the resulting task system is called a weighted task system. For a weighted task system, the goal is to minimize the total w-weighted error or the maximum w-weighted error. We use w(TS) to denote the minimum of the total w-weighted error of TS, and ϒw(TS) to denote the minimum of the maximum w-weighted error of TS. Note that the w-weight is applied only to the total weighted error, whereas the w-weight is applied only to the maximum weighted error.

In this chapter, we will give algorithms for finding a schedule that minimizes the total w-weighted error as well as the maximum w-weighted error. Our study encompasses a single processor, parallel and identical processors, as well as uniform processors. In the next chapter, we will give algorithms for bicriteria scheduling problems and other related problems. For bicriteria scheduling problems, the goal is to minimize the total w-weighted error, subject to the constraint that the maximum w-weighted error is minimum, or to minimize the maximum w-weighted error, subject to the constraint that the total w-weighted error is minimum.

Blazewicz [6] was the first to study the problem of minimizing the total w-weighted error for a special case of the weighted task system, where each task has its optional subtask only; i.e., mi= 0 for each 1≤ i ≤ n. He showed that both parallel and identical processor, and uniform processor systems can be reduced to minimum-cost–maximum-flow problems, which can be transformed into linear programming problems. Blazewicz and Finke [7] later gave faster algorithms for both problems; see also Leung [8]. Potts and Van Wassenhove [9] studied the same problem on a single processor, assuming that all tasks have identical release times and identical weights. They gave an O(n log n)-time algorithm for preemptive scheduling and showed that the problem becomes NP-hard for nonpreemptive scheduling. They [10] later gave a polynomial approximation scheme and two fully polynomial approximation schemes for the nonpreemptive case.

For imprecise computation tasks, Shih et al. [4] gave an O(n2log2n)-time algorithm to minimize the total error on a parallel and identical processor system. Shih et al. [11] and Leung et al. [12] later gave faster algorithms on a single processor that runs in O(n log n) time. For the weighted case, Shih et al. [4] again showed that the problem can be transformed into a minimum-cost–maximum-flow problem, thus giving an O(n2log3n)-time algorithm for parallel and identical processors. For a single processor, Shih et al. [11] gave a faster algorithm that runs in O(n2logn) time, which was subsequently improved by Leung et al. [12] to O(n log n+ kn) time, where k is the number of distinct w-weights. The minimum- cost–maximum-flow approach can be extended to solve the uniform processors case by using the idea of Federgruen and Groenevelt [13] to handle the different speeds of the processors. Using Orlin’s [14] minimum-cost–maximum-flow algorithm, the total weighted error problem on uniform processors can be solved in O(m2n4log mn) time.

Ho et al. [15] gave an algorithm to minimize the maximum w-weighted error. Their algorithm runs in O(n3log2n) time for parallel and identical processors, and O(n2) time for a single processor. Recently, Wan et al. [16] extended the ideas of Ho et al. to solve the uniform processors case giving an algorithm that runs in O(mn4) time.

This chapter is organized as follows. In the next section, we will consider the total w-weighted error— Section 7.2.1 considers the single processor case, Section 7.2.2 considers the parallel and identical processor case, and Section 7.2.3 considers the uniform processor case. In Section 7.3, we will consider the maximum w-weighted error for the cases of a single processor, parallel and identical processors, and uniform processors. Finally, we draw some concluding remarks in the last section.

7.2 Total Weighted Error

In this section, we will give algorithms to minimize the total weighted error. The case of a single processor, parallel and identical processors, and uniform processors will be given in the next three subsections.

7.2.1 Single Processor

In this subsection, we will give an O(n log n+ kn)-time algorithm for the total weighted error problem (see Leung et al. [12]). Each imprecise computation task j is represented by two subtasks: mandatory (Mj) and optional (Oj). Both subtasks have ready time rjand deadline ¯dj. The optional subtask has execution time oiand weight wi, and the mandatory subtask has execution time miand weight max{wi} + 1. We assign the highest weight to each mandatory subtask to ensure that each of them will be executed to completion (i.e., no unfinished mandatory subtask). In this way, we can reduce the problem to that of minimizing the total weighted number of tardy units. Note that this technique is only applicable to a single processor but not applicable to parallel and identical processors or uniform processors. This is because for parallel and identical processors or uniform processors, the schedule might assign the mandatory and optional subtasks of an imprecise computation task to the same time interval on two different processors, which is not allowed in any feasible schedules.

We first describe an algorithm for minimizing the total (unweighted) number of tardy task units; the algorithm will later be extended to solve the weighted case. The algorithm only schedules the nontardy units of a task, assuming that the tardy units are either not scheduled or scheduled at the end. Let the tasks be ordered in descending order of release times. If several tasks have identical release times, they are ordered in descending order of their deadlines. Further ties can be broken arbitrar- ily. Let 0= min{ri} = u0<u1<· · · < up= max{¯di} be the p + 1 distinct integers obtained from the multiset {r1, . . . , rn, ¯d1, . . . , ¯dn}. These p + 1 integers divide the time frame into p segments: [u0, u1], [u1, u2], . . . , [up−1, up]. The algorithm uses an n× p matrix S to represent a schedule, where S(i, j) con- tains the number of time units task i is scheduled in segment j (i.e., [uj−1, uj]). Below is a formal description of the algorithm.

Algorithm NTU

(1) For i= 1, . . . , p do: li← ui− ui−1. (2) For i= 1, . . . , n do:

Find a satisfying ua= ¯diand b satisfying ub= ri. For j= a, a − 1, . . . , b + 1 do:

δ← min{lj, ei}.

S(i, j)← δ, lj← lj− δ, ei← ei− δ. repeat

repeat

The algorithm schedules tasks in descending order of their release times. When a task is scheduled, it is assigned from the latest segment [ua−1, ua] in which it can be scheduled until the earliest segment [ub, ub+1]. Let us examine the time complexity of the algorithm. The time it takes to sort the tasks in descending order of their release times as well as obtaining the set{u0, u1, . . . , up} is O(n log n). Step 1 of the algorithm takes linear time and a straightforward implementation of Step 2 takes O(n2) time. Thus, it appears that the running time of the algorithm is O(n2). However, observe that whenever a segment is scheduled, either all the units of a task are scheduled or the segment is saturated, or both. Hence, at most O(n) segments have positive values. Thus, if we can avoid scanning those segments that have zero values, then Step 2 takes only linear time. As it turns out, this can be done by the special UNION-FIND algorithm owing to Gabow and Tarjan [17].

Ti T1 T2 T3 T4 T4 T4 T4 T4 T8 T3 T3 T3 T7 T7 T7 T2 T2 T2 T1 T1 T1 T1 T5 T5 T5 T1 T1 T1 T8 T8 T8 ri di ei wi T1 T2 T3 T4 T5 T6 T7 T8 T9 6 5 5 5 5 5 2 2 2 2 2 3 3 3 3 3 4 1 6 15 8 6 7 14 5 10 17 5 4 2 0 10 4 3 0 0 0 (a) (b) (c) (d) 1 0 0 0 1 1 2 12 12 3 3 3 4 7 11 4 4 4 5 5 5 8 8 8 10 10 15 14 14 14 15 15 15 17 17 17

FIGURE 7.1 An example illustrating algorithm WNTU: (a) schedule S obtained after the first phase; (b) schedule S2

obtained in the second phase; (c) schedule S2obtained in the second phase; and (d) final schedule obtained by Algorithm WNTU.

A schedule produced by Algorithm NTU will be denoted as NTU-schedule. Define a block as a maximal time interval in which there is only one task assigned (task block) or the processor is idle (idle block). Without any increase in time complexity, the algorithm can be modified to produce a schedule represented by a doubly linked list of blocks. As shown in Leung et al. [12], the number of blocks in an NTU-schedule is no more than 2n+ 1.

We can use Algorithm NTU to solve the weighted case as follows. Sort the tasks in decreasing order of their weights. Let πi, 1≤ i ≤ n, denote the number of nontardy units of task i in an optimal schedule. Once the values of πiare known, an optimal schedule can be obtained in O(n log n) time by the Earliest Due Date rule. We determine these values in phases as follows. After j phases, it would have already determined the values π1, π2, . . . , πj. In the ( j+ 1)th phase, it uses Algorithm NTU to solve the unweighted problem for tasks 1, 2, . . . , j+ 1, where the execution times of the first j tasks are π1, . . . , πj, and the execution time of the ( j+ 1)th task is ej+1. Let x be the number of tardy units obtained in the NTU-schedule. πj+1is then set to be ej+1− x, and the algorithm proceeds to the next phase. Note that we can assign x tardy units to task j+ 1 since the first j tasks can be scheduled on time in previous iterations.

The above algorithm makes n calls to Algorithm NTU. Since Algorithm NTU takes linear time after the initial sorting, the running time of the algorithm becomes O(n2). The drawback of the above approach

is that tasks are scheduled one by one, which slows down the algorithm. To speed up the algorithm, we need to schedule several tasks simultaneously, say all tasks with identical weights. However, if we schedule several tasks together, then it is not clear how to assign tardy units to the tasks. The trick here is to find a way to allocate tardy units to the new tasks so that the previously scheduled tasks remain intact.

Let there be k different weights, w1>w2>· · · > wk, and let Tj, 1≤ j ≤ k, be the set of all tasks with weight wj. We use T to store the tasks (and their execution times) whose nontardy units have already been determined; initially, T is an empty set. Let S be an empty schedule. The tasks are scheduled in phases. At the end of the jth phase, the algorithm would have already determined the nontardy units of the tasks in T1, . . . , Tj. These tasks and their execution times are stored in T. In the ( j+ 1)th phase, the algorithm uses Algorithm NTU to construct a schedule Sj+1for T∪ Tj+1. It then goes through an adjustment step (described below) transforming Sj+1into Sj+1with S as a template. The adjustment step is needed to allocate nontardy units to the new tasks (i.e., tasks in Tj+1) in such a way that the previously scheduled tasks (i.e., tasks in T) remain intact. We now set T to be T∪ Tj+1and the execution times of the tasks in T are set to the nontardy units in Sj+1. Finally, we apply Algorithm NTU to T to obtain the schedule S before we go to the next phase. We repeat this process until the kth phase is finished.

The adjustment step proceeds as follows. Let there be q blocks in S: Vi= [vi−1, vi], 1≤ i ≤ q. Sj+1is transformed block by block from V1to Vq. Transformation is applied only to the task blocks in S but not to the idle blocks. Let Vibe a task block in S and let task l be scheduled in the block. Let N (l) (resp. Nj+1(l)) denote the number of time units task l has executed in S (resp. Sj+1) from the beginning until time vi. If N (l) > Nj+1(l), then assign (N (l)− Nj+1(l)) more time units to task l within Viin Sj+1, by removing any task, except task l that was originally assigned in Vi. (Note that this reassignment can always be done.) Otherwise, no adjustment is needed.

Figure 7.1 gives a set of tasks with two distinct weights. The schedule S after the first phase is shown in Figure 7.1a. S2and S2are shown in Figures 7.1b and 7.1c, respectively. Finally, the schedule S after the second phase is shown in Figure 7.1d, which is an optimal schedule for the set of tasks.

Algorithm WNTU

(1) Let there be k distinct weights, w1>· · · > wk, and let Tjbe the set of tasks with weight wj. (2) Let S be an empty schedule and T be an empty set.

(3) For j= 1, . . . , k do:

Sj← schedule obtained by Algorithm NTU for T ∪ Tj. Begin (Adjustment Step)

Let there be q blocks in S: Vi= [vi−1, vi], 1≤ i ≤ q. For i= 1, . . . , q do: