1 Tsvi Kopelowitz Knapsack 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 ID: 326944
Download Presentation The PPT/PDF document "Approximation Algorithms for Knapsack P..." 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.
Slide1
Approximation Algorithms for Knapsack Problems
1
Tsvi
KopelowitzSlide2
Knapsack
Given: a set S of n objects with weights and values, and a weight bound:
w
1
, 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.Problem is known to be NP-hard
2Slide3
Assumptions
.
.
Values, weights, and bound are all integers.
Note:This is a maximum problem.Define: OPT = The optimal solution.We will see a ½ approximation for two versions of knapsack.
3Slide4
Uniform Knapsack
(value=weight)
½-approximation algorithm:
Sort the items such that v
1 ≥ v2 ≥ … ≥ vn.Pick such that and .4Slide5
Uniform Knapsack
Claim: .
Proof:
Assume (by contradiction): . => . => =>contradiction. (Since items were sorted)5Slide6
½-approximation
(general knapsack)
Define:
Sort items such that r
1 ≥ r2 ≥ … ≥ rn.Pick such that and .If( ) returnelse return A.
6Slide7
Claim:
Proof:
Consider fractional knapsack –
the optimal solution is A’= A and a fraction of vj+1. . .½-approximation
(general knapsack)
7Slide8
8
A(i,j) = Smallest weight subset of objects 1,…,i with a total value of j.
A DP algorithm for knapsack
A 1 2 3 j n
vmax
1
2
3
i
n
Upper bound on optimal profitSlide9
A DP algorithm for knapsack
The result is: max j such that A(n, j) ≤ B.
The runtime is: O(n2vmax)Pseudo-polynomial 9Slide10
10
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/ε)Definition: Pseudo-polynomial
If input of integers is given in unary form, runs in polynomial time.
DefinitionsSlide11
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.11Slide12
Correctness
Claim:
Proof: For every i: .
(1) => (3)
(2) (4) 12Slide13
Correctness
Proof continued:
(1) (3)
(2) (4)
13Slide14
Complexity and Notes
Time:
algorithm is a FPTAS.
14