Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 1 Approximation.

Similar presentations


Presentation on theme: "CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 1 Approximation."— Presentation transcript:

1

2 CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 1 http://www.cs.cityu.edu.hk/~helena Approximation Algorithms

3 CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 2 http://www.cs.cityu.edu.hk/~helena Approximation Algorithms Coming up Concepts of approximation algorithms Examples of approximation algorithms The Vertex-Cover Problem The Traveling Salesman Problem (Chap 35)

4 CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 3 http://www.cs.cityu.edu.hk/~helena 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

5 CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 4 http://www.cs.cityu.edu.hk/~helena 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.

6 CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 5 http://www.cs.cityu.edu.hk/~helena 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/  ) 2 n 3 ).

7 CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 6 http://www.cs.cityu.edu.hk/~helena Optimal solution (C*) Approximation Algorithms The Vertex-Cover Problem: bcd gaef bcd gaef bcd gaef bcd gaef bcd g a ef b c d ga e f Near-optimal solution (C) 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} 6remove from E’ every edge joining either u or v 7 return C

8 CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 7 http://www.cs.cityu.edu.hk/~helena Optimal solution (C*) Approximation Algorithms Approx_Vertex_Cover is a 2-approximation algorithm. bcd g a ef b c d ga e f Near-optimal solution (C) 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} 6remove from E’ every edge joining either u or v 7 return C 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*|

9 CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 8 http://www.cs.cityu.edu.hk/~helena 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. c b d g a e f h c b d g a e f h c b d g a e f h c b d g a e f h Near-optimal solution (C) Optimal solution (C*) c b d g a e f h

10 CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 9 http://www.cs.cityu.edu.hk/~helena Approximation Algorithms The Traveling-Salesman Problem (where the edge weights are the Euclidean distances) Approx_TSP_Tour is a 2-approximation algorithm. 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*. c b d g a e f h c b d g a e f h Near-optimal solution (C) Optimal solution (C*) c b d g a e f h c b d g a e f h Proof:

11 CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 10 http://www.cs.cityu.edu.hk/~helena Approximation Algorithms Summary Concepts of approximation algorithms Examples of approximation algorithms The Vertex-Cover Problem The Traveling Salesman Problem


Download ppt "CS3381 Des & Anal of Alg (2001-2002 SemA) City Univ of HK / Dept of CS / Helena Wong 8. Approximation Alg. - 1 Approximation."

Similar presentations


Ads by Google