Docsity

Approximation Algorithms - Algorithm and Complexity Analysis - Lecture Slides, Slides of Computer Science

Toggle sidebar
bg1
Approximation Algorithms
2
Coping With NP-Hardness
Suppose you need to solve NP-hard problem X.
■Theory says you aren’t likely to find a polynomial algorithm.
■Should you just give up?
!Probably yes, if you’re goal is really to find a polynomial
algorithm.
!Probably no, if you’re job depends on it.
3
Coping With NP-Hardness
Brute-force algorithms.
■Develop clever enumeration strategies.
■Guaranteed to find optimal solution.
■No guarantees on running time.
Heuristics.
■Develop intuitive algorithms.
■Guaranteed to run in polynomial time.
■No guarantees on quality of solution.
Approximation algorithms.
■Guaranteed to run in polynomial time.
■Guaranteed to find "high quality" solution, say within 1% of optimum.
■Obstacle: need to prove a solution’s value is close to optimum,
without even knowing what optimum value is!
4
Approximation Algorithms and Schemes
ρ-approximation algorithm.
■An algorithm A for problem P that runs in polynomial time.
■For every problem instance, A outputs a feasible solution within
ratio ρof true optimum for that instance.
Polynomial-time approximation scheme (PT AS).
■A family of approximation algorithms {Aε: ε> 0} for a problem P.
■Aεis a (1 + ε) - approximation algorithm for P.
■Aεis runs in time polynomial in input size for a fixed ε.
Fully polynomial-time approximation scheme (FPTAS).
■PTAS where Aεis runs in time polynomial in input size and 1 / ε.
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Approximation Algorithms - Algorithm and Complexity Analysis - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Approximation Algorithms

Coping With NP-HardnessSuppose you need to solve NP-hard problem X. n Theory says you aren’t likely to find a polynomial algorithm. n Should you just give up? 3 Probably yes, if you’re goal is really to find a polynomialalgorithm. 3 Probably no, if you’re job depends on it.

3

Coping With NP-HardnessBrute-force algorithms. n Develop clever enumeration strategies. n Guaranteed to find optimal solution. n No guarantees on running time.Heuristics. n Develop intuitive algorithms. n Guaranteed to run in polynomial time. n No guarantees on quality of solution.Approximation algorithms. n Guaranteed to run in polynomial time. n Guaranteed to find "high quality" solution, say within 1% of optimum. n Obstacle: need to prove a solution’s value is close to optimum,without even knowing what optimum value is!

Approximation Algorithms and Schemes ρ-approximation algorithm. n An algorithm A for problem P that runs in polynomial time. n For every problem instance, A outputs a feasible solution withinratio^ ρ^ of true optimum for that instance.Polynomial-time approximation scheme (PTAS). n A family of approximation algorithms {A

:^ ε^ > 0} for a problem P.ε n^ Ais a (1 +^ ε) - approximation algorithm for P.ε^ n^ Ais runs in time polynomial in input size for a fixedε^

ε. Fully polynomial-time approximation scheme (FPTAS).^ n^ PTAS where Ais runs in time polynomial in input size and 1 /ε^

ε^. Docsity.com

5

Approximation Algorithms and SchemesTypes of approximation algorithms. n Fully polynomial-time approximation scheme. n Constant factor.

Knapsack ProblemKnapsack problem. n Given N objects and a "knapsack." n Item i weighs w > 0 Newtons and has value vi

0.i n^ Knapsack can carry weight up to W Newtons. n^ Goal: fill knapsack so as to maximize total value.Item^ Value^

Weight 1 1 1 Greedy = 35: { 5, 2, 1 } 2 6 2 3 18 5 OPT value = 40: { 3, 4 } 4 22 6 5 28 7 W = 11 v/ w^ i^ i 7

Knapsack is NP-HardKNAPSACK: Given a finite set X, nonnegative weights w

, nonnegativei values v, a weight limit W, and a desired value V, is there a subset Si^

X such that: SUBSET-SUM: Given a finite set X, nonnegative values u

, and ani integer t, is there a subset S

⊆^ X whose elements sum to t? Claim. SUBSET-SUM^ ≤^ P^

KNAPSACK.

Proof: Given instance (X, t) of SUBSET-SUM, create KNAPSACKinstance:^ n^ v= w^ = u^ i^ i^ i^ n^ V = W = t

Ww≤∑iSi∈ Vv ≥∑i Si∈ tu ≤∑ iSi ∈^ tu ≥∑ iSi ∈

