Top Banner
Advanced Algorithms – COMS31900 Approximation algorithms part two more constant factor approximations Benjamin Sach
175

Approximation Algorithms Part Two: More Constant factor approximations

Jan 20, 2017

Download

Education

Benjamin Sach
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Approximation Algorithms Part Two: More Constant factor approximations

Advanced Algorithms – COMS31900

Approximation algorithms part two

more constant factor approximations

Benjamin Sach

Page 2: Approximation Algorithms Part Two: More Constant factor approximations

Approximation Algorithms Recap

An algorithmA is an α-approximation algorithm for problem P if,

◦A runs in polynomial time

◦A always outputs a solution with value s

Here P is an optimisation problem with optimal solution of value Opt

• If P is a maximisation problem, Optα 6 s 6 Opt

within an α factor of Opt

• If P is a minimisation problem, Opt 6 s 6 α ·Opt

We have seen

a 3/2-approximation algorithm for Bin Packing(and a faster 2-approximation)

Page 3: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

m identical

machines

n jobs

time taken

Goal: minimise the (wall-clock) time

taken to process all jobs

Page 4: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

m identical

machines

n jobs

time taken

Goal: minimise the (wall-clock) time

taken to process all jobs

(it’s NP-hard)

Page 5: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Goal: minimise the (wall-clock) time

taken to process all jobs

wall-clock time (also called makespan)

Page 6: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Goal: minimise the (wall-clock) time

taken to process all jobs

wall-clock time (also called makespan)

• Job j takes tj time units

Page 7: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Goal: minimise the (wall-clock) time

taken to process all jobs

wall-clock time (also called makespan)

• We say that j ∈ J(i) iff job j is assigned to machine i

• Job j takes tj time units

Page 8: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Goal: minimise the (wall-clock) time

taken to process all jobs

wall-clock time (also called makespan)

• We say that j ∈ J(i) iff job j is assigned to machine i

• The load of machine i is Li =∑j∈J(i) tj

• Job j takes tj time units

Page 9: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Goal: minimise the (wall-clock) time

taken to process all jobs

wall-clock time (also called makespan)

• We say that j ∈ J(i) iff job j is assigned to machine i

• The load of machine i is Li =∑j∈J(i) tj

• Job j takes tj time units

L2

L3

L1

Page 10: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Goal: minimise the (wall-clock) time

taken to process all jobs

wall-clock time (also called makespan)

• We say that j ∈ J(i) iff job j is assigned to machine i

• The load of machine i is Li =∑j∈J(i) tj

• Job j takes tj time units

• So the wall-clock time is maxi Li (which we want to minimise)

L2

L3

L1

Page 11: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Goal: minimise the (wall-clock) time

taken to process all jobs

wall-clock time (also called makespan)

• We say that j ∈ J(i) iff job j is assigned to machine i

• The load of machine i is Li =∑j∈J(i) tj

• Job j takes tj time units

• So the wall-clock time is maxi Li (which we want to minimise)

L2

L3

L1L1

Page 12: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Page 13: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 14: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 15: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 16: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 17: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 18: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 19: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 20: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 21: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 22: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 23: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 24: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 25: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 26: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 27: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 28: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

Page 29: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

How long does it take to compute this schedule?

Page 30: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

How long does it take to compute this schedule?

m machines

n jobs

Page 31: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

How long does it take to compute this schedule?

O(nm) time naively,O(n logm) time using a priority queue

m machines

n jobs

Page 32: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

How long does it take to compute this schedule?

O(nm) time naively,O(n logm) time using a priority queue

(it’s also an online solution)

m machines

n jobs

Page 33: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling Jobs on Parallel Machines

1

2

3

4

5

Algorithm: Put job j on the machine i with smallest (current) load

How long does it take to compute this schedule?

O(nm) time naively,O(n logm) time using a priority queue

How good is it?

(it’s also an online solution)

m machines

n jobs

Page 34: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Job j takes tjtime units

Li is the load of

machine i

m machines

n jobs

Page 35: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

• Before we prove this, we prove two useful facts,

Theorem The greedy algorithm given is a 2-approximation algorithm

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Job j takes tjtime units

Li is the load of

machine i

m machines

n jobs

Page 36: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

• Before we prove this, we prove two useful facts,

Fact Opt > maxj tj

Theorem The greedy algorithm given is a 2-approximation algorithm

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Job j takes tjtime units

