comp 7720 - online algorithms online bin packingkamalis/cmp7720/l22handout.pdfcomp 7720 - online...

22
COMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University of Manitoba COMP 7720 - Online Algorithms Online Bin Packing 1/1

Upload: trantu

Post on 21-May-2018

261 views

Category:

Documents


9 download

TRANSCRIPT

Page 1: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

COMP 7720 - Online Algorithms

Online Bin Packing

Shahin Kamali

Lecture 22 - Nov. 23rd, 2017

University of Manitoba

COMP 7720 - Online Algorithms Online Bin Packing 1 / 1

Page 2: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Review & Plan

COMP 7720 - Online Algorithms Online Bin Packing 1 / 1

Page 3: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Today’s plan

Logistics

Online bin packing with advice

Online Edge-coloring

COMP 7720 - Online Algorithms Online Bin Packing 2 / 1

Page 4: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Logistics

Assignment 3 is posted

It is due on Saturday November 25th (8 pm).

Project presentation day is on Thursday 30th (next Thursday)

Present the problem and partial results/insights that you have5-7 minutes for individual projects and 7-9 minutes for projects of 2students

Final exam is on Thursday, December 7th (last day of class).

Project final report is due December21st.

COMP 7720 - Online Algorithms Online Bin Packing 3 / 1

Page 5: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

ReserveCritical Algorithm

At the beginning, reserve a space of size 2/3 for critical items

huge items: open a new bin (no other item goes there)critical items: place in a reserve spacemini item: place two of them in the same bin (no other item goesthere)tiny items: apply FF to place in bins with critical or other tiny items

σ = 〈 0.3 0.9 0.6 0.5 0.1 0.1 0.56 0.4 0.3 0.45 0.8 0.51 0.41 0.2 0.1 0.37 0.3 〉

COMP 7720 - Online Algorithms Online Bin Packing 4 / 1

Page 6: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

ReserveCritical algorithm

Theorem

Competitive ratio of ReserveCritical is at most 1.5.

With O(log n) bits of advice, one can achieve a competitive ratio of1.5

Can we improve this?

COMP 7720 - Online Algorithms Online Bin Packing 5 / 1

Page 7: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

RedBlue Algorithm (sketch)

Instead of receiving the number of critical items in O(log n) bits,receive the ratio between critical and tiny bins in the final packingof ReserveCritical

Treat Huge and mini items as before

Place a critical item in the reserved space of a critical bin; if noreserve space exists, open a new bin and declare it as critical

Place a tiny item in non-reserved space of critical bins (using FF)

If no such bin exists, open a new binDeclare the new bin to be a critical or a tiny bin so that the ratiobetween the number of these bins becomes closer to the ratioreceived in advice

COMP 7720 - Online Algorithms Online Bin Packing 6 / 1

Page 8: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

RedBlue Algorithm (sketch)

If the ratio between critical and tiny bins is encoded using k bits ofadvice, RedBlue algorithm has a competitive ratio of at most1.5 + 15

2k/2+1

Theorem

With constant number of bits of advice, one can achieve a com-petitive ratio of (almost) 1.5.

Can we do better?

COMP 7720 - Online Algorithms Online Bin Packing 7 / 1

Page 9: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Power of Advice of Constant Size

In fact, with a more complicated argument, we can show that withadvice of constant size, one can achieve a competitive ratio of 1.47

Idea: pack items of size larger than 1/3 separately from the rest.

How advice can help in packing items of size larger than 1/3?

COMP 7720 - Online Algorithms Online Bin Packing 8 / 1

Page 10: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Power of Advice of Constant Size

It is often useful to think of algorithms that ‘complement’ each other

Assume all items are larger than 1/3:

Sbf: All small items (< 1/2) are packed according to BestFit, andeach large item (≥ 1/2) is placed in a new bin.Lbf: All large items are packed according to BestFit, and each smallitem is placed in a new bin.

σ = 〈0.45 0.6 0.75 0.34 0.40 0.56 0.35 0.55 0.50〉

COMP 7720 - Online Algorithms Online Bin Packing 9 / 1

Page 11: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Power of Advice of Constant Size

Theorem

When all items are larger than 1/3, the better algorithm amongSbf and Lbf has a competitive ratio of 1.39.

With only one bit of advice, one can achieve a competitive ratio of1.39 (when all items are larger than 1/3).

COMP 7720 - Online Algorithms Online Bin Packing 10 / 1

Page 12: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Lower bound

Advice of size Ω(n) is required to achieve an algorithm with c.r.≤ 9/8

A reduction from binary guessing problem

Consider

σ = 〈0.5 + ε, . . . 0.5 + ε,︸ ︷︷ ︸m green items

a1, a2, a3 . . . , a2m,︸ ︷︷ ︸white items in range(1/3,1/2]

b1, . . . bm︸ ︷︷ ︸complements of smaller white items

