Minimizing Average Flow- Time Naveen Garg IIT Delhi Joint work with Amit Kumar, Jivi Chadha ,V Muralidha
Mar 29, 2015
Minimizing Average Flow-Time
Naveen Garg
IIT Delhi
Joint work with Amit Kumar, Jivi Chadha ,V Muralidhara, S. Anand
Problem Definition Given : A set of M machines
A set of jobs
A matrix of processing times of
job i on machine j.
Each job specifies a release date
pij
r j
r j
Problem Definition Conditions :
r j
r j Pre-emption allowed
Migration not allowed
Problem Definition
r j C j
Flow-time of j,
Goal : Find a schedule which minimizes the average flow-time
F j=C j− r j
Special Cases
Parallel : all machines identical
Related : machines have different speeds
Subset Parallel : parallel except that a job can only go on a subset of machines
Subset Related
pij=p j
pij=p j /s i
pij p j
All of these are NP-hard.
Previous work
• The problem is well studied when the machines are identical.
• For a single machine the Shortest-remaining-processing-time (SRPT) rule is optimum.
• [Leonardi-Raz 97] argued that for parallel machines SRPT is O(min (log n/m, log P)) competitive, where P is max/min processing time. They also show a lower bound of (log P) on competitive ratio
Preemptive, unweighted Flow time
Online OfflineParallel machines
O(log P), (log P) [LR97]
(log1-ε P) [GK07]
Related machines
O(log P) [GK06]
Subset parallel
Unbounded [GK07]
O(log P) (log P/loglogP) [GK07]
Unrelated machines
O(k) [S09]
Fractional flow-time
O(1=²O(1))
pj(t) = remaining processing of job j at time t remaining fraction at time t =
ab
time processing total
(t)pj
Fractional flow-time of j = t≥rj pj(t)/pj
Recall, flow-time of j =
j
j
C
rt
1
Fractional flow-time
O(1=²O(1))
1 5 12
Fractional flow-time = 1*2 + 2/3*3 + 1/3*7
Fractional flow-time can be much smaller than (integral) flow-time
O(1=²O(1))
20
Integer Program
Define 0-1 variables :
x(i,j,t) : 1 iff job j processed on i during [t,t+1] Write constraints and objective in terms of these variables.
Fractional flow-time of j = t ≥ rj (t-rj) x(i,j,t)/pij
LP Relaxation
0t)j,x(i,
ti,allfor1t)j,x(i,
jallfor1p
t)j,x(i,
)r(tp
t)j,x(i,Min
j
ti, ij
jtj,i, ij
One Caveat …
Fractional flow-time
A job can be done simultaneously on many machines : flow-time is almost 0
LP Relaxation
0t)j,x(i,
ti,allfor1t)j,x(i,
jallfor1p
t)j,x(i,
t)j,x(i,)r(tp
t)j,x(i,Min
j
ti, ij
tj,i,j
tj,i, ij
Add a term for processing time
Class of a job
p j : The processing time of j rounded up to nearest power of 2
p j 2 kIf , we say k is the class of job j
Number of different classes = O(log P)
Modified Linear Program
0t)j,x(i,
ti,allfor1t)j,x(i,
jallfor1p
t)j,x(i,
t)j,x(i,)r(tp
t)j,x(i,Min
j
ti, ij
tj,i,j
tj,i, ij
Modified LP
LP value changes by a constant factor only.
But : rearranging jobs of the same class does not change objective value.
From fractional to integral
• The solution to the LP is not feasible for our (integral) problem since it schedules the same job on multiple m/c’s.
• We now show how to get a feasible, non-migratory schedule.
Rounding the LP solution
• Consider jobs of one class, say blue.
• Find the optimum solution to the LP.
Rounding the LP solution (contd.)
• Rearrange blue jobs in the space occupied by the blue jobs so that each job is scheduled on only one m/c.
• If additional space is needed it is created at the end of the schedule
Additional space
Preemptive, unweighted Flow time
Online OfflineParallel machines
O(log P), (log P) (log1-ε P)
Related machines
O(log P)
Subset parallel Unbounded O(log P)(log P/loglogP)
Unrelated machines
O(k)
Assignment as flowFix a class k : arrange the jobs in ascending order of release dates.
r10
iv(i,k,j)
z i , jtx i , j , t
p j
s
Flow = ?
r7r6r5r4r3r2
Unsplittable Flow Problem
s
d1 d2
d3
Unsplittable Flow Problem
s
d1 d2
d3
Flow can be converted to an unsplittable flow such that excess flow on any edge is at most the max demand [Dinitz,Garg, Goemans]
Back to scheduling...Fix a class k : find unsplittable flow
10 2 3 4 5 6 7
iv(i,j,k) p j
s
Gives assignment of jobs to machines
Back to scheduling...J(i,k) : jobs assigned to machine i
10 2 3 4 5 6 7
iv(i,j,k) p j
s
Can we complete J(i,k) on class k slots in I ?
Building the Schedule
Flow increases by at most max processing time = 2k
So all but at most 2 jobs in J(i,k) can be packed into these slotsExtra slots are created at the end to accommodate this spillover
Increase in Flow-timeHow well does
capture the flow-time of j ?
Charge to the processing time of other classes
1
ij
j
ti, p
)r(tt)j,x(i,
Finally...Since there are only log P classes…
Can get OPT + O(log P).processing time flow-time for subset parallel case.
Preemptive, unweighted Flow time
Online OfflineParallel machines
O(log P), (log P) (log1-ε P)
Related machines
O(log P)
Subset parallel Unbounded O(log P)(log P/loglogP)
Unrelated machines
O(k)
Integrality Gap for our LP(identical m/c)
0 mk-1 2mk-1 mk +mk-1
mk
mk-1
m
T
1
Phase 0 1 k-1 k
Integrality Gap for our LP(identical m/c)
• For sufficiently large T, flow time ≥ mT(1+k/2)
0 mk-1 2mk-1 mk +mk-1
T
Phase 0 1 k-1 k
Blue jobs can be scheduled only in this area of volume (mk+mk-1)m/2
At least m/2 blue jobs left At least mk/2 jobs left
Integrality Gap for our LP(identical m/c)
• Optimum fractional solution is roughly mT
0 mk-1 2mk-1 mk +mk-1
mk
mk-1
m
T
1
Phase 0 1 k-1 k
Integrality gap• Optimum flow time is at least mT(1+k/2)• Optimum LP solution has value roughly mT• So integrality gap is (k).• Largest job has size P = mk.• For k = mc, c>1, we get an integrality gap of (log P/loglogP)
Hardness results• We use the reduction from 3-dimensional
matching to makespan minimization on unrelated machines [lenstra,shmoys,tardos] to create a hard instance for subset-parallel.
• Each phase of the integrality gap example would have an instance created by the above reduction.
• To create a hard instance for parallel machines we do a reduction from 3-partition.
Preemptive, unweighted Flow time
Online OfflineParallel machines
O(log P), (log P) (log1-ε P)
Related machines
O(log P)
Subset parallel Unbounded O(log P)(log P/loglogP)
Unrelated machines
O(k)
A bad example
0 T
B x
A x
A+B=TA> T/2
T+L
A x
Flow time is at least AxL > T L/2OPT flow time is O(T2+L) Ω(T) lower bound on any online algorithm
Other Models
• What if we allow the algorithm extra resources ?
• In particular, suppose the algorithm can process (1+ε) units in 1 time-unit. [first proposed by Kalyanasundaram,Pruhs95]
Resource Augmentation Model
Resource Augmentation
• For a single machine, many natural scheduling algorithms are O(1/eO(1))-competitive with respect to any Lp norm [Bansal Pruhs ‘03]
• Parallel machines : randomly assign each job to a machine – O(1/eO(1)) competitive
[Chekuri, Goel, Khanna, Kumar ’04]
• Unrelated Machines : O(1/e2)-competitive, even for weighted case. [Chadha, Garg, Kumar, Muralidhara ‘09]
O(1=²O(1))
Our Algorithm
When a job arrives, we dispatch it to one of the machines.
Each machine just follows the optimal policy : Shortest Remaining Processing Time (SRPT)
What is the dispatch policy ? GREEDY
pj1(t)
The dispatch policy
When a job j arrives, compute for each machine i the increase in flow-time if we dispatch j to i.
j1
j2
jr
jr+1
js
j arrives at time t : pij1(t) ≤ pij2
(t) ≤ …
pijr(t) < pij < pijr+1
(t)
j
Increase in flow-time = pj1
(t) + … + pjr(t) + pij+ pij(s-r)
Our Algorithm
When a job j arrives, compute for each machine i the increase in flow-time if we dispatch j to i.
Dispatch j to the machine for which increase in fractional flow-time is minimum.
Analyzing our algorithm
Primal LPDual LP
LP opt. valueAlgorithm’s value
Construct a dualsolution
Show that the dual solution value and algorithm’s flow-time are close to each other.
Dual LP
0t)j,x(i,
ti,allfor1t)j,x(i,
jallfor1p
t)j,x(i,
t)j,x(i,)r(tp
t)j,x(i,Min
j
ti, ij
tj,i,j
tj,i, ij
αj
βit
Dual LP
0,
rtt,j,i,allfor1p
rt
p
Max
itj
jij
jit
ij
j
ti,it
jj
βα
βα
βα
pj1(t)
αj = pj1
(t) + … + pjr(t) + pij + pij(s-r)
Setting the Dual Values
When a job j arrives, set αj to the increase in flow-time when j is dispatched greedily.
j1
j2
jr
jr+1
js
j arrives at time t : pij1(t) ≤ pij2
(t) ≤ …
pijr(t) < pij < pijr+1
(t)
Thus j αj is equal to the total flow-time.
βit = s
Setting the Dual Values
j1
j2
jr
jr+1
js
pj1(t)
Set βit to be the number of jobs waiting at time t for machine i.
Thus i,t βit is equal to the total flow-time.
Need to verify
Dual Feasibility
j1
j2
jl
jl+1
js
pj1(t)
)( ls ji'ji'jjj pp(t)p...(t)pl1
Fix a machine i’, a job j and time t’.
1p
tt'p ji'
t'i'ji'
j
βα
Suppose pi’jl(t) < pi’j < pi’jl+1
(t)
Dual Feasibility
j1
j2
jl
jl+1
js
pj1(t)
ls ji'ji'jjj pp(t)p...(t)pl1
11p
(t)p...(t)p
p ti'ji'
jj
ji'
j l1
βslsα
1
What happens when t’ = t ?
Dual Feasibility
j1
j2
jl
jl+1
js
t'i'ji'ji'
ji'
jj
ji'
jjjj
ji'
j
1p
t)(t'1)k-(s 1
pt)(t'
1p
(t)p...(t)pt)(t'
1p
(t)p...(t)p(t)p...(t)p
p
lk
lk1-k1
β
ls
lsα
δ
What happens when t’ = t + δ? Suppose at time t’ job jk is being processed
Case 1: k ≤ l
Dual Feasibility
j2
jr
jr+1
js
t'i'ji'ji'
ji'
jjjj
ji'
ji'ji'jj
ji'
j
1p
t)(t'1)k-(s 1
pt)(t'
1p
(t)p...(t)p(t)p...(t)p
p
pp(t)p...(t)p
p
1-k1lr1
l1
β
ks
lsα
1
Case 2: k > l ¢
Dual Feasibility
So, αj, βit are dual feasible
But i,t βit and j αj both equal the total flow time and hence the dual objective value is
1p
t)(t'p ji'
t'i'ji'
j
βα
Hence, for any machine i’, time t’ and job j
0,
, ti
tij
j
Incorporating machine speed-up
So the values αj, βit/(1+ε) are dual feasible for an instance with processing times larger by a factor (1+ε)
1pt)(t'
p ji'
t'i'
ji'
j
111
βα
For any machine i’, time t’ and job j
Equivalently, schedule given instance on machines ofspeed (1+ε) to determine αj, βit. The values αj, βit/(1+ε) are dual feasible.
Dual Objective Value
The dual value is less than the optimum fractional flow time.
jj
ti
ti
jj
11,
,
Since i,t βit = j αj the value of the dual is
Hence, the flow time of our solution, j αj, is at most (1+1/ε) times the optimum fractional flow time.
Extensions
• Can extend this analysis to the Lp-norm of the flow time to get a similar result.
• Analysis also extends to the case of minimizing sum of flow time and energy on unrelated machines.
Open Problems
Single Machine :
Constant factor approximation algorithm for weighted flow-time.
loglog n approx [Bansal Pruhs ’10]
2+ε quasi polynomial time algorithm [Chekuri Khanna Zhu ‘01]
Open Problems
Parallel machines :
Constant factor approximation algorithm if we allow migration of a job from one machine to another.
The (log1-ε P) hardness is for non-migratory schedules
Open Problems
Unrelated Machines :
poly-log approximation algorithm
(LP integrality gap ?)
O(k) approximation [Sitters 08] is known, where k is the number of different processing times.
Thank You