Li is the load of

machine i

m machines

n jobs

Page 37: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

• Before we prove this, we prove two useful facts,

Fact Opt > maxj tj

◦ Some machine must process the largest job

Theorem The greedy algorithm given is a 2-approximation algorithm

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Job j takes tjtime units

Li is the load of

machine i

m machines

n jobs

Page 38: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

• Before we prove this, we prove two useful facts,

Fact Opt > maxj tj

Fact Opt >

∑j tjm

◦ Some machine must process the largest job

Theorem The greedy algorithm given is a 2-approximation algorithm

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Job j takes tjtime units

Li is the load of

machine i

m machines

n jobs

Page 39: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

• Before we prove this, we prove two useful facts,

Fact Opt > maxj tj

Fact Opt >

∑j tjm

◦ Some machine must process the largest job

◦ There is a total of∑j tj time units of work to be done

Theorem The greedy algorithm given is a 2-approximation algorithm

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Job j takes tjtime units

Li is the load of

machine i

m machines

n jobs

Page 40: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

• Before we prove this, we prove two useful facts,

Fact Opt > maxj tj

Fact Opt >

∑j tjm

◦ Some machine must process the largest job

◦ There is a total of∑j tj time units of work to be done

◦ Some machine i must have load Li at least

∑j tjm

Theorem The greedy algorithm given is a 2-approximation algorithm

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Job j takes tjtime units

Li is the load of

machine i

m machines

n jobs

Page 41: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

• Before we prove this, we prove two useful facts,

Fact Opt > maxj tj

Fact Opt >

∑j tjm

◦ Some machine must process the largest job

◦ There is a total of∑j tj time units of work to be done

◦ Some machine i must have load Li at least

∑j tjm

(them machines can’t all have below average load)

Theorem The greedy algorithm given is a 2-approximation algorithm

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Job j takes tjtime units

Li is the load of

machine i

m machines

n jobs

Page 42: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

m machines

n jobs

Page 43: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

Proof Consider the machine i with largest load Tg = Li

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

m machines

n jobs

Page 44: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

Proof Consider the machine i with largest load Tg = Li

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

Page 45: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

Page 46: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 47: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 48: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

Page 49: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 50: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

So. . .

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 51: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Li − tj 6 Lk for all 1 6 k 6 m,

So. . .

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 52: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Li − tj 6 Lk for all 1 6 k 6 m,

So. . .

• If we then sum over all k,

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 53: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Li − tj 6 Lk for all 1 6 k 6 m,

So. . .

• If we then sum over all k,

m(Li − tj) 6m∑k=1

Lk

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 54: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Li − tj 6 Lk for all 1 6 k 6 m,

So. . .

• If we then sum over all k,

m(Li − tj) 6m∑k=1

Lk

so (Li − tj) 6∑m

k=1 Lk

m 6 Opt (by the second fact)

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 55: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Li − tj 6 Lk for all 1 6 k 6 m,

So. . .

• If we then sum over all k,

m(Li − tj) 6m∑k=1

Lk

so (Li − tj) 6∑m

k=1 Lk

m 6 Opt (by the second fact)

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Fact Opt >

∑j tjm

Page 56: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Li − tj 6 Lk for all 1 6 k 6 m,

So. . .

• If we then sum over all k,

m(Li − tj) 6m∑k=1

Lk

so (Li − tj) 6∑m

k=1 Lk

m 6 Opt (by the second fact)

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 57: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Li − tj 6 Lk for all 1 6 k 6 m,

So. . .

• If we then sum over all k,

m(Li − tj) 6m∑k=1

Lk

so (Li − tj) 6∑m

k=1 Lk

m 6 Opt (by the second fact)

also tj 6 Opt (by the first fact)

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 58: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Li − tj 6 Lk for all 1 6 k 6 m,

So. . .

• If we then sum over all k,

m(Li − tj) 6m∑k=1

Lk

so (Li − tj) 6∑m

k=1 Lk

m 6 Opt (by the second fact)

also tj 6 Opt (by the first fact)

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Fact Opt > maxj tj

Page 59: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Li − tj 6 Lk for all 1 6 k 6 m,

So. . .

• If we then sum over all k,

m(Li − tj) 6m∑k=1

Lk

so (Li − tj) 6∑m

k=1 Lk

m 6 Opt (by the second fact)

