Post on 31-Dec-2015
description
Ecole Polytechnique, Nov 7, 20071
Minimizing Total Completion Time
Each job specified by procesing time (length pj)
release time rj
Goal: compute a schedule (preemptive or not) that maximizes the total completion time
all integer
Cj = completion time of j in a given schedule
In Graham’s notation: Non preemptive version: 1|rj,pj|∑Cj
Preemptive version: 1|rj,pj,pmtn|∑Cj
Ecole Polytechnique, Nov 7, 20072
Preemptive Scheduling
Example: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
12
3
4
56
Schedule A
∑Cj = 4+7+8+9+11+12 = 51
Schedule B
∑Cj = 1+2+3+5+6+9+12 = 38
Ecole Polytechnique, Nov 7, 20073
Online version:
• jobs are revealed at their release time• algorithm must execute a job without
knowing future jobs• Note: different from list scheduling! (Decision time = processing time)
Algorithm SRPT: At each step schedule the job with the shortest remaining processing time
Theorem: Algorithm SRPT computes an optimal solution (that is, SRPT is 1-competitive)
Example: Schedule B on previous slide is SRPT
Ecole Polytechnique, Nov 7, 20074
Proof: Exchange agument. Convert any schedule S into one satisfying the SRPT rule.
Take any jobs i and j in S. W.l.o.g. assume ri ≤ rj. Let T = set of time slots occupied by i and j starting at rj
i ji j j j ji i i i i i j j
rjriat rj: b units of jand a≤b units of i
unit a+b in T
i ji jj j ji iiiii j j
rjri
Reschedule i and j within T using SRPT:
unit ≥ a in T
unit a+b in T
unit a in T
So ∑Cj cannot increase !!!
Ecole Polytechnique, Nov 7, 20075
So we know: that one SPRT-reschedule does not increase ∑Cj
let k = minimum length job with rk = 0
• SRPT will schedule one unit of k at time 0
start with any schedule Qrepeat: apply SRPT-reschedule to all pairs i,juntil Q does not change
phase
• after phase 1, one unit of k will be scheduled at time 0 in Q and will remain there
• So Q and SRPT are the same at time unit 0 after phase 1
• We can modify the instance:• change pk = pk-1• change all release times rj=0 to rj=1
and apply the argument recursively to the new instance
Thus we convert Q into SRPT without increasing ∑Cj
So ∑Cj(SRPT) ≤ ∑Cj(Q)
Ecole Polytechnique, Nov 7, 20076
Non-Preemptive Scheduling
Example: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
12
3
4
56
Schedule A
∑Cj = 4+7+8+9+11+12 = 51
Schedule C
∑Cj = 2+3+5+6+10+13 = 39
Schedule B
∑Cj = 4+5+6+7+9+11 = 42
Ecole Polytechnique, Nov 7, 20077
Algorithm SPT: at each step, when no job is running, execute the job with shortest processing timeQuestion: Is SPT’s schedule optimal?
Intuition: If a big job is pending, an optimal schedule sometimes needs to wait to execute more small jobs that are about to arrive
Question: Is SPT competitive?
No: Schedule B on previous slide is SPT
Ecole Polytechnique, Nov 7, 20078
Question: Is SPT competitive?
r1=0 p1=p
n jobs with ri=1 and pi=1
∑Cj ≥ np
∑Cj ≤ n(n+1) + (n+1+p) ≤ 2n(n+1)+p
SPT:
0
Q:
1
So for p = 2n(n+1)
ratio SPT/Q ≥ n·2n(n+1) / 4n(n+1) = n/2
Ecole Polytechnique, Nov 7, 20079
Theorem: No online algorithm has competitive ratio < 2
r1=0 p1=p
∑Cj(A) ≥ n(2p-1) = 2pn+(n)
So for p = n2
ratio A/Q ≥ 2 - O(1/n) 2
Proof: A = online algorithm. At time 0 release job 1:
If A schedules 1 at time t ≥ p-2 then ratio ≥ (2p-2)/p = 2-2/p 2
Else, release n jobs at time p-1 of length 1
Consider Q:∑Cj(Q) ≤ n(p-1+n)+(2p+n) = pn+(n+p)
In A:
Ecole Polytechnique, Nov 7, 200710
Intuition: To be competitive, an algorithm needs to wait even if jobs are available
Algorithm SSPT:• When job j arrives, reset its release time to r’j = rj+pj
• Apply SPT with respect to these new release timesTheorem: SSPT is 2-competitive.
Proof idea: I = input instance. Define an SSPT-induced instance I” such that:
• optimum(I”) ≤ 2 · optimum(I)• SSPT’s schedule for I = SRPT schedule for I”
So ∑Cj(SPT on I) = ∑Cj(SRPT on I”)
= optimum(I”) ≤ 2 · optimum(I)
Ecole Polytechnique, Nov 7, 200711
Claim 1: optimum(I”) ≤ 2 · optimum(I)
Proof: Q = optimal schedule for I.Consider schedule Z for I” where Sj(Z) = 2Sj(Q)+pj
Then• Z is feasible for I” because jobs in Z do not overlap and
Sj(Z) = 2Sj(Q)+pj
≥ 2rj + pj ≥ r”j
• ∑Cj(Z) = 2∑Cj(Q) because
Cj(Z) = Sj(Z)+pj
= 2 Sj(Q)+pj+pj
= 2[Sj(Q)+pj] = 2Cj(Q)
Let T = schedule of SSPT on IDefine I” by changing release times to r”j = min { Sj(T) ,
2rj+pj }
Ecole Polytechnique, Nov 7, 200712
Claim 2: T is also an SRPT schedule for I”
Proof: Suppose T executes k and h is pending
Recall: T = schedule of SSPT on I I” obtained by changing rj to r”j = min{Sj(T),2rj+pj}
We need (SRPT of k) ≤ ph at any time t ≥ r”h.
It’s enough to show it for t=Sh(T) or t= 2rh+ph (since T runs k)
• T runs h after k so Sh(T) ≥ Ck(T) we are OK for t = Sh(T)
• At t=2rh+ph we need ph ≥ Ck(T)-(2rh+ph)
This is equivalent to 2(rh+ph) ≥ Sk(T)+pk
Case 1: h pending at Sk(T).
Since T chose k, we have ph ≥ pk and k only gets
shorter so T obeys the SRPT rule for k and h
h
k
Case 2: h was released after Sk(T). h
r’h = rh+ph
k h
h
r’h = rh+ph
k h
2rh+ph
True, because 2(rh+ph) ≥ 2Sk(T)
≥ Sk(T)+r’k ≥ Sk(T)+pk