820 likes | 837 Views
Approximation Algorithms. Guo QI, Chen Zhenghai, Wang Guanhua, Shen Shiqi, Himeshi De Silva. Introduction. Shen Shiqi. Definition. Approximation Algorithm Return the solutions to optimization problem. Comparison Approximation algorithm: provably close to optimal
E N D
Approximation Algorithms Guo QI, Chen Zhenghai, Wang Guanhua, Shen Shiqi, Himeshi De Silva
Introduction Shen Shiqi
Definition • Approximation Algorithm • Return the solutions to optimization problem • Comparison • Approximation algorithm: provably close to optimal • Heuristic: may or may not find a good solution
Background • NP Problem • A set of decision problems in which given a solution, you can check it in polynomial time. • Approximation Ratio (approximation factor) • Ratio between the result obtained by the algorithm and the optimal cost • K-approximation algorithm • NP-hard Problem • A problem is NP-hard if all other problems in NP can be polynomially reduced to it. • At least as hard as the hardest problem in NP problems • NP-complete Problem • A problem is NP-complete if it is in NP and NP-hard.
Steiner Tree Problem Assume we are given: • a graph , • edge weights , • a set of required nodes R, • a set of steiner nodes S. Assume that . The Steiner Tree Problem is to find a subset of the Steiner points and a spanning tree of minimum weight. The weight of Tree is defined to be:
3 variants of Steiner Tree Problem • Euclidean • weights refers to the Euclidean distance from u and v • Metric • a metric distance function d: VxV → R which satisfies the following properties: • Non-negativity: for all u, v ∈V, d(u, v)≥0 • Identity: for all u∈V, d(u, u)=0 • Symmetric: for all u, v ∈V, d(u, v)=d(v, u) • Triangle Inequality: for all u, v, w∈V, d(u, v)+d(v, w)≥d(u, w) • General • weights can be arbitrary
Steiner Tree Problem → Metric Steiner Tree Problem Theorem: There is an approximation factor preserving reduction from the Steiner tree problem to the metric Steiner tree problem. Proof: • A instance I of the Steiner tree problem, consisting of graph G=(V,E) • Generate a complete undirected graph G’ on vertex set V. The cost of edge (u,v) in G’ is the smallest cost of u-v path in G • Find the Steiner Tree T’ in G’ • Replace each edge (u,v) in T’ by corresponding path in G • Delete edges if there are cycles ⇒ Obtain the Steiner Tree T for G
Minimum Spanning Tree • Definition of Minimum Spanning Tree • Given a graph G=(V, E) and edge weights , find a subset of the edges such that: • the subgraph is a spanning tree • the sum of edge weights is minimized.
Minimum Spanning Tree • Kruskal’salgorithm • create an empty set A • for each vertex v in V : • MAKE-SET(v) • sort E in nondecreasing order by weight w • for each (u, v) taken from the sorted list : • if u and v are not in the same set : • then add (u, v) into A • UNION(u, v) • if all nodes are in same set: • break A={(a,e),(c,d)} A={(a,e),(c,d),(a,b),(b,c)} A={(a,e)} A={(a,e),(c,d),(a,b)} A={} {a,e,b,c,d} {a,e,b}, {c,d} {a}, {b}, {c}, {d}, {e} {a,e}, {b}, {c,d} {a,e}, {b}, {c}, {d} 1 a e 4 7 6 3 b c d 5 2
Minimum Spanning Tree vs. Steiner Tree c c 5 km 5 km D=16 km 2 km 2 km a a b b e e D=17 km 3 km 5 km 4 km 4 km d d 3 km
MST-based Approximation Algorithm Wang Guanhua
MST-based Approximation Algorithm Method: Perform minimum spanning tree(MST) algorithm on Required vertices without any steiner vertices. Kruskal O(m*log n) MST algorithms Prim O(n^2)
The cost of a MST on R is within 2*OPT Theorem: For a set of required nodes R, a set of Steiner nodes S, and a metric distance function d. Consider an Optimal Steiner Tree(R+S, d) of cost OPT. The cost of a minimum spanning tree of (R, d) is within 2*OPT. Cost(MST) ≤ 2*OPT
Euler tour & Eulerian Graph Euler tour: An Euler tour is a trail which starts and ends at the same graph vertex. In other words, it is a graph cycle which uses each graph edge exactly once. (Also named by Eulerian cycle, Eulerian circuit, Euler circuit, etc.) degree = 3 (odd) Eulerian Graph: An Eulerian graph is a graph containing an Euler tour. Theorem: A connected graph has an Euler tour if and only if it has no graph vertices of odd degree.
Hamiltonian cycle Hamiltonian cycle: Is a graph cycle through a graph that visits each node exactly once.
Proof of 2*OPT • An example: An undirected, complete graph 1 b h 1 1 1 d g 1 c a 1 1 1 f e Green nodes: Required vertices Red nodes: Steiner vertices Assume: All edges drawn have distance 1(e.g. d to f), All edges not drawn have distance 2 (e.g. a to e) .
Proof of 2*OPT • An example: An undirected, complete graph 1 b h 1 1 1 d g 1 c a 1 1 1 f e Green nodes: Required vertices Red nodes: Steiner vertices Assume: All edges drawn have distance 1(e.g. d to f), All edges not drawn have distance 2 (e.g. a to e) .
Proof of 2*OPT • An example: An undirected, complete graph 1 b h 1 1 1 d g 1 c a 1 1 2 1 f e Green nodes: Required vertices Red nodes: Steiner vertices Assume: All edges drawn have distance 1(e.g. d to f), All edges not drawn have distance 2 (e.g. a to e) .
Step 1: Optimal Steiner tree • Optimal Steiner tree T. 1 b a 2 h 1 1 1 1 1 g h e d g 1 c 1 1 1 1 a 1 1 1 d f c b f e OPT=Cost(T) = 8 The cost is the sum of distance of all edges: 1 + 1 + 1+ 1 + 1 + 1 + 2 = 8
Step 2 • Obtain an Eulerian graph by doubling edges. a a 2 2 1 1 1 1 2 1 1 g h e g h e doubling edges 1 1 1 1 1 1 1 1 1 1 1 1 d f c b d f c b Optimal steiner tree Eulerian graph OPT = 8 Cost(EG) = 16
Step 3 • Find an Euler Tour by traversing edges of Eulerian graph in depth first search (DFS) order . a g h e d f c b Eulerian tour
Step 3 • Find an Euler Tour by traversing edges of Eulerian graph in depth first search (DFS) order . a g h e d f c b Eulerian tour
Step 3 • Find an Euler Tour by traversing edges of Eulerian graph in depth first search (DFS) order . a g h e d f c b Eulerian tour
Step 3 • Find an Euler Tour by traversing edges of Eulerian graph in depth first search (DFS) order . a g h e Cost(ET) = 16 d f c b Euler tour
Step 4 • Remove Steiner vertices from Euler Tour a a 2 2 1 1 1 2 1 2 1 2 g h e h e Remove g 1 1 2 1 1 1 1 1 1 1 1 1 1 d f c b d f c b (a,g)-> (g,d) (a,d) (d,g)-> (g,f) (d,f) (f,g)-> (g,a) (f,a)
Step 4 • Remove Steiner vertices from Euler Tour a a 2 2 2 2 2 2 2 h e e Remove h 1 2 2 2 1 1 1 1 2 d f c b d f c b Cost = 15 (a,h)-> (h,c) (a,c) (c,h)-> (h,b) (c,b) (b,h)-> (h,a) (b,a)
Step 5 • Obtain a Hamiltonian cycle by removing the duplicates. a a 2 2 2 2 2 2 e e Remove duplicates 2 2 2 1 1 2 2 2 d f c b d f c b a -> d -> f ->c -> b -> e -> a a -> d -> f ->a-> c -> b -> a -> e -> a “Short-cutting” Hamiltonian cycle (f,a)-> (a,c) (f,c) (b,a)-> (a,e) (b,e)
Step 5 • Obtain a Hamiltonian cycle by removing the duplicates. a a Because of triangle inequality, the shortcuts do not increase the cost. 2 2 2 2 2 2 e e Remove duplicates 2 2 2 1 1 2 2 2 d f c b d f c b a -> d -> f ->c -> b -> e -> a a -> d -> f ->a-> c -> b -> a -> e -> a “Short-cutting” Hamiltonian cycle (f,a)-> (a,c) (f,c) (b,a)-> (a,e) (b,e)
Step 5 • Obtain a Hamiltonian cycle by removing the duplicates. a a 2 2 2 2 2 2 e e Remove duplicates 2 2 2 1 1 2 2 2 d f c b d f c b a -> d -> f ->c -> b -> e -> a a -> d -> f ->a-> c -> b -> a -> e -> a “Short-cutting” Hamiltonian cycle (f,a)-> (a,c) (f,c) (b,a)-> (a,e) (b,e) Cost = 15 Cost (HC)= 11
Step 6 • Step 4: Remove any one arbitrary of the highest cost edge . It becomes to a spanning tree ST. a a 2 2 2 e e Remove (a,e) 2 2 1 1 2 2 2 2 d f c b d f c b Spanning Tree Hamiltonian cycle Cost(HC) = 11 Cost (ST)= 9
Step 5 • Step 4: Remove any one arbitrary of the highest cost edge . It becomes to a spanning tree ST. a a 2 2 2 e e Remove (a,e) 2 2 1 1 2 2 2 2 d f c b d f c b Spanning Tree Hamiltonian cycle Cost(HC) = 11 Cost (ST)= 9 Cost(MST) ≤ Cost (ST)
Conclusion • Conclusion: The minimum spanning tree has cost at most twice the cost of the optimal spanning tree T. Minimum spanning tree Spanning tree Hamiltonian cycle 2*Optimal steiner tree Cost(MST) ≤ cost(ST) ≤ cost(HC) ≤ 2*OPT Cost(MST) ≤ 2*OPT
Metric Travelling Salesman Problem Himeshi De Silva
The Travelling Salesman Problem (TSP) (A complete graph is a simple (no loops/multiple edges) undirected graph where every pair of distinct vertices is connected by a unique edge) (A tour is a path which visits all vertices of a graph and returns to its starting vertex) • NP-Hard Given a complete graph G=(V, E) with non-negative edge costs, find a minimum cost tour visiting each vertex exactly once
TSP example 2 ➩ 6 3 1 Cost of solution = 6 Thick edges = 1, thin edges= 2 5 4 • No constant factor approximation algorithm for TSP in general
Metric TSP • Metric TSP - a relaxed version of the problem allows for approximation • Assumption: The edges of the graph satisfy the triangle inequality 2 Cost(6,4) ≤ Cost(6,5) + Cost(5,4) 6 3 1 Still NP-complete, but no longer harder to approximate! 5 4
Example: Step 1 • Find an MST, T, of G. 2 2 ➩ 6 3 6 3 1 1 5 4 5 4 Thick edges = 1, thin edges= 2
Example: Step 2 • Double every edge in the MST to obtain an Eulerian graph 2 6 3 1 5 4
Example: Step 3 • Find an Eulerian tour, 𝛵, on the graph 2 1→2→1→4→1→3→1→5→1→6→1 6 3 1 5 4
Example: Step 4 • Output the tour that visits vertices of the graph in the order of their first appearance in 𝛵. Let C be this tour. 2 T: 1→2→1→4→1→3→1→5→1→6→1 6 3 ⇓ 1 C: 1→2→4→3→5→6→1 “Short-cutting” 5 4
Result C: 1→2→4→3→5→6→1 2 6 3 1 Cost of the tour = 1 + 2 + 1 + 2 + 1 + 1 = 8 5 4
Factor 2 Analysis Proof: (important observation) Delete any edge from an optimal solution to TSP forms a spanning tree. Cost(T) ≤ OPT (OPT - cost of optimal TSP solution)
Factor 2 Analysis Proof: Eulerian tour contains every edge of MST twice: Cost(𝒯) = 2*Cost(T)
Factor 2 Analysis Proof: Eulerian tour contains every edge of MST twice: Cost(𝒯) = 2*Cost(T) “Short-cutting” steps obey the triangular inequality: Cost(C) ≤ Cost(𝒯)
Factor 2 Analysis Combining all, Cost(T) ≤ OPT Cost(𝒯) = 2*Cost(T) ≤ 2*OPT Cost(C) ≤ Cost(𝒯) Cost(C) ≤ 2*OPT
Improving the factor to 3/2 - Christofides’ Algorithm Chen Zhenghai
Improving the factor Double an MST -> Eulerian graph -> Eulerian tour -> Short-cutting Cheaper way to get Eulerian graph? A graph has an Euler tour iff all its vertices has even degrees Only need to be concerned about the odd degree vertices
Minimum weight perfect matching Perfect matching: Every vertex of the graph is incident to exactly one edge of the matching. Input Graph Minimum matching 1 Minimum matching 2
Handshaking Lemma (Euler) The size of V ′ (odd degree vertices set) is even in undirected graph. Proof. Every edge contributes 2 degree. So the total degree is equal to 2|E|, which is even. Thus the number of odd degree vertices is also even.