also tj 6 Opt (by the first fact)

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 60: Approximation Algorithms Part Two: More Constant factor approximations

The greedy approximation

Theorem The greedy algorithm given is a 2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tg = Li

• When job j was assigned, machine i had the smallest load, Li − tj

Li − tj 6 Lk for all 1 6 k 6 m,

So. . .

• If we then sum over all k,

m(Li − tj) 6m∑k=1

Lk

so (Li − tj) 6∑m

k=1 Lk

m 6 Opt (by the second fact)

also tj 6 Opt (by the first fact)

Therefore, Tg = Li = (Li − tj) + tj 6 Opt + Opt = 2Opt

Let Opt denote the time taken by the optimal scheduling of jobs

Let Tg denote the time taken by the greedy schedule

Li is the load of

machine i

Job j takes tjtime units

1

2

3

4

5

Li = Tg

m machines

n jobs

job j

Page 61: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Page 62: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Page 63: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 64: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 65: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 66: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 67: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 68: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 69: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 70: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 71: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 72: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 73: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 74: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 75: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 76: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 77: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 78: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

Page 79: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

greedy

solution

Page 80: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

greedy

solution

How long does it take to compute this schedule?

Page 81: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

greedy

solution

How long does it take to compute this schedule?

O(n logn) time (to sort the jobs)

Page 82: Approximation Algorithms Part Two: More Constant factor approximations

Longest Processing Time (LPT)

1

2

3

4

5

Step 1: Sort the jobs into non-increasing order (job 1 is now largest)

Step 2: Put job j on the machine i with smallest (current) load

greedy

solution

How long does it take to compute this schedule?

O(n logn) time (to sort the jobs)

How good is it?

Page 83: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let Tl denote the time taken by the LPT scheduleLi is the load of

machine i

m machines

n jobs

Job j takes tjtime units

Page 84: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Before we prove this, we prove another useful fact and a Lemma

• Let Tl denote the time taken by the LPT scheduleLi is the load of

machine i

m machines

n jobs

Job j takes tjtime units

Page 85: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Before we prove this, we prove another useful fact and a Lemma

Fact If there are at mostm jobs (n 6 m) then LPT is optimal

• Let Tl denote the time taken by the LPT scheduleLi is the load of

machine i

m machines

n jobs

Job j takes tjtime units

Page 86: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Before we prove this, we prove another useful fact and a Lemma

Fact If there are at mostm jobs (n 6 m) then LPT is optimal

LPT gives each job its own machine so maxi Li 6 maxj tj 6 Opt

• Let Tl denote the time taken by the LPT scheduleLi is the load of

machine i

m machines

n jobs

Job j takes tjtime units

If there are at mostm jobs then

Page 87: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Before we prove this, we prove another useful fact and a Lemma

Fact If there are at mostm jobs (n 6 m) then LPT is optimal

Lemma If n > m then Opt > 2t(m+1) (after sorting)

LPT gives each job its own machine so maxi Li 6 maxj tj 6 Opt

• Let Tl denote the time taken by the LPT scheduleLi is the load of

machine i

m machines

n jobs

Job j takes tjtime units

If there are at mostm jobs then

Page 88: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Before we prove this, we prove another useful fact and a Lemma

Fact If there are at mostm jobs (n 6 m) then LPT is optimal

Lemma If n > m then Opt > 2t(m+1) (after sorting)

LPT gives each job its own machine so maxi Li 6 maxj tj 6 Opt

• Let Tl denote the time taken by the LPT schedule

Proof

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

If there are at mostm jobs then

Page 89: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Before we prove this, we prove another useful fact and a Lemma

Fact If there are at mostm jobs (n 6 m) then LPT is optimal

Lemma If n > m then Opt > 2t(m+1) (after sorting)

LPT gives each job its own machine so maxi Li 6 maxj tj 6 Opt

◦ Note that t1 > t2 > t3 > . . . tm > t(m+1)

• Let Tl denote the time taken by the LPT schedule

Proof

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

If there are at mostm jobs then

Page 90: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Before we prove this, we prove another useful fact and a Lemma

Fact If there are at mostm jobs (n 6 m) then LPT is optimal

Lemma If n > m then Opt > 2t(m+1) (after sorting)

LPT gives each job its own machine so maxi Li 6 maxj tj 6 Opt

◦ Note that t1 > t2 > t3 > . . . tm > t(m+1)

◦ One of them machines must be assigned

