/
Approximation algorithms Approximation algorithms

Approximation algorithms - PowerPoint Presentation

marina-yarberry
marina-yarberry . @marina-yarberry
Follow
457 views
Uploaded On 2016-09-02

Approximation algorithms - PPT Presentation

Algorithms and Networks 20152016 Hans L Bodlaender Johan M M van Rooij TexPoint fonts used in EMF Read the TexPoint manual before you delete this box A A A A A A A A A A What to do if a problem is ID: 459227

algorithm approximation cover time approximation algorithm time cover opt polynomial vertex set solution ratio weight algorithms constant factor alg

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Approximation algorithms" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Approximation algorithms

Algorithms and Networks 2015/2016Hans L. BodlaenderJohan M. M. van Rooij

TexPoint fonts used in EMF.

Read the TexPoint manual before you delete this box.:

A

A

A

A

A

A

A

A

A

ASlide2

What to do if a problem is

NP-complete?We have already seen many options to deal with NP-complete problems.FTP, special cases, exact exponential-time algorithms, heuristics.In other courses: local search, ILP, constraint programming, …

Approximation algorithms are one of these options.

An approximation algorithm is a heuristic with a performance guarantee.

We consider polynomial-time approximation algorithms.

Non-optimal solutions, but with some performance guarantee compared to the optimal

solution.

Also useful as a starting point for other approaches:

Local search, branch and bound.Slide3

Different forms of approximation algorithms (outline of lecture)

Qualities of polynomial-time approximation algorithms: Absolute constant difference.|OPT – ALG|

·

c

APX

: Constant-factor approximation.

Approximation ratio: ALG/OPT

·

c for minimisation problems.

Approximation ratio: OPT/ALG

·

c for maximisation problems.

f(n)-APX

: Approximation by a factor of f(n).

f(n) depends only one the size of the input.

PTAS

: Polynomial-time approximation scheme.

Approximation ratio 1+

²

for any

²

>

0, while the algorithm runs in polynomial time for any fixed

²

.

FPTAS

: Fully polynomial-time approximation scheme.

Approximation ratio 1+

²

for any

²

>

0, while the algorithm runs in time polynomial in n and 1/

²

.Slide4

Absolute constant difference

Algorithms that run in worst-case polynomial time, with:|OPT – ALG| · cExample: Planar graph colouring.

Algorithm that tests 1 and 2-colourability and if no solution found always outputs 4.

Algorithm has an error of at most 1.

These examples are rare.

Not so difficult to show:

TSP cannot be approximated by a constant factor unless P

NP.Slide5

Constant-factor approximation

Approximation ratio:ALG/OPT · c for minimisation problems.OPT/ALG

·

c for maximisation problems.

Ratio always bigger or equal to 1.

Class of problems with a constant factor approximation algorithm:

APX

.

Notions of APX-completeness also exist.

Examples of constant-factor approximation algorithms from earlier lectures:

2-approximations: MST based algorithms for metric TSP. (TSP with triangle inequality).

1.5-approximation:

Christofides

algorithm for metric TSP.Slide6

Approximation for vertex cover

Approximation algorithm for vertex cover:Let E’ = E, C = ;While E’

;

Let {

u,v

} be any edge from E’

C = C

