Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to...
Transcript of Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to...
![Page 1: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/1.jpg)
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)
December 6, 2018
Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms December 6, 2018 1 / 23
![Page 2: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/2.jpg)
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 December 6, 2018 2 / 23
![Page 3: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/3.jpg)
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 December 6, 2018 2 / 23
![Page 4: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/4.jpg)
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 December 6, 2018 2 / 23
![Page 5: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/5.jpg)
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 December 6, 2018 3 / 23
![Page 6: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/6.jpg)
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 December 6, 2018 3 / 23
![Page 7: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/7.jpg)
Competitive Analysis
∀I Alg(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 December 6, 2018 4 / 23
![Page 8: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/8.jpg)
Competitive Analysis
∀I Alg(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 December 6, 2018 4 / 23
![Page 9: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/9.jpg)
Competitive Analysis
∀I Alg(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 December 6, 2018 4 / 23
![Page 10: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/10.jpg)
Competitive Analysis
∀I Alg(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 December 6, 2018 4 / 23
![Page 11: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/11.jpg)
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 December 6, 2018 5 / 23
![Page 12: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/12.jpg)
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 December 6, 2018 5 / 23
![Page 13: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/13.jpg)
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 December 6, 2018 5 / 23
![Page 14: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/14.jpg)
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 December 6, 2018 5 / 23
![Page 15: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/15.jpg)
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 December 6, 2018 5 / 23
![Page 16: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/16.jpg)
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 December 6, 2018 5 / 23
![Page 17: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/17.jpg)
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 December 6, 2018 5 / 23
![Page 18: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/18.jpg)
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 December 6, 2018 5 / 23
![Page 19: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/19.jpg)
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 December 6, 2018 5 / 23
![Page 20: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/20.jpg)
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 December 6, 2018 5 / 23
![Page 21: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/21.jpg)
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 December 6, 2018 5 / 23
![Page 22: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/22.jpg)
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 December 6, 2018 5 / 23
![Page 23: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/23.jpg)
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 and 1 to rent.
We choose the algorithm: Buy on day 10.
The optimal offline algorithm, Opt:d = the number of days we get to stayif 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 at (or 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 December 6, 2018 6 / 23
![Page 24: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/24.jpg)
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 and 1 to rent.
We choose the algorithm: Buy on day 10.
The optimal offline algorithm, Opt:d = the number of days we get to stayif 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 at (or 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 December 6, 2018 6 / 23
![Page 25: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/25.jpg)
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 and 1 to rent.
We choose the algorithm: Buy on day 10.
The optimal offline algorithm, Opt:d = the number of days we get to stayif 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 at (or 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 December 6, 2018 6 / 23
![Page 26: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/26.jpg)
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 and 1 to rent.
We choose the algorithm: Buy on day 10.
The optimal offline algorithm, Opt:d = the number of days we get to stayif 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 at (or 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 December 6, 2018 6 / 23
![Page 27: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/27.jpg)
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 and 1 to rent.
We choose the algorithm: Buy on day 10.
The optimal offline algorithm, Opt:d = the number of days we get to stayif 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 at (or 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 December 6, 2018 6 / 23
![Page 28: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/28.jpg)
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 and 1 to rent.
We choose the algorithm: Buy on day 10.
The optimal offline algorithm, Opt:d = the number of days we get to stayif 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 at (or 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 December 6, 2018 6 / 23
![Page 29: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/29.jpg)
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 and 1 to rent.
We choose the algorithm: Buy on day 10.
The optimal offline algorithm, Opt:d = the number of days we get to stayif 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 at (or 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 December 6, 2018 6 / 23
![Page 30: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/30.jpg)
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 December 6, 2018 7 / 23
![Page 31: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/31.jpg)
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 December 6, 2018 7 / 23
![Page 32: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/32.jpg)
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 December 6, 2018 7 / 23
![Page 33: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/33.jpg)
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 December 6, 2018 7 / 23
![Page 34: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/34.jpg)
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 December 6, 2018 7 / 23
![Page 35: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/35.jpg)
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 December 6, 2018 7 / 23
![Page 36: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/36.jpg)
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 December 6, 2018 7 / 23
![Page 37: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/37.jpg)
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 December 6, 2018 7 / 23
![Page 38: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/38.jpg)
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 December 6, 2018 7 / 23
![Page 39: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/39.jpg)
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 December 6, 2018 7 / 23
![Page 40: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/40.jpg)
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 December 6, 2018 7 / 23
![Page 41: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/41.jpg)
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 December 6, 2018 7 / 23
![Page 42: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/42.jpg)
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 December 6, 2018 7 / 23
![Page 43: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/43.jpg)
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 December 6, 2018 7 / 23
![Page 44: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/44.jpg)
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 December 6, 2018 7 / 23
![Page 45: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/45.jpg)
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 December 6, 2018 8 / 23
![Page 46: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/46.jpg)
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 December 6, 2018 8 / 23
![Page 47: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/47.jpg)
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 December 6, 2018 9 / 23
![Page 48: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/48.jpg)
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 December 6, 2018 10 / 23
![Page 49: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/49.jpg)
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 December 6, 2018 10 / 23
![Page 50: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/50.jpg)
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 December 6, 2018 10 / 23
![Page 51: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/51.jpg)
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 December 6, 2018 10 / 23
![Page 52: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/52.jpg)
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 December 6, 2018 10 / 23
![Page 53: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/53.jpg)
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 December 6, 2018 10 / 23
![Page 54: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/54.jpg)
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 December 6, 2018 10 / 23
![Page 55: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/55.jpg)
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 December 6, 2018 10 / 23
![Page 56: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/56.jpg)
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 December 6, 2018 10 / 23
![Page 57: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/57.jpg)
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 December 6, 2018 11 / 23
![Page 58: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/58.jpg)
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 December 6, 2018 12 / 23
![Page 59: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/59.jpg)
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 December 6, 2018 13 / 23
![Page 60: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/60.jpg)
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 December 6, 2018 13 / 23
![Page 61: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/61.jpg)
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 December 6, 2018 13 / 23
![Page 62: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/62.jpg)
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 December 6, 2018 13 / 23
![Page 63: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/63.jpg)
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 December 6, 2018 13 / 23
![Page 64: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/64.jpg)
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 December 6, 2018 13 / 23
![Page 65: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/65.jpg)
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 December 6, 2018 13 / 23
![Page 66: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/66.jpg)
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 December 6, 2018 13 / 23
![Page 67: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/67.jpg)
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 December 6, 2018 14 / 23
![Page 68: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/68.jpg)
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 December 6, 2018 14 / 23
![Page 69: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/69.jpg)
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 December 6, 2018 14 / 23
![Page 70: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/70.jpg)
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 December 6, 2018 14 / 23
![Page 71: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/71.jpg)
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 December 6, 2018 14 / 23
![Page 72: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/72.jpg)
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 December 6, 2018 14 / 23
![Page 73: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/73.jpg)
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 December 6, 2018 14 / 23
![Page 74: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/74.jpg)
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 December 6, 2018 14 / 23
![Page 75: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/75.jpg)
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 December 6, 2018 14 / 23
![Page 76: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/76.jpg)
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 December 6, 2018 14 / 23
![Page 77: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/77.jpg)
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 December 6, 2018 14 / 23
![Page 78: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/78.jpg)
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 December 6, 2018 14 / 23
![Page 79: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/79.jpg)
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 December 6, 2018 14 / 23
![Page 80: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/80.jpg)
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 December 6, 2018 14 / 23
![Page 81: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/81.jpg)
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 December 6, 2018 14 / 23
![Page 82: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/82.jpg)
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 December 6, 2018 14 / 23
![Page 83: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/83.jpg)
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 December 6, 2018 15 / 23
![Page 84: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/84.jpg)
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 December 6, 2018 15 / 23
![Page 85: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/85.jpg)
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 December 6, 2018 16 / 23
![Page 86: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/86.jpg)
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 December 6, 2018 17 / 23
![Page 87: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/87.jpg)
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 December 6, 2018 18 / 23
![Page 88: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/88.jpg)
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 December 6, 2018 19 / 23
![Page 89: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/89.jpg)
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 December 6, 2018 19 / 23
![Page 90: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/90.jpg)
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 December 6, 2018 19 / 23
![Page 91: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/91.jpg)
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 December 6, 2018 19 / 23
![Page 92: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/92.jpg)
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 December 6, 2018 19 / 23
![Page 93: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/93.jpg)
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 December 6, 2018 19 / 23
![Page 94: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/94.jpg)
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 December 6, 2018 19 / 23
![Page 95: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/95.jpg)
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 December 6, 2018 19 / 23
![Page 96: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/96.jpg)
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 December 6, 2018 19 / 23
![Page 97: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/97.jpg)
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 December 6, 2018 20 / 23
![Page 98: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/98.jpg)
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 December 6, 2018 20 / 23
![Page 99: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/99.jpg)
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 December 6, 2018 20 / 23
![Page 100: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/100.jpg)
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 December 6, 2018 20 / 23
![Page 101: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/101.jpg)
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 December 6, 2018 20 / 23
![Page 102: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/102.jpg)
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 December 6, 2018 20 / 23
![Page 103: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/103.jpg)
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 December 6, 2018 20 / 23
![Page 104: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/104.jpg)
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 December 6, 2018 20 / 23
![Page 105: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/105.jpg)
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 December 6, 2018 20 / 23
![Page 106: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/106.jpg)
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 December 6, 2018 20 / 23
![Page 107: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/107.jpg)
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 December 6, 2018 20 / 23
![Page 108: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/108.jpg)
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 December 6, 2018 21 / 23
![Page 109: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/109.jpg)
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 December 6, 2018 22 / 23
![Page 110: Online Algorithms [2ex] a topic in [2ex] DM534 Introduction to …rolf/Edu/DM534/E18/lectureOnline.pdf · 2018. 12. 12. · Online Algorithms a topic in DM534 { Introduction to Computer](https://reader035.fdocuments.us/reader035/viewer/2022071108/5fe3156e4886bf08db3c22a3/html5/thumbnails/110.jpg)
IMADA People in Online Algorithms
Online Algorithms
Joan BoyarOnline algorithms, combinatorialoptimization, cryptology, computationalcomplexity
Lene Monrad Favrholdt Online algorithms, graph algorithms
Kim Skak LarsenOnline algorithms, algorithms and datastructures, database systems, semantics
Christian Kudahl Online algorithms
Caroline Berntsen Knudsen Online algorithms
Kim Skak Larsen (IMADA) DM534 topic: Online Algorithms December 6, 2018 23 / 23