Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online...

110
Online Algorithms a topic in DM534 – Introduction to Computer Science Kim Skak Larsen Department of Mathematics and Computer Science (IMADA) University of Southern Denmark (SDU) [email protected] November 17, 2016 Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 1 / 23

Transcript of Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online...

Page 1: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Online Algorithms

a topic in

DM534 – Introduction to Computer Science

Kim Skak Larsen

Department of Mathematics and Computer Science (IMADA)University of Southern Denmark (SDU)

[email protected]

November 17, 2016

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 1 / 23

Page 2: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

A highly skilled, successful computer scientist is rewarded a ski vacation untilher company desperately needs her again, at which point she is called homeimmediately, being notified when she wakes up in the morning.

At the ski resort, skis cost 10 units in the local currency.

One can rent skis for 1 unit per day.

Of course, if she buys, she doesn’t have to rent anymore.

Which algorithm does she employ to minimize her spending?

What is a good algorithm?

How do we measure if it’s a good algorithm?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 2 / 23

Page 3: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

A highly skilled, successful computer scientist is rewarded a ski vacation untilher company desperately needs her again, at which point she is called homeimmediately, being notified when she wakes up in the morning.

At the ski resort, skis cost 10 units in the local currency.

One can rent skis for 1 unit per day.

Of course, if she buys, she doesn’t have to rent anymore.

Which algorithm does she employ to minimize her spending?

What is a good algorithm?

How do we measure if it’s a good algorithm?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 2 / 23

Page 4: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

A highly skilled, successful computer scientist is rewarded a ski vacation untilher company desperately needs her again, at which point she is called homeimmediately, being notified when she wakes up in the morning.

At the ski resort, skis cost 10 units in the local currency.

One can rent skis for 1 unit per day.

Of course, if she buys, she doesn’t have to rent anymore.

Which algorithm does she employ to minimize her spending?

What is a good algorithm?

How do we measure if it’s a good algorithm?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 2 / 23

Page 5: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

Competitive analysis is one way to measure the quality of an online algorithm.

Idea:

Let Opt denote an optimal offline algorithm.

“Offline” means getting the entire input before having to compute.

This corresponds to knowing the future!

We calculate how well we perform compared to Opt.

Notation:

Alg(I ) denote the result of running an algorithm Alg on the input sequence I .

Thus, Opt(I ) is the result of running Opt on I .

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 3 / 23

Page 6: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

Competitive analysis is one way to measure the quality of an online algorithm.

Idea:

Let Opt denote an optimal offline algorithm.

“Offline” means getting the entire input before having to compute.

This corresponds to knowing the future!

We calculate how well we perform compared to Opt.

Notation:

Alg(I ) denote the result of running an algorithm Alg on the input sequence I .

Thus, Opt(I ) is the result of running Opt on I .

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 3 / 23

Page 7: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

∀IAlg(I )Opt(I ) ≤ c

An algorithm, Alg, is c-competitive if

∀I :Alg(I )

Opt(I )≤ c .

Alg has competitive ratio c if

c is the best (smallest) c for which Alg is c-competitive.

Technically, the definition of being c-competitive is that ∃b ∀I : Alg(I ) ≤ c Opt(I ) + b, but the additive term, b, does not become relevant for whatwe consider. Also not relevant today, a best c does not necessarily exist, so the competitive ratio is inf {c | Alg is c-competitive}.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 4 / 23

Page 8: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

∀IAlg(I )Opt(I ) ≤ c

An algorithm, Alg, is c-competitive if

∀I :Alg(I )

Opt(I )≤ c .

Alg has competitive ratio c if

c is the best (smallest) c for which Alg is c-competitive.

Technically, the definition of being c-competitive is that ∃b ∀I : Alg(I ) ≤ c Opt(I ) + b, but the additive term, b, does not become relevant for whatwe consider. Also not relevant today, a best c does not necessarily exist, so the competitive ratio is inf {c | Alg is c-competitive}.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 4 / 23

Page 9: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

∀IAlg(I )Opt(I ) ≤ c

An algorithm, Alg, is c-competitive if

∀I :Alg(I )

Opt(I )≤ c .

Alg has competitive ratio c if

c is the best (smallest) c for which Alg is c-competitive.

Technically, the definition of being c-competitive is that ∃b ∀I : Alg(I ) ≤ c Opt(I ) + b, but the additive term, b, does not become relevant for whatwe consider. Also not relevant today, a best c does not necessarily exist, so the competitive ratio is inf {c | Alg is c-competitive}.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 4 / 23