• Let Tl denote the time taken by the LPT schedule

Proof

(at least) two of thesem+ 1 jobs under any schedule

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

If there are at mostm jobs then

Page 91: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Before we prove this, we prove another useful fact and a Lemma

Fact If there are at mostm jobs (n 6 m) then LPT is optimal

Lemma If n > m then Opt > 2t(m+1) (after sorting)

LPT gives each job its own machine so maxi Li 6 maxj tj 6 Opt

◦ Note that t1 > t2 > t3 > . . . tm > t(m+1)

◦ One of them machines must be assigned

• Let Tl denote the time taken by the LPT schedule

Proof

(at least) two of thesem+ 1 jobs under any schedule

◦ So we have that any schedule takes at least 2t(m+1) time

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

If there are at mostm jobs then

Page 92: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Before we prove this, we prove another useful fact and a Lemma

Fact If there are at mostm jobs (n 6 m) then LPT is optimal

Lemma If n > m then Opt > 2t(m+1) (after sorting)

LPT gives each job its own machine so maxi Li 6 maxj tj 6 Opt

◦ Note that t1 > t2 > t3 > . . . tm > t(m+1)

◦ One of them machines must be assigned

• Let Tl denote the time taken by the LPT schedule

Proof

(at least) two of thesem+ 1 jobs under any schedule

◦ So we have that any schedule takes at least 2t(m+1) time

Li is the load of

machine i

m machines

n jobs

in particular Opt > 2t(m+1)

Job j takes tjtime units

If there are at mostm jobs then

Page 93: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

Page 94: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

Proof Consider the machine i with largest load Tl = Li

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

Page 95: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

Page 96: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 97: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 98: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 99: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 100: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

because LPT is optimal in this case

Page 101: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 102: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 103: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Fact Opt > maxj tj

Page 104: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 105: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

so assume that (Li − tj) > 0

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 106: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

so assume that (Li − tj) > 0

• Therefore machine i was assigned at least two jobs

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 107: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

so assume that (Li − tj) > 0

• Therefore machine i was assigned at least two jobs

By the algorithm description, we have that j > m+ 1

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 108: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

so assume that (Li − tj) > 0

• Therefore machine i was assigned at least two jobs

By the algorithm description, we have that j > m+ 1

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

it doesn’t assign a second job to any machine untilevery machine has at least one job

Page 109: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

so assume that (Li − tj) > 0

• Therefore machine i was assigned at least two jobs

By the algorithm description, we have that j > m+ 1

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 110: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

so assume that (Li − tj) > 0

• Therefore machine i was assigned at least two jobs

By the algorithm description, we have that j > m+ 1

tj 6 tm+1 6 Opt/2 (by the Lemma)

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 111: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

so assume that (Li − tj) > 0

• Therefore machine i was assigned at least two jobs

By the algorithm description, we have that j > m+ 1

tj 6 tm+1 6 Opt/2 (by the Lemma)

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Lemma If n > m then Opt > 2t(m+1) (after sorting)

Page 112: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

so assume that (Li − tj) > 0

• Therefore machine i was assigned at least two jobs

By the algorithm description, we have that j > m+ 1

tj 6 tm+1 6 Opt/2 (by the Lemma)

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 113: Approximation Algorithms Part Two: More Constant factor approximations

The LPT approximation

Theorem The LPT algorithm is a 3/2-approximation algorithm

• Let j denote the last job machine i completes

Proof Consider the machine i with largest load Tl = Li

• Using the same argument as before, we have that,

(Li − tj) 6 Opt

Therefore, Tl = Li = (Li − tj) + tj 6 Opt + Opt/2 = (3/2) ·Opt

• If n 6 m then we are done so assume n > m

• Further if (Li − tj) = 0 then Tl = Li = tj 6 Opt

so assume that (Li − tj) > 0

• Therefore machine i was assigned at least two jobs

By the algorithm description, we have that j > m+ 1

tj 6 tm+1 6 Opt/2 (by the Lemma)

Li is the load of

machine i

m machines

n jobs

Job j takes tjtime units

job j

12345

Page 114: Approximation Algorithms Part Two: More Constant factor approximations

Scheduling conclusions

Theorem The LPT algorithm is a 3/2-approximation algorithm

which runs inO(n logn) time

Theorem The greedy algorithm is a 2-approximation algorithm

which runs inO(n logm) time and it’s online

In fact, LPT is a 4/3-approximation algorithm (using better analysis)

m machines

n jobs

Page 115: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

Goal Minimise the largest distance from any site to the closest center

Page 116: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

Goal Minimise the largest distance from any site to the closest center

Page 117: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

Goal Minimise the largest distance from any site to the closest center

Page 118: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Page 119: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

(i.e. ‘normal’ euclidean distance)

Page 120: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Select k sites to be

centers

(i.e. ‘normal’ euclidean distance)

Page 121: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Select k sites to be

centers

(i.e. ‘normal’ euclidean distance)

Page 122: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Select k sites to be

centers

Page 123: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Goal Minimise the largest distance from any site to the closest center

Select k sites to be

centers

Page 124: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Goal Minimise the largest distance from any site to the closest center

Select k sites to be

centers

Page 125: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Goal Minimise the largest distance from any site to the closest center

Select k sites to be

centers

r

r

Page 126: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Goal Minimise the largest distance from any site to the closest center

Select k sites to be

centers

Page 127: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Goal Minimise the largest distance from any site to the closest center

Select k sites to be

centers

Page 128: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Goal Minimise the largest distance from any site to the closest center

Select k sites to be

centers

r

Page 129: Approximation Algorithms Part Two: More Constant factor approximations

k-centers

n points (sites) in 2D space

The distance between points si, sj is√

(xi − xj)2 + (yi − yj)2

Goal Minimise the largest distance from any site to the closest center

Goal Minimise the largest distance from any site to the closest center

(in general it’s NP-hard)

Select k sites to be

centers

r

Page 130: Approximation Algorithms Part Two: More Constant factor approximations

A Greedy approximation

Page 131: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

A Greedy approximation

Page 132: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

A Greedy approximation

Page 133: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 134: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 135: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 136: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 137: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 138: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 139: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 140: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 141: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 142: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 143: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 144: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 145: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 146: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

Page 147: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

A Greedy approximation

r

Page 148: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

This takesO(nk) time

A Greedy approximation

Page 149: Approximation Algorithms Part Two: More Constant factor approximations

Start by picking any point to be a center

Repeatedly pick the site which is furthest from any existing center

This takesO(nk) time

A Greedy approximation

but is it any good?

Page 150: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Page 151: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 1: No si, si′ ∈ Cg are closest to the same sj ∈ COpt

Page 152: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 1: No si, si′ ∈ Cg are closest to the same sj ∈ COpt

Optimal centers

Page 153: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 1: No si, si′ ∈ Cg are closest to the same sj ∈ COpt

Optimal centers

Opt

Page 154: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 1: No si, si′ ∈ Cg are closest to the same sj ∈ COpt

Optimal centers

Opt

Sites

Page 155: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 1: No si, si′ ∈ Cg are closest to the same sj ∈ COpt

Optimal centers

Opt

Sitespurposes only

Disclaimer: for illustrative

Page 156: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 1: No si, si′ ∈ Cg are closest to the same sj ∈ COpt

Optimal centers

Opt

Sitespurposes only

Disclaimer: for illustrative

Greedy centers

Page 157: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 1: No si, si′ ∈ Cg are closest to the same sj ∈ COpt

Optimal centers

Opt

Sitespurposes only

Disclaimer: for illustrative

Greedy centers

Page 158: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 1: No si, si′ ∈ Cg are closest to the same sj ∈ COpt

Optimal centers

Opt

Sitespurposes only

Disclaimer: for illustrative

Greedy centers

Distance at most 2Opt

Page 159: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 1: No si, si′ ∈ Cg are closest to the same sj ∈ COpt

Optimal centers

Opt

Sitespurposes only

Disclaimer: for illustrative

Greedy centers

Distance at most 2Opt

so rg 6 2Opt

Page 160: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 2: Some si, si′ ∈ Cg are closest to the same sj ∈ COpt

Page 161: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 2: Some si, si′ ∈ Cg are closest to the same sj ∈ COpt

si

si′

Page 162: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 2: Some si, si′ ∈ Cg are closest to the same sj ∈ COpt

Assume wlog. that Greedy made si a center after si′

si

si′

Page 163: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 2: Some si, si′ ∈ Cg are closest to the same sj ∈ COpt

Assume wlog. that Greedy made si a center after si′

si

si′

si was added as a center because it was

Page 164: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 2: Some si, si′ ∈ Cg are closest to the same sj ∈ COpt

