39
1 • The instructor will be absent on March 29 th . • The class resumes on March 31 st .

The instructor will be absent on March 29 th . The class resumes on March 31 st

  • Upload
    quasar

  • View
    26

  • Download
    2

Embed Size (px)

DESCRIPTION

The instructor will be absent on March 29 th . The class resumes on March 31 st. Section 9-7 PTAS. Error Ratio Polynomial-Time Approximation Scheme A family of approximation algorithms For any pre-specified E, there exists an approximation algorithm with error ratio E - PowerPoint PPT Presentation

Citation preview

Page 1: The instructor will be absent on March 29 th . The class resumes on March 31 st

1

• The instructor will be absent on March 29th.

• The class resumes on March 31st.

Page 2: The instructor will be absent on March 29 th . The class resumes on March 31 st

2

Section 9-7 PTAS

• Error Ratio

• Polynomial-Time Approximation Scheme– A family of approximation algorithms– For any pre-specified E, there exists an

approximation algorithm with error ratio E– And the complexity is still polynomial

• O(n/E)

OPT

APXOPT

OPT

APX 1

Page 3: The instructor will be absent on March 29 th . The class resumes on March 31 st

3

Planar Graph

• Definition: A graph is said to be embedded on a surface S if it can be drawn on S so that its edges intersect only at their end vertices.

• A graph is a planar graph if it can be embedded on a plane.

Page 4: The instructor will be absent on March 29 th . The class resumes on March 31 st

4

Examples

Page 5: The instructor will be absent on March 29 th . The class resumes on March 31 st

5

Face

• Definition: A face is a region defined by a planar embedding.– The unbound face is called exterior face

• e.g. 1-4-3-2-1

– All other faces are called interior faces.• e.g. 1-2-6-5-1 1

2 3

4

5

6 7

8

Page 6: The instructor will be absent on March 29 th . The class resumes on March 31 st

6

k-outerplanar

• In a planar graph, we can associate each node with a level.– Node on exterior face are of level 1.

• A graph is k-outerplanar if it has no nodes with level greater than k.

2

1

65

4

3

7

Page 7: The instructor will be absent on March 29 th . The class resumes on March 31 st

7

Example

2

3

45

1

76

111210

8 91617

1514

13

Page 8: The instructor will be absent on March 29 th . The class resumes on March 31 st

8

Level 1

2

3

45

1

76

111210

8 91617

1514

13

Page 9: The instructor will be absent on March 29 th . The class resumes on March 31 st

9

Level 2

76

111210

8 91617

1514

13

Page 10: The instructor will be absent on March 29 th . The class resumes on March 31 st

10

Level 3

1617

15

Page 11: The instructor will be absent on March 29 th . The class resumes on March 31 st

11

Max Independent Set Problem

• c.f Maximum & Maximal.• Maximum independent set problem on plan

ar graphs is NP-hard.• For a k-outerplanar graph, an optimal soluti

on for the maximum independent set problem can be found in O(8kn) time,– through the dynamic programming approach– n is the number of vertices.

Page 12: The instructor will be absent on March 29 th . The class resumes on March 31 st

A Planar Graph with 9 Levels

Page 13: The instructor will be absent on March 29 th . The class resumes on March 31 st

Nodes on Level 1,4,7

Page 14: The instructor will be absent on March 29 th . The class resumes on March 31 st

Nodes on Level 2,5,8

Page 15: The instructor will be absent on March 29 th . The class resumes on March 31 st

Nodes on Level 3,6,9

Page 16: The instructor will be absent on March 29 th . The class resumes on March 31 st

Graph Obtained by Removing Nodes on Level 3,6,9

This is a 2-outerplanar graph.

Maximum Independent Set Problem can be solved in O(8kn) time, where k=2.

Page 17: The instructor will be absent on March 29 th . The class resumes on March 31 st

17

Algorithm 9-7 An Approximation Algorithm to Solve the Max Independent Set Problem on Planar Graph