Page 10: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

∀IAlg(I )Opt(I ) ≤ c

An algorithm, Alg, is c-competitive if

∀I :Alg(I )

Opt(I )≤ c .

Alg has competitive ratio c if

c is the best (smallest) c for which Alg is c-competitive.

Technically, the definition of being c-competitive is that ∃b ∀I : Alg(I ) ≤ c Opt(I ) + b, but the additive term, b, does not become relevant for whatwe consider. Also not relevant today, a best c does not necessarily exist, so the competitive ratio is inf {c | Alg is c-competitive}.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 4 / 23

Page 11: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day

rent

it’s a new day rent...

...

it’s a new day rent

it’s a new day buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 12: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day rent...

...

it’s a new day rent

it’s a new day buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 13: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day

rent...

...

it’s a new day rent

it’s a new day buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 14: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day rent

......

it’s a new day rent

it’s a new day buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 15: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day rent...

...

it’s a new day

rent

it’s a new day buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 16: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day rent...

...

it’s a new day rent

it’s a new day buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 17: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day rent...

...

it’s a new day rent

it’s a new day

buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 18: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day rent...

...

it’s a new day rent

it’s a new day buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 19: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day rent...

...

it’s a new day rent

it’s a new day buy

it’s a new day

do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 20: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day rent...

...

it’s a new day rent

it’s a new day buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 21: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day rent...

...

it’s a new day rent

it’s a new day buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 22: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

We have a very simple request sequence with very simple responses:

input sequence decision

it’s a new day rent

it’s a new day rent...

...

it’s a new day rent

it’s a new day buy

it’s a new day do nothing

it’s a new day do nothing...

...

come home go home

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 5 / 23

Page 23: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

So all reasonable algorithms are of the form Buy on day X (or never buy).

Reminder: It costs 10 to buy skis.

We choose the algorithm: Buy on day 10.

The optimal offline algorithm, Opt:d = the day we are called homeif d < 10:

rent every dayelse: # d ≥ 10

buy on day 1

If we are called home before day 10, we are optimal!

Our cost: d < 10.Opt’s cost: d .

In the worst case, we are called home (any time) after day 10:

Our cost: 9 + 10.Opt’s cost: 10.

Result: we perform at most 1910 < 2 times worse than Opt.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 6 / 23

Page 24: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

So all reasonable algorithms are of the form Buy on day X (or never buy).

Reminder: It costs 10 to buy skis.

We choose the algorithm: Buy on day 10.

The optimal offline algorithm, Opt:d = the day we are called homeif d < 10:

rent every dayelse: # d ≥ 10

buy on day 1

If we are called home before day 10, we are optimal!

Our cost: d < 10.Opt’s cost: d .

In the worst case, we are called home (any time) after day 10:

Our cost: 9 + 10.Opt’s cost: 10.

Result: we perform at most 1910 < 2 times worse than Opt.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 6 / 23

Page 25: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

So all reasonable algorithms are of the form Buy on day X (or never buy).

Reminder: It costs 10 to buy skis.

We choose the algorithm: Buy on day 10.

The optimal offline algorithm, Opt:d = the day we are called homeif d < 10:

rent every dayelse: # d ≥ 10

buy on day 1

If we are called home before day 10, we are optimal!

Our cost: d < 10.Opt’s cost: d .

In the worst case, we are called home (any time) after day 10:

Our cost: 9 + 10.Opt’s cost: 10.

Result: we perform at most 1910 < 2 times worse than Opt.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 6 / 23

Page 26: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

So all reasonable algorithms are of the form Buy on day X (or never buy).

Reminder: It costs 10 to buy skis.

We choose the algorithm: Buy on day 10.

The optimal offline algorithm, Opt:d = the day we are called homeif d < 10:

rent every dayelse: # d ≥ 10

buy on day 1

If we are called home before day 10, we are optimal!

Our cost: d < 10.Opt’s cost: d .

In the worst case, we are called home (any time) after day 10:

Our cost: 9 + 10.Opt’s cost: 10.

Result: we perform at most 1910 < 2 times worse than Opt.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 6 / 23

Page 27: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

So all reasonable algorithms are of the form Buy on day X (or never buy).

Reminder: It costs 10 to buy skis.

We choose the algorithm: Buy on day 10.

The optimal offline algorithm, Opt:d = the day we are called homeif d < 10:

rent every dayelse: # d ≥ 10

buy on day 1

If we are called home before day 10, we are optimal!

