0% found this document useful (0 votes)
2 views35 pages

UNIT 5 ApproximationAlgorithms

The document discusses approximation algorithms, which provide near-optimal solutions to NP-complete problems in a more efficient manner than exact algorithms. It explains the concept of approximation ratio bounds and provides examples, including the Vertex Cover Problem, Bin Packing Problem, and Traveling Salesperson Problem, along with their respective approximation algorithms. The document also covers the minimum Euclidean weighted matching problem and the approximation algorithm for the Euclidean Traveling Salesperson Problem, detailing their complexities and performance guarantees.

Uploaded by

jasminejas110101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views35 pages

UNIT 5 ApproximationAlgorithms

The document discusses approximation algorithms, which provide near-optimal solutions to NP-complete problems in a more efficient manner than exact algorithms. It explains the concept of approximation ratio bounds and provides examples, including the Vertex Cover Problem, Bin Packing Problem, and Traveling Salesperson Problem, along with their respective approximation algorithms. The document also covers the minimum Euclidean weighted matching problem and the approximation algorithm for the Euclidean Traveling Salesperson Problem, detailing their complexities and performance guarantees.

Uploaded by

jasminejas110101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 35

Approximation Algorithm

1
Approximation Algorithm
 Up to now, the best algorithm for
solving an NP-complete problem
requires exponential time in the worst
case. It is too time-consuming.
 To reduce the time required for solving
a problem, we can relax the problem,
and obtain a feasible solution “close” to
an optimal solution
2
Approximation Algorithm
 One compromise is to use heuristic
solutions.

 The word “heuristic” may be


interpreted as “educated guess.”

3
Approximation Algorithm
An algorithm that returns near-optimal solutions is called
an approximation algorithm.

We need to find an approximation ratio bound for an


approximation algorithm.

4
Approximation ratio bound
We say an approximation algorithm for the problem has a ratio
bound of  (n) if for any input size n, the cost C of the solution

produced by the approximation algorithm is within a factor of


 (n) of the C* of the optimal solution:

C C*
max{ , }  (n)
C* C
This definition applies for both minimization and maximization
problems.
5
-approximation algorithm
 An approximation algorithm with an
approximation ratio bound of  is
called a -approximation algorithm or
a (1+)-approximation algorithm.

 Note that  is always larger than 1 and


=-1.

6
Vertex Cover Problem
 Let G=(V, E). The subset S of V
that meets every edge of E is
called the vertex cover.
 The Vertex Cover problem is to
find a vertex cover of the minimum
size. It is NP-hard or the
optimization version of an NP-
Complete decision problem.
7
Examples of vertex cover

8
APPROX_VERTEX_COVER(G)
1 C 
2 E'  E( G )
3 while E' 
4 do let ( u, v ) be an arbitrary edge of E'
5 C  C  {u , v}
6 remove from E' every edge incident on either u or v
7 return C
9
b c d b c d

a e f g a e f g

b c d b c d

a e f g a e f g

b c d b c d

a e f g a e f g

Complexity: O(E) 10
Theorem 35.1 APPROX_VERTEX_COVER has ratio
bound of 2. C*: optimal solution
C: approximate solution
Proof. A: the set of edges selected in
step
Let A be the set of selected 4
edges.
| C| 2| A| When one edge is selected, 2 vertices are added
into C.
| A| | C*| No two edges in A share a common
endpoint due to step 6.
 | C| 2| C*|

11
Bin Packing Problem
 Given n items of sizes a1, a2, …, an, 0 ai  1 for 1 
i  n, which have to be placed in bins of unit
capability, the bin packing problem is to determine
the minimum number of bins to accommodate all
items.
 If we regard the items of different sizes to be the
lengths of time of executing different jobs on a
standard processor, the problem becomes to use
minimum number of processors which can finish all
of the jobs within a fixed time. //You can assume
the longest job takes one unit time, which equals to
the fixed time.
12
Example of Bin Packing
Problem
 E.g. Given n = 5 items with sizes 0.3,
0.5, 0.8, 0.2 0.4, the optimal solution is
3 bins.

The bin packing problem is NP-


13
An approximation
algorithm for the bin
packing problem
 An approximation algorithm: (first-fit) place
item i into the lowest-indexed bin which can
accommodate it.
 OPT: the number of bins of the optimal
solution
 FF: the number of bins in the first-fit
algorithm

C(Bi): the sum of the sizes of items packed
in bin Bi in the first-fit algorithm
 Let FF=m.
14
An approximation
algorithm for the bin
packing problem
 OPT   n  , ceiling of sum of sizes of all
 i a
items  i 1 
C(Bi): the sum of sizes of items packed in b
 C(Bi) + C(Bi+1)  1 (a)(Otherwise, the items in
Bi+1 will be put in Bi.)
 C(B1) + C(Bm)  1 (b)(Otherwise, the items in Bm
will be put in B1. )
 For m nonempty bins,
C(B1)+C(B2)+…+C(Bm)m/2, (a)+(b)for i=1,..,m
m n

 FF = m < 2  C( B =
)
i 1 2  a  2 OPT
i
i 1
i

