Docsity

Approximation Algorithms for NP-Hard Problems | COMP 157, Study notes of Algorithms and Programming

Partial preview of the text

Download Approximation Algorithms for NP-Hard Problems | COMP 157 and more Study notes Algorithms and Programming in PDF only on Docsity!

Approximation

Algorithms

for^ NP‐Hard

Problems^ COMP157Dec

12,^2007

http://eagereyes.org/topics/ZIPScribbleMaps

NP‐HARD

-^ Definition:^ The

complexity^ class

of^ problems that^ are^ intrinsically

harder^ than^ those

that can^ be^ solved

by^ a^ nondeterministic

Turing machine^ in^ polynomial

time.

-^ When^ a^ decision

version^ of^ a^ combinatorial optimization^ problem

is^ proved^ to^ be

NP‐

complete ,^ then

the^ optimization

version^ is NP‐hard.

http://www.nist.gov/dads/HTML/nphard.html

Approximation

Algorithms

-^ Find^ a^ “good” solution

fast

-^ sufficient^ for^ many

applications

-^ we^ often^ have

inaccurate^ data

to^ start^ with,^ so approximation^ may

be^ as^ good^ as^ optimal

solution

Heuristics

-^ A^ heuristic^ is

a^ common^ sense

rule^ drawn from^ experience^ –^ not^ a^ mathematically

proven^ assertion

-^ a^ “rule‐of‐thumb” • Examples: –^ TSP:^ go^ to^ next

nearest^ city

-^ Knapsack:^ start

with^ highest^ value/weight

ratio

-^ Packing^ (a^ suitcase):

start^ with^ largest

items

Performance

Ratio

-^ if^ the^ exists^

c^ ≥^ 1,^ such^ that

r(s)^ ≤^ c^ for^ alla^ instances^ of^ a

problem,^ the

given^ algorithm

is

called^ a^ c‐approximation

algorithm

-^ The^ smallest

value^ of^ c^ that

holds^ for^ all instances^ is^ called

the^ performance

ratio ,^ R^ ,A^ of^ the^ algorithm,

Unfortunately

-^ c‐approximation

algorithms^ are

good^ if^ you can^ find^ one^ –^ if^ c=1.1,^ your

approximation^

is^ never^ more^ than 10%^ worse^ than

optimal

-^ but^ … in^ some

cases,^ no^ bound

for^ c^ can^ be found^ –^ approx.^ alg.^ may

be^ great^ for^ 99%

of^ instances, but^ there^ are^ a^ few

really^ terrible^ cases

TSP:^ nearest

neighbor

  1. Start^ at^ any

city.

  1. Repeat^ until

all^ nodes^ are^

visited: Go^ to^ next^ nearest

city.

  1. Return^ to^ starting

city.

TSP:^ nearest

neighbor

(^1) ab 6233 d c^1 nearest neighbor will produce:aÆbÆcÆdÆa, length 10optimal tour:aÆbÆdÆcÆa, length 8r(s^ ) = 10/8 = 1.25a no bound for r(s^ a

) can be determined for all instances: suppose length(a

Æd) = 1000, or 1000000, or ….

TSP:^ Limited

Cases

(^1) ab?^233 d c^1 The problem with this instance is thatthere may be a very large distanceassociated with last edge a

Æd. Is this a “real-world” instance? If this graph represents straight-line distancesbetween cities on a map, the length of a

Æd must be bounded, relative to the other distances (geometry)If this graph represents costs of airline flights, the costof aÆd could be out of proportion to the other edges

TSP:^ Euclidean

Instances

-^ Euclidean^ instances

of^ the^ TSP^ problem obey^ the^ natural

geometry^ of^ a

2D^ map.

-^ triangle^ inequality:

d[i,j]^ ≤^ d[i,k]^ +^ d[k,j]

-^ symmetry:^ d[i,j]

=^ d[j]

-^ For^ Euclidean

instances,^ the

nearest^ neighbor algorithm^ satisfies:r(s)^ ≤^ ½ (loga^

n^ +^ 1),^ where 2

n^ =^ #^ cities

-^ (still^ not^ a^ c‐approximation

algorithm)

TSP:^ Multifragment

‐heuristic

(^1) ab edge list: 6233 d c^1 edge list:^ (a,b),^ (c,d), (b,c), (a,c), (b,c), (a,d)tour:^ (c,d) , (b,c), (a,c), (b,c), (a,d)tour: (a,b)edge list:^ (b,c) , (a,c), (b,c), (a,d)tour: (a,b), (c,d)tour: (a,b), (c,d), (b,c), (a,d) length 10

TSP:^ Twice

Around^ the

Tree

  1. Compute^ MST

from^ the^ graph

  1. Walk^ around

the^ tree^ (DFS)

and record^ nodes^

as^ you^ pass^ them

  1. Eliminate^ duplicates

from^ the^ generated node^ list This^ is^ a^2 ‐approximation

algorithm^ for Euclidean^ TSP.

TSP:^ Iterative

Improvement A number of algorithms usean iterative improvementstrategy.

Example:^ 2-opt algorithm^ delete 2 non-adjacent edgesreplace them with a different pair

TSP:^2 ‐opt^ no improvement