Our cost: d < 10.Opt’s cost: d .

In the worst case, we are called home (any time) after day 10:

Our cost: 9 + 10.Opt’s cost: 10.

Result: we perform at most 1910 < 2 times worse than Opt.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 6 / 23

Page 28: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

So all reasonable algorithms are of the form Buy on day X (or never buy).

Reminder: It costs 10 to buy skis.

We choose the algorithm: Buy on day 10.

The optimal offline algorithm, Opt:d = the day we are called homeif d < 10:

rent every dayelse: # d ≥ 10

buy on day 1

If we are called home before day 10, we are optimal!

Our cost: d < 10.Opt’s cost: d .

In the worst case, we are called home (any time) after day 10:

Our cost: 9 + 10.Opt’s cost: 10.

Result: we perform at most 1910 < 2 times worse than Opt.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 6 / 23

Page 29: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Ski Rental – a simplest online problem

So all reasonable algorithms are of the form Buy on day X (or never buy).

Reminder: It costs 10 to buy skis.

We choose the algorithm: Buy on day 10.

The optimal offline algorithm, Opt:d = the day we are called homeif d < 10:

rent every dayelse: # d ≥ 10

buy on day 1

If we are called home before day 10, we are optimal!

Our cost: d < 10.Opt’s cost: d .

In the worst case, we are called home (any time) after day 10:

Our cost: 9 + 10.Opt’s cost: 10.

Result: we perform at most 1910 < 2 times worse than Opt.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 6 / 23

Page 30: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 31: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive?

Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 32: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 33: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive?

Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 34: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 35: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive?

Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 36: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 37: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive?

No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 38: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 39: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ?

Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 40: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 41: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2?

No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 42: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 43: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5?

No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 44: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis

In general, we want to define good algorithms for online problems and prove thatthey are good.

The ratio ( 1910 ) from ski rental is a guarantee:

That algorithm never performs worse than 1910 times Opt.

Is our algorithm 1910 -competitive? Yes

Is our algorithm also 2-competitive? Yes

Is our algorithm also 42-competitive? Yes

Is our algorithm 1.5-competitive? No

Does our algorithm have competitive ratio 1910 ? Yes

Does our algorithm have competitive ratio 2? No

Does our algorithm have competitive ratio 1.5? No

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 7 / 23

Page 45: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Online Problems

So, what characterizes an online problem?

Input arrives one request at a time.

For each request, we have to make an irrevocable decision.

We want to minimize cost.

Sometimes we want to maximize a profit instead of minimizing a cost and there are some technicalities in adjusting definitions to accommodate thatpossibility.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 8 / 23

Page 46: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Online Problems

So, what characterizes an online problem?

Input arrives one request at a time.

For each request, we have to make an irrevocable decision.

We want to minimize cost.

Sometimes we want to maximize a profit instead of minimizing a cost and there are some technicalities in adjusting definitions to accommodate thatpossibility.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 8 / 23

Page 47: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling

m ≥ 1 machines.

n jobs of varying sizes arriving one at a time to be assigned to a machine.

The goal is to minimize makespan, i.e., finish all jobs as early as possible.

Algorithm List Scheduling (Ls): place next job on the least loaded machine.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 9 / 23

Page 48: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3

4

4

7

7

14 5

34

7

M1 M2 M3 M4

Ls

10 Is 10 a good result?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 10 / 23

Page 49: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

14

4

5

5

3

3

4

4

7

7

1

4 53

4

7

M1 M2 M3 M4

Ls

10 Is 10 a good result?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 10 / 23

Page 50: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4 5

5

3

3

4

4

7

7

14

53

4

7

M1 M2 M3 M4

Ls

10 Is 10 a good result?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 10 / 23

Page 51: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

53

3

4

4

7

7

14 5

34

7

M1 M2 M3 M4

Ls

10 Is 10 a good result?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 10 / 23

Page 52: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3 4

4

7

7

14 5

3

4

7

M1 M2 M3 M4

Ls

10 Is 10 a good result?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 10 / 23

Page 53: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3

4

47

7

14 5

34

7

M1 M2 M3 M4

Ls

10 Is 10 a good result?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 10 / 23

Page 54: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3

4

4

7

7

14 5

34

7

M1 M2 M3 M4

Ls

10 Is 10 a good result?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 10 / 23

Page 55: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3

4

4

7

7

14 5

34

7

M1 M2 M3 M4

Ls

10

Is 10 a good result?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 10 / 23

Page 56: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3

4

4

7

7

14 5

34

7

