• No results found

Algorithm Design (XVII)

N/A
N/A
Protected

Academic year: 2021

Share "Algorithm Design (XVII)"

Copied!
57
0
0

Loading.... (view fulltext now)

Full text

(1)

Algorithm Design (XVII)

Approximation Algorithms II

Guoqiang Li

(2)
(3)

Bin Packing: Problem Statement

Givennitems with sizesa1, . . . ,an∈(0,1], find a packing inunit-sized bins

(4)

An 2-approximation Algorithm

First-Fit Algorithm:

• Consider items inarbitrary order.

• In thei-th step, it has a list of partially packed bins, sayB1, . . . ,Bk. • It attempts to put the next item,ai, in one of these bins, in this order. • Ifai does not fit into any of these bins, it opens anewbinBk+1, and puts

(5)

An 2-approximation Algorithm

First-Fit Algorithm:

• Consider items inarbitrary order.

• In thei-th step, it has a list of partially packed bins, sayB1, . . . ,Bk. • It attempts to put the next item,ai, in one of these bins, in this order. • Ifai does not fit into any of these bins, it opens anewbinBk+1, and puts

(6)

An 2-approximation Algorithm

First-Fit Algorithm:

• Consider items inarbitrary order.

• In thei-th step, it has a list ofpartially packed bins, sayB1, . . . ,Bk.

• It attempts to put the next item,ai, in one of these bins, in this order. • Ifai does not fit into any of these bins, it opens anewbinBk+1, and puts

(7)

An 2-approximation Algorithm

First-Fit Algorithm:

• Consider items inarbitrary order.

• In thei-th step, it has a list ofpartially packed bins, sayB1, . . . ,Bk. • It attempts to put the next item,ai, in one of these bins, in this order.

• Ifai does not fit into any of these bins, it opens anewbinBk+1, and puts ai in it.

(8)

An 2-approximation Algorithm

First-Fit Algorithm:

• Consider items inarbitrary order.

• In thei-th step, it has a list ofpartially packed bins, sayB1, . . . ,Bk. • It attempts to put the next item,ai, in one of these bins, in this order. • Ifai does not fit into any of these bins, it opens anewbinBk+1, and puts

(9)

Analysis

If the algorithm usesmbins, thenat leastm−1bins aremore than half full. Therefore, n X i=1 ai >m−1 2

Since the sum of the item sizes is alower boundonOPT,m−1<2·OPT, i.e.,m≤2·OPT.

(10)

Analysis

If the algorithm usesmbins, thenat leastm−1bins aremore than half full.

Therefore, n X i=1 ai >m−1 2

Since the sum of the item sizes is alower boundonOPT,m−1<2·OPT, i.e.,m≤2·OPT.

(11)

Analysis

If the algorithm usesmbins, thenat leastm−1bins aremore than half full. Therefore, n X i=1 ai >m−1 2

Since the sum of the item sizes is alower boundonOPT,m−1<2·OPT, i.e.,m≤2·OPT.

(12)

Analysis

If the algorithm usesmbins, thenat leastm−1bins aremore than half full. Therefore, n X i=1 ai >m−1 2

Since the sum of the item sizes is alower boundonOPT,m−1<2·OPT, i.e.,m≤2·OPT.

(13)

A Hardness Result

For any > 0, there is noapproximation algorithmhaving a guarantee of3/2−for the bin packing problem, assumingP=NP.

Theorem

Proof.

If there were such an algorithm, then theNPC problemof deciding if there is a way to partitionn nonnegative numbersa1, . . . ,an into two sets, each adding up to1/2P

iai.

The answer to this question is “yes” iff thenitems can be packed in2bins of size1/2P

iai.

If the answer is “yes” the3/2−factor algorithm will have to give an optimal packing.

(14)

A Hardness Result

For any > 0, there is noapproximation algorithmhaving a guarantee of3/2−for the bin packing problem, assumingP=NP.

Theorem

Proof.

If there were such an algorithm, then theNPC problemof deciding if there is a way to partitionn nonnegative numbersa1, . . . ,an into two sets, each adding up to1/2P

iai.

The answer to this question is “yes” iff thenitems can be packed in2bins of size1/2P

iai.

If the answer is “yes” the3/2−factor algorithm will have to give an optimal packing.

(15)

A Hardness Result

For any > 0, there is noapproximation algorithmhaving a guarantee of3/2−for the bin packing problem, assumingP=NP.

Theorem

Proof.

If there were such an algorithm, then theNPC problemof deciding if there is a way to partitionnnonnegative numbersa1, . . . ,an into two sets, each adding up to1/2P

iai.

The answer to this question is “yes” iff thenitems can be packed in2bins of size1/2P