Knapsack: Dynamic Programming Solution 1OPT(n, w) = max profit subset of items {1,... , n} with weight limit w. n Case 1: OPT selects item n.^ –^ new weight limit = w – w

n

-^ OPT selects best of {1, 2,... , n – 1} using this new weight limit n Case 2: OPT does not select item n. –^ OPT selects best of {1, 2,... , n – 1} using weight limit w^ {^ Directly leads to O(N W) time algorithm. n W = weight limit. n Not polynomial in input size!

}

otherwise), 1 (

),, 1 (max

wwif

0 nif

n n

wnOPTwwnOPTvwnOPTn^

wnOPT

Docsity.com

vvn ** Sn vnSn -(vnSn I-vn * Sn )/(* NNVV^ *) 1 ( V^13

∑≥∑ n Sn ∈∈ ∑≥∈ ≥∑∈ ≥∑∈ ε−= ε−≥

Knapsack: FPTASKnapsack FPTAS.v^ n n Round all values:=vn^  – V = largest value in original instance – ε = precision parameter – θ = scaling factor =^ ε^ V / N n Bound on optimal value V :VNVV ≤≤ * instanceoriginalinitemsofsetopt=S instanceroundedinitemsofsetopt* = S

Proof of Correctness

Knapsack: State of the ArtThis lecture. n "Rounding and scaling" method finds a solution within a (1 -

ε) factor of optimum for any

ε^ > 0. (^3) n Takes O(N/^ ε) time and space.Ibarra-Kim (1975), Lawler (1979). n Faster FPTAS: O(N log (1 /

(^4) ε) + 1 / ε) time. n^ Idea: group items by value into "large" and "small" classes.^ –^ run dynamic programming algorithm only on large items^ –^ insert small items according to ratio v

/ w^ n n

-^ clever analysis 15

Approximation Algorithms and SchemesTypes of approximation algorithms. n Fully polynomial-time approximation scheme. n Constant factor.

Traveling Salesperson ProblemTSP: Given a graph G = (V, E), nonnegative edge weights c(e), and aninteger C, is there a Hamiltonian cycle whose total cost is at most C?Is there a tour of length at most 1570?

Docsity.com

17

Traveling Salesperson ProblemTSP: Given a graph G = (V, E), nonnegative edge weights c(e), and aninteger C, is there a Hamiltonian cycle whose total cost is at most C?Is there a tour of length at most 1570?

Yes, red tour = 1565.

Hamiltonian Cycle Reduces to TSPHAM-CYCLE: given an undirected graph G = (V, E), does there existsa simple cycle C that contains every vertex in V.TSP: Given a complete (undirected) graph G, integer edge weightsc(e) ≥ 0, and an integer C, is there a Hamiltonian cycle whose totalcost is at most C?Claim. HAM-CYCLE is NP-complete.Proof. (HAM-CYCLE transforms to TSP) n Given G = (V, E), we want to decide if it is Hamiltonian. n Create instance of TSP with G’ = complete graph. n Set c(e) = 1 if e^ ∈^ E, and c(e) = 2 if e

∉^ E, and choose C = |V|. n^ Γ^ Hamiltonian cycle in G

ba dc G ⇔ Γ has cost exactly |V| in G’. Γ not Hamiltonian in G ⇔ Γ has cost at least |V| + 1 in G’. (^2) ab^1 dc G’

19

TSP

TSP-OPT: Given a complete (undirected) graph G = (V, E) with integeredge weights c(e)^ ≥^ 0, find a Hamiltonian cycle of minimum cost?Claim. If P^ ≠^ NP, there is no

ρ-approximation for TSP for any

ρ ≥^ 1. Proof (by contradiction).^ n^ Suppose A is^ ρ-approximation algorithm for TSP.^ n^ We show how to solve instance G of HAM-CYCLE.^ n^ Create instance of TSP with G’ = complete graph.^ n^ Let C = |V|, c(e) = 1 if e

∈^ E, and c(e) =^ ρ^ |V | + 1 if e

∉^ E.

n^ Γ^ Hamiltonian cycle in G

⇔^ Γ^ has cost exactly |V| in G’ Γ not Hamiltonian in G ⇔^ Γ^ has cost more than

ρ^ |V| in G’ n^ Gap^ ⇒^ If G has Hamiltonian cycle, then A must return it.

TSP Heuristic

APPROX-TSP(G, c)^ n^ Find a minimum spanning tree T for (G, c).

a^ d e bgf c h MST da e bgf c h Input(assume Euclidean distances)

Docsity.com

25

TSP With Triangle InequalityTheorem. APPROX-TSP is a 2-approximation algorithm for

∆-TSP.

Proof. Let H* denote an optimal tour. Need to show c(H)

≤^ 2c(H). n^ c(T)^ ≤^ c(H) since we obtain spanning tree by deleting any edgefrom optimal tour. n^ c(W) = 2c(T) since every edge visited exactly twice.da^ e b c h

a^ gfb c h MST T d e gf Walk W a b c b h b a d e f e g e d a^

TSP With Triangle InequalityTheorem. APPROX-TSP is a 2-approximation algorithm for

∆-TSP.

Proof. Let H* denote an optimal tour. Need to show c(H)

≤^ 2c(H). n^ c(T)^ ≤^ c(H) since we obtain spanning tree by deleting any edgefrom optimal tour. n^ c(W) = 2c(T) since every edge visited exactly twice. n^ c(H)^ ≤^ c(W) because of^ ∆-inequality.da e bgf c h Walk W a b c b h b a d e f e g e d a

da e bgf c h Hamiltonian Cycle H a b c h d e f g a 27

TSP: Christofides AlgorithmTheorem. There exists a 1.5-approximation algorithm for

∆-TSP.

CHRISTOFIDES(G, c)^ n^ Find a minimum spanning tree T for (G, c).^ n^ M^ ←^ min cost perfect matching of odd degree nodes in T.da^ b c h

e gf MST T

e bgf c h Matching M

TSP: Christofides AlgorithmTheorem. There exists a 1.5-approximation algorithm for

∆-TSP.

CHRISTOFIDES(G, c)^ n^ Find a minimum spanning tree T for (G, c).^ n^ M^ ←^ min cost perfect matching of odd degree nodes in T.^ n^ G’^ ←^ union of spanning tree and matching edges.da^ b c h

e gf G’ = MST + Matching

e bgf c h Matching MDocsity.com

29

TSP: Christofides AlgorithmTheorem. There exists a 1.5-approximation algorithm for

∆-TSP.

CHRISTOFIDES(G, c)^ n^ Find a minimum spanning tree T for (G, c).^ n^ M^ ←^ min cost perfect matching of odd degree nodes in T.^ n^ G’^ ←^ union of spanning tree and matching edges.^ n^ E^ ←^ Eulerian tour in G’.da^ b c h

e gf E = Eulerian tour in G’

e bgf c h Matching M

TSP: Christofides AlgorithmTheorem. There exists a 1.5-approximation algorithm for

∆-TSP.

CHRISTOFIDES(G, c)^ n^ Find a minimum spanning tree T for (G, c).^ n^ M^ ←^ min cost perfect matching of odd degree nodes in T.^ n^ G’^ ←^ union of spanning tree and matching edges.^ n^ E^ ←^ Eulerian tour in G’.^ n^ H^ ←^ short-cut version of Eulerian tour in E.da^ b c h

e gf E = Eulerian tour in G’

da e bgf c h Hamiltonian Cycle H 31

TSP: Christofides AlgorithmTheorem. There exists a 1.5-approximation algorithm for

∆-TSP.

Proof. Let H* denote an optimal tour. Need to show c(H)

≤^ 1.5 c(H). n^ c(T)^ ≤^ c(H) as before. n^ c(M)^ ≤^ ½ c(Γ)^ ≤^ ½ c(H).^ –^ second inequality follows from

∆-inequality

-^ even number of odd degree nodes –^ Hamiltonian cycle on even # nodes comprised of two matchings

e bgf c h Matching M e bgf c h Optimal Tour Γ* on Odd Nodes

TSP: Christofides AlgorithmTheorem. There exists a 1.5-approximation algorithm for

∆-TSP.

Proof. Let H* denote an optimal tour. Need to show c(H)

≤^ 1.5 c(H). n^ c(T)^ ≤^ c(H) as before. n^ c(M)^ ≤^ ½ c(Γ)^ ≤^ ½ c(H). n^ Union of MST and and matching edges is Eulerian.^ –^ every node has even degree n^ Can shortcut to produce H and c(H)

≤^ c(M) + c(T). h da e bgf c MST + Matching

da e bgf c h Hamiltonian Cycle HDocsity.com

37

Greedy algorithm.^ n^ Consider jobs in some fixed order.^ n^ Assign job j to machine whose load is smallest so far.^ FOR i = 1 to mT ←^ 0, Si^^ n^ Note: this is an "on-line" algorithm.

Load Balancing LIST-SCHEDULING (m, n, p^ ,... , p^ )^1 n ← φ i^ FOR j = 1 to n machine with smallest load i = argmin^ Tk^ k S ← S ∪^ {j}i i assign job j to machine i T ← T+ pi i j

Load BalancingTheorem (Graham, 1966). Greedy algorithm is a 2-approximation. n First worst-case analysis of an approximation algorithm. n Need to compare resulting solution with optimal makespan T*.Lemma 1. The optimal makespan is at least n The total processing time is^ Σ^ p^ .j^ j^ n One of m machines must do at least a 1/m fraction of total work.Lemma 2. The optimal makespan is at least n Some machine must process the most time-consuming job.

1 .* ≥pT∑j^ j^ m .max*pT ≥jj^

39

Load BalancingLemma 1. The optimal makespan is at leastLemma 2. The optimal makespan is at leastTheorem. Greedy algorithm is a 2-approximation.Proof. Consider bottleneck machine i that works for T units of time. n Let j be last job scheduled on machine i. n When job j assigned to machine i, i has smallest load. It’s loadbefore assignment is T- p^ ⇒^ T^ - p^ ≤^ T^ i^ j^ i^ j^ k^

1 .* ≥pT∑j^ j^ m for all 1^ ≤^ k^ ≤^ m. Machine 1Machine 2Machine 3

A DB FC

E^ IH j = GJ 0

T = T^ i T^ - p^ i^ i

.max*pT ≥jj Machine i

Load BalancingLemma 1. The optimal makespan is at leastLemma 2. The optimal makespan is at leastTheorem. Greedy algorithm is a 2-approximation.Proof. Consider bottleneck machine i that works for T units of time. n Let j be last job scheduled on machine i. n When job j assigned to machine i, i has smallest load. It’s loadbefore assignment is T- p^ ⇒^ T^ - p^ ≤^ T^ i^ j^ i^ j^ k^

for all 1^ ≤^ k^ ≤^ n. n^ Sum inequalities over all k and divide by m,and then apply L1. n^ Finish off using L2.

1 TpT≤−∑kjimk 1 p=∑kmk *T ≤

)(ppTT+−=jjii TT+≤ * 2 T = 1 . ≥pT∑j^ j^ m.maxpT ≥jj^ Docsity.com

41

Load BalancingIs our analysis tight? n Essentially yes. n We give instance where solution is almost factor of 2 from optimal. – m machines, m(m-1) jobs with of length 1, 1 job of length m – 10 machines, 90 jobs of length 1, 1 job of length 10Machine 5

65 75 85 Machine 6 6 16 26 36 46 56

66 76 86 Machine 7 7 17 27 37 47 57

67 77 87 Machine 8 8 18 28 38 48 58

Machine 2 68 78 88 1 11 21 31 41 51

61 71 81 Machine 2 2 12 22 32 42 52

62 72 82 Machine 3 3 13 23 33 43 53

63 73 83 Machine 4 4 14 24 34 44 54

64 74 84 Machine 9 9 19 29 39 49 59

69 79 89 Machine 10 10 20 30 40 50 60

List Schedule makespan = 19

Load BalancingIs our analysis tight? n Essentially yes. n We give instance where solution is almost factor of 2 from optimal. – m machines, m(m-1) jobs with of length 1, 1 job of length m – 10 machines, 90 jobs of length 1, 1 job of length 10Machine 5

65 75 85 Machine 6 6 16 26 36 46 56

66 76 86 Machine 7 7 17 27 37 47 57

67 77 87 Machine 8 8 18 28 38 48 58

Machine 1 68 78 88 1 11 21 31 41 51

61 71 81 Machine 2 2 12 22 32 42 52

62 72 82 Machine 3 3 13 23 33 43 53

63 73 83 Machine 4 4 14 24 34 44 54

64 74 84 Machine 9 9 19 29 39 49 59

102030405060708069 79 8990 Machine 10 (^91) Optimal makespan = 10 43

Load Balancing: State of the ArtWhat’s known. n 2-approximation algorithm. n 3/2-approximation algorithm: homework. n 4/3-approximation algorithm: extra credit. n PTAS.

Docsity.com