Approximation Algorithms Lecture for CS 302
What is a NP problem? Given an instance of the problem, V, and a ‘certificate’, C, we can verify V is in the language in polynomial time All problems in P are NP problems – Why?
VERTEX-COVER Given a graph, G, return the smallest set of vertices such that all edges have an end point in the set
HAMILTONIAN PATH Given a graph, G, find a path that visits every vertex exactly once Alt version: Find the path with the minimum weight
What is NP-Complete? A problem is NP-Complete if: – It is in NP – Every other NP problem has a polynomial time reduction to this problem NP-Complete problems: – 3-SAT – VERTEX-COVER – CLIQUE – HAMILTONIAN-PATH (HAMPATH)
Applications
SAT is used to verify circuit design NEED MORE EXAMPLES. WANT PICTURES
Dilemma NP problems need solutions in real-life We only know exponential algorithms What do we do?
Accuracy NP problems are often optimization problems It’s hard to find the EXACT answer Maybe we just want to know our answer is close to the exact answer?
Approximation Algorithms Can be created for optimization problems The exact answer for an instance is OPT The approximate answer will never be far from OPT We CANNOT approximate decision problems
k-approximation S is the approx. answer, OPT is optimal Maximization – k*OPT ≤ S ≤ OPT Minimization – OPT ≤ S ≤ k*OPT
Approximate Vertex-Cover Let S be the cover Pick an edge (u,v) in the graph Add it’s end-points u and v to S Remove any edge that neighbors u or v Repeat until there are no edges left
Approximate Vertex-Cover OPT must cover every edge so either u or v must be in the cover => OPT > ½|S| => 2*OPT ≥ |S| We have a 2-approximation
Traveling Salesperson Problem Given a graph, find a minimum weight hamiltonian path There is a 2-approximation based on MINIMUM SPANNING TREES
Minimum Spanning Tree Given a graph, G, a Spanning Tree of G is a subgraph with no cycles that connects every vertex together A MST is a Spanning Tree with minimal weight
Finding a MST Finding a MST can be done in polynomial time using PRIM’S ALGORITHM or KRUSKAL’S ALGORITHM Both are greedy algorithms Details can be found on Wikipedia
MST vs HAMPATH Any HAMPATH becomes a Spanning Tree by removing an edge cost(MST) ≤ cost(min-HAMPATH)
Approximate TSP Given a complete graph G Compute G’s MST, M The tour is the pre-order traversal of M This is a 2-approximation
Approximating 3-SAT f is a Boolean formula in 3-CNF form if: What’s the optimization version of 3-SAT? Satisfy as many clauses as you can
Approximating 3-SAT Algorithm: – For each variable x i assign True with probability ½, False with probability ½ – This satisfies 7/8ths of the clauses in expectation
Approximating 3-SAT x1x1 x2x2 x3x3 TTTT TTTF TTFT TTFF TFTT TFTF TFFT FFFF The only way we don’t satisfy the clause is if we select the last assignment. This happens only 1/8 th of the time.