iai.

If the answer is “yes” the3/2−factor algorithm will have to give an optimal packing.

(16)

A Hardness Result

For any > 0, there is noapproximation algorithmhaving a guarantee of3/2−for the bin packing problem, assumingP=NP.

Theorem

Proof.

If there were such an algorithm, then theNPC problemof deciding if there is a way to partitionnnonnegative numbersa1, . . . ,an into two sets, each adding up to1/2P

iai.

The answer to this question is “yes” iff thenitems can be packed in2bins of size1/2P

iai.

If the answer is “yes” the3/2−factor algorithm will have to give an optimal packing.

(17)

A Hardness Result

For any > 0, there is noapproximation algorithmhaving a guarantee of3/2−for the bin packing problem, assumingP=NP.

Theorem

Proof.

If there were such an algorithm, then theNPC problemof deciding if there is a way to partitionnnonnegative numbersa1, . . . ,an into two sets, each adding up to1/2P

iai.

The answer to this question is “yes” iff thenitems can be packed in2bins of size1/2P

iai.

If the answer is “yes” the3/2−factor algorithm will have to give an optimal packing.

(18)

APTAS

Anasymptotic polynomial-time approximation scheme (APTAS)is a

family of algorithm{A}along with a constantc where there is an algorithmA for each > 0such thatA returns a solution of valueat

most(1+)OPT+c for minimization problems. Definition

(19)

An APTAS for Bin-Packing

For any,0< ≤1/2, there is an algorithmAthat runs in time polynomial innand finds a packing using at most(1+2)OPT+1bins.

(20)

An APTAS for Bin-Packing

For any,0< ≤1/2, there is an algorithmAthat runs in time polynomial innand finds a packing using at most(1+2)OPT+1bins.

(21)

Instances with Large Items

Let >0be fixed, and let K be a fixed nonnegative integer. Consider the restriction of the bin packing problem to instances in which each item isof size at leastand the number of distinct item sizes isK. There isa polynomial time algorithm that optimally solves

this restricted problem. Lemma

(22)

Instances with Large Items

Proof.

The number of items in a bin is bounded byb1/c. Denote this byM. Therefore, the number of different bin types is bounded by

R= M+K M

!

which is alargeconstant.

The total number of bins used is at mostn. Therefore, the number of possible feasible packings is bounded by

P= n+R R

!

which ispolynomial inn.

(23)

Instances with Large Items

Proof.

The number of items in a bin is bounded byb1/c. Denote this byM. Therefore, the number of different bin types is bounded by

R= M+K M

!

which is alargeconstant.

The total number of bins used is at mostn. Therefore, the number of possible feasible packings is bounded by

P= n+R R

!

which ispolynomial inn.

(24)

Instances with Large Items

Proof.

The number of items in a bin is bounded byb1/c. Denote this byM. Therefore, the number of different bin types is bounded by

R= M+K M

!

which is alargeconstant.

The total number of bins used is at mostn. Therefore, the number of possible feasible packings is bounded by

P= n+R R

!

(25)

Instances with Large Items

Proof.

The number of items in a bin is bounded byb1/c. Denote this byM. Therefore, the number of different bin types is bounded by

R= M+K M

!

which is alargeconstant.

The total number of bins used is at mostn. Therefore, the number of possible feasible packings is bounded by

P= n+R R

!

which ispolynomial inn.

(26)

k Composition ofM

x1+x2+. . .+xk=M

• k composition ofM: xi ≥1

(27)

k Composition ofM

x1+x2+. . .+xk=M

• k composition ofM: xi≥1

(28)

k Composition ofM x1+x2+. . .+xk=M • k composition ofM: xi≥1 M−1 k−1 ! • weakkcomposition ofM: xi≥0

(29)

k Composition ofM x1+x2+. . .+xk=M • k composition ofM: xi≥1 M−1 k−1 ! • weakkcomposition ofM: xi≥0

(30)

k Composition ofM x1+x2+. . .+xk=M • k composition ofM: xi≥1 M−1 k−1 ! • weakkcomposition ofM: xi≥0 M+k−1 k−1 !

(31)

Removing the Restriction of K

Let > 0be fixed. Consider the restriction of the bin packing problem to instances in which each item is of size at least. There is a polyno-mial time approximation algorithmthat solves this restricted problem

within a factor of(1+). Lemma

(32)

Removing the Restriction of K

LetI denote the given instance. Sort thenitems byincreasing size, and partition them intoK =d1/2egroups each having at mostQ=bn2citems. Notice that two groups may contain items of the same size.

(33)

Removing the Restriction of K

Construct instanceJbyrounding upthe size of each item to the size of the largest item in its group. InstanceJ has at mostK different item sizes. Then we can find anoptimal packingforJ, this will also be a valid packing for the original item size.

