30
Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

  • Upload
    others

  • View
    45

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Approximation Algorithms (Load Balancing)

July 16, 2014

Approximation Algorithms (Load Balancing)

Page 2: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 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 suchthat the maximum load is minimized.In other words, we would like to balance the loads.

Approximation Algorithms (Load Balancing)

Page 3: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 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 suchthat the maximum load is minimized.In other words, we would like to balance the loads.

Approximation Algorithms (Load Balancing)

Page 4: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Let A(i) be the set of jobs that are assigned to Mi .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. Evenwhen there are two machines.

Approximation Algorithms (Load Balancing)

Page 5: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Let A(i) be the set of jobs that are assigned to Mi .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. Evenwhen there are two machines.

Approximation Algorithms (Load Balancing)

Page 6: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

2

J1 J2 J3 J4 J5 J6

2 6 3 4 2

M1 M2 M3

2

6

3

2

4

2

Approximation Algorithms (Load Balancing)

Page 7: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

2

J1 J2 J3 J4 J5 J6

2 6 3 4 2

M1 M2 M3

2

6

3

2

4

2

Approximation Algorithms (Load Balancing)

Page 8: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

2

J1 J2 J3 J4 J5 J6

2 6 3 4 2

M1 M2 M3

2

6

3

2

4

2

Approximation Algorithms (Load Balancing)

Page 9: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 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

Approximation Algorithms (Load Balancing)

Page 10: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

1) The optimal load T ∗ is at least

T ∗ ≥ 1

m

∑j

tj

2) T ∗ ≥ maxj tj .

Lemma

Algorithm Greedy-Balance produces an assignment of jobs tomachines with max load T ≤ 2T ∗.

Approximation Algorithms (Load Balancing)

Page 11: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

1) The optimal load T ∗ is at least

T ∗ ≥ 1

m

∑j

tj

2) T ∗ ≥ maxj tj .

Lemma

Algorithm Greedy-Balance produces an assignment of jobs tomachines with max load T ≤ 2T ∗.

Approximation Algorithms (Load Balancing)

Page 12: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

1) The optimal load T ∗ is at least

T ∗ ≥ 1

m

∑j

tj

2) T ∗ ≥ maxj tj .

Lemma

Algorithm Greedy-Balance produces an assignment of jobs tomachines with max load T ≤ 2T ∗.

Approximation Algorithms (Load Balancing)

Page 13: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Lemma

Algorithm Greedy-Balance produces an assignment of jobs tomachines with max load T ≤ 2T ∗.

Proof.

Consider the time we add job j into machine Mi . The load ofmachine 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 − ti ) ≤∑k

Tk

Also we know that∑

k Tk ≤∑

j tj . Therefore

Ti − tj ≤ 1m

∑j tj ≤ T ∗. Also we know that tj ≤ T ∗.

Therefore load of Mi after adding Jj is Ti = (Ti − tj) + tj ≤ 2T ∗.

Approximation Algorithms (Load Balancing)

Page 14: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Lemma

Algorithm Greedy-Balance produces an assignment of jobs tomachines with max load T ≤ 2T ∗.

Proof.

Consider the time we add job j into machine Mi . The load ofmachine 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 − ti ) ≤∑k

Tk

Also we know that∑

k Tk ≤∑

j tj . Therefore

Ti − tj ≤ 1m

∑j tj ≤ T ∗. Also we know that tj ≤ T ∗.

Therefore load of Mi after adding Jj is Ti = (Ti − tj) + tj ≤ 2T ∗.

Approximation Algorithms (Load Balancing)

Page 15: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Lemma

Algorithm Greedy-Balance produces an assignment of jobs tomachines with max load T ≤ 2T ∗.

Proof.

Consider the time we add job j into machine Mi . The load ofmachine 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 − ti ) ≤∑k

Tk

Also we know that∑

k Tk ≤∑

j tj . Therefore

Ti − tj ≤ 1m

∑j tj ≤ T ∗. Also we know that tj ≤ T ∗.

Therefore load of Mi after adding Jj is Ti = (Ti − tj) + tj ≤ 2T ∗.

Approximation Algorithms (Load Balancing)

Page 16: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Lemma

Algorithm Greedy-Balance produces an assignment of jobs tomachines with max load T ≤ 2T ∗.

Proof.

Consider the time we add job j into machine Mi . The load ofmachine 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 − ti ) ≤∑k

Tk

Also we know that∑

k Tk ≤∑

j tj . Therefore

Ti − tj ≤ 1m

∑j tj ≤ T ∗. Also we know that tj ≤ T ∗.

Therefore load of Mi after adding Jj is Ti = (Ti − tj) + tj ≤ 2T ∗.

Approximation Algorithms (Load Balancing)

Page 17: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Lemma

Algorithm Greedy-Balance produces an assignment of jobs tomachines with max load T ≤ 2T ∗.

Proof.

Consider the time we add job j into machine Mi . The load ofmachine 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 − ti ) ≤∑k

Tk

Also we know that∑

k Tk ≤∑

j tj . Therefore

Ti − tj ≤ 1m

∑j tj ≤ T ∗.

