Upload
giles-spencer
View
220
Download
0
Tags:
Embed Size (px)
Citation preview
An introduction to An introduction to Approximation AlgorithmsApproximation Algorithms
Presented By Presented By Iman SadeghiIman Sadeghi
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 22
OverviewOverview IntroductionIntroduction Performance ratiosPerformance ratios The vertex-cover problemThe vertex-cover problem Traveling salesman problemTraveling salesman problem Set cover problemSet cover problem
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 33
IntroductionIntroduction There are many important NP-There are many important NP-
Complete problemsComplete problems There is no fast solution !There is no fast solution !
But we want the answer …But we want the answer … If the input is small use backtrack.If the input is small use backtrack. Isolate the problem into P-problems !Isolate the problem into P-problems ! Find the Find the Near-OptimalNear-Optimal solution in solution in
polynomial time.polynomial time.
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 44
Performance ratiosPerformance ratios We are going to find a Near-We are going to find a Near-
Optimal solution for a given Optimal solution for a given problem.problem.
We assume two hypothesis :We assume two hypothesis : Each potential solution has a positive Each potential solution has a positive
cost.cost. The problem may be either a The problem may be either a
maximization or a minimization maximization or a minimization problem on the cost.problem on the cost.
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 55
Performance ratios …Performance ratios … If for any input of size n, the cost C If for any input of size n, the cost C
of the solution produced by the of the solution produced by the algorithm is within a factor of algorithm is within a factor of ρ(n)ρ(n) of the cost C* of an optimal of the cost C* of an optimal solution:solution:
Max ( C/C* , C*/C ) ≤ ρ(n)Max ( C/C* , C*/C ) ≤ ρ(n) We call this algorithm as an ρ(n)-We call this algorithm as an ρ(n)-
approximation algorithm.approximation algorithm.
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 66
Performance ratios …Performance ratios … In Maximization problems:In Maximization problems:
0<C≤C* , ρ(n) = C*/C0<C≤C* , ρ(n) = C*/C In Minimization Problems:In Minimization Problems:
0<C*≤C , ρ(n) = C/C*0<C*≤C , ρ(n) = C/C* ρ(n) is never less than 1. ρ(n) is never less than 1. A 1-approximation algorithm is the optimal A 1-approximation algorithm is the optimal
solution.solution. The goal is to find a polynomial-time The goal is to find a polynomial-time
approximation algorithm with small approximation algorithm with small constant approximation ratios.constant approximation ratios.
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 77
Approximation schemeApproximation scheme Approximation schemeApproximation scheme is an is an
approximation algorithm that takes Є>0 approximation algorithm that takes Є>0 as an input such that for any fixed Є>0 as an input such that for any fixed Є>0 the scheme is (1+Є)-approximation the scheme is (1+Є)-approximation algorithm.algorithm.
Polynomial-time approximation Polynomial-time approximation scheme scheme is such algorithm that runs in is such algorithm that runs in time polynomial in the size of input.time polynomial in the size of input. As the Є decreases the running time of the As the Є decreases the running time of the
algorithm can increase rapidly:algorithm can increase rapidly: For example it might be O(nFor example it might be O(n2/Є2/Є))
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 88
Approximation schemeApproximation scheme We haveWe have Fully Polynomial-time Fully Polynomial-time
approximation scheme approximation scheme when its when its running time is polynomial not only running time is polynomial not only in n but also in in n but also in 11//ЄЄ
For example it could be O((For example it could be O((11//ЄЄ))33nn22))
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 99
Some examples:Some examples:
Vertex cover problem.Vertex cover problem. Traveling salesman problem.Traveling salesman problem. Set cover problem.Set cover problem.
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 1010
The vertex-cover problemThe vertex-cover problem A vertex-cover of an undirected A vertex-cover of an undirected
graph G is a subset of its vertices graph G is a subset of its vertices such that it includes at least one such that it includes at least one end of each edge.end of each edge.
The problem is to find minimum size The problem is to find minimum size of vertex-cover of the given graph.of vertex-cover of the given graph.
This problem is an NP-Complete This problem is an NP-Complete problem.problem.
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 1111
The vertex-cover problemThe vertex-cover problem ……
Finding the optimal solution is hard Finding the optimal solution is hard (its NP!) but finding a near-optimal (its NP!) but finding a near-optimal solution is easy.solution is easy.
There is an 2-approximation There is an 2-approximation algorithm:algorithm: It returns a vertex-cover not more It returns a vertex-cover not more
than twice of the size optimal than twice of the size optimal solution.solution.
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 1212
The vertex-cover problemThe vertex-cover problem ……
APPROX-VERTEX-COVER(G)APPROX-VERTEX-COVER(G)
1 1 C ← ØC ← Ø2 2 E′ ← E[G]E′ ← E[G]3 3 while while E′ ≠ ØE′ ≠ Ø4 4 do do let (u, v) be an arbitrary edge of E′let (u, v) be an arbitrary edge of E′5 5 C ← C U {u, v}C ← C U {u, v}6 6 remove every edge in E′ incident on u or remove every edge in E′ incident on u or
vv7 7 return return CC
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 1313
The vertex-cover problemThe vertex-cover problem ……
OptimalSize=3
Near Optimalsize=6
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 1414
The vertex-cover problemThe vertex-cover problem ……
This is a polynomial-time This is a polynomial-time
2-aproximation algorithm. (Why?)2-aproximation algorithm. (Why?) Because:Because:
APPROX-VERTEX-COVER is O(V+E)APPROX-VERTEX-COVER is O(V+E) |C*| ≥ |A||C*| ≥ |A|
|C| = 2|A||C| = 2|A|
|C| ≤ 2|C*||C| ≤ 2|C*|Optimal
Selected Edges
Selected Vertices
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 1515
Traveling salesman problemTraveling salesman problem Given an undirected weighted Given an undirected weighted
Graph G we are to find a minimum Graph G we are to find a minimum cost Hamiltonian cycle.cost Hamiltonian cycle.
Satisfying triangle inequality or not Satisfying triangle inequality or not this problem is NP-Complete.this problem is NP-Complete.
We can solve Hamiltonian path.We can solve Hamiltonian path.
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 1616
Traveling salesman problemTraveling salesman problem Exact exponential solution:Exact exponential solution:
Branch and boundBranch and bound Lower bound:Lower bound:
(sum of two lower degree of vertices)/2(sum of two lower degree of vertices)/2
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 1717
Traveling salesman problemTraveling salesman problem
A: 2+3A: 2+3B: 3+3B: 3+3C: 4+4C: 4+4D: 2+5D: 2+5E: 3+6E: 3+6= 35= 35
Bound: 17,5Bound: 17,5d
ce
ba
7 4
3
3
56
2
64
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 1818
Traveling salesman problemTraveling salesman problem
Ab,~ac,ad
Ab,~ac,ad~ac,bc Ab,~ac,ad,~ac,~bc
All Terms
ab ~ab
~ab,~ac ab,acab,ac => ~ac,ad ab
17.5
Ab,~ac,~ad23
2123
18
17.5
17.5 18.5
20.5 21 18.5
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 1919
Traveling salesman problemTraveling salesman problem Near Optimal solutionNear Optimal solution
FasterFaster More easy to impliment.More easy to impliment.
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 2020
Traveling salesman problem Traveling salesman problem with triangle inequality.with triangle inequality.
APPROX-TSP-TOUR(G, c)APPROX-TSP-TOUR(G, c)
1 1 select a vertex select a vertex rr ЄЄ V[V[GG] to be root.] to be root.
2 2 compute a compute a MSTMST for for GG from root r using from root r using Prim Alg.Prim Alg.
3 3 LL=list of vertices in preorder walk of that =list of vertices in preorder walk of that MSTMST..
4 4 returnreturn the Hamiltonian cycle the Hamiltonian cycle HH in the order in the order LL..
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 2121
Traveling salesman problem Traveling salesman problem with triangle inequality.with triangle inequality.
root
MST
Pre-Order walk
Hamiltonian Cycle
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 2222
Traveling salesman problemTraveling salesman problem This is polynomial-time 2-This is polynomial-time 2-
approximation algorithm. (Why?)approximation algorithm. (Why?) Because:Because:
APPROX-TSP-TOUR is O(VAPPROX-TSP-TOUR is O(V22)) C(MST) C(MST) ≤ C(H*)≤ C(H*)
C(W)=2C(MST)C(W)=2C(MST)
C(W)≤2C(H*)C(W)≤2C(H*)
C(H)≤C(W)C(H)≤C(W)
C(H)≤2C(H*)C(H)≤2C(H*)
Optimal
Pre-order
Solution
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 2323
Traveling salesman problem In Traveling salesman problem In GeneralGeneral
Theorem:Theorem:If P ≠ NP, then for any constant ρ≥1, If P ≠ NP, then for any constant ρ≥1,
there is no polynomial time ρ-there is no polynomial time ρ-approximation algorithm. approximation algorithm.
c(u,w) ={uEw ? 1 : ρ|V|+1}c(u,w) ={uEw ? 1 : ρ|V|+1}
ρ|V|+1ρ|V|+1++|V|-1|V|-1>ρ|V|>ρ|V|
Selected edge not in
E
Rest of edges
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 2424
The set-CoverThe set-Cover Generalization of vertex-cover Generalization of vertex-cover
problem.problem. We have given (X,F) :We have given (X,F) :
X : a finite set of elements.X : a finite set of elements. F : family of subsets of X such that F : family of subsets of X such that
every element of X belongs to at least every element of X belongs to at least one subset in F.one subset in F.
Solution C : subset of F that Includes Solution C : subset of F that Includes all the members of X.all the members of X.
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 2525
The set-Cover …The set-Cover …
Minimal Covering
setsize=3
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 2626
The set-Cover …The set-Cover …GREEDY-SET-COVER(X,F)GREEDY-SET-COVER(X,F)
1 M ← X1 M ← X
2 C ← Ø2 C ← Ø
3 3 while while M ≠ Ø M ≠ Ø dodo
44 select an SЄF that maximizes |S select an SЄF that maximizes |S |M|M חח
55 M ← M – SM ← M – S
66 C ← C U {S}C ← C U {S}
7 7 return return CC
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 2727
The set-Cover …The set-Cover …
3rd chose
1st chose
2nd chose
4th chose
GreedyCovering
setsize=4
Spring 2003Spring 2003 Approximation AlgorithmesApproximation Algorithmes 2828
This greedy algorithm is polynomial-This greedy algorithm is polynomial-time ρ(n)-approximation algorithmtime ρ(n)-approximation algorithm
ρ(n)=H(max{|S| : S Є F})ρ(n)=H(max{|S| : S Є F}) HHdd
The proof is beyond of scope of this The proof is beyond of scope of this presentation.presentation.
The set-Cover …The set-Cover …
=∑=∑i=1i=1dd