We will show that

(34)

Removing the Restriction of K

Construct instanceJbyrounding upthe size of each item to the size of the largest item in its group. InstanceJ has at mostK different item sizes.

Then we can find anoptimal packingforJ, this will also be a valid packing for the original item size.

We will show that

(35)

Removing the Restriction of K

Construct instanceJbyrounding upthe size of each item to the size of the largest item in its group. InstanceJ has at mostK different item sizes. Then we can find anoptimal packingforJ, this will also be a valid packing for the original item size.

We will show that

(36)

Removing the Restriction of K

Construct instanceJbyrounding upthe size of each item to the size of the largest item in its group. InstanceJ has at mostK different item sizes. Then we can find anoptimal packingforJ, this will also be a valid packing for the original item size.

We will show that

(37)

Removing the Restriction of K

Construct instanceJbyrounding upthe size of each item to the size of the largest item in its group. InstanceJ has at mostK different item sizes. Then we can find anoptimal packingforJ, this will also be a valid packing for the original item size.

We will show that

(38)

Proof

Let us construct another instance, sayJ0, byrounding downthe size of each item to that of the smallest item in its group.

ClearlyOPT(J0)≤OPT(I).

The crucial observation is that a packing for instanceJyields a packing for all but the largestQ items of instanceJ. Therefore,

OPT(J)≤OPT(J0) +Q≤OPT(I) +Q Since each item inI has size at least,OPT(I)≥n. Therefore

(39)

Proof

Let us construct another instance, sayJ0, byrounding downthe size of each item to that of the smallest item in its group.

ClearlyOPT(J0)≤OPT(I).

The crucial observation is that a packing for instanceJyields a packing for all but the largestQ items of instanceJ. Therefore,

OPT(J)≤OPT(J0) +Q≤OPT(I) +Q Since each item inI has size at least,OPT(I)≥n. Therefore

(40)

Proof

Let us construct another instance, sayJ0, byrounding downthe size of each item to that of the smallest item in its group.

ClearlyOPT(J0)≤OPT(I).

The crucial observation is that a packing for instanceJyields a packing for all but the largestQ items of instanceJ. Therefore,

OPT(J)≤OPT(J0) +Q≤OPT(I) +Q Since each item inI has size at least,OPT(I)≥n. Therefore

(41)

Proof

Let us construct another instance, sayJ0, byrounding downthe size of each item to that of the smallest item in its group.

ClearlyOPT(J0)≤OPT(I).

The crucial observation is that a packing for instanceJyields a packing for all but the largestQ items of instanceJ. Therefore,

OPT(J)≤OPT(J0) +Q≤OPT(I) +Q Since each item inI has size at least,OPT(I)≥n. Therefore

(42)

Proof

Let us construct another instance, sayJ0, byrounding downthe size of each item to that of the smallest item in its group.

ClearlyOPT(J0)≤OPT(I).

The crucial observation is that a packing for instanceJyields a packing for all but the largestQ items of instanceJ. Therefore,

OPT(J)≤OPT(J0) +Q≤OPT(I) +Q

Since each item inI has size at least,OPT(I)≥n. Therefore Q=bn2c ≤OPT(I). Hence,OPT(J)(1+)OPT(I).

(43)

Proof

Let us construct another instance, sayJ0, byrounding downthe size of each item to that of the smallest item in its group.

ClearlyOPT(J0)≤OPT(I).

The crucial observation is that a packing for instanceJyields a packing for all but the largestQ items of instanceJ. Therefore,

OPT(J)≤OPT(J0) +Q≤OPT(I) +Q Since each item inI has size at least,OPT(I)≥n. Therefore

(44)

The Algorithm

Now we present theAPTASalgorithm for Bin-Packing.

• LetI denote the given instance, andI0denote the instance obtained by discarding items of size< fromI.

• By previous lemma, we can find a packing forI0using at most (1+)OPT(I0)bins.

• Next, we start packing the small items (of size< ) in aFirst-Fit manner

in the bins opened for packingI. Additional bins are opened if an item does not fit into any of the already open bins.

(45)

The Algorithm

Now we present theAPTASalgorithm for Bin-Packing.

• LetI denote the given instance, andI0denote the instance obtained by discarding items of size< fromI.

• By previous lemma, we can find a packing forI0using at most (1+)OPT(I0)bins.

• Next, we start packing the small items (of size< ) in aFirst-Fit manner

in the bins opened for packingI. Additional bins are opened if an item does not fit into any of the already open bins.

(46)

The Algorithm

Now we present theAPTASalgorithm for Bin-Packing.

