• Stick with small
problems
• Stick with small problems.
• Find special cases solvable in polynomial
time.
• Stick with small problems.
• Find special cases solvable in polynomial time.
• Find near –optimal solutions with approximate
algorithms
Approximation
Algorithms
By Riya Singh
Introduction
 An Approximate Algorithm is a way of approach NP-COMPLETENESS for the
optimization problem. This technique does not guarantee the best solution.
The goal of an approximation algorithm is to come as close as possible to the
optimum value in a reasonable amount of time which is at the most
polynomial time. Such algorithms are called approximation algorithm or
heuristic algorithm.
 For the traveling salesperson problem, the optimization problem is to find the
shortest cycle, and the approximation problem is to find a short cycle.
 For the vertex cover problem, the optimization problem is to find the vertex cover
with fewest vertices, and the approximation problem is to find the vertex cover
with few vertices.
Performance Ratios
 If for any input of size n, the cost C of the
solution produced by the algorithm is
within a factor of ρ(n) of the cost C* of an
optimal solution:
Max ( C/C* , C*/C ) ≤ ρ(n)
 We call this algorithm as an ρ(n)-
approximation algorithm.
Terminology
 P: Represents an NP-Hard problem such as 0/1 Knapsack or Traveling
Salesperson Problem.
 I: Represents an instance of problem P.
 F*(I): Represents an optimal solution to I.
 F^(I): Represents feasible solution produced for I by an approximation
algorithm.
 A: Represents an algorithm that generates a feasible solution to every
instance I of a problem P.
F*(I)>F^(I) if P is a maximization problem
F^(I)>F*(I) if P is a minimization problem
Approximation Scheme
 Absolute Approximation: A is absolute approximation
algorithm for problem P iff for every instance I of P,
|F*(I)-F^(I)|<=k for some constant k.
 f(n)-Approximation: A is an f(n)-approximation
algorithm of problem P iff for every instance I of size
n, |F*(I) – F^(I) |/ F*(I) <= f(n) for F*(I) >0.
 ε-Approximation: A is an epsilon (ε) approximation
algorithm of problem P iff A is f(n)-approximation
algorithm for which f(n) <=ε, where ε is some
constant.
Vertex Cover
The vertex-cover problem is to find a
vertex cover of minimum size in a
given undirected graph. We call such
a vertex cover an optimal vertex
cover. This problem is the
optimization version of an NP-
complete decision problem.
Vertex Cover
The VERTEX COVER problem is NP-hard.
VERTEX COVER
Input: An undirected graph G = (V, E).
Output: A subset of the vertices S ⊆ V
that touches every edge.
Goal: Minimize |S|.
Input: G
b
a
c
e
d
f
gf
b
a
c
e
d
f
gf
b
a
c
e
d
f
gf
Output: C = { b, d, e }
b
a
c
e
d
f
gf
Greedy-Vertex-Cover (G)
1. C={ }
2. do choose v in V with max deg
3. C = C + {v}
4. remove v
5. and every edge adjacent to v
6. until all edges are covered
7. return C
Input: G
b
a
c
e
d
f
gf
b
a
c
e
d
f
gf
b
a
c
e
d
f
gf
3 possible choices here determines the outcome
b
a
c
e
d
f
gf
b
a
c
e
d
f
gf
b
a
c
e
d
f
gf
b
a
c
e
d
f
gf
b
a
c
e
d
f
gf
Goodness of solution depends on
the (random) choices made
b
a
c
e
d
f
gf
Vertex Cover Algorithm
Approx-Vertex-Cover (G = (V, E))
{
C = empty-set;
E'= E;
While E' is not empty do
{
Let (u, v) be any edge in E': (*)
Add u and v to C;
Remove from E' all edges incident to
u or v;
}
Return C;
}
C={ }
E={ (a-b), (b-c), (c-e), (c-d), (e-f), (e-d), (f-d), (d-g) }
b
a
c
e
d
f
gf
C={ }
E={ (a-b), (b-c), (c-e), (c-d), (e-f), (e-d), (f-d), (d-g) }
b
a
c
e
d
f
gf
C={(b-c) }
E={ (e-f), (e-d), (f-d), (d-g) }
b
a
c
e
d
f
gf
C={(b-c) }
E={ (e-f), (e-d), (f-d), (d-g) }
b
a
c
e
d
f
gf
C={(b-c), (e-f) }
E={ (d-g) }
b
a
c
e
d
f
gf
C={ (b-c), (e-f) }
E={ (d-g) }
b
a
c
e
d
f
gf
C={ (b-c), (e-f), (d-g) }
E={ }
b
a
c
e
d
f
gf
C={ (b-c), (e-f), (d-g) }
C={ b, c, e, f, d, g }
|C|=6=2.3<=2.|C*|
the algorithm found a 2- approximation
b
a
c
e
d
f
gf
The traveling-salesman problem
 In the traveling salesman Problem, a salesman must visits n