[

{

u,v

}

Remove every edge incident to u of v from E’.

Return C

Runs in polynomial time.

Returns a vertex cover.

How good is this vertex cover?Slide7

2-approximation for vertex cover

Theorem:The algorithm on the previous slide is a 2-approximation.Proof:Let A be the set of edges which endpoints we picked.

OPT

¸

|A|, because every edge in A must be covered.

ALG = 2|A|

·

2OPT, hence ALG/OPT

·

2.Slide8

Approximation by a factor of f(n)

Approximation ratio of f(n).Approximation ratio depends on the size of the input (and can be very bad) Set Cover

Given:

finite set U and a family F of subsets of U.

Question:

Does there exists a subset C of F of size at most k such that

[

S2C

S = U?

Greedy algorithm:

While U

;

:

Select S

2

F that maximises |S

Å

U|

Add S to C and let U := U \ SSlide9

An (ln

(n)+1)-approximation algorithm for set coverTheorem:The greedy set cover algorithm is an (ln(n)+1)-approximation.

Proof:

The algorithm runs in polynomial time and returns a set cover.

Let

S

i

be the

i

th

set from F picked by the algorithm.

We assign cost

c

x

to elements from x:

Let x be firstly covered by set S

i

while running the algorithm.

And, let Xi = Si \ (S1 [ S2 [ ... [ Si-1)Define: cx = 1 / |Xi|.Now we have:...Slide10

Proof of the (ln

(n)+1)-approximation algorithm for set coverThe nth Harmonic number H(n) is defined as: From mathematics (bounding using integrals):

On the next two slides, we will prove that for any S

2

F:

From this we derive our approximation ratio:

Where C* is the optimal set cover.Slide11

Bounding the cost of any set S

What remains is to prove that for any S 2 F:Remind:If x firstly covered by Si, then

c

x

= 1 / |X

i

|

Where: X

i

= S

i

\ (S

1

[

S

2

[ ... [ Si-1)For any S 2 F, let ui be the number of uncovered items in S when the algorithm selects Si.Take the smallest value k s.t. uk = 0.With the last equality due to the selection by the algorithm.Then...Slide12

Bounding the cost of any set S

To prove:

Last slide:

Thus:

Remind:

Q.E.D.Slide13

PTAS

A Polynomial Time Approximation Scheme is an algorithm, that gets two inputs: the “usual” input X, and a real value e

>0.

For each fixed

e

>0, the algorithm

Uses polynomial time

Is an (1+

e

)-approximation algorithmSlide14

FPTAS

A Fully Polynomial Time Approximation Scheme is an algorithm, that gets two inputs: the “usual” input X, and a real value

e

>0, and

For each fixed

e

>0, the algorithm

Is an (1+

e

)-approximation algorithm

The algorithm uses time that is polynomial in the size of X and 1/

e

.Slide15

Example: Knapsack

Given: n items each with a positive integer weight w(i

) and integer value v(

i

) (1 ≤

i

n

), and an integer B.

Question

: select items with total weight at most B such that the total value is as large as possible.Slide16

Dynamic Programming for Knapsack

Let P be the maximum value of any item.We can solve the problem in O(n2P) time with dynamic programming:Tabulate M(

i,Q

): minimum total weight of a subset of items 1, …,

i

with total value Q for Q at most

nP

M(0,0) = 0

M(0,

Q

) =

, if Q>0

M(i+1,Q) = min{ M(

i,Q

), M(

i,Q

-v(i+1)) + w(i+1) }

This algorithm is clearly correct and runs in the given time.Slide17

Scaling for Knapsack

Take input for knapsackThrow away all items that have weight larger than B (they are never used)Let c be some constantBuild new input: do not change weights, but set new values v’(i)

=

ë

v(

i

) / c

û

Solve scaled instance with DP optimally

Output this solution: approximates solution for original instanceSlide18

The Question is….

How do we set c, such thatApproximation ratio good enoughPolynomial timeSlide19

Approximation ratio

Consider optimal solution Y for original problem, value OPTValue in scaled instance: at least OPT/c – nAt most n items, for each v(i

)/c -

ë

v(

i

)/c

û

<1

So, DP finds a solution of value at least OPT/c –n for scaled problem

So, value of approximate solution for original instance is at least c*(OPT/c –n) = OPT -

ncSlide20

Setting c

Set c = eP/(2n)This is an FPTAS

Running time:

Largest value of an item is at most P/c = P / (

e

P

/(2n)) = 2n/

e

.

Running time is O(n

2

* 2n/

e

) = O(n

3

/

e

)

Approximation: … next Slide21

e

-approximationNote that each item is a solution (we removed items with weight more than B).So OPT ≥ P.Algorithm gives solution of value at least:

OPT –

nc

= OPT – n(

e

P

/ (2n) ) = OPT –

e

/2 P

OPT / (OPT –

e

/2 P) ≤ OPT / (OPT –

e

/2 OPT)

= 1/(1-

e

/2) ≤ 1+

eQED.Slide22

2-approximation for minimum weight vertex cover

Minimum weight vertex cover:Vertex cover where each vertex has a weight.We look for the minimum weight vertex cover.2-approximation for vertex cover no longer works.

We may select very heavy vertices using that algorithm.

Consider the following ILP:

It’s LP relaxation is ILP with the last constraint replaced by:

0

·

x(v)

·

1Slide23

2-approximation algorithm

for minimum weight vertex coverAlgorithm:Compute the optimal solution to the LP relaxation.Output all v with x(v) ¸

½.

Algorithm runs in polynomial time.

Linear programming can be solved in polynomial time.

Not by the simplex algorithm!!

Ellipsoid method / interior point methods.

Algorithm returns a vertex cover.

For every edge, sum of incident vertices at least 1.

Hence at least one of the vertex variables at least ½.Slide24

Proof of 2-approximation algorithm

for minimum weight vertex coverLet z* be the solution to the LP.Because any vertex cover is a solution to the LP we have:Also, we can bound ALG in terms of z*:

Hence:

QEDSlide25

Conclusion

Qualities of polynomial-time approximation algorithms: Absolute constant difference.Planar graph colouring.

APX

: Constant-factor approximation.

TSP with triangle inequality.

Vertex cover.

f(n)-APX

: Approximation by a factor of f(n).

Set cover.

PTAS

: Polynomial-time approximation scheme.

FPTAS

: Fully polynomial-time approximation scheme.

Scaling for Knapsack.