Assume wlog. that Greedy made si a center after si′

si

si′

si was added as a center because it was

the furthest from any existing Greedy center

Page 165: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 2: Some si, si′ ∈ Cg are closest to the same sj ∈ COpt

Assume wlog. that Greedy made si a center after si′

si

si′

si was added as a center because it was

the furthest from any existing Greedy center

However, si is at most 2Opt away from si′

Page 166: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 2: Some si, si′ ∈ Cg are closest to the same sj ∈ COpt

Assume wlog. that Greedy made si a center after si′

si

si′

si was added as a center because it was

the furthest from any existing Greedy center

However, si is at most 2Opt away from si′

Page 167: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 2: Some si, si′ ∈ Cg are closest to the same sj ∈ COpt

Assume wlog. that Greedy made si a center after si′

si

si′

si was added as a center because it was

the furthest from any existing Greedy center

However, si is at most 2Opt away from si′

So even before adding si as a center, all sites

were 6 2Opt away from a Greedy center

Page 168: Approximation Algorithms Part Two: More Constant factor approximations

The Greedy approximation

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

Let Cg (resp. COpt) denote the set of centers selected by Greedy (resp. Optimal)

Proof

Let rg (resp. Opt) denote largest site-center distance using Greedy (resp. Optimal)

Case 2: Some si, si′ ∈ Cg are closest to the same sj ∈ COpt

Assume wlog. that Greedy made si a center after si′

si

si′

si was added as a center because it was

the furthest from any existing Greedy center

However, si is at most 2Opt away from si′

So even before adding si as a center, all sites

were 6 2Opt away from a Greedy center

Therefore, rg 6 2Opt

Page 169: Approximation Algorithms Part Two: More Constant factor approximations

k-center Conclusions

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

which runs inO(nk) time

Page 170: Approximation Algorithms Part Two: More Constant factor approximations

k-center Conclusions

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

which runs inO(nk) time

• The approximation works for any (metric) distance function,

Page 171: Approximation Algorithms Part Two: More Constant factor approximations

k-center Conclusions

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

which runs inO(nk) time

• The approximation works for any (metric) distance function,

d(si, sj) = L1 or L∞ for example

Page 172: Approximation Algorithms Part Two: More Constant factor approximations

k-center Conclusions

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

which runs inO(nk) time

• The approximation works for any (metric) distance function,

d(si, sj) = L1 or L∞ for example

d(x, y) = d(y, x), d(x, y) > 0

• Distance function d is a metric iff

(d(x, y) = 0 iff x = y) and d(x, z) 6 d(x, y) + d(y, z)

Page 173: Approximation Algorithms Part Two: More Constant factor approximations

k-center Conclusions

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

which runs inO(nk) time

• The approximation works for any (metric) distance function,

d(si, sj) = L1 or L∞ for example

• For a general (metric) d, the problem is not α-approximable with α < 2

d(x, y) = d(y, x), d(x, y) > 0

• Distance function d is a metric iff

(d(x, y) = 0 iff x = y) and d(x, z) 6 d(x, y) + d(y, z)

Page 174: Approximation Algorithms Part Two: More Constant factor approximations

k-center Conclusions

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

which runs inO(nk) time

• The approximation works for any (metric) distance function,

d(si, sj) = L1 or L∞ for example

• For a general (metric) d, the problem is not α-approximable with α < 2

d(x, y) = d(y, x), d(x, y) > 0

• For d = L2 , the problem is not α-approximable with α <√3 ≈ 1.73

• Distance function d is a metric iff

(d(x, y) = 0 iff x = y) and d(x, z) 6 d(x, y) + d(y, z)

Page 175: Approximation Algorithms Part Two: More Constant factor approximations

k-center Conclusions

Theorem The Greedy algorithm for k-center is a 2-approximation algorithm

which runs inO(nk) time

• The approximation works for any (metric) distance function,

d(si, sj) = L1 or L∞ for example

• For a general (metric) d, the problem is not α-approximable with α < 2

d(x, y) = d(y, x), d(x, y) > 0

• For d = L2 , the problem is not α-approximable with α <√3 ≈ 1.73

• For d = L1 or d = L∞ , the problem is not α-approximable with α < 2

• Distance function d is a metric iff

(d(x, y) = 0 iff x = y) and d(x, z) 6 d(x, y) + d(y, z)