Also we know that tj ≤ T ∗.

Therefore load of Mi after adding Jj is Ti = (Ti − tj) + tj ≤ 2T ∗.

Approximation Algorithms (Load Balancing)

Page 18: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Lemma

Algorithm Greedy-Balance produces an assignment of jobs tomachines with max load T ≤ 2T ∗.

Proof.

Consider the time we add job j into machine Mi . The load ofmachine 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 − ti ) ≤∑k

Tk

Also we know that∑

k Tk ≤∑

j tj . Therefore

Ti − tj ≤ 1m

∑j tj ≤ T ∗. Also we know that tj ≤ T ∗.

Therefore load of Mi after adding Jj is Ti = (Ti − tj) + tj ≤ 2T ∗.

Approximation Algorithms (Load Balancing)

Page 19: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

Lemma

Algorithm Greedy-Balance produces an assignment of jobs tomachines with max load T ≤ 2T ∗.

Proof.

Consider the time we add job j into machine Mi . The load ofmachine 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 − ti ) ≤∑k

Tk

Also we know that∑

k Tk ≤∑

j tj . Therefore

Ti − tj ≤ 1m

∑j tj ≤ T ∗. Also we know that tj ≤ T ∗.

Therefore load of Mi after adding Jj is Ti = (Ti − tj) + tj ≤ 2T ∗.

Approximation Algorithms (Load Balancing)

Page 20: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

The Greedy-Balance could actually be as close as possible to 2T ∗.

1

J1 J2

1

M1 M2 M4

4

1

J3

1

J4

1

J5

1

J6

1

J7

1

J8

1

J9 J10

1

J11

1

J12

1

J13

4

M3 M1 M2 M3 M4

Greedy Algorithm Optimal

Approximation Algorithms (Load Balancing)

Page 21: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

The Greedy-Balance could actually be as close as possible to 2T ∗.

1

J1 J2

1

M1 M2 M4

4

1

J3

1

J4

1

J5

1

J6

1

J7

1

J8

1

J9 J10

1

J11

1

J12

1

J13

4

M3 M1 M2 M3 M4

Greedy Algorithm Optimal

Approximation Algorithms (Load Balancing)

Page 22: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

In general suppose there are m machines and n = m(m − 1) + 1jobs.

The first m(m − 1) jobs each with time tj = 1 and the last jobn = m(m − 1) + 1 has time tn = m.

The optimal has T ∗ = m while the Greedy algorithms has maxload 2m − 1.

Approximation Algorithms (Load Balancing)

Page 23: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

In general suppose there are m machines and n = m(m − 1) + 1jobs.

The first m(m − 1) jobs each with time tj = 1 and the last jobn = m(m − 1) + 1 has time tn = m.

The optimal has T ∗ = m while the Greedy algorithms has maxload 2m − 1.

Approximation Algorithms (Load Balancing)

Page 24: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

In general suppose there are m machines and n = m(m − 1) + 1jobs.

The first m(m − 1) jobs each with time tj = 1 and the last jobn = m(m − 1) + 1 has time tn = m.

The optimal has T ∗ = m while the Greedy algorithms has maxload 2m − 1.

Approximation Algorithms (Load Balancing)

Page 25: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 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

Approximation Algorithms (Load Balancing)

Page 26: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

If there are more than m jobs, then T ∗ ≥ 2tm+1.

Lemma

Algorithm Sort-Balance produces an assignment of jobs tomachines with max load T ≤ 3

2T∗.

Using similar analysis as in the previous lemma (leave it as exercise)

Approximation Algorithms (Load Balancing)

Page 27: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

If there are more than m jobs, then T ∗ ≥ 2tm+1.

Lemma

Algorithm Sort-Balance produces an assignment of jobs tomachines with max load T ≤ 3

2T∗.

Using similar analysis as in the previous lemma (leave it as exercise)

Approximation Algorithms (Load Balancing)

Page 28: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

There exists an algorithm that find a solution for Load balancingvery close to optimal T ∗

In fact there is an algorithm that for every ε > 0 it finds a solutionthat is not worse that (1 + ε)T ∗.

But the running time of the algorithm is

O(n(1ε)1.5)

where n is the number of jobs.

Approximation Algorithms (Load Balancing)

Page 29: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

There exists an algorithm that find a solution for Load balancingvery close to optimal T ∗

In fact there is an algorithm that for every ε > 0 it finds a solutionthat is not worse that (1 + ε)T ∗.

But the running time of the algorithm is

O(n(1ε)1.5)

where n is the number of jobs.

Approximation Algorithms (Load Balancing)

Page 30: Approximation Algorithms (Load Balancing)arashr/lecture24.pdf · Approximation Algorithms (Load Balancing) July 16, 2014 Approximation Algorithms (Load Balancing)

There exists an algorithm that find a solution for Load balancingvery close to optimal T ∗

In fact there is an algorithm that for every ε > 0 it finds a solutionthat is not worse that (1 + ε)T ∗.

But the running time of the algorithm is

O(n(1ε)1.5)

where n is the number of jobs.

Approximation Algorithms (Load Balancing)