• Step 1. For all i = 0, 1, 2, …, k, do– (1.1) Let Gi be the graph obtained by deleting all nodes

with levels congruent to i (mod k+1). The remaining subgraphs are all k-outerplanar graphs.

– (1.2) For each k-outerplanar graph, find its maximum independent set. Let Si denote the union of these solutions.

• Step 2. Among S0, S1, …, Sk, choose the Sj with the maximum size and let it be our approximation solution SAPX.

Time Complexity: O(8kkn)

Page 18: The instructor will be absent on March 29 th . The class resumes on March 31 st

18

Analysis

• All nodes are divided into (k+1) classes– Each class corresponds to a level congruent to i (mod

k+1), for i = 0, 1, …, k.

• For every independent set S, the average number of nodes in this set for each class is |S|/(k+1).

• There is at least one r, such that at most 1/(k+1) of vertices in SOPT are at a level which is congruent to r (mod k+1).

Page 19: The instructor will be absent on March 29 th . The class resumes on March 31 st

19

Analysis (cont.)

• Because at most |SOPT|/(k+1) nodes are deleted, the solution Sr obtained by deleting the nodes in class r from SOPT will have at least |SOPT|(1 – 1/(k+1)) = |SOPT| k/(k+1) nodes.

• |Sr||SOPT| k/(k+1)

• According to our algorithm, |SAPX| |Sr|

1

1

||

||

kS

SS

OPT

APXOPT

Page 20: The instructor will be absent on March 29 th . The class resumes on March 31 st

20

PTAS• If we set k = ceiling(1/E) –1, the above formula

becomes

• Thus for every given error bound E, we have a corresponding k to guarantee that the approximate solution differs from the optimum one within this error ratio.

• No matter how small the error is, the complexity of the algorithm is O(8kkn), which is polynomial with respect to n.

E

Ek

/1

1

1

1

Page 21: The instructor will be absent on March 29 th . The class resumes on March 31 st

21

0/1 Knapsack Problem

• n objects, each with a weight wi > 0

a profit pi > 0

• capacity of knapsack : M

• Maximize• Subject to

• xi = 0 or 1, 1 i n

i

iixp

Mxwi

ii

Page 22: The instructor will be absent on March 29 th . The class resumes on March 31 st

22

Greedy on Density

• M=2k, APX=2k+3, OPT=4k

• M=2k+1, APX=OPT=4k+3

1 2 3

P 2k+3 2k 2k

W k+1 k k

Page 23: The instructor will be absent on March 29 th . The class resumes on March 31 st

PTAS of 0/1 Knapsack Problem

• We shall demonstrate how to obtain an approximation algorithm with error ratio , no matter how small is.

Page 24: The instructor will be absent on March 29 th . The class resumes on March 31 st

Step 1: Sort the items according to the density.

i 1 2 3 4 5 6 7 8

pi 90 61 50 33 29 23 15 13

wi 33 30 25 17 15 12 10 9

pi /wi 2.72 2.03 2.0 1.94 1.93 1.91 1.5 1.44

Page 25: The instructor will be absent on March 29 th . The class resumes on March 31 st

25

Step 2: Calculate a number Q

• Find the largest d such that W=w1+w2+…+wdM.

• If d=n or W=M, then– Set PAPX =p1+p2+…+pd and INDICES={1,2,…,d} and

stop.

– In this case, POPT=PAPX

• Otherwise, set Q=p1+p2+…+pd +pd+1

• For our case, d=3 and Q=90+61+50+33=234

Page 26: The instructor will be absent on March 29 th . The class resumes on March 31 st

26

Characteristics of Q

1. p1+p2+…+pd POPT

2. wd+1M, therefore pd+1 is a feasible solution

• pd+1 POPT

3. Q= p1+p2+… +pd+pd+1 2POPT

4. POPT is a feasible solution and Q is not, so POPTQ

• Q/2POPTQ

Page 27: The instructor will be absent on March 29 th . The class resumes on March 31 st

27

Step 3: Calculate a normalizing factor

=Q( /3)2

• Let to be 0.6– In our case, =234(0.6/3)2=234(0.2)2=9.36

• Calculate

• Set T=Q( /3)– In our case, T = 234(0.6/3)=46.8

25)6.0/3()/3(/ 22 Qg

Page 28: The instructor will be absent on March 29 th . The class resumes on March 31 st

28

Step 4.1: SMALL & BIG

• Let SMALL collect all items whose profits are smaller than or equial to T.

• Collect all other items into BIG.

• In our case,– SMALL = {4, 5, 6, 7, 8}– BIG = {1, 2, 3}

Page 29: The instructor will be absent on March 29 th . The class resumes on March 31 st

29

Step 4.2 Normalize items in BIG

In our case,

/'ii pp

936.9/90'1 p

636.9/61'2 p

536.9/50'3 p

Page 30: The instructor will be absent on March 29 th . The class resumes on March 31 st

30

Step 4.3 Initialize an array A

• Array A has size g. Each entry corresponds to a combination of pi

’s.

• Each entry A[i] consists of three fields– I: index of the combination– P: sum of profits– W: sum of weights

Page 31: The instructor will be absent on March 29 th . The class resumes on March 31 st

31

Step 4.4 Run a dynamic programming on items in BIG

• When i=1, p1’=9

I P W

0 0 0123456789 1 90 33101112

Page 32: The instructor will be absent on March 29 th . The class resumes on March 31 st

32

• When i=2, p2’=6

I P W

0 0 0123456 2 61 30789 1 90 33101112

131415 1,2 151 6316171819202122232425

Page 33: The instructor will be absent on March 29 th . The class resumes on March 31 st

33

• When i=3, p3’=5

I P W

0 0 012345 3 50 256 2 61 30789 1 90 331011 2,3 111 5512

1314 1,3 140 5815 1,2 151 631617181920 1,2,3 201 882122232425

Page 34: The instructor will be absent on March 29 th . The class resumes on March 31 st

34

Step 5. Add items in SMALL using the greedy algorithmI P W FILL Profit

0 0 0 4,5,6,7,8 113

12345 3 50 25 4,5,6,7,8 1636 2 61 30 4,5,6,7 161

789 1 90 33 4,5,6,7 190

1011 2,3 111 55 4,5 173121314 1,3 140 58 4,5 20215 1,2 151 63 4,6 207

1617181920 1,2,3 201 88 2012122232425

Step 6: Pick the largest profit to be our approximate solution

Page 35: The instructor will be absent on March 29 th . The class resumes on March 31 st

35

Why is it polynomial?

• Step 4.4 is an exhaustive scanning step.• Intuitively, it will take exponential time:

– 2|BIG|

• Actually, the size of array A is not longer than g.

g

Q

ppp

ppp

ppp

j

j

j

iii

iii

iii

/

/)...(

/...//

...

21

21

21

'''

Page 36: The instructor will be absent on March 29 th . The class resumes on March 31 st

36

Time Complexity

• Step 1: O(n log n)

• Step 2: O(n)

• Step 4.1 to 4.2: O(n)

• Step 4.3: O(g)

• Step 4.4: O(ng)

• Step 5: O(ng)

• Step 6: O(g)

• Total: O(n log n) + O(ng) = O(n log n) + O(n(3/)2).

Page 37: The instructor will be absent on March 29 th . The class resumes on March 31 st

37

Error Analysis

Page 38: The instructor will be absent on March 29 th . The class resumes on March 31 st

38

Exercise

• Use the example given in P.493, – Run the PTAS with =0.75. – What is the solution you obtain?– What is the error ratio?

• Due: April 14th

• The instructor will be absent in next week.

Page 39: The instructor will be absent on March 29 th . The class resumes on March 31 st

39

Exercise

• Write a program which runs the PTAS of 0/1 Knapsack Problem. (Due: April 19th)

• Input format:81000.7590 3361 3050 2533 1729 1523 1215 1013 9