1 / 15

Approximation Algorithms for Knapsack Problems

Approximation Algorithms for Knapsack Problems. Tsvi Kopelowitz Modified by Ariel Rosenfeld. Given: a set S of n objects with weights and values, and a weight bound: w 1 , w 2 , …, w n , B (weights, weight bound). v 1 , v 2 , …, v n (values - profit).

terra
Télécharger la présentation

Approximation Algorithms for Knapsack Problems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Approximation Algorithms for Knapsack Problems TsviKopelowitz Modified by Ariel Rosenfeld

  2. Given: a set S of n objects with weights and values, and a weight bound: • w1, w2, …, wn, B (weights, weight bound). • v1, v2, …, vn (values - profit). • Find: subset of S with total weight at most B, and maximum total value. Formally: • Problem is known to be NP-hard Knapsack

  3. . (every item can be added to T) • . (non-negative values) • Values, weights, and bound are all integers. Note: • This is a maximum problem. • Define: OPT = The optimal solution. • We will see a 2-approximation for two versions of knapsack. Assumptions

  4. Uniform Knapsack (simple form) • (value=weight) • 2-approximation algorithm: • Sort the items such that v1 ≥ v2 ≥ … ≥ vn. • Pick such that and .

  5. Uniform Knapsack (proff) • Claim: . • Proof: • Assume (by contradiction): . • By the algorithm: => . • => =>contradiction. (Since items were sorted)

  6. Define ratio: • Sort items such that r1 ≥ r2 ≥ … ≥ rn. • Pick such that and . • If( ) return • else return A. 2-approximation (general knapsack)

  7. 2-approximation try it yourself…

  8. Claim: Proof sketch (fill the details yourselves): • Consider fractional knapsack (where we can take some of each item)– the optimal solution is A’= (A and a fraction of vj+1.) • . • . 2-approximation (general knapsack)

  9. A DP algorithm for knapsack A 1 2 3 j n vmax 1 2 3 i n Upper bound on optimal profit A(i,j) = Smallest weight subset of objects 1,…,i with a total value of j.

  10. The result is: max j such that A(n, j) ≤ B. • The runtime is: O(n2vmax) • Pseudo-polynomial A DP algorithm for knapsack

  11. Definition: Pseudo-polynomial If input of integers is given in unary form, runs in polynomial time. Definition: Fully Polynomial Time Approximation Scheme (FPTAS) Given ε, delivers a solution with a ratio of (1- ε) for maximum and a ratio of (1+ ε) for minimum, and runs in time polynomial in the size of the input and (1/ε) Definitions

  12. FPTAS for knapsack The Idea – use scaling!! • Given error bound , define . • For each object i, define . • Use DP to find optimal solution OPT’ for the rounded values. • Return the set OPT’ with the original values.

  13. Correctness • Claim: Proof: For every i: . (1) => (3) (2) (4)

  14. Correctness Proof continued: (1) (3) (2) (4) 

  15. Complexity and Notes Time: • algorithm is a FPTAS.

More Related