advanced algorithms coms31900 approximation algorithms
play

Advanced Algorithms COMS31900 Approximation algorithms part three - PowerPoint PPT Presentation

Advanced Algorithms COMS31900 Approximation algorithms part three (Fully) Polynomial Time Approximation Schemes Rapha el Clifford Slides by Benjamin Sach Approximation Algorithms Recap An algorithm A is an -approximation algorithm for


  1. | S | = m An exact solution Let S = { s 1 , s 2 , s 3 . . . s m } be the set of items and S i = { s 1 , s 2 , . . . , s i } Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t (here t = 12 ) S L 3 = { 0 , 2 , 4 , 6 , 8 , 10 } S 3 The largest subset of S (of size at most t ) is the largest number in L m We compute L i from L i − 1 : L i = L i − 1 ∪ ( L i − 1 + s i ) where ( x + s i ) ∈ ( L i − 1 + s i ) iff x ∈ L i − 1 and x + s i � t

  2. | S | = m An exact solution Let S = { s 1 , s 2 , s 3 . . . s m } be the set of items and S i = { s 1 , s 2 , . . . , s i } Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t (here t = 12 ) S L 3 = { 0 , 2 , 4 , 6 , 8 , 10 } L 3 + s 4 = L 3 + 7 = { 7 , 9 , 11 } S 3 The largest subset of S (of size at most t ) is the largest number in L m We compute L i from L i − 1 : L i = L i − 1 ∪ ( L i − 1 + s i ) where ( x + s i ) ∈ ( L i − 1 + s i ) iff x ∈ L i − 1 and x + s i � t

  3. | S | = m An exact solution Let S = { s 1 , s 2 , s 3 . . . s m } be the set of items and S i = { s 1 , s 2 , . . . , s i } Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t (here t = 12 ) S L 3 = { 0 , 2 , 4 , 6 , 8 , 10 } L 3 + s 4 = L 3 + 7 = 7 { 7 , 9 , 11 } s 4 S 3 The largest subset of S (of size at most t ) is the largest number in L m We compute L i from L i − 1 : L i = L i − 1 ∪ ( L i − 1 + s i ) where ( x + s i ) ∈ ( L i − 1 + s i ) iff x ∈ L i − 1 and x + s i � t

  4. | S | = m An exact solution Let S = { s 1 , s 2 , s 3 . . . s m } be the set of items and S i = { s 1 , s 2 , . . . , s i } Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t (here t = 12 ) S L 3 = { 0 , 2 , 4 , 6 , 8 , 10 } L 3 + s 4 = L 3 + 7 = 7 { 7 , 9 , 11 } 2 s 4 S 3 The largest subset of S (of size at most t ) is the largest number in L m We compute L i from L i − 1 : L i = L i − 1 ∪ ( L i − 1 + s i ) where ( x + s i ) ∈ ( L i − 1 + s i ) iff x ∈ L i − 1 and x + s i � t

  5. | S | = m An exact solution Let S = { s 1 , s 2 , s 3 . . . s m } be the set of items and S i = { s 1 , s 2 , . . . , s i } Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t (here t = 12 ) S L 3 = { 0 , 2 , 4 , 6 , 8 , 10 } L 3 + s 4 = L 3 + 7 = 7 4 { 7 , 9 , 11 } s 4 S 3 The largest subset of S (of size at most t ) is the largest number in L m We compute L i from L i − 1 : L i = L i − 1 ∪ ( L i − 1 + s i ) where ( x + s i ) ∈ ( L i − 1 + s i ) iff x ∈ L i − 1 and x + s i � t

  6. | S | = m An exact solution Let S = { s 1 , s 2 , s 3 . . . s m } be the set of items and S i = { s 1 , s 2 , . . . , s i } Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t (here t = 12 ) S L 3 = { 0 , 2 , 4 , 6 , 8 , 10 } L 3 + s 4 = L 3 + 7 = 7 4 { 7 , 9 , 11 } 2 s 4 S 3 The largest subset of S (of size at most t ) is the largest number in L m We compute L i from L i − 1 : L i = L i − 1 ∪ ( L i − 1 + s i ) where ( x + s i ) ∈ ( L i − 1 + s i ) iff x ∈ L i − 1 and x + s i � t

  7. | S | = m An exact solution Let S = { s 1 , s 2 , s 3 . . . s m } be the set of items and S i = { s 1 , s 2 , . . . , s i } Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t (here t = 12 ) S L 3 = { 0 , 2 , 4 , 6 , 8 , 10 } L 3 + s 4 = L 3 + 7 = 7 4 4 { 7 , 9 , 11 } s 4 S 3 The largest subset of S (of size at most t ) is the largest number in L m We compute L i from L i − 1 : L i = L i − 1 ∪ ( L i − 1 + s i ) where ( x + s i ) ∈ ( L i − 1 + s i ) iff x ∈ L i − 1 and x + s i � t

  8. | S | = m An exact solution Let S = { s 1 , s 2 , s 3 . . . s m } be the set of items and S i = { s 1 , s 2 , . . . , s i } Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t (here t = 12 ) S L 3 = { 0 , 2 , 4 , 6 , 8 , 10 } L 3 + s 4 = L 3 + 7 = 7 4 4 { 7 , 9 , 11 } 2 s 4 S 3 The largest subset of S (of size at most t ) is the largest number in L m We compute L i from L i − 1 : L i = L i − 1 ∪ ( L i − 1 + s i ) where ( x + s i ) ∈ ( L i − 1 + s i ) iff x ∈ L i − 1 and x + s i � t

  9. | S | = m An exact solution Let S = { s 1 , s 2 , s 3 . . . s m } be the set of items and S i = { s 1 , s 2 , . . . , s i } Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t (here t = 12 ) S L 3 = { 0 , 2 , 4 , 6 , 8 , 10 } L 3 + s 4 = L 3 + 7 = 7 4 4 { 7 , 9 , 11 } 2 2 s 4 L 4 = { 0 , 2 , 4 , 6 , 7 , 8 , 9 , 10 , 11 } S 3 The largest subset of S (of size at most t ) is the largest number in L m We compute L i from L i − 1 : L i = L i − 1 ∪ ( L i − 1 + s i ) where ( x + s i ) ∈ ( L i − 1 + s i ) iff x ∈ L i − 1 and x + s i � t

  10. | S | = m An exact solution Let S = { s 1 , s 2 , s 3 . . . s m } be the set of items and S i = { s 1 , s 2 , . . . , s i } Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t (here t = 12 ) S L 3 = { 0 , 2 , 4 , 6 , 8 , 10 } L 3 + s 4 = L 3 + 7 = 7 4 4 { 7 , 9 , 11 } 2 2 s 4 L 4 = { 0 , 2 , 4 , 6 , 7 , 8 , 9 , 10 , 11 } S 3 The largest subset of S (of size at most t ) is the largest number in L m We compute L i from L i − 1 : L i = L i − 1 ∪ ( L i − 1 + s i ) where ( x + s i ) ∈ ( L i − 1 + s i ) iff x ∈ L i − 1 and x + s i � t We don’t have any duplicates in L i - so | L i | � t

  11. | S | = m An exact solution The algorithm ◦ Let L 0 = { 0 } ◦ For i = 1 . . . m : ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m

  12. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } ◦ For i = 1 . . . m : ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m

  13. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m

  14. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m

  15. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time

  16. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t

  17. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t The overall time complexity is therefore O ( mt )

  18. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt )

  19. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ?

  20. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ? n is the length of the input (measured in words)

  21. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ? n is the length of the input (measured in words) Input n words

  22. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ? n is the length of the input (measured in words) Input n words a w bit word

  23. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ? n is the length of the input (measured in words) Input n words (conventionally w ∈ Θ(log n ) ) a w bit word

  24. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ? n is the length of the input (measured in words) Input n words

  25. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ? n is the length of the input (measured in words) Input n words The input to the Subset Sum problem is a list of the elements of S along with t encoded in binary in a total of n words

  26. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ? n is the length of the input (measured in words) s 1 s 2 s 3 t Input n words The input to the Subset Sum problem is a list of the elements of S along with t encoded in binary in a total of n words

  27. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ? n is the length of the input (measured in words) s 1 s 2 s 3 t Input n words The input to the Subset Sum problem is a list of the elements of S along with t encoded in binary in a total of n words As m � n , the time is O ( nt )

  28. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ? n is the length of the input (measured in words) s 1 s 2 s 3 t Input n words The input to the Subset Sum problem is a list of the elements of S along with t encoded in binary in a total of n words As m � n , the time is O ( nt ) . . . but t could be (for example) 2 n

  29. | S | = m An exact solution O (1) time The algorithm ◦ Let L 0 = { 0 } O ( | L i − 1 | ) time ◦ For i = 1 . . . m : O ( | L i | ) time ◦ Compute ( L i − 1 + s i ) from L i − 1 ◦ Compute L i = L i − 1 ∪ ( L i − 1 + s i ) ◦ Output the largest number in L m O ( | L m | ) time Each L i is of length | L i | � t Is this polynomial in n ? The overall time complexity is therefore O ( mt ) What even is n ? n is the length of the input (measured in words) s 1 s 2 s 3 t Input n words The input to the Subset Sum problem is a list of the elements of S along with t encoded in binary in a total of n words As m � n , the time is O ( nt ) . . . but t could be (for example) 2 n . . . in other words O ( n 2 n ) time!

  30. Pseudo-polynomial time algorithms We say that an algorithm is pseudo-polynomial time if it runs in polynomial time when all the numbers are integers � n c for some constant c

  31. Pseudo-polynomial time algorithms We say that an algorithm is pseudo-polynomial time if it runs in polynomial time when all the numbers are integers � n c for some constant c The algorithm for Subset Sum given takes O ( nt ) = O ( n c +1 ) time (in this case)

  32. Pseudo-polynomial time algorithms We say that an algorithm is pseudo-polynomial time if it runs in polynomial time when all the numbers are integers � n c for some constant c The algorithm for Subset Sum given takes O ( nt ) = O ( n c +1 ) time (in this case) So there is a pseudo-polynomial time algorithm for Subset Sum

  33. Pseudo-polynomial time algorithms We say that an algorithm is pseudo-polynomial time if it runs in polynomial time when all the numbers are integers � n c for some constant c The algorithm for Subset Sum given takes O ( nt ) = O ( n c +1 ) time (in this case) So there is a pseudo-polynomial time algorithm for Subset Sum A diversion into computational complexity

  34. Pseudo-polynomial time algorithms We say that an algorithm is pseudo-polynomial time if it runs in polynomial time when all the numbers are integers � n c for some constant c The algorithm for Subset Sum given takes O ( nt ) = O ( n c +1 ) time (in this case) So there is a pseudo-polynomial time algorithm for Subset Sum A diversion into computational complexity We say that an NP -complete problem is weakly NP -complete if there is a pseudo-polynomial time algorithm for it

  35. Pseudo-polynomial time algorithms We say that an algorithm is pseudo-polynomial time if it runs in polynomial time when all the numbers are integers � n c for some constant c The algorithm for Subset Sum given takes O ( nt ) = O ( n c +1 ) time (in this case) So there is a pseudo-polynomial time algorithm for Subset Sum A diversion into computational complexity We say that an NP -complete problem is weakly NP -complete if there is a pseudo-polynomial time algorithm for it The decision version of Subset Sum is weakly NP -complete

  36. Pseudo-polynomial time algorithms We say that an algorithm is pseudo-polynomial time if it runs in polynomial time when all the numbers are integers � n c for some constant c The algorithm for Subset Sum given takes O ( nt ) = O ( n c +1 ) time (in this case) So there is a pseudo-polynomial time algorithm for Subset Sum A diversion into computational complexity We say that an NP -complete problem is weakly NP -complete if there is a pseudo-polynomial time algorithm for it The decision version of Subset Sum is weakly NP -complete We say that an NP -complete problem is strongly NP -complete if it remains NP -complete when all the numbers are integers � n c

  37. Pseudo-polynomial time algorithms We say that an algorithm is pseudo-polynomial time if it runs in polynomial time when all the numbers are integers � n c for some constant c The algorithm for Subset Sum given takes O ( nt ) = O ( n c +1 ) time (in this case) So there is a pseudo-polynomial time algorithm for Subset Sum A diversion into computational complexity We say that an NP -complete problem is weakly NP -complete if there is a pseudo-polynomial time algorithm for it The decision version of Subset Sum is weakly NP -complete We say that an NP -complete problem is strongly NP -complete if it remains NP -complete when all the numbers are integers � n c The decision version of Bin packing is strongly NP -complete

  38. Pseudo-polynomial time algorithms We say that an algorithm is pseudo-polynomial time if it runs in polynomial time when all the numbers are integers � n c for some constant c The algorithm for Subset Sum given takes O ( nt ) = O ( n c +1 ) time (in this case) So there is a pseudo-polynomial time algorithm for Subset Sum A diversion into computational complexity We say that an NP -complete problem is weakly NP -complete if there is a pseudo-polynomial time algorithm for it The decision version of Subset Sum is weakly NP -complete We say that an NP -complete problem is strongly NP -complete if it remains NP -complete when all the numbers are integers � n c The decision version of Bin packing is strongly NP -complete (this only makes sense if you rephrase the problem)

  39. Pseudo-polynomial time algorithms We say that an algorithm is pseudo-polynomial time if it runs in polynomial time when all the numbers are integers � n c for some constant c The algorithm for Subset Sum given takes O ( nt ) = O ( n c +1 ) time (in this case) So there is a pseudo-polynomial time algorithm for Subset Sum A diversion into computational complexity We say that an NP -complete problem is weakly NP -complete if bins have size t ∈ [ n c ] there is a pseudo-polynomial time algorithm for it The decision version of Subset Sum is weakly NP -complete We say that an NP -complete problem is strongly NP -complete if 4 it remains NP -complete when all the numbers are integers � n c item sizes are The decision version of Bin packing is strongly NP -complete integers in [ n c ] (this only makes sense if you rephrase the problem)

  40. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P

  41. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could:

  42. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt

  43. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt Let ǫ = 0 . 01 so that A 0 . 01 also runs in polynomial time and outputs a subset of size at least Opt 1 . 01 > 0 . 99 · Opt

  44. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt Let ǫ = 0 . 01 so that A 0 . 01 also runs in polynomial time and outputs a subset of size at least Opt 1 . 01 > 0 . 99 · Opt Let ǫ = 0 . 001 so that A 0 . 001 also runs in polynomial time and outputs a subset of size at least Opt 1 . 001 > 0 . 999 · Opt

  45. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt

  46. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt A PTAS does not have to have a time complexity which is polynomial in 1 /ǫ

  47. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt A PTAS does not have to have a time complexity which is polynomial in 1 /ǫ c ǫ ) for example A ǫ can have a time complexity of O ( n

  48. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt A PTAS does not have to have a time complexity which is polynomial in 1 /ǫ c ǫ ) for example A ǫ can have a time complexity of O ( n O ( n 10 c ) vs. O ( n 100 c ) vs. O ( n 1000 c ) in our example ǫ = 0 . 1 ǫ = 0 . 01 ǫ = 0 . 001

  49. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt A PTAS does not have to have a time complexity which is polynomial in 1 /ǫ

  50. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt A PTAS does not have to have a time complexity which is polynomial in 1 /ǫ A fully PTAS (FPTAS) has a time complexity which is polynomial in 1 /ǫ (as well as polynomial in n )

  51. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt A PTAS does not have to have a time complexity which is polynomial in 1 /ǫ A fully PTAS (FPTAS) has a time complexity which is polynomial in 1 /ǫ (as well as polynomial in n ) i.e. the time complexity is O (( n/ǫ ) c ) for some constant c

  52. Polynomial time approximation schemes A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, A ǫ such that A ǫ is a (1 + ǫ ) -approximation algorithm for P • If we had a PTAS for Subset Sum we could: Let ǫ = 0 . 1 so that A 0 . 1 runs in polynomial time and outputs a subset of size at least Opt 1 . 1 > 0 . 9 · Opt A PTAS does not have to have a time complexity which is polynomial in 1 /ǫ A fully PTAS (FPTAS) has a time complexity which is polynomial in 1 /ǫ (as well as polynomial in n ) i.e. the time complexity is O (( n/ǫ ) c ) for some constant c In our example O ((10 n ) c ) = O ((100 n ) c ) = O ((1000 n ) c ) = O ( n c ) ǫ = 0 . 1 ǫ = 0 . 01 ǫ = 0 . 001

  53. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) S 7 3 4 4 (here t = 12 ) 2 2 S 4 L 4 = { 0 , 2 , 4 , 6 , 7 , 8 , 9 , 10 , 11 } 4 2 2 4 4 2 7 7 7 4 4 4 4 2

  54. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) S 7 3 4 4 (here t = 12 ) 2 2 S 4 L 4 = { 0 , 2 , 4 , 6 , 7 , 8 , 9 , 10 , 11 } 4 2 2 4 4 2 7 7 7 4 4 4 4 2 The exact algorithm for Subset Sum was slow (in general) because each list of possible subset sizes L i could become very large

  55. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that

  56. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i )

  57. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i ) i | � n c for some c ) The length of L ′ i is polynomial in the input length (i.e. | L ′

  58. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i ) i | � n c for some c ) The length of L ′ i is polynomial in the input length (i.e. | L ′ For every y ∈ L i , there is a z ∈ L ′ i which is almost as big

  59. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i ) i | � n c for some c ) The length of L ′ i is polynomial in the input length (i.e. | L ′ For every y ∈ L i , there is a z ∈ L ′ i which is almost as big Trim ( L i , δ ) : Include L i [ j ] in L ′ Consider this process called Trim . . . i iff L i [ j ] > (1 + δ ) · prev where prev is the previous entry we included in L ′ i

  60. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i ) i | � n c for some c ) The length of L ′ i is polynomial in the input length (i.e. | L ′ For every y ∈ L i , there is a z ∈ L ′ i which is almost as big Trim ( L i , δ ) : Include L i [ j ] in L ′ Consider this process called Trim . . . i iff L i [ j ] > (1 + δ ) · prev L 4 = { 0 , 2 , 4 , 6 , 7 , 8 , 9 , 10 , 11 } where prev is the previous entry we included in L ′ i 4 2 2 4 4 2 7 7 7 4 4 4 4 2

  61. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i ) i | � n c for some c ) The length of L ′ i is polynomial in the input length (i.e. | L ′ For every y ∈ L i , there is a z ∈ L ′ i which is almost as big Trim ( L i , δ ) : Include L i [ j ] in L ′ Consider this process called Trim . . . i iff L i [ j ] > (1 + δ ) · prev L 4 = { 0 , 2 , 4 , 6 , 7 , 8 , 9 , 10 , 11 } where prev is the previous entry we included in L ′ i 4 2 2 4 4 2 7 7 7 4 4 4 4 2 for δ = 1 . . . L ′ 4 = { 0 , 2 , 6 }

  62. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i ) i | � n c for some c ) The length of L ′ i is polynomial in the input length (i.e. | L ′ For every y ∈ L i , there is a z ∈ L ′ i which is almost as big Trim ( L i , δ ) : Include L i [ j ] in L ′ Consider this process called Trim . . . i iff L i [ j ] > (1 + δ ) · prev L 4 = { 0 , 2 , 4 , 6 , 7 , 8 , 9 , 10 , 11 } where prev is the previous entry we included in L ′ i 4 2 2 4 4 2 7 7 7 4 4 4 4 2 L ′ 4 is a small subset of L 4 and for any y ∈ L 4 , for δ = 1 . . . L ′ 4 = { 0 , 2 , 6 } there is an z ∈ L ′ 4 with z � y/ 2

  63. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i ) i | � n c for some c ) The length of L ′ i is polynomial in the input length (i.e. | L ′ For every y ∈ L i , there is a z ∈ L ′ i which is almost as big Trim ( L i , δ ) : Include L i [ j ] in L ′ Consider this process called Trim . . . i iff L i [ j ] > (1 + δ ) · prev where prev is the previous entry we included in L ′ i

  64. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i ) i | � n c for some c ) The length of L ′ i is polynomial in the input length (i.e. | L ′ For every y ∈ L i , there is a z ∈ L ′ i which is almost as big Trim ( L i , δ ) : Include L i [ j ] in L ′ Consider this process called Trim . . . i iff L i [ j ] > (1 + δ ) · prev where prev is the previous entry we included in L ′ i Unfortunately, this hasn’t really achieved anything. . .

  65. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i ) i | � n c for some c ) The length of L ′ i is polynomial in the input length (i.e. | L ′ For every y ∈ L i , there is a z ∈ L ′ i which is almost as big Trim ( L i , δ ) : Include L i [ j ] in L ′ Consider this process called Trim . . . i iff L i [ j ] > (1 + δ ) · prev where prev is the previous entry we included in L ′ i Unfortunately, this hasn’t really achieved anything. . . we don’t have time to compute L i and then trim it (because L i might be very big)

  66. A PTAS for Subset Sum Recall that L i is the set of sizes of all S ′ ⊆ S i which are not larger than t (where S i = { s 1 , s 2 , . . . , s i } - the first i numbers in the input) Key Idea Construct a trimmed version of L i (denoted L ′ i ⊆ L i ) so that L ′ i is a subset of L i (i.e. L ′ i ⊆ L i ) i | � n c for some c ) The length of L ′ i is polynomial in the input length (i.e. | L ′ For every y ∈ L i , there is a z ∈ L ′ i which is almost as big Trim ( L i , δ ) : Include L i [ j ] in L ′ Consider this process called Trim . . . i iff L i [ j ] > (1 + δ ) · prev where prev is the previous entry we included in L ′ i Unfortunately, this hasn’t really achieved anything. . . we don’t have time to compute L i and then trim it (because L i might be very big) Instead, we will trim as we go along. . .

  67. | S | = m A PTAS for Subset Sum Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t - L ′ i is the trimmed version of L i The algorithm ◦ Let L ′ 0 = { 0 } , δ = ǫ/ (2 m ) ◦ For i = 1 . . . m : ◦ Compute ( L ′ i − 1 + s i ) from L ′ i − 1 ◦ Compute U = L ′ i − 1 ∪ ( L ′ i − 1 + s i ) ◦ Let L ′ i = Trim ( U, δ ) ◦ Output the largest number in L ′ m

  68. | S | = m A PTAS for Subset Sum Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t - L ′ i is the trimmed version of L i The algorithm ◦ Let L ′ 0 = { 0 } , δ = ǫ/ (2 m ) ◦ For i = 1 . . . m : ◦ Compute ( L ′ i − 1 + s i ) from L ′ i − 1 ◦ Compute U = L ′ i − 1 ∪ ( L ′ i − 1 + s i ) ◦ Let L ′ i = Trim ( U, δ ) ◦ Output the largest number in L ′ m Trim ( U, δ ) : Include U [ j ] in L ′ i iff U [ j ] > (1 + δ ) · prev where prev is the previous thing we included in L ′ i

  69. | S | = m A PTAS for Subset Sum Let L i be the set of sizes of all S ′ ⊆ S i which are not larger than t - L ′ i is the trimmed version of L i The algorithm ◦ Let L ′ 0 = { 0 } , δ = ǫ/ (2 m ) ◦ For i = 1 . . . m : ◦ Compute ( L ′ i − 1 + s i ) from L ′ i − 1 ◦ Compute U = L ′ i − 1 ∪ ( L ′ i − 1 + s i ) ◦ Let L ′ i = Trim ( U, δ ) ◦ Output the largest number in L ′ m

Recommend


More recommend