0% found this document useful (0 votes)
2 views

ALGO-35

The document discusses approximation algorithms for NP-hard problems, focusing on the vertex-cover problem and the traveling-salesman problem. It explains performance bounds for approximation algorithms, including ratio bounds and relative error bounds, and presents specific examples and theorems related to these problems. Additionally, it covers the subset-sum problem and introduces concepts related to fully polynomial-time approximation schemes.

Uploaded by

Kevin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

ALGO-35

The document discusses approximation algorithms for NP-hard problems, focusing on the vertex-cover problem and the traveling-salesman problem. It explains performance bounds for approximation algorithms, including ratio bounds and relative error bounds, and presents specific examples and theorems related to these problems. Additionally, it covers the subset-sum problem and introduces concepts related to fully polynomial-time approximation schemes.

Uploaded by

Kevin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

---------------------------- 35 ---------------------------- 35-2

e2
Approximation Algorithms 35.1 The vertex-cover problem e3 e1
e4 v
Two approaches to NP-hard problems: A vertex cover of an undirected graph G=(V,E) is
e.g. O(2n) a subset C of V such that for each (u, v)∈E, either
(1) Exponential algorithms: (for small inputs) u∈C or v∈C.
• brute-force search
• branch-and-bound The vertex-cover problem is to find for G a vertex
(2) Near-optimal solutions: (polynomial time) cover of minimum size. (an NP-hard problem)
• approximation algorithms (with performance select
bounds) b c d b c d
• heuristic algorithms
a e f g a e f g
Performance bounds (n is the input size)
e.g. ρ(n) = 1.5 (a) remove (b)
C is at most 1.5 times of C*
 C / C * ≤ ρ( n ) for minimizati on
ratio bound:  b c d b c d select
C * / C ≤ ρ(n ) for maximizati on
C is at least 1/1.5 times of C*
(Note that ρ(n) ≥ 1.)
e.g. ε(n) = 0.5 -> error within 50% a e f g a e f g
| C − C* |
relative error bound: ≤ ε (n ) select
(c)
remove
(d)
C*
(for both minimization & maximization) 1/3
35-1x
b c d b c d
ε(n), ρ(n) may be  function of n (e.g., lg n, n )
 constant (e.g., 0.5, 2.6)
* For many problems, there are approximation
algorithms with constant ratio bounds (relative a e f g a e f g
error bounds), independent of n. (e) (f) optimal
C = {b, c, d, e, f, g} C* = {b, d, e}
A needs at lest |A| vertices 35-4xa

35-3 C* covers A (A is a subgraph of G) 35-4


* (e): a vertex cover C={b, c, d, e, f, g} Let C* be an optimal cover. C* should cover A.
(f): the optimal vertex cover C*={b, d, e} That is, C* should include at least one endpoint of
each edge in A. Since no two edges in A share an
endpoint, we have |C*|≥|A| (=|C|/2) and thus
C/C*≤2. . Q.E.D.
+ C ≤ 2C* 
uncovered edges 35.2 The traveling-salesman problem (NP-C) 35-4b

35.2.1 The Euclidean TSP problem (NP-C)


complete  non-neg., triangle ineq.
The Euclidean traveling-salesman problem
is to find in acomplete weighted undirected graph
G=(V,E) a hamiltonian cycle (a tour) with minimum
cost. The edges weights c(u,v) are nonnegative
integers. And, the weight function satisfies the
* Time: O(E) C ≤ 2C*  u
following triangle inequality:
ε(n) = 1
Theorem 35.1: Approx-Vertex-Cover has ρ(n) = 2. c(u,w) ≤ c(u,v)+c(v,w).
Proof: Let A be the set of edges picked in Line 4. w v
Since no two edges in A share an endpoint, we
have |C|=2|A|.

a1 a3

a2 a4 H W
arbitrarily select
35-5 35-6
root * (b): T: a minimum spanning tree T
T O(V) (c): W: a full walk of T
(d): H: a tour of length 19.074
(e): H*: an optimal tour of length
2
14.715
E+V (unsorted array)
Prim’s algo E lg V (binary heap)
minimum Time: O(E)=O(V2) E + V lg V (Fib. heap)
spanning tree Why not Kruskal's MST algo? O(E lg V)
(Prim's algo) complete graph
H ≤ 2H*
Theorem 35.2: Approx-TSP-Tour has ρ(n) = 2.
W
35-5a
H Proof: Let T be a minimum spanning tree.
Deleting any edge from H*, we can obtain a
spanning tree. Thus, |T| ≤ |H*|.  35-6x

A full walk, denoted by W, of T lists the 35-6y

vertices when they are first visited and also


tour whenever they are return to after a visit to a
according subtree. In our example,
full walk to W
W=(a, b, c, b, h, b, a, d, e, f, e, g, e, d, a).
W = (a, b, c, b, h, b, a, d, e, ...) |H| = 19.074  1 2 3 4 5 6 7 8 1
Clearly, |W|=2|T|. Thus, |W|≤2|H*|.
Note that W is not a tour. It visits a vertex more
than once. However, by triangle inequality, we can
delete unnecessary visits to a vertex without
increasing the cost to obtain H. (In our example,
H* H=(a, b, c, h, d, e, f, g).) Thus, |H|≤|W|≤2|H*|.
|H*| = 14.715 (optimal) Q.E.D. triangle ineq.
35-7 35-8
35.2.2 The general TSP problem
The subset-sum problem:
Current: 0.814 lg n S’ ⊆ S, sum(S’) = t
Without triangle inequality, an approximation Decision version: Given a set S of positive
algorithm with constant ratio bound does not exist integers and an integer t, determine whether there
∈ NP-C is a subset of S that adds up exactly to the target
unless P = NP.
t.
S’ ⊆ S, sum(S’) ≤ t, sum(S’) is max
Optimalization version: find a subset of S
35.5 The subset-sum problem whose sum is as large as possible but not larger
than t. (Ex. 16.2-2, see 16-3ab)
Approximation scheme: an approximation * special case of the knapsack problem: 35-8x

algorithm takes as input not only an instance of (C = t, all vi = wi) O(nC) by DP (pseudo-polynomial)
the problem, but also a constant relative error An exponential-time algorithm
35-8a

(A branch&bound algo - BFS)


bound ε > 0. * T(n) is a function of n & 1/ε
part of input (e.g., (1/ε)2n/3, n 3/ε, (1/ε)2n3, 2n/ε)
Li: all combinations of {x1, x2, ... xi}
Polynomial-time approximation scheme: an (sorted)
approximation scheme runs in O(nk) time, where k Cut 1:拿掉相同的
O(2|Li-1|) time 35-8z

is a constant. (e.g., O(n3/ε).) n沒出現在指數


* polynomial for fixed ε
e.g., O((1/ε)2n3)
n,1/ε都沒出現在指
Fully polynomial-time approximation scheme: (must be valid)
Cut 2:拿掉不合法的
an approximation scheme runs in O((1/ε)c nk) time,
Example: Let S=(2, 2, 14, 3) and t = 15.
c and k are constants. (e.g., O((1/ε)2 n3) time)  L0=<0>
*ε 減小,只影響constant factor <0>∪(<0>+2)=<0,2>  L1=<0,2>
L0 ∪ (L0 + 2) (sorted)
拿掉相同的
L1 L1 + 2 35-9 21,22 ≤ 20 x 1.1 35-10
11 ≤ 10 x 1.1
<0,2>∪(<0,2>+2)=<0,2,2,4>  L2=<0,2,4> Example:
L2∪(L2+14)=<0,2,4,14,16,18>  L3=<0,2,4,14> Let L = (10, 11, 12, 15, 20, 21, 22, 23, 24, 29).
拿掉不合法的 If δ = 0.1, we have
L3∪(L3+3)=<0,2,3,4,5,7,14,17>
L' = (10, 12, 15, 20, 23, 29).
 L4=<0,2,3,4,5,7,14>
optimal Let L = (y1, y2, …, ym). The following procedure
35-9x 35-9a
trims L in O(m) time.
Time:  2 | Li | = O(2n ). Note that |Li|=O(2i).
0 ≤ i ≤ n −1 
L'=(......, last)
e.g. t = O(n2), Li = O(t),  Li = O(nt) = O(n3)
 * In case t is polynomial in n, we have |Li|=O(t). “yi > (1+δ) × last”?
Thus, the algorithm performs in polynomial time. L=(........, yi, ............)
e.g. m = max(S) = O(n ), Li = O(nm),  Li = O(n m)
2 2

 * In case all integers in S are bounded by a = O(n4)


polynomial in n, the algorithm also performs in
polynomial time.
* pseudo-polynomial 35-9y z* ≤ t*; 0 ≤ (t*-z*)/t* ≤ 1
35-10x
A fully polynomial-time approximation scheme An approximation scheme (0 < ε < 1)
/delta/ 35-9b

To trim a list L by δ is to remove as many e.g., ε = 20%, n = 4


elements from L as possible, in such a way that if  δ =ε/4 =5%
L' is the result of trimming L, then for every c1:拿掉相同的
element y that was removed from L, there is an
element z≤y still in L' such that error ≤ δz δ = ε/n 35-10y

z y y ≤ z(1+δ) (y-z ≤ δz) (relative


error ≤ δ)
why removing y, not z?
(We can think of “z representing y” in L'.) c2:拿掉不合法的!
c3:拿掉很接近的
(進階版 c1)(吃掉 c1)
35-11 35-12
Example: Let S=<104, 102, 201, 101>, t=308, (b) relative error bound is within ε: 35-12a

and ε = 0.2. We have δ =ε/4 =0.05 and


δ = ε/n z1 t*
(z0 )
i=1
merge: delete same #
z2
seed of t* is
trim
cut by z1
remove > t
i=2 z*<= zk
seed of t*(z1) is
trim cut by z2
t * − z * =  ( zi'−1 − zi )
1≤ i ≤ k
i=3
≤  δ × zi
trim 1≤ i ≤ k zi ≤ t*
≤ kδt *
remove > t (308) k≤n
i=4 ≤ nδt *
δ = ε/n
≤ εt *
trim
Time =  2|Li|= O( |Li|)
remove > t (308) (c) fully polynomial-time:
≥1 ≤t 35-12x

The answer is z*=302, which is well within ε = 20%. Li: y1 = 0, y2, y3, …, yk
(The optimal answer is 307 (=104+102+101).) (distinct integers)

Theorem 35.8 Approx-Subset-Sum is a fully Since y2 ≥ 1 and yi > yi-1×(1+δ), we have


polynomial-time approximation scheme.
Proof: yk > (1+δ)k-2. 
(a) Clearly, the answer is legal. (not larger than t
and being the sum of a subset).
yk > (1+δ)k-2  35-13 35-14
Since yk ≤ t, we have Differences in the 3rd Edition
 k ≤ lg t+2
1+δ
k-2 ≤ log1+δ t. Thus, Approximation scheme: (1st) ε
(defined by relative error bound)
k = | Li | ≤ log1+δ t + 2 Given a parameter: α (0.6)
ln t Goal: ε = α (0.6)
= +2 lgc b
ln(1 + δ ) (lga b =
lg c a
) (or simply "Given ε")
(set δ = ε / n) (0.06 for n = 10)
(1 + δ ) ln t
≤ +2
δ Approximation scheme: (2nd, 3rd)
x Approximation Scheme: ρ
(by (3.17), ≤ ln(1 + x ) for x > -1) (defined by ratio bound)
1+ x
ε Given a parameter: α (0.6)
n(1 + ) ln t ε Goal: ρ = 1 + α (1.6)
≤ n +2 δ=n
ε (for MAX, set δ = α / 2n) (0.03 for n = 10)
2n ln t ε (In the textbook, ε is used to denote α)
≤ + 2 (by < 1)
ε n
ε < 1 (See 35-10)
Time = O(  | Li |)
0 ≤ i ≤ n −1
2n ln t
= O( n ( + 2))
ε
1 polynomial or 35-13x

= O( n 2 log2t ) pseudo-polynomial?
ε
fully polynomial Q.E.D.
Homework: Ex. 35.1-4, 35.5-4.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy