I am curious if it is possible to modify (or use) a DP algorithm of the Unbounded Knapsack Problem to minimize the total value of items in the knapsack while making the total weight at least some minimum constraint C.
A bottom-up DP algorithm for the maximization version of UKP:
let w = set of weights (0-indexed)
and v = set of values (0-indexed)
DP[i][j] = max{ DP[i-1][j], DP[i][j - w[i-1]] + v[i-1] }
for i = 0,...,N and j = 0,...,C
given DP[0][j] = 0 and DP[i][0] = 0
where N = amount of items
and C = maximum weight
DP[N][C] = the maximum value of items for a knapsack capacity of C
Can we make a minimization UKP ? If not, can anyone offer another solution or technique to solve a problem like this?
Thanks, Dan
You'll have the new recurrence
DP[i][j] (i = 0, j = 0) = 0
DP[i][j] (i = 0, j > 0) = infinity
DP[i][j] (i > 0 ) = min{ DP[i-1][j], DP[i-1][max(0, j - w[i-1])] + v[i-1] },
which gives, for each i
and j
, the minimum value of items 0..i-1
to make weight at least j
. infinity
should be some sufficiently large value such that any legitimate value is smaller than infinity
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With