M1 M2 M3 M4

Ls

10 Is 10 a good result?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 10 / 23

Page 57: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

On some sequences, 10 is a good result.

On some sequences, 1.000.000 is a good result.

Sometimes 1000 is a bad result.

It depends on what is possible, i.e., how large or “difficult” the input is.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 11 / 23

Page 58: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Competitive Analysis – why Opt?

Opt is not an online algorithm.

However, it is a natural reference point:

Our online algorithms cannot perform better than Opt.

As input sequences I get harder, Opt(I ) typically grows, so a comparison toOpt remains somewhat reasonable.

Formally:

For any Alg and any I ,Alg(I )

Opt(I )≥ 1.

We want to design algorithms with smallest possible competitive ratio.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 12 / 23

Page 59: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3

4

4

7

7

14 5

34

7

M1 M2 M3 M4

Ls

14 5

3

4 7

M1 M2 M3 M4

Opt

107

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 13 / 23

Page 60: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

14

4

5

5

3

3

4

4

7

7

1

4 53

4

7

M1 M2 M3 M4

Ls

1

4 5

3

4 7

M1 M2 M3 M4

Opt

107

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 13 / 23

Page 61: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4 5

5

3

3

4

4

7

7

14

53

4

7

M1 M2 M3 M4

Ls

14

5

3

4 7

M1 M2 M3 M4

Opt

107

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 13 / 23

Page 62: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

53

3

4

4

7

7

14 5

34

7

M1 M2 M3 M4

Ls

14 5

3

4 7

M1 M2 M3 M4

Opt

107

What does Opt do now?

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 13 / 23

Page 63: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3 4

4

7

7

14 5

3

4

7

M1 M2 M3 M4

Ls

14 5

3

4 7

M1 M2 M3 M4

Opt

107

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 13 / 23

Page 64: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3

4

47

7

14 5

34

7

M1 M2 M3 M4

Ls

14 5

3

4

7

M1 M2 M3 M4

Opt

107

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 13 / 23

Page 65: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3

4

4

7

7

14 5

34

7

M1 M2 M3 M4

Ls

14 5

3

4 7

M1 M2 M3 M4

Opt

107

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 13 / 23

Page 66: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – List Scheduling example

1

1

4

4

5

5

3

3

4

4

7

7

14 5

34

7

M1 M2 M3 M4

Ls

14 5

3

4 7

M1 M2 M3 M4

Opt

107

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 13 / 23

Page 67: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11 1 1 11 1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1 11 1 11 1 1

4m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 68: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1 1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1

1 1 11 1 1 11 1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1

1 11 1 11 1 11 1 1

4m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 69: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1 1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1

1 11 1 1 11 1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1

11 1 11 1 11 1 1

4m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 70: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1 1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1

11 1 1 11 1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 1

1 1 11 1 11 1 1

4m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 71: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1 1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 1

1 1 1 11 1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11

1 11 1 11 1 1

4m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 72: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1 1

1

1

1

1

1

1

1

1

1

1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11

1 1 11 1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1

11 1 11 1 1

4m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 73: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1 1

1

1

1

1

1

1

1

1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11 1

1 11 1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1 1

1 1 11 1 1

4m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 74: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1

1

1 1

1

1

1

1

1

1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11 1 1

11 1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1 11

1 11 1 1

4m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 75: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1 1

1

1

1

1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11 1 1 1

1 1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1 11 1

11 1 1

4m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 76: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1 1

1

1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11 1 1 11

1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1 11 1 1

1 1 14m

74

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 77: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1 1

1

1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11 1 1 11 1

1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1 11 1 11

1 14m

74

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 78: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1 1

1

4

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11 1 1 11 1 1

1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1 11 1 11 1

14m

74

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 79: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

14

4m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11 1 1 11 1 1 1

4m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1 11 1 11 1 1

4m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 80: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

4

4

m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11 1 1 11 1 1 1

4

m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1 11 1 11 1 1

4

m7

4

(m − 1)m

m − 1

m

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 81: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

4

4

m

M1 M2 M3 M4

. . . Mm

Ls

1 1 1 11 1 1 11 1 1 1

4

m

M1 M2 M3 M4

. . . Mm

Opt

1 1 11 1 11 1 11 1 1

4

m

74

(m − 1)m

m − 1

m

m

Thus,Alg(I )

Opt(I )=

7

4= 2− 1

4

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 82: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is at best (2− 1m)-competitive

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

44

m

M1 M2

M3 M4

. . . Mm

Ls