cities. We can say that salesman wishes to make a tour or
Hamiltonian cycle, visiting each city exactly once and finishing
at the city he starts from. There is a non-negative cost c (i, j)
to travel from the city i to city j. The goal is to find a tour of
minimum cost. We assume that every two cities are connected.
Such problems are called Traveling-salesman problem (TSP).
 We can model the cities as a complete graph of n vertices,
where each vertex represents a city.
 It can be shown that TSP is NPC.
Traveling salesman problem
Given an undirected weighted
Graph G we are to find a
minimum cost Hamiltonian cycle.
Satisfying triangle inequality or
not this problem is NP-Complete.
We can solve Hamiltonian path.
Traveling salesman problem
Exact exponential
solution:
Branch and bound
• Lower bound: (sum of two
lower degree of vertices)/2
Traveling salesman problem
A: 2+3
B: 3+3
C: 4+4
D: 2+5
E: 3+6
= 35
Bound: 17.5
d
c
e
ba
7 4
3
3
56
2
6
4
Traveling salesman problem with
triangle inequality.
APPROX-TSP-TOUR(G, c)
1 select a vertex r Є V[G] to be root.
2 compute a MST for G from root r using Prim
Alg.
3 L=list of vertices in preorder walk of that MST.
4 return the Hamiltonian cycle H in the order L.
Traveling salesman problem with
triangle inequality.
root
MST
Pre-Order walk Hamiltonian
Cycle
The set-Cover
Generalization of vertex-cover problem.
We have given (X,F) :
X : a finite set of elements.
F : family of subsets of X such that every
element of X belongs to at least one subset
in F.
Solution C : subset of F that Includes all the
members of X.
Any Question?