• LetI denote the given instance, andI0denote the instance obtained by discarding items of size< fromI.

• By previous lemma, we can find a packing forI0using at most (1+)OPT(I0)bins.

• Next, we start packing the small items (of size< ) in aFirst-Fit manner

in the bins opened for packingI. Additional bins are opened if an item does not fit into any of the already open bins.

(47)

The Algorithm

Now we present theAPTASalgorithm for Bin-Packing.

• LetI denote the given instance, andI0denote the instance obtained by discarding items of size< fromI.

• By previous lemma, we can find a packing forI0using at most (1+)OPT(I0)bins.

• Next, we start packing the small items (of size< ) in aFirst-Fit manner

in the bins opened for packingI. Additional bins are opened if an item does not fit into any of the already open bins.

(48)

Analysis

If no additional bins are needed, then we have a packing in (1+)OPT(I0)≤(1+)OPT(I)bins.

In the second case, letM be the total number of bins used. Clearly, all but the last bin must be full to the extent of at least1−.

Therefore, the sum of the item sizes inI is at least(M−1)(1−). Since this

(49)

Analysis

If no additional bins are needed, then we have a packing in (1+)OPT(I0)≤(1+)OPT(I)bins.

In the second case, letM be the total number of bins used. Clearly, all but the last bin must be full to the extent of at least1−.

Therefore, the sum of the item sizes inI is at least(M−1)(1−). Since this

(50)

Analysis

If no additional bins are needed, then we have a packing in (1+)OPT(I0)≤(1+)OPT(I)bins.

In the second case, letM be the total number of bins used. Clearly, all but the last bin must be full to the extent of at least1−.

Therefore, the sum of the item sizes inI is at least(M−1)(1−). Since this

(51)

Analysis

If no additional bins are needed, then we have a packing in (1+)OPT(I0)≤(1+)OPT(I)bins.

In the second case, letM be the total number of bins used. Clearly, all but the last bin must be full to the extent of at least1−.

Therefore, the sum of the item sizes inI is at least(M−1)(1−). Since this

(52)

Analysis

M≤ OPT

(1−)+1≤(1+2)OPT+1

where we have used the assumption that≤1/2.

Hence, for each value of,0< ≤1/2, we have a polynomial time algorithm achieving a guarantee of(1+2)OPT+1.

(53)

Analysis

M≤ OPT

(1−)+1≤(1+2)OPT+1

where we have used the assumption that≤1/2.

Hence, for each value of,0< ≤1/2, we have a polynomial time algorithm achieving a guarantee of(1+2)OPT+1.

(54)

Analysis

M≤ OPT

(1−)+1≤(1+2)OPT+1

where we have used the assumption that≤1/2.

Hence, for each value of,0< ≤1/2, we have a polynomial time algorithm achieving a guarantee of(1+2)OPT+1.

(55)

Summary of Algorithm

AlgorithmA is summarized below.

1. Remove items of size< .

2. Round to obtain constant number of item sizes.

3. Find optimal packing.

4. Use this packing for original item sizes.

(56)

Summary of Algorithm

AlgorithmA is summarized below.

1. Remove items of size< .

2. Round to obtain constant number of item sizes.

3. Find optimal packing.

4. Use this packing for original item sizes.

(57)

Summary of Algorithm

AlgorithmA is summarized below.

1. Remove items of size< .

2. Round to obtain constant number of item sizes.

3. Find optimal packing.

4. Use this packing for original item sizes.

References

Related documents

In sections III-IV the ground state energy and effective mass of a single large anharmonic polaron are calculated, using perturbation theory in section III and Feynman’s path

How the study was conducted The researchers used a 3-D global atmospheric download to predict how the radioactive material download move over earth and a health-effects model to see

In a particular period, denoted by n, the borrower faces a payment amount m n (i.e., monthly or yearly payment) that depends on the size of the original loan, D 0 , the length of

Quality: We measure quality (Q in our formal model) by observing the average number of citations received by a scientist for all the papers he or she published in a given

Still thinking of the last full week of work, record the total number of two-way trips (leaving work and then returning) that you made during work hours which were at least

Instead we will use the quantitative generalization of the classical Lindeberg-Feller central limit theory as developed by Berckmoes, Lowen and Van Casteren in [4] to produce a

The study covered on the issue of abandoned building that existence in Peninsular Malaysia only because The Housing Development (Control and Licensing) Act 1966 (Act 118) used for

4 www.cpsc.gov HOME ELECTRICAL SAfETy CHECkLIST KITCHEN BA THROOMS OTHERS OUTDOORS BEDROOMS CONTENTS PUBLICA TIONS 5 ALL ROOMS In ALL Rooms Check Lights.. Check each light in the