• No results found

ZZZ: Scheduling Jobs to Minimize Average Waiting Time

N/A
N/A
Protected

Academic year: 2021

Share "ZZZ: Scheduling Jobs to Minimize Average Waiting Time"

Copied!
19
0
0

Loading.... (view fulltext now)

Full text

(1)

Algorithms & Models of Computation

CS/ECE 374, Fall 2020

19.3

Scheduling Jobs to Minimize Average

Waiting Time

(2)

The Problem

n jobs J1, J2, . . . , Jn.

EachJi has non-negative processing timepi

One server/machine/person available to process jobs. Schedule/order jobs to min. total or average waiting time

Waiting time ofJi in schedule σ: sum of processing times of all jobs scheduled

beforeJi

J1 J2 J3 J4 J5 J6

time 3 4 1 8 2 6

Example: schedule isJ1, J2, J3, J4, J5, J6. Total waiting time is

0 + 3 + (3 + 4) + (3 + 4 + 1) + (3 + 4 + 1 + 8) + . . . =

(3)

The Problem

n jobs J1, J2, . . . , Jn.

EachJi has non-negative processing timepi

One server/machine/person available to process jobs. Schedule/order jobs to min. total or average waiting time

Waiting time ofJi in schedule σ: sum of processing times of all jobs scheduled

beforeJi

J1 J2 J3 J4 J5 J6

time 3 4 1 8 2 6

Example: schedule isJ1, J2, J3, J4, J5, J6. Total waiting time is

0 + 3 + (3 + 4) + (3 + 4 + 1) + (3 + 4 + 1 + 8) + . . . =

(4)

The Problem

n jobs J1, J2, . . . , Jn.

EachJi has non-negative processing timepi

One server/machine/person available to process jobs. Schedule/order jobs to min. total or average waiting time

Waiting time ofJi in schedule σ: sum of processing times of all jobs scheduled

beforeJi

J1 J2 J3 J4 J5 J6

time 3 4 1 8 2 6

Example: schedule isJ1, J2, J3, J4, J5, J6. Total waiting time is

0 + 3 + (3 + 4) + (3 + 4 + 1) + (3 + 4 + 1 + 8) + . . . =

(5)

The Problem

n jobs J1, J2, . . . , Jn.

EachJi has non-negative processing timepi

One server/machine/person available to process jobs. Schedule/order jobs to min. total or average waiting time

Waiting time ofJi in schedule σ: sum of processing times of all jobs scheduled

beforeJi

J1 J2 J3 J4 J5 J6

time 3 4 1 8 2 6

Example: schedule isJ1, J2, J3, J4, J5, J6. Total waiting time is

0 + 3 + (3 + 4) + (3 + 4 + 1) + (3 + 4 + 1 + 8) + . . . =

(6)

Optimality of Shortest Job First (SJF)

Theorem 19.1.

Shortest Job First gives an optimum schedule for the problem of minimizing total waiting time.

Proof strategy: exchange argument

(7)

Optimality of Shortest Job First (SJF)

Theorem 19.1.

Shortest Job First gives an optimum schedule for the problem of minimizing total waiting time.

Proof strategy: exchange argument

(8)

Optimality of Shortest Job First (SJF)

Theorem 19.1.

Shortest Job First gives an optimum schedule for the problem of minimizing total waiting time.

Proof strategy: exchange argument

Assume without loss of generality that job sorted in increasing order of processing time

(9)
(10)
(11)
(12)
(13)
(14)

Inversions

Definition 19.2.

A scheduleJi1, Ji2, . . . , Jin has an inversionif there are jobs Ja and Jb such that S

schedulesJa before Jb, but pa > pb.

Claim 19.3.

If a schedule has an inversion then there is an inversion between two adjacent scheduled jobs.

(15)

Inversions

Definition 19.2.

A scheduleJi1, Ji2, . . . , Jin has an inversionif there are jobs Ja and Jb such that S

schedulesJa before Jb, but pa > pb.

Claim 19.3.

If a schedule has an inversion then there is an inversion between two adjacent scheduled jobs.

(16)

Proof of optimality of SJF

SJF= Shortest Job First

RecallSJF order isJ1, J2, . . . , Jn.

LetJi1, Ji2, . . . , Jin be an optimum schedule with fewest inversions.

If schedule has no inversions then it is identical toSJF schedule and we are done.

Otherwise there is an 1 ≤ ` < n such that i` > i`+1 since schedule has inversion

among two adjacent scheduled jobs

Claim 19.4.

The schedule obtained from Ji1, Ji2, . . . , Jin byexchanging/swapping positions of jobs

Ji` and Ji`+1 is also optimal and has one fewer inversion.

Assuming claim we obtain a contradiction and hence optimum schedule with fewest

(17)

Proof of optimality of SJF

SJF= Shortest Job First

RecallSJF order isJ1, J2, . . . , Jn.

LetJi1, Ji2, . . . , Jin be an optimum schedule with fewest inversions.

If schedule has no inversions then it is identical toSJF schedule and we are done.

Otherwise there is an 1 ≤ ` < n such that i` > i`+1 since schedule has inversion

among two adjacent scheduled jobs

Claim 19.4.

The schedule obtained from Ji1, Ji2, . . . , Jin byexchanging/swapping positions of jobs

Ji` and Ji`+1 is also optimal and has one fewer inversion.

Assuming claim we obtain a contradiction and hence optimum schedule with fewest

(18)

Exercise: A Weighted Version

n jobs J1, J2, . . . , Jn. Ji has non-negative processing timepi and a non-negative

weightwi

One server/machine/person available to process jobs.

Schedule/order the jobs to minimize total or average waiting time

Waiting time ofJi in schedule σ: sum of processing times of all jobs scheduled

beforeJi

Goal: minimize total weighted waiting time.

Formally, compute a permutation π that minimizes Pn

(19)

THE END

...

References

Related documents

The graphical method normally used is the isobologram, where is possible to compare the predicted isobole to a concentration combination that cause a predefined effect

profits of competitors: neither for the insider firms, whose joint profits even the sum of insiders’ pre- merger profits, since * * ; nor for the outsider whose

The posture adjustment motion and insertion motion under the transitional mode and the master – slave motion under the trocar mode are shown through evaluations of the master –

Workshop 3 „ Code: MGT2LG033 „ Extent: 2 ECTS „ Timing: 2nd semester „ Language: English „ Level: core studies „ Type: compulsory.

Kennametal manufactures many mixing chambers from ROCTEC ® composite carbide and special tungsten carbide grades, thereby minimizing wear to the mixing chamber area and

Cal recordar que en utilitzar la propietat simètrica en una taula de co-ocurrència de k dimensions, és necessari establir un ordre a les diferents combinacions de

Consult with your integral recovery team as you work on this paper and present the results to your group for comment and discussion. With the approval of your integral recovery

Epidemiological studies illustrating the role of Polyphenols in the Prevention of Alzheimer’s disease.  Several epidemiological studies have also been carried