The algorithm should ‘guess’ whether each white item is among thelarger half of smaller half of white items!

COMP 7720 - Online Algorithms Online Bin Packing 11 / 1

Page 13: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Lower bound〈0.51, . . . , 0.51,︸ ︷︷ ︸

m green items

0.42, 0.37, 0.4, 0.39, 0.38, 0.385, 0.388, 0.386︸ ︷︷ ︸2m white items

, 0.63, 0.62, 0.615, 0.614︸ ︷︷ ︸red complements

Guess if an item is among smaller or larger half of white items

open a new bin for smaller half of white items (in anticipation oftheir complements coming in the future)for the larger half of white items, put them with green items

The ‘type’ (being in smaller or larger half) of the white item cannotbe revealed from knowing types of previous white items

For any four mistakes in guessing, at least 1 extra bin is opened

COMP 7720 - Online Algorithms Online Bin Packing 12 / 1

Page 14: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Lower bound

Theorem

In order to achieve a competitive ratio better than 9/8, adviceof linear size is required

This result can be improved to show that for a competitive ratiobetter than 4− 2

√2 ≈ 1.172, a linear number of bits are required.

COMP 7720 - Online Algorithms Online Bin Packing 13 / 1

Page 15: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

General Picture for Advice Complexity of BinPacking

With Θ(n logN) bits, one can achieve an optimal solutionBoyKamSTACS.

With Θ(log n) bits, one can achieve a competitive ratio of 1.5(better than all online algorithms)

With linear number bits, one can achieve a competitive ratio of 4/3

For a competitive ratio better than 9/8, a linear number of bits arerequired BoyKamSTACS.

With linear number bits, one can achieve a competitive ratio of 1.0

With k ≥ 4 bits, one can get a competitive ratio of 1.5 + 152k/2+1

With Θ(1) bits, one can get a competitive ratio of 1.4702

For a competitive ratio better than 7/6, a linear number of bits arerequired

For a competitive ratio better than 4− 2√

2 ≈ 1.172, a linearnumber of bits are required

COMP 7720 - Online Algorithms Online Bin Packing 14 / 1

Page 16: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

General Picture for Advice Complexity of BinPacking

12

adv

ice

siz

e

56

78

10

4

9

advice size

competitive ratio

1.7

1.58171.5403

1.172

7/6 1.666

9/8 = 1.125

1.5

1.47012

Θ (log n) Θ (n)

4/3 1.333

Ω (n) Θ (n log N)16big

constant

COMP 7720 - Online Algorithms Online Bin Packing 15 / 1

Page 17: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Online Edge Coloring in Graphs

COMP 7720 - Online Algorithms Online Bin Packing 15 / 1

Page 18: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Problem Definition

In edge coloring, the goal is to color edges of a graph with minimumnumber of colors

No two adjacent edges (edges sharing an endpoint) should have thesame color

In the offline setting, the problem is NP-hard!

For a graph of degree ∆, at least ∆ and at most ∆ + 1 colors arerequired (Vizing theorem)

this implies that cost(Opt) ≈ ∆

COMP 7720 - Online Algorithms Online Bin Packing 16 / 1

Page 19: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Problem Definition

In the online setting, edges arrive one by one, and an algorithmshould take an irrevocable decision on coloring the edges withoutany knowledge about future edges (or how graph looks).

For example, Greedy family of algorithms maintain a set of colorsand use them, if possible, before requesting a new coloring

cost of Opt is 3

Cost of Greedy is 4, which is not optimal

COMP 7720 - Online Algorithms Online Bin Packing 17 / 1

Page 20: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Greedy Algorithm

For a graph of degree ∆, a Greedy algorithm uses at most 2∆− 1colors.

Assume otherwise, so, there is an edge e with color 2∆.Assume the two endpoints of e have degrees a and b before addinge (we have a, b < ∆).Greedy uses at most a and b distinct colors for edges adjacent to e.So, e can be colored using color a + b + 1 < 2∆ → contradiction.

COMP 7720 - Online Algorithms Online Bin Packing 18 / 1

Page 21: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Greedy algorithm

Theorem

Greedy has a competitive ratio of at most 2.

For any graph of degree ∆, cost of Opt is at least ∆.

Cost of greedy is at most 2∆− 1.

COMP 7720 - Online Algorithms Online Bin Packing 19 / 1

Page 22: COMP 7720 - Online Algorithms Online Bin Packingkamalis/cmp7720/l22handout.pdfCOMP 7720 - Online Algorithms Online Bin Packing Shahin Kamali Lecture 22 - Nov. 23rd, 2017 University

Lower Bound

Theorem

No deterministic online algorithm can have a competitive ratiobetter than 2.

This implies that greedy algorithms are the best deterministicalgorithm

We see the proof in the next class

COMP 7720 - Online Algorithms Online Bin Packing 20 / 1