1 1 1 11 1 1 11 1 1 1

4

m

M1 M2

M3 M4

. . . Mm

Opt

1 1 11 1 11 1 11 1 1

4

m

74

(m − 1)m

m − 1

m

m

In general,Alg(I )

Opt(I )≥ (m − 1) + m

m=

2m − 1

m= 2− 1

m

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 14 / 23

Page 83: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling - proof techniques

You have just seen a

lower bound proof

In our context, that is relatively easy: Just demonstrate an example (family ofexamples), where the algorithm performs worse than some ratio.

Now we want to show the much harder

upper bound proof

We must show that it is never worse than a given ratio for any of the (potentiallyinfinitely many) possible input sequences.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 15 / 23

Page 84: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling - proof techniques

You have just seen a

lower bound proof

In our context, that is relatively easy: Just demonstrate an example (family ofexamples), where the algorithm performs worse than some ratio.

Now we want to show the much harder

upper bound proof

We must show that it is never worse than a given ratio for any of the (potentiallyinfinitely many) possible input sequences.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 15 / 23

Page 85: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling – Ls is (2− 1m)-competitive

1 2 m

V

t

`

Ls

t ends at the makespan and start at `

tmax is the length of the longest job

T is the total length of all jobs

Opt ≥ T/m

Opt ≥ tmax

V = ` ·mT ≥ V + t, due to Ls’s choice for t

Ls = ` + t

