Unformatted text preview: A[0,w] = 0 ‐ When there are no items to be considered, there is no value A[i, 0] = 0 – When there is no weight remaining, there is no value A[i, w] = A[i ‐ 1,w ] ( if w i > w) – New item being considered weighs more than the current limit A[i, w] = max(A[i ‐ 1,w], m[i ‐ 1,w ‐ w i ]+v i ) (if w i ≤ w) Calculating A[N,W] given there are N items and a total Weight of W gets the optimal solution to the DP 4. MATLAB Code A Dynamic Programming Problem has been written in MATLAB and can be downloaded from: http://www.mathworks.com/matlabcentral/fileexchange/22783 ‐ ‐ 1 ‐ knapsack Download and look at the code to see the Dynamic Programming Algorithm at work. 5. Extension Study the MATLAB code for the Knapsack DP for next week’s lab....
View
Full Document
 Spring '11
 Daniel
 Dynamic Programming, WI, Knapsack problem

Click to edit the document details