• 沒有找到結果。

Approximation Algorithms

N/A
N/A
Protected

Academic year: 2022

Share "Approximation Algorithms"

Copied!
30
0
0

加載中.... (立即查看全文)

全文

(1)

Approximation Algorithms

Wei-Yin Lin (林蔚茵)

Department of Computer Science and Information Engineering National Taiwan University

June 10, 2011

(2)

Why approximation algorithms?

Why approximation algorithms?

如果已知要解的問題是NP-Complete的問題, 該怎麼辦?

可找出exact solutions的演算法中,某些problem instances得花 上exponential time

有些時候不要太執著會比較好

想法:多項式時間內可解, 並保證我們所找到的解不會太差

想一個快速的方法來找到near-optimal solutions

(也就是近似演算法)

實用性高

(3)

Approximation ratio

Approximation ratio

在解一個optimization problem時, 我們希望近似演算法的解和最佳 解不會差太多

假設input的大小為n, 在最糟的情況下, 近似演算法的解也會 被approximation ratio ρ(n)給限制住

C:某一個演算法的解 C

:最佳解

max(C C

,C

C ) ≤ ρ(n)

若達到此ratio, 則稱此演算法為一個ρ(n)-approximation algorithm

此定義在minimization和maximization problems上都適用

(4)

Approximation ratio

Approximation ratio

我們希望ρ(n)越小越好

小到ρ(n) = 1時, 最佳解就跑出來了

ratio的形式不一(等等會看到例子)

1 a small constant

2 a function of n

3 有些會隨著執行時間的增加而變得越來越好

此類的演算法通常都不會很複雜, 但是...

(5)

Approximation ratio

Approximation scheme

Approximation scheme

Input除了大小為n的problem instance之外, 還多加了一個正的常數, 使其成為一個(1+)-approximation algorithm

Polynomial-time approximation scheme (PTAS)

任給一個 > 0, 該scheme都可以在多項式時間內執行完畢

可以任意地逼近最佳解, 感覺很棒!

但是...隨著的值越小, 所花的時間可能會急遽增加 比方說時間複雜度為 O(n

2/

)

Fully polynomial-time approximation scheme (FPTAS)

執行時間為n且為1/的多項式, 例如O((1/)

2

n

3

)

如此一來, 隨著常數倍的減少, 時間必定也只會有常數倍的增加

(6)

The vertex-cover problem

The vertex-cover problem

Problem 1 (The vertex-cover problem)

A vertex cover of an undirected graph G = (V, E) is a subset V

0

⊂ V such that if (u, v) is an edge of G, then either u ∈ V

0

or v ∈ V

0

(or both). The size of a vertex cover is the number of vertices in it. The vertex-cover problem is to find a vertex cover of minimum size in a given undirected graph.

此問題的decision版本為NP-Complete (Section 34.5.2)

(7)

The vertex-cover problem

以下的演算法所找到的vertex cover, 其size保證不超過最佳解的兩倍

APPROX-VERTEX-COVER(G) 1 C = φ

2 E

0

= G.E 3 while E

0

6= φ

4 let (u, v) be an arbitrary edge of E

0

5 C = C ∪ {u, v}

6 remove from E

0

every edge incident on either u or v

7 return C

(8)

The vertex-cover problem

Example

(9)

The vertex-cover problem

Theorem

APPROX-VERTEX-COVER is a polynomial-time 2-approximation algorithm

Proof

最終回傳的C會是一個vertex cover

為什麼C的大小不會超過最佳解大小的兩倍?

令A為所有在APPROX-VERTEX-COVER的第4行中所挑出的邊 重要觀察:

A 中的每個邊皆不會具有共同的端點

, 所以

1 可得知C

的lower bound為

|C

| ≥ |A|

2 可得知C的(tight) upper bound為

|C| = 2|A|

⇒ |C| = 2|A| ≤ 2|C

|

(10)

The vertex-cover problem

APPROX-VERTEX-COVER的執行時間為O(|V | + |E|)

我們不需要知道optimal vertex cover的大小, 就能夠找 到approximation ratio!

關鍵是甚麼?

(11)

The traveling-salesman problem

The traveling-salesman problem

Problem 2 (The traveling-salesman problem)

Given a complete undirected graph G = (V, E) that has a nonnegative integer cost c(u, v) associated with each edge (u, v) ∈ E, the

traveling-salesman problem is to find a hamiltonian cycle (a tour) of G with minimum cost.

此問題的decision版本為NP-Complete (Section 34.5.4)

(12)

The traveling-salesman problem

The traveling-salesman problem with the triangle inequality

令c(A)為cost的總合, 其中A ⊆ E i.e., c(A) = X

(u,v)∈A

c(u, v)

• Triangle inequality:

