This preview shows page 1. Sign up to view the full content.
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 weeks lab....
View
Full
Document
This note was uploaded on 04/20/2011 for the course MIE 376 taught by Professor Daniel during the Spring '11 term at University of Toronto Toronto.
 Spring '11
 Daniel

Click to edit the document details