≤ T−tm + t, since ` = V

m and V ≤ T − t

= Tm + (1− 1

m )t

≤ Tm + (1− 1

m )tmax

≤ Opt+(1− 1m )Opt, from Opt inequalities above

= (2− 1m )Opt

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 16 / 23

Page 86: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Machine Scheduling

Since we have both an upper and lower bound, we have shown the following:

TheoremThe algorithm Ls for minimizing makespan in machine scheduling with m ≥ 1machines has competitive ratio 2− 1

m .

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 17 / 23

Page 87: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing

Unbounded supply of bins of size 1.

n items, each of size strictly between zero and one, to be placed in a bin.

Obviously, the items placed in any given bin cannot be larger than 1 in total.

The goal is to minimize the number of bins used.

Algorithm First-Fit (Ff): place next item in the first bin with enough space.The ordering of the bins is determined by the first time they receive an item.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 18 / 23

Page 88: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – Ff example

0.2

0.2

0.5

0.5

0.4

0.4

0.7

0.7

0.1

0.1

0.3

0.3

0.8

0.8

0.2

0.5

0.4

0.7

0.1

0.3

0.8

Ff

4

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 19 / 23

Page 89: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – Ff example

0.2

0.2

0.5

0.5

0.4

0.4

0.7

0.7

0.1

0.1

0.3

0.3

0.8

0.8

0.2

0.5

0.4

0.7

0.1

0.3

0.8

Ff

4

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 19 / 23

Page 90: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – Ff example

0.2

0.2

0.5

0.5 0.4

0.4

0.7

0.7

0.1

0.1

0.3

0.3

0.8

0.8

0.2

0.5

0.4

0.7

0.1

0.3

0.8

Ff

4

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 19 / 23

Page 91: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – Ff example

0.2

0.2

0.5

0.5

0.4

0.4

0.7

0.7

0.1

0.1

0.3

0.3

0.8

0.8

0.2

0.5

0.4

0.7

0.1

0.3

0.8

Ff

4

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 19 / 23

Page 92: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – Ff example

0.2

0.2

0.5

0.5

0.4

0.4

0.7

0.7

0.1

0.1

0.3

0.3

0.8

0.8

0.2

0.5

0.4

0.7

0.1

0.3

0.8

Ff

4

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 19 / 23

Page 93: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – Ff example

0.2

0.2

0.5

0.5

0.4

0.4

0.7

0.7

0.1

0.10.3

0.3

0.8

0.8

0.2

0.5

0.4

0.7

0.1

0.3

0.8

Ff

4

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 19 / 23

Page 94: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – Ff example

0.2

0.2

0.5

0.5

0.4

0.4

0.7

0.7

0.1

0.1

0.3

0.3

0.8

0.8

0.2

0.5

0.4

0.7

0.1

0.3

0.8

Ff

4

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 19 / 23

Page 95: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – Ff example

0.2

0.2

0.5

0.5

0.4

0.4

0.7

0.7

0.1

0.1

0.3

0.3

0.8

0.8

0.2

0.5

0.4

0.7

0.1

0.3

0.8

Ff

4

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 19 / 23

Page 96: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – Ff example

0.2

0.2

0.5

0.5

0.4

0.4

0.7

0.7

0.1

0.1

0.3

0.3

0.8

0.8

0.2

0.5

0.4

0.7

0.1

0.3

0.8

Ff

4

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 19 / 23

Page 97: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/2

1/2

1/2

1/2

1/2

1/2

1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/31/3

1/31/3

1/2 1/2 1/2 1/2 1/3 1/3 1/3 1/3

1/2 1/2 1/2 1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 98: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3 1/3

1/3

1/3

1/3

1/3

1/3

1/2

1/2

1/2

1/2

1/2

1/2

1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/3

1/31/31/3

1/2 1/2 1/2 1/2

1/3

1/3 1/3 1/3

1/2 1/2 1/2 1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 99: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3

1/3

1/3 1/3

1/3

1/3

1/3

1/2

1/2

1/2

1/2

1/2

1/2

1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/31/3

1/31/3

1/2 1/2 1/2 1/2

1/3 1/3

1/3 1/3

1/2 1/2 1/2 1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 100: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3

1/3

1/3

1/3

1/3 1/3

1/3

1/2

1/2

1/2

1/2

1/2

1/2

1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/31/3

1/3

1/31/2 1/2 1/2 1/2

1/3 1/3 1/3

1/3

1/2 1/2 1/2 1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 101: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/3 1/2

1/2

1/2

1/2

1/2

1/2

1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/31/3

1/31/3

1/2 1/2 1/2 1/2

1/3 1/3 1/3 1/3

1/2 1/2 1/2 1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 102: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/2

1/2 1/2

1/2

1/2

1/2

1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/31/3

1/31/3

1/2

1/2 1/2 1/2

1/3 1/3 1/3 1/3

1/2

1/2 1/2 1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 103: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/2

1/2

1/2

1/2 1/2

1/2

1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/31/3

1/31/3

1/2 1/2

1/2 1/2

1/3 1/3 1/3 1/3

1/2 1/2

1/2 1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 104: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/2

1/2

1/2

1/2

1/2

1/2 1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/31/3

1/31/3

1/2 1/2 1/2

1/2

1/3 1/3 1/3 1/3

1/2 1/2 1/2

1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 105: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/2

1/2

1/2

1/2

1/2

1/2

1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/31/3

1/31/3

1/2 1/2 1/2 1/2 1/3 1/3 1/3 1/3

1/2 1/2 1/2 1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 106: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/2

1/2

1/2

1/2

1/2

1/2

1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/31/3

1/31/3

1/2 1/2 1/2 1/2 1/3 1/3 1/3 1/3

1/2 1/2 1/2 1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 107: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – simple lower bound against Ff

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/3

1/2

1/2

1/2

1/2

1/2

1/2

1/2

1/2

All items are slightly larger than the indicated fraction, e.g., 13 + 1

1000 .

1/31/3

1/31/3

1/2 1/2 1/2 1/2 1/3 1/3 1/3 1/3

1/2 1/2 1/2 1/2

Ff Opt

3n4

n2

n

Thus,Ff(I )

Opt(I )≥

n4 + n

2n2

=3

2

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 20 / 23

Page 108: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

Bin Packing – First-Fit

Ff has been shown to be 1.7-competitive [hard].Thus, the competitive ratio is at most 1.7.

We have just shown that the competitive ratio is at least 1.5.

So, the competitive ratio of Ff is in the interval [1.5, 1.7].

We’ll approach the precise value in the exercises.

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 21 / 23

Page 109: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

How To Learn More

You’ll meet online algorithms in courses, without necessarily being told that theyare online problems.A formal treatment of this topic is somewhat abstract and heavy on proofs, andmore appropriate for the MS level. At that point, you can take the course

DM860: Online Algorithms

or read

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 22 / 23

Page 110: Online Algorithms [2ex] a topic in [2ex] DM534 ...rolf/Edu/DM534/E16/lectureOnline.pdf · Online Algorithms a topic in DM534 { Introduction to Computer Science Kim Skak Larsen Department

IMADA People in Online Algorithms

Online Algorithms

Joan BoyarOnline algorithms, combinatorialoptimization, cryptology, data structures,computational complexity

Lene Monrad Favrholdt Online algorithms, graph algorithms

Kim Skak LarsenOnline algorithms, algorithms and datastructures, database systems, semantics

Christian Kudahl Online algorithms

Jesper With Mikkelsen Online algorithms

Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms November 17, 2016 23 / 23