Approximation Algorithms (Load Balancing)

Approximation Algorithms (Load Balancing)
Arash Rafiey
March 26, 2015
Arash Rafiey
Approximation Algorithms (Load Balancing)
Problem Definition :
We are given a set of n jobs {J1 , J2 , . . . , Jn }.
Each job Ji has a processing time ti ≥ 0.
We are given m identical machines.
Arash Rafiey
Approximation Algorithms (Load Balancing)
Problem Definition :
We are given a set of n jobs {J1 , J2 , . . . , Jn }.
Each job Ji has a processing time ti ≥ 0.
We are given m identical machines.
Goal :
We want to assign (load) the jobs to machines such
that the maximum load is minimized.
In other words, we would like to balance the loads.
Arash Rafiey
Approximation Algorithms (Load Balancing)
Let A(i) be the set of jobs that are assigned
to Mi .
P
Then the load of Mi denoted by Ti = j∈A(i) ti .
We wish to minimize T = maxi Ti .
Arash Rafiey
Approximation Algorithms (Load Balancing)
Let A(i) be the set of jobs that are assigned
to Mi .
P
Then the load of Mi denoted by Ti = j∈A(i) ti .
We wish to minimize T = maxi Ti .
The load balancing problem in NP-complete. Even
when there are two machines.
Arash Rafiey
Approximation Algorithms (Load Balancing)
J1
J2
J3
J4
J5
J6
2
2
6
3
4
2
6
2
2
2
M1
3
M2
Arash Rafiey
4
M3
Approximation Algorithms (Load Balancing)
J1
J2
J3
J4
J5
J6
2
2
6
3
4
2
6
2
2
2
M1
3
M2
Arash Rafiey
4
M3
Approximation Algorithms (Load Balancing)
J1
J2
J3
J4
J5
J6
2
2
6
3
4
2
2
2
2
6
3
M1
M2
Arash Rafiey
4
M3
Approximation Algorithms (Load Balancing)
Greedy-Balance
1. Set Ti = 0 and A(i) = ∅ for all machines Mi .
2. for j = 1 to n
3.
Let Mi be a machine with minimum load (mink Tk ).
4.
Assign job j to machine Mi .
5.
Set A(i) ← A(i) ∪ {Jj }
6.
Set Ti ← Ti + tj
Arash Rafiey
Approximation Algorithms (Load Balancing)
1) The optimal load T ∗ is at least
T∗ ≥
1 X
tj
m
j
Arash Rafiey
Approximation Algorithms (Load Balancing)
1) The optimal load T ∗ is at least
T∗ ≥
1 X
tj
m
j
2) T ∗ ≥ maxj tj .
Arash Rafiey
Approximation Algorithms (Load Balancing)
1) The optimal load T ∗ is at least
T∗ ≥
1 X
tj
m
j
2) T ∗ ≥ maxj tj .
Lemma
Algorithm Greedy-Balance produces an assignment of jobs to
machines with max load T ≤ 2T ∗ .
Arash Rafiey
Approximation Algorithms (Load Balancing)
Lemma
Algorithm Greedy-Balance produces an assignment of jobs to
machines with max load T ≤ 2T ∗ .
Proof.
Consider the time we add job j into machine Mi . The load of
machine Mi was Ti − tj before adding Jj to Mi .
Arash Rafiey
Approximation Algorithms (Load Balancing)
Lemma
Algorithm Greedy-Balance produces an assignment of jobs to
machines with max load T ≤ 2T ∗ .
Proof.
Consider the time we add job j into machine Mi . The load of
machine Mi was Ti − tj before adding Jj to Mi . Also Ti − tj was
the smallest load. Every other machine has load at least Ti − tj .
Therefore :
Arash Rafiey
Approximation Algorithms (Load Balancing)
Lemma
Algorithm Greedy-Balance produces an assignment of jobs to
machines with max load T ≤ 2T ∗ .
Proof.
Consider the time we add job j into machine Mi . The load of
machine Mi was Ti − tj before adding Jj to Mi . Also Ti − tj was
the smallest load. Every other machine has load at least Ti − tj .
Therefore :
m(Ti − tj ) ≤
X
Tk
k
Arash Rafiey
Approximation Algorithms (Load Balancing)
Lemma
Algorithm Greedy-Balance produces an assignment of jobs to
machines with max load T ≤ 2T ∗ .
Proof.
Consider the time we add job j into machine Mi . The load of
machine Mi was Ti − tj before adding Jj to Mi . Also Ti − tj was
the smallest load. Every other machine has load at least Ti − tj .
Therefore :
m(Ti − tj ) ≤
X
Tk
k
Also we know that
P
k
Tk ≤
P
Arash Rafiey
j tj .
Therefore
Approximation Algorithms (Load Balancing)
Lemma
Algorithm Greedy-Balance produces an assignment of jobs to
machines with max load T ≤ 2T ∗ .
Proof.
Consider the time we add job j into machine Mi . The load of
machine Mi was Ti − tj before adding Jj to Mi . Also Ti − tj was
the smallest load. Every other machine has load at least Ti − tj .
Therefore :
m(Ti − tj ) ≤
X
Tk
k
P
P
Also we know that k Tk ≤ j tj . Therefore
P
Ti − tj ≤ m1 j tj ≤ T ∗ .
Arash Rafiey
Approximation Algorithms (Load Balancing)
Lemma
Algorithm Greedy-Balance produces an assignment of jobs to
machines with max load T ≤ 2T ∗ .
Proof.
Consider the time we add job j into machine Mi . The load of
machine Mi was Ti − tj before adding Jj to Mi . Also Ti − tj was
the smallest load. Every other machine has load at least Ti − tj .
Therefore :
m(Ti − tj ) ≤
X
Tk
k
P
P
Also we know that k Tk ≤ j tj . Therefore
P
Ti − tj ≤ m1 j tj ≤ T ∗ . Also we know that tj ≤ T ∗ .
Arash Rafiey
Approximation Algorithms (Load Balancing)
Lemma
Algorithm Greedy-Balance produces an assignment of jobs to
machines with max load T ≤ 2T ∗ .
Proof.
Consider the time we add job j into machine Mi . The load of
machine Mi was Ti − tj before adding Jj to Mi . Also Ti − tj was
the smallest load. Every other machine has load at least Ti − tj .
Therefore :
m(Ti − tj ) ≤
X
Tk
k
P
P
Also we know that k Tk ≤ j tj . Therefore
P
Ti − tj ≤ m1 j tj ≤ T ∗ . Also we know that tj ≤ T ∗ .
Therefore load of Mi after adding Jj is Ti = (Ti − tj ) + tj ≤ 2T ∗ .
Arash Rafiey
Approximation Algorithms (Load Balancing)
The Greedy-Balance could actually be as close as possible to 2T ∗ .
J1
J2
J3
J4
J5
J6
J7
J8
J9
J10
J11
J12
1
1
1
1
1
1
1
1
1
1
1
1
J13
4
Greedy Algorithm
Optimal
4
M1
M2
M3
M4
Arash Rafiey
M1
M2
M3
M4
Approximation Algorithms (Load Balancing)
The Greedy-Balance could actually be as close as possible to 2T ∗ .
J1
J2
J3
J4
J5
J6
J7
J8
J9
J10
J11
J12
1
1
1
1
1
1
1
1
1
1
1
1
J13
4
Greedy Algorithm
Optimal
4
M1
M2
M3
M4
Arash Rafiey
M1
M2
M3
M4
Approximation Algorithms (Load Balancing)
In general suppose there are m machines and n = m(m − 1) + 1
jobs.
Arash Rafiey
Approximation Algorithms (Load Balancing)
In general suppose there are m machines and n = m(m − 1) + 1
jobs.
The first m(m − 1) jobs each with time tj = 1 and the last job
n = m(m − 1) + 1 has time tn = m.
Arash Rafiey
Approximation Algorithms (Load Balancing)
In general suppose there are m machines and n = m(m − 1) + 1
jobs.
The first m(m − 1) jobs each with time tj = 1 and the last job
n = m(m − 1) + 1 has time tn = m.
The optimal has T ∗ = m while the Greedy algorithms has max
load 2m − 1.
Arash Rafiey
Approximation Algorithms (Load Balancing)
An Improved Approximation Algorithm
Sort-Balance
1. Set T0 = 0 and A(i) = ∅ for all machines Mi .
2. Sort the jobs in decreasing order of processing times tj .
3. Assume t1 ≥ t2 ≥ ... ≥ tn .
4. for j = 1 to n
5.
Let Mi be a machine with minimum load (mink Tk ).
6.
Assign job j to machine Mi .
7.
Set A(i) ← A(i) ∪ {Jj }
8.
Set Ti ← Ti + tj
Arash Rafiey
Approximation Algorithms (Load Balancing)
If there are more than m jobs, then T ∗ ≥ 2tm+1 .
Arash Rafiey
Approximation Algorithms (Load Balancing)
If there are more than m jobs, then T ∗ ≥ 2tm+1 .
Lemma
Algorithm Sort-Balance produces an assignment of jobs to
machines with max load T ≤ 32 T ∗ .
Using similar analysis as in the previous lemma (leave it as exercise)
Arash Rafiey
Approximation Algorithms (Load Balancing)
There exists an algorithm that finds a solution for Load balancing
very close to optimal T ∗
Arash Rafiey
Approximation Algorithms (Load Balancing)
There exists an algorithm that finds a solution for Load balancing
very close to optimal T ∗
In fact there is an algorithm that for every > 0 it finds a solution
that is not worse that (1 + )T ∗ .
Arash Rafiey
Approximation Algorithms (Load Balancing)
There exists an algorithm that finds a solution for Load balancing
very close to optimal T ∗
In fact there is an algorithm that for every > 0 it finds a solution
that is not worse that (1 + )T ∗ .
But the running time of the algorithm is
1 1.5
O(n( ) )
where n is the number of jobs.
Arash Rafiey
Approximation Algorithms (Load Balancing)