FF < 2 OPT
15
The traveling salesperson problem
with triangle inequality
 Given a graph G=(V, E), the TSP problem is to
find a tour, starting from any vertex, visiting every
other vertex and returning to the starting vertex,
with the minimum cost.
 Triangle inequality for the cost matrix:
c( u, w ) c( u, v )  c( v , w ) u, v , w V

16
The TSP with triangle inequality

APPROX_TSP_TOUR(G,c)
1 Select a vertex r V [ G ] to be a root vertex
2 grow a MST T for G from root r using
MST_PRIM(G,c,r)
3 Let L be the list of vertices visited in a preorder
walk of T.
4 return the hamiltonian cycle H that visit the vertices in
the order L.

17
a d T a d T a d
e e e
b f g b f g b f g
c h c h c h

optimal
T a d a d solution
e e
b f g b f g
c h H c h H*

18
Theorem 35.2. APPROX_TSP_TOUR is an approximation
algorithm with ratio bound of 2 for TSP with triangular
inequality.
Proof.
c( T ) c( H*)

c( W ) 2 c( T ) 2 c( H*)

c( H ) c( W )

 c( H ) 2 c( H*)
19
An approximation algorithm
for Euclidean traveling
salesperson problem (ETSP)
 The ETSP is to find a shortest
closed path through a set S of n
points in the plane.
 The ETSP is NP-hard.

20
Approximation Algorithm for
ETSP
 Input: A set S of n points in the plane.
 Output: An approximate traveling salesperson
tour of S.
 Step 1: Find a minimum spanning tree T of S.
 Step 2: Find a minimum Euclidean weighted
matching M on the set of vertices of odd
degrees in T. Let G=M∪T.
 Step 3: Find an Eulerian cycle of G and then
traverse it to find a Hamiltonian cycle as an
approximate tour of ETSP by bypassing all
previously visited vertices.

21
Eulerian Cycle
 An Eulerian path (Eulerian trail, Euler
walk) in a graph is a path that uses each
edge precisely once. If such a path exists,
the graph is called traversable.
 An Eulerian cycle (Eulerian circuit,
Euler tour) in a graph is a cycle with
uses each edge precisely once. If such a
cycle exists, the graph is called Eulerian.

22
 L. Euler showed that an Eulerian cycle
exists if and only if all vertices in the
graph are of even degree and all edges
are contained in the same component.
 L. Euler also showed an Eulerian path
exists, if and only if at most two vertices
in the graph are of odd degree and all
edges are contained in the same
component.

23
 Leonhard Euler (April 15, 1707 -
September 18, 1783) (pronounced "oiler")
was a Swiss mathematician and physicist.
He is considered (together with Gauss) to
be the greatest mathematician ever.
 Leonhard Euler stated and solved the
problem of Seven Bridges of Königsberg
in 1736, which is the first formally
discussed problem in graph theory.

24
Eulerian Cycle exists because
degree(V1) = 4
degree(V2) = 2
degree(V3) = 4
degree(V4) = 4.
25
This is the Eulerian Cycle.

26
 A Hamiltonian path (also called
traceable path) is a path that visits
each vertex exactly once.

 A Hamiltonian cycle (also called


Hamiltonian circuit, vertex tour or
graph cycle) is a cycle that visits each
vertex exactly once, except for the
starting vertex.
27
Minimum Euclidean Weighted
Matching (MEWM) Problem
 Given a set of points in the plane,
the minimum Euclidean weighted
matching problem is to join the
points in pairs by line segments
such that the total length is
minimum.

28
Approximation Algorithm for
ETSP
 E.g.
Step1:

29
Approximation Algorithm for
ETSP
 Step2:The number of points with
n

 d 2 E
odd degrees must be even. i 1
i

One edge contributes 2 degrees


, which is even

30
Approximation Algorithm for
ETSP
 Step3:
P3 and P4 are
visited twice.
By bypassing P3
and P4 and
connecting P6
to P1 directly,
we obtain a
Hamiltonian
cycle.

31
Approximation Algorithm for
ETSP
 Time complexity: O(n3)
Step 1: O(n log n)
Step 2: O(n3)
Step 3: O(n)

 How close the approximate


solution to an optimal solution?
32
How good is the solution ?
 The approximate tour is within 3/2 of the
optimal one.
 Reasoning:
L: optimal ETSP tour, T: MST, Lp: a path
derived by removing one edge from L (Lp is
also a spanning tree)
 length(T)length(Lp)length(L)

Let Lp=j1…i1j2…i2j3…i2m, where {i1, i2,…, i2m} is
the set of odd-degree vertices in T where
indices of vertices in the set are arranged in
the same order as they are in the optimal ETSP
tour L.

33
How good is the solution ?
Let M be the minimum Euclidean weighted matching
(MEWM).
Consider the two matchings:
M1={[i1,i2],[i3,i4],…,[i2m-1,i2m]} and M2={[i2,i3],[i4,i5],…,[i2m,i1]}.
We have
(by triangular inequality)
length(L)  length(M1) + length(M2)  2 length(M )
 length(M) 1/2 length(L )
G = T∪M
 length(T) + length(M)  length(L) + 1/2 length(L)
= 3/2 length(L)

34
Q&A
35

You might also like