Approximation

  • 2.
    • Stick withsmall problems
  • 3.
    • Stick withsmall problems. • Find special cases solvable in polynomial time.
  • 4.
    • Stick withsmall problems. • Find special cases solvable in polynomial time. • Find near –optimal solutions with approximate algorithms
  • 5.
  • 6.
    Introduction  An ApproximateAlgorithm is a way of approach NP-COMPLETENESS for the optimization problem. This technique does not guarantee the best solution. The goal of an approximation algorithm is to come as close as possible to the optimum value in a reasonable amount of time which is at the most polynomial time. Such algorithms are called approximation algorithm or heuristic algorithm.  For the traveling salesperson problem, the optimization problem is to find the shortest cycle, and the approximation problem is to find a short cycle.  For the vertex cover problem, the optimization problem is to find the vertex cover with fewest vertices, and the approximation problem is to find the vertex cover with few vertices.
  • 7.
    Performance Ratios  Iffor any input of size n, the cost C of the solution produced by the algorithm is within a factor of ρ(n) of the cost C* of an optimal solution: Max ( C/C* , C*/C ) ≤ ρ(n)  We call this algorithm as an ρ(n)- approximation algorithm.
  • 8.
    Terminology  P: Representsan NP-Hard problem such as 0/1 Knapsack or Traveling Salesperson Problem.  I: Represents an instance of problem P.  F*(I): Represents an optimal solution to I.  F^(I): Represents feasible solution produced for I by an approximation algorithm.  A: Represents an algorithm that generates a feasible solution to every instance I of a problem P. F*(I)>F^(I) if P is a maximization problem F^(I)>F*(I) if P is a minimization problem
  • 9.
    Approximation Scheme  AbsoluteApproximation: A is absolute approximation algorithm for problem P iff for every instance I of P, |F*(I)-F^(I)|<=k for some constant k.  f(n)-Approximation: A is an f(n)-approximation algorithm of problem P iff for every instance I of size n, |F*(I) – F^(I) |/ F*(I) <= f(n) for F*(I) >0.  ε-Approximation: A is an epsilon (ε) approximation algorithm of problem P iff A is f(n)-approximation algorithm for which f(n) <=ε, where ε is some constant.
  • 10.
    Vertex Cover The vertex-coverproblem is to find a vertex cover of minimum size in a given undirected graph. We call such a vertex cover an optimal vertex cover. This problem is the optimization version of an NP- complete decision problem.
  • 11.
    Vertex Cover The VERTEXCOVER problem is NP-hard. VERTEX COVER Input: An undirected graph G = (V, E). Output: A subset of the vertices S ⊆ V that touches every edge. Goal: Minimize |S|.
  • 12.
  • 13.
  • 14.
  • 15.
    Output: C ={ b, d, e } b a c e d f gf
  • 16.
    Greedy-Vertex-Cover (G) 1. C={} 2. do choose v in V with max deg 3. C = C + {v} 4. remove v 5. and every edge adjacent to v 6. until all edges are covered 7. return C
  • 17.
  • 18.
  • 19.
  • 20.
    3 possible choiceshere determines the outcome b a c e d f gf
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
    Goodness of solutiondepends on the (random) choices made b a c e d f gf
  • 26.
    Vertex Cover Algorithm Approx-Vertex-Cover(G = (V, E)) { C = empty-set; E'= E; While E' is not empty do { Let (u, v) be any edge in E': (*) Add u and v to C; Remove from E' all edges incident to u or v; } Return C; }
  • 27.
    C={ } E={ (a-b),(b-c), (c-e), (c-d), (e-f), (e-d), (f-d), (d-g) } b a c e d f gf
  • 28.
    C={ } E={ (a-b),(b-c), (c-e), (c-d), (e-f), (e-d), (f-d), (d-g) } b a c e d f gf
  • 29.
    C={(b-c) } E={ (e-f),(e-d), (f-d), (d-g) } b a c e d f gf
  • 30.
    C={(b-c) } E={ (e-f),(e-d), (f-d), (d-g) } b a c e d f gf
  • 31.
    C={(b-c), (e-f) } E={(d-g) } b a c e d f gf
  • 32.
    C={ (b-c), (e-f)} E={ (d-g) } b a c e d f gf
  • 33.
    C={ (b-c), (e-f),(d-g) } E={ } b a c e d f gf
  • 34.
    C={ (b-c), (e-f),(d-g) } C={ b, c, e, f, d, g } |C|=6=2.3<=2.|C*| the algorithm found a 2- approximation b a c e d f gf
  • 35.
    The traveling-salesman problem In the traveling salesman Problem, a salesman must visits n cities. We can say that salesman wishes to make a tour or Hamiltonian cycle, visiting each city exactly once and finishing at the city he starts from. There is a non-negative cost c (i, j) to travel from the city i to city j. The goal is to find a tour of minimum cost. We assume that every two cities are connected. Such problems are called Traveling-salesman problem (TSP).  We can model the cities as a complete graph of n vertices, where each vertex represents a city.  It can be shown that TSP is NPC.
  • 36.
    Traveling salesman problem Givenan undirected weighted Graph G we are to find a minimum cost Hamiltonian cycle. Satisfying triangle inequality or not this problem is NP-Complete. We can solve Hamiltonian path.
  • 37.
    Traveling salesman problem Exactexponential solution: Branch and bound • Lower bound: (sum of two lower degree of vertices)/2
  • 38.
    Traveling salesman problem A:2+3 B: 3+3 C: 4+4 D: 2+5 E: 3+6 = 35 Bound: 17.5 d c e ba 7 4 3 3 56 2 6 4
  • 39.
    Traveling salesman problemwith triangle inequality. APPROX-TSP-TOUR(G, c) 1 select a vertex r Є V[G] to be root. 2 compute a MST for G from root r using Prim Alg. 3 L=list of vertices in preorder walk of that MST. 4 return the Hamiltonian cycle H in the order L.
  • 40.
    Traveling salesman problemwith triangle inequality. root MST Pre-Order walk Hamiltonian Cycle
  • 41.
    The set-Cover Generalization ofvertex-cover problem. We have given (X,F) : X : a finite set of elements. F : family of subsets of X such that every element of X belongs to at least one subset in F. Solution C : subset of F that Includes all the members of X.
  • 42.