This is a polynomial-time algorithm that may not find the optimal solution, but it is never too far for optimal.
Consider any minimization or maximization problem and suppose we have algorithm A. For each problem instance I, it returns a solution with values .
Approximation Ratio
The approximation ration of algorithm is defined as:
Minimization problem:
Maximization problem:Where is the value of the optimal solution to instance I
for minimization problems for maximization problems . Since A is an approximation, it will not be optimal.
Given a problem whose search version is NP Complete, the goal is to find an algorithm A with closest to 1. This needs to run in Polynomial Time.
Traveling Salesman Problem with Triangle Inequality
- Compute a Minimum Spanning Tree of graph G
- Duplicate each edge
- Compute a Eulerian Cycle of the graph with duplicated edges
- To make a tour, follow the cycle and skip any vertex you have already visited
- Skipping makes a shortcut by the triangle inequality
- The length of the optimal TSP ≥ length of the MST (since a tour is a spanning tree)
- Since we doubled each edge and used an eulerian cycle, this is an approximation algorithm with a at worst.
- The runtime here is where the bottleneck is making the MST
We can also solve Hamiltonian Paths using general TSP without the triangle inequality where we set the lengths to 1 if , or if . An HC is found in G if it uses all edges of length 1. Otherwise, it finds a tour of length . In this case, since A is an approximation, , which means there is no HC in G.
Rsults
Unless P=NP, there is no factor approximation algorithm for the TSP for any .
So if we drop the triangle approximation, even though this is NP complete, there is no approximation.
Knapsack without Repetition
We had an time Dynamic Programming algorithm as W is exponential in input size. We can modify this to find an algorithm and then a more efficient one.
Here, is the sum of all the values. The subproblem is . if no such set of items exists. is either just , or so we either use or we don’t. The smallest subproblem is and . Our runtime is and our answer is such that ≤ W.
The Approximation
Input: An ε > 0; a knapsack problem instance.
Discard any item with weight > W
Let v_max = max_i v_i
Rescale values of each item:
v̂_i = floor(v_i n / (ε v_max))
Run the O(nV) dynamic programming algorithm where each item i has value v̂_i and weight w_i
Output the resulting choice of itemsThis is a approximation algorithm with runtime . This gives us an arbitrarily good approximation.