Presentation is loading. Please wait.

Presentation is loading. Please wait.

School of Computing Clemson University Fall, 2012

Similar presentations


Presentation on theme: "School of Computing Clemson University Fall, 2012"— Presentation transcript:

1 School of Computing Clemson University Fall, 2012
Lecture 15. Approximation Algorithms CpSc 212: Algorithms and Data Structures Brian C. Dean School of Computing Clemson University Fall, 2012

2 College Life: Pick Any Two of
the Following… Good grades Sleep Social Life

3 Hard Problems: Pick Any Two
of the Following… An optimal solution To every possible input In polynomial time

4 Hard Problems: Pick Any Two
of the Following… An optimal solution To every possible input In polynomial time This gives us several possible approaches: (1+2). Study heuristics that tend to give us fast algorithms that work well “in practice” but don’t have any theoretical performance guarantees. (1+3). Study special cases that can be solved in polytime. (2+3). Devise approximation algorithms that run fast, but might produce suboptimal solutions (hopefully within some provably close distance of an optimal solutions).

5 Special Cases Special cases of many NP-hard or worse problems can be solved in polynomial time. Example: Bitonic TSP (a.k.a. “Touring Canada”) We often want to find the minimal instances of a problem that are NP-hard and the maximal special cases that can be solved in polytime. Example: the rank aggregation problem can be solved in polytime for k = 2, and it’s NP-hard for k ≥ 4.

6 Approximation Algorithms
An α-approximation algorithm is an algorithm (typically that runs in polytime) whose solution never differs from an optimal solution by more than a factor of α. The factor α is called the performance guarantee of the algorithm. The smaller, the better. The difficulty with approximation algorithms, of course, is proving that your solution is not far away from an optimal solution you don’t know!

7 The Minimum Spanning Tree Problem
Goal: Find a min-cost subnetwork that connects together all nodes. Very well-studied problem; can be solved very efficiently. And the cost of an MST is a lower bound on an optimal TSP tour! 7 19 8 10 9 12 15 11 2 14 4 16 3

8 A 2-Approximation Algorithm
for “Metric” TSP Suppose we have a graph whose edge costs satisfy the triangle inequality (a fairly common occurrence): c(i, j) + c(j, k) ≥ c(i, k) for all (i, j, k). (note that this implies that all edges are present in the graph) Let T* be an optimal TSP tour. Recall that cost(MST) ≤ cost(T*). We’ll show how to construct a tour T of cost at most 2cost(MST) ≤ 2cost(T*)…

9 Walking Around a Tree and Introducing Shortcut Edges
Start by walking “around” the tree. New cost: 2cost(MST) ≤ 2cost(T*). Now add “shortcut” edges to convert into a proper tour; note this doesn’t increase cost, due to the triangle inequality!

10 Tracing Can you trace the following figure without lifting your pen from the paper? (no silly tricks like folding the paper over, etc…!)

11 The Bridges of Königsberg
Perhaps the earliest occurrence of this type of problem dates back to early 18th century... Residents of Königsberg (a city in East Prussia with 4 distinct “regions” separated by rivers) supposedly wanted to know if there was a way to walk around so that each bridge is crossed exactly once…

12 Eulerian Tours Leonard Euler gave an elegant proof that no path exists! He started by modeling the city abstractly as a graph: Now we want to find a path through the graph that follows every edge exactly once. Such a path is now called an Euler (or Eulerian) path.

13 It’s All About Parity! 3 We can find an Euler path only if at most two nodes have odd degree. Note that it’s impossible for only one node to have odd degree… why? If all nodes have even degree, then we can find an Eulerian cycle (an Eulerian path that ends where it started). Easy construction: start at any node, and walk around arbitrarily (erasing the edges we take) until we get back to where we started. This traces out a cycle. Repeat until all edges are gone, then “splice” together all the cycles we found. If we start with two nodes having odd degree, temporarily join them with an edge e, find an Eulerian cycle, and then remove e to get an Eulerian path. 5 3 3

14 Eulerian Cycles : Further Notes
We can also easily find an Eulerian cycle on a directed graph, as long as each node has equal indegree and outdegree. By contrast, a Hamiltonian cycle (visiting every node exactly once, rather than every edge) is NP-hard to find! As a consequence, it is NP-hard to approximate the non-metric TSP to within any factor!

15 A 3/2-Approximation Algorithm
for Metric TSP Start with a MST Super-impose a min-cost matching on its odd-degree nodes. Resulting graph now has all even degrees, so we can find an Eulerian tour and shortcut it down to a valid TSP tour. Analysis: Cost(MST) ≤ Cost(T*) Cost(Matching) ≤ ½ Cost(T*) Shortcutting doesn’t increase cost.


Download ppt "School of Computing Clemson University Fall, 2012"

Similar presentations


Ads by Google