對所有的u, v, w ∈ V , c(u, w) ≤ c(u, v) + c(v, w)

若給定的cost function符合triangular inequality, 此問題的decision版 本依然是NP-Complete (Exercise 35.2-2)

但是我們有一個2-approximation algorithm可以來解這個問題

想法同the vertex-cover problem, 此時該怎麼找lower bound?

(13)

The traveling-salesman problem

Input: G: complete undirected graph, c: cost function

MST-PRIM: 找minimum spanning tree的演算法 (Section 23.2)

若c符合三角不等式, 以下演算法可保證找到一個hamiltonian cycle H, 其cost總合不超過optimal hamiltonian cycle的2倍

APPROX-TSP-TOUR(G,c)

1 select a vertex r ∈ G.V to be a “root” vertex

2 compute a minimum spanning tree T for G from root r using MST-PRIM(G, c, r)

3 let H be a list of vertices, ordered according to when they are first visited in a preorder tree walk of T

4 return the hamiltonian cycle H

執行時間:Θ(|V |

2

)

(14)

The traveling-salesman problem

Example

(15)

The traveling-salesman problem

Theorem

APPROX-TSP-TOUR is a polynomial-time 2-approximation algorithm for the traveling-salesman problem with the triangle inequality

Proof

H

: optimal tour

W : 在做preorder traversal時, 把過程中第一次和回程時經過的每一 點都記錄下來 (稱之為full walk)

(ex. 承上例, full walk就是 a, b, c, b, h, b, a, d, e, f, e, g, e, d, a)

將W中前面已出現過的點刪除, 再連回起點, 就是我們要的H (ex. 承上例, hamiltonian cycle就是 a, b, c, h, d, e, f, g, a)

1 c(T ) ≤ c(H

)

2 c(W ) = 2c(T )

⇒ c(H) ≤ c(W ) = 2c(T ) ≤ 2c(H

)

(16)

The traveling-salesman problem

The general traveling-salesman problem

看起來要找個2-approximation algorithm好像不算太難

何不來教一個解general TSP的近似演算法呢?

因為找不到...

Theorem

If P6=NP, then for any constant ρ ≥ 1, there is no polynomial-time approximation algorithm with approximation ratio ρ for the general traveling-salesman problem.

(17)

The traveling-salesman problem

Proof

利用矛盾證法, 假設存在ratio為ρ的近似演算法A可解TSP 其中ρ ≥ 1為一常數

Claim: A可在polynomial time之內解hamiltonian cycle的問題 (HC) Proof.

(a) 將HC的problem instance G = (V, E) 轉為TSP的problem instance G

0

= (V, E

0

)

• E

0

= {(u, v) : u, v ∈ V and u 6= v}: 將G轉換成complete graph c(u, v) =

 1 if (u, v) ∈ E, ρ|V | + 1 otherwise

• 此轉換可在polynomial time之內完成 (b) G 中具有一個hamiltonian cycle H

⇔ (G

0

, c) 具有一個cost為|V |的tour

⇔ A會回報 一個cost不超過ρ|V |的tour

∵不在原本G中的邊都太貴了

i.e., (ρ|V | + 1) + (|V | − 1) = ρ|V | + |V | > ρ|V |

(18)

The set-covering problem

The set-covering problem

到目前為止所看到的都是constant ratio

有時候隨著input的大小增加, ratio也會變大

也就是說, 如果input越大, ouput離最佳解可能會差得越多

但如果ratio的成長速度不會太快, 就還可以接受 比方說, ratio是一個logarithm function

The set-covering problem主要應用在於解決資源分配的問題

此亦為The vertex-cover problem的推廣問題

⇒ The set-covering problem is NP-hard (Excercise 35.3-2) 這等等會說明, 先來看看問題的定義吧!

(19)

The set-covering problem

Problem definition

Problem instance: (X, F ) X: a finite set

F : a set of subsets of X, where X = [

S∈F

S

X中的每一個元素都會至少屬於F中某一個集合

C

covers

X: X = [

S∈C

S

Problem 3 (The set-covering problem)

The set-covering problem is to find a minimum-size subset C ⊆ F whose members covers all of X.

(20)

The set-covering problem

Example

X = {所有的黑點點}

F = {S

1

, S

2

, S

3

, S

4

, S

5

, S

6

}

A set cover of size 4: C = {S

1

, S

4

, S

5

, S

6

}

(21)

The set-covering problem

舉個活生生的例子

某國國會要組一個預算審查委員會

徵求精通以下項目的人才: 交通, 城市發展, 醫療, 司法, 勞工, 衛 生, 教育, 環境保護, 能源, 國土安全, 財政貿易, 外交

A議員擅長:醫療, 環境保護, 能源 B議員擅長:城市發展, 財政貿易, 外交

C議員擅長:交通, 城市發展, 衛生, 教育, 環境保護, 能源, 國土安 全, 財政貿易, 外交

D議員擅長:勞工 ...

為了要節省成本, 委員會的人數不能太多

C議員超強, 應該要優先考慮將他列為議程委員 選他就不用選B了

(22)

The set-covering problem

A greedy approximation algorithm

GREEDY-SET-COVER(X,F ) 1 U = X

2 C = φ 3 while U 6= φ

4 select an S ∈ F that maximizes |S ∩ U | 5 U = U − S

6 C = C ∪ {S}

7 return C

while迴圈最多會執行min(|X|, |F|)次

⇒ 總執行時間為 O(|X||F| min(|X|, |F|))

(23)

The set-covering problem

GREEDY-SET-COVER的ratio 分析

Theorem

GREEDY-SET-COVER is a polynomial-time ρ(n)-approximation algorithm, where ρ(n) = H(max{|S| : S ∈ F }).

在找ratio之前, 先來定義一些我們在證明裡需要東西:

H(d) = H

d

=P

d i=1

1/i

C

: 最佳解

C: 演算法回傳的解

S

i

: 在執行到第i個iteration時所選取的subset

(24)

The set-covering problem

GREEDY-SET-COVER的ratio 分析

假設每選取完一個subset時, cost就會增加1

將執行完第i輪時的cost均分給所有在S

i

才第一次被cover到 的element

也就是說, 令c

x

為x被分到的cost值, 則 c

x

=

|S 1

i

−(S

1

∪S

2

∪...∪S

i−1

)|

Claim:

For any set S belonging to the family F , X

x∈S

c

x

≤ H(|S|).

不等式的證明請參考P1120-1121)

(25)

The set-covering problem

GREEDY-SET-COVER的ratio 分析

Proof

|C| = X

x∈X

c

x

(1)

≤ X

S∈C

X

x∈S

c

x

(2)

≤ X

S∈C

H(|S|) (3)

≤ |C

| · H(max{|S| : S ∈ F }). (4)

(26)

The set-covering problem

GREEDY-SET-COVER的ratio 分析

由上述的定理與不等式H

n

≤ ln n + 1可得到以下的推廣:

Corollary

GREEDY-SET-COVER is a polynomial-time (ln |X| + 1)-approximation algorithm

(27)

The set-covering problem

GREEDY-SET-COVER的ratio 分析

在某些特定的情形下, max{|S| : S ∈ F}會是一個不太大的常數

此時在應用上反而可以得到一個還不錯的ratio

譬如說在一個degree不超過3的圖上找vertex cover, 利

用GREEDY-SET-COVER, 我們會得到一個ρ(n) =

11 6

的近似演算法

這比之前提的GREEDY-SET-COVER還要好

(28)

The set-covering problem

The vertex-cover problem ≤ p The set-covering problem

假設G = (V, E)為The vertex-cover problem的problem instance

問題的轉換方式如下:

X = E, n = |V | F = {S

1

, S

2

, ..., S

n

}

S

i

= {e

j

| e

j

is incident with v

i

}, for i = 1 to n

G中具有size為k的vertex cover

⇔ (X, F )具有size為k的set cover

(29)

The set-covering problem

永無止盡地追求更好的ratio...

若限制input G中所有的點的degree皆不超過3

執行GREEDY-SET-COVER, 最終可得一vertex cover H, 其大小不超過最佳解的H(3) = 11/6倍

2 → 15/8 → 3/2 → PTAS →?

(30)

The set-covering problem

超感謝大 家的啦! :D

參考文獻

相關文件

This project aims to cover a range of learning targets and objectives in the Knowledge, Interpersonal and Experience Strands/Dimensions, language development strategies and

 The TRG consists of two components: a basic component which is an annual recurrent cash grant provided to schools for the appointment of supply teachers to cover approved

Section 3 is devoted to developing proximal point method to solve the monotone second-order cone complementarity problem with a practical approximation criterion based on a new

The purpose of this talk is to analyze new hybrid proximal point algorithms and solve the constrained minimization problem involving a convex functional in a uni- formly convex

Miroslav Fiedler, Praha, Algebraic connectivity of graphs, Czechoslovak Mathematical Journal 23 (98) 1973,

Given a connected graph G together with a coloring f from the edge set of G to a set of colors, where adjacent edges may be colored the same, a u-v path P in G is said to be a

To complete the “plumbing” of associating our vertex data with variables in our shader programs, you need to tell WebGL where in our buffer object to find the vertex data, and

Given an undirected graph with nonnegative edge lengths and nonnegative vertex weights, the routing requirement of a pair of vertices is assumed to be the product of their weights.