Approx
Approx
Approximation
Algorithms
1
NP-completeness
2
Coping With NP-Hardness
Brute-force algorithms.
Develop clever enumeration strategies.
Guaranteed to find optimal solution.
No guarantees on running time.
Heuristics.
Develop intuitive algorithms.
Guaranteed to run in polynomial time.
No guarantees on quality of solution.
Approximation algorithms.
• Guaranteed to run in polynomial time.
• Guaranteed to find "high quality" solution, say within 1% of optimum.
Obstacle: need to prove a solution’s value is close to optimum,
without even knowing what optimum value is!
3
Performance guarantees
4
Different Approaches
5
Vertex Cover
6
Approximation Algorithms
7
Vertex Cover: Greedy Algorithm 1
Idea: Keep finding a vertex which covers the maximum number of edges.
Greedy Algorithm 1:
1. Find a vertex v with maximum degree.
2. Add v to the solution and remove v and all its incident edges from the graph.
3. Repeat until all the edges are covered.
8
Vertex Cover: Greedy Algorithm 1
Generalizing
the example!
Let C* denote the optimal vertex cover of G which contain m number of vertices
|Gi-1| denote the number of edges in the graph Gi-1.
Then
mi=1 d i
mi=1 |G i-1
| /m mi=1 |G | /m =|G | = |G| -mi=1 d
m m i
11
Vertex Cover: Greedy Algorithm 1
Thus
after m.log |G| iterations
all the edges of G have been removed
Greedy approach does not always lead to the best approximation algorithm
C=
while G has atleast one edge
(u,v) any edge of G
G = G \ {u, v}
C = C {u, v}
return C
For edge (u, v), at least one of the vertex u or v must be in any
optimal cover
14
Traveling Salesman
Consider G be an arbitrary undirected graph with n vertices
Traveling salesman problem is NP hard even if all the edge lengths are 1 or 2
Due to polynomial time reduction from Hamiltonian cycle to this type
of Traveling salesman problem
15
Traveling Salesman
We can replace the values in length function by any values we like
17
Traveling Salesman : A Special Case
18
Traveling Salesman : A Special Case
Demonstration
Demonstration
Demonstration
Consider this as
root
Demonstration
7
6
1 5
2
3 4
Demonstration
7
6
1 5
2
3 4
Demonstration
7
6
1 5
3
2
4
Demonstration
7
6
1 5
3
2
4
Output quality :
Cost of the tour using this algorithm
2* cost of minimum spanning tree
2* cost of optimal solution
26
Traveling Salesman : A Improved heuristic
1 5
2
3 4
1
5
1
5
2
3 4
Idea: Keep finding a set which is the most effective in covering remaining elements.
Greedy Algorithm:
1. Find a set S which is most cost-effective.
2. Add S to the solution and remove all the elements it covered from the ground set.
3. Repeat until all the elements are covered.
30
Logarithmic Approximation
Theorem. The greedy algorithm is an O(log n) approximation for the set cover problem.
31
Lower bound and Approximation Algorithm
33
An Example: Vertex Cover
0.5 1
0.5 0.5 1 0
0.5 0.5 1 1 34
Linear Programming Relaxation for Vertex Cover
First solve the linear program to obtain the fractional values x*.
Then flip a (biased) coin for each set with probability x*(S) being “head”.
elements
Add all the “head” vertices to the set cover. Repeat log(n) rounds.
37
Performance
Claim 1: The sets picked in each round have an expected cost of at most LP.
Claim 2: Each element is covered with high probability after O(log(n)) rounds.
So, after O(log(n)) rounds, the expected total cost is at most O(log(n)) LP,
and every element is covered with high probability, and hence the theorem.
Claim 1: The sets picked in each round have an expected cost of at most LP.
Q.E.D.
39
Feasibility
Claim 2: Each element is covered with high probability after O(log(n)) rounds.
First consider the probability that an element e is covered after one round.
40
Pr[e is not covered in one round] <= (1 – 1/k)k
Feasibility
Claim 2: Each element is covered with high probability after O(log(n)) rounds.
First consider the probability that an element e is covered after one round.
So,
41
Feasibility
Claim 2: Each element is covered with high probability after O(log(n)) rounds.
So,
So,
42
Remark
Let say the sets picked have an expected total cost of at most clog(n) LP.
Claim: The total cost is greater than 4clog(n) LP with probability at most ¼.