400 likes | 1.02k Views
Approximation Algorithms. Approximation Algorithms. Coming up Concepts of approximation algorithms Examples of approximation algorithms The Vertex-Cover Problem The Traveling Salesman Problem (Chap 35). Approximation Algorithms. If a problem is NP-complete, what can we do?
E N D
Approximation Algorithms Coming up • Concepts of approximation algorithms • Examples of approximation algorithms • The Vertex-Cover Problem • The Traveling Salesman Problem (Chap 35)
Approximation Algorithms If a problem is NP-complete, what can we do? • If the actual inputs are small, an algorithm with exponential running time may be satisfactory. • We may be able to isolate important special cases that are solvable in polynomial time. • It may still be possible to find near-optimal solutions in polynomial time. Approximation Algorithm near-optimal solutions
Approximation Algorithms For optimization problems, solutions are associated with a cost. • The optimal solution should provide an optimal cost: C*. • An approx. algorithm gives a near-optimal solution with a cost, say C. We care about how C is near to C*. Consider C/C* and C*/C. For minimization problems: C/C* > 1, C*/C<1 => max(C/C*, C*/C) = C/C* describes how good C is. For maximization problems: C*/C > 1, C/C*<1 => max(C/C*, C*/C) = C*/C describes how good C is. Thus, max (C/C*, C*/C) describes how C* is near to the optimal.
Approximation Algorithms Given an optimization alg., we say it has an approximation ratio of (n) if:For any input of size n, max (C/C*, C*/C) (n). It is a (n)-approximation algorithm. A 1-approximation algorithm produces an optimal solution. Some polynomial-time approx. algorithms have approximation ratios that grow as functions of the input size n.(eg. set-cover) Some polynomial-time approx. algorithms have approximation ratios that improve when it is allowed to spend longer and longer time to run.(eg. Subset-sum) Some polynomial-time approx. algorithms have approximation ratios that can be specified by you as 1+ and it runs as a (1+)-approx alg.. T(n) could be polynomial or exponential in 1/ etc.. eg.O((1/ )2n3).
b c d b c d a e f g a e f g b c d b c d a e f g a e f g b c d b c d a e f g a e f g Approximation Algorithms Approx_Vertex_Cover(G) /* G = (V,E) */ 1 C = 2 E’ = E 3 while E’ 4 let (u,v) be an arbitrary edge of E’ 5 C = C U {u,v} 6 remove from E’ every edge joining either u or v 7 return C The Vertex-Cover Problem: Optimal solution (C*) Near-optimal solution (C)
b c d b c d a e f g a e f g Approximation Algorithms Approx_Vertex_Cover(G) /* G = (V,E) */ 1 C = 2 E’ = E 3 while E’ 4 let (u,v) be an arbitrary edge of E’ 5 C = C U {u,v} 6 remove from E’ every edge joining either u or v 7 return C Approx_Vertex_Cover is a 2-approximation algorithm. Proof: Consider line 4. Suppose there are totally |A| edges considered in line 4. Then |C*||A| But |C| = 2|A| Hence |C| = 2|A| 2|C*| Optimal solution (C*) Near-optimal solution (C)
a a a d d d a a d d e e e e e b b b f f f g g g b b f f g g c c c c c h h h h h Optimal solution (C*) Approximation Algorithms The Traveling-Salesman Problem (where the edge weights are the Euclidean distances) Given a complete graph, Find a simple cycle thru all vertices with minimum total weight. Near-optimal solution (C)
a a d d a a d d e e e e b b f f g g b b f f g g c c c c h h h h Optimal solution (C*) Near-optimal solution (C) Approximation Algorithms The Traveling-Salesman Problem (where the edge weights are the Euclidean distances) Approx_TSP_Tour is a 2-approximation algorithm. Proof: • If we removed one edge from C*, we get a spanning tree. • ie. The cost of C* some spanning tree. • Cost of the min. spanning tree costs of all spanning trees. • => Cost of the min. spanning tree cost of C*. • Cost of C 2 x cost of the minimum spanning tree. • Conclusion: cost of C 2 x cost of C*.
Approximation Algorithms Summary • Concepts of approximation algorithms • Examples of approximation algorithms • The Vertex-Cover Problem • The Traveling Salesman Problem