Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimization of the Unbounded Knapsack with Dynamic Programming

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

like image 312
danrpts Avatar asked Aug 17 '14 23:08

danrpts


Video Answer


1 Answers

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.

like image 58
David Eisenstat Avatar answered Oct 20 '22 00:10

David Eisenstat