17 Approximation Algorithms
17 Approximation Algorithms
Algorithms
Approximation
• A strategy applied to problem domains that
are in NP-Complete Class
• Optimum or exact solutions for these
problems not possible in polynomial time
• But, near-optimal solution may be derived
in polynomial time
• Algorithms that provide near-optimal
solutions are called Approximation
Algorithms
2
Approximation Ratio
• Performance of the Approximation
Algorithms measured by Approximation
Ratio
• The Ratio is equal or greater than 1
• Approximation Ratio equal to 1 indicates
Optimal Solution is reached
• Smaller values of the Ratio indicate better
approximation
3
Approximation Ratio
• Approximation Ratio is defined
differently for Minimisation and
Maximisation problems
• Let C*(n) be cost of optimum algorithm
with input size n, with C(n) be cost of
approximate algorithm for the same input
• Approximation Ratio, defined as
ρ(n) = (C*(n)/C(n)), for Maximisation
ρ(n) = (C(n)/C*(n)), for Minimisation
4
Categories of Approximation
• Category 1: Approximation Ratio is
independent of input size
• Category 2: Approximation Ratio increases
with input size
• Category 3: Approximation Ratio increases
with input size, also, decreases with
increasing computation time
– If the program runs longer, it arrives at a
better solution for a given input
5
Approximation Schemes
• Category 3 algorithms having two inputs:
– Input size (n)
– Error Factor, ε, greater than zero
• Approximation Ratio achieved is (1 + ε),
with time complexity depending on n and
inverse of Error Factor, ε
• Called Polynomial Time Approximation
Scheme (PTAS)
• Example: T(n) O(n2/ε)
6
Approximation Schemes
• Special Case: Approximation Schemes with
time complexity in polynomial order of
input size, n, and, also in polynomial order
of inverse of error factor, (1/ε)
• Example: T(n) O(n2(1/ε)3)
• Called Fully Polynomial Time
Approximation Scheme (FPTAS)
7
Vertex Cover
• For an undirected graph, Vertex Cover
indicates a set of vertices which covers all
edges in the graph
• Optimal Vertex Cover is such a set that
contains the minimum number of vertices
• NP Complete Problem
• Approximate Vertex Cover can be derived
in polynomial time
8
Vertex Cover
B C E
A D F G
9
Vertex Cover
B C E
A D F G
Optimum Solution
10
Approximate Vertex Cover
Procedure Approx_Vertex_cover (G)
Begin
Initialize C as Null set // C is vertex cover set
End Repeat
Return C
End
11
Approximate Vertex Cover
B C E
A D F G
Algorithm
12
Approximate Vertex Cover
• Approximation Algorithm for Vertex Cover
has time complexity O(V + E), when
Adjacency List is used
• Approximate Vertex Cover typically twice
the size of Optimal Solution
• Category 1 Algorithm - Approximation
factor not dependent upon size of Graph
• 2-Approximation Algorithm
13
Traveling Salesperson Problem
• In an undirected graph, a Hamiltonian
Path traverses every vertex only once
• Traveling Salesperson Problem is the
Hamiltonian Path with minimum cost
• NP Complete problem
• Traveling Salesperson Problem (TSP) for a
graph with n vertices, using Dynamic
Programming, can be computed with time
complexity, T(n) Θ (n2 2n)
14
Approximate TSP Algorithm
• Approximation approach:
– Create an MST, T, for the graph, G
– Traverse T in Pre-Order, add vertices visited in set H
– Return H as the Hamiltonian Path
• Polynomial time algorithm (MST, Pre-Order)
• Approximation Cost twice of Optimal Cost
– Every vertex visited twice (MST, Pre-Order)
• Approximation Factor independent of Input Size
(Category 1)
• 2 Approximation Algorithm
15
Approximate Set Cover
• Problem:
– Given a Set S and X as set of subsets of S, with
every element of S belonging to at least one
subset of X
– Optimal Solution: Minimum X for a given S
– NP Complete Problem
• Approximate Set Cover is a Category 2
Algorithm
• Approximation Ratio increases with
increase in size of S, in logarithmic order 16
Approximate Subset Sum
• Problem:
– A Set S of positive integers and a value, T, check
if sum of any elements of S is equal to T
– NP Complete Problem
• Approximate Subset Sum is a Category 3
Algorithm
• A Fully Polynomial Time Approximation
Scheme, with time complexity in polynomial
order of input size and inverse of Error
Factor, ε, where 0 < ε < 1. 17
The End