dp - IEOR E4004: Introduction to OR: Deterministic Models 1...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: IEOR E4004: Introduction to OR: Deterministic Models 1 Dynamic Programming Following is a summary of the problems we discussed in class. (We do not include the discussion on the “container” problem or the cannibals and missionaries problem because these were mostly “philosophical” discussions.) 1.1 Matrix Multiplication We wish to compute the matrix product A 1 A 2 ...A n- 1 A n , where A i has a i rows and a i +1 columns. How can find this product while minimizing the number of multiplications used? To study this problem using dynamic programming, we let m ij be the optimal number of multiplica- tions to find the product A i A i +1 ...A j , for i < j . The DP recursion is easily seen to be: m i,i +1 = a i a i +1 a i +2 , and m i,j = min k : i<k<j m i,k + m k,j + a i a k +1 a j +1 , ∀ j > i + 1 . Alternatively, one can say: m i,i = 0 , and m i,j = min k : i ≤ k ≤ j m i,k + m k,j + a i a k +1 a j +1 , ∀ j > i. We first find m ( · ) for all i and j for which j- i is 0, then for all i and j for which j- i is 1, etc. Observe that the DP recursion is such that if ( j- i ) = k , then m ( i,j ) depends on m ( · ) values for those ( i ,j ) pairs for which j- i < k . (Thus our way of finding the m ( · ) will work.) We are of course interested in m (1 ,n ). The algorithm runs in O ( n 3 ) time: we need to fill a table of size O ( n 2 ), each of which requires O ( n ) time to fill. 1.2 Knapsack problem We are given a knapsack with capacity W . We have n items labeled 1 , 2 ,...,n- 1 ,n ; item i has size s i and value v i . Any subset of items with total size ≤ W can be packed into the knapsack. Thus our goal is to pack into the knapsack a subset of maximum value, among all possible subsets whose total size is at most W . Assume all the data are non-negative integers. How does one identify a maximum value subset? 1 We let f ( j,w ) be the maximum value one can achieve in the knapsack problem with items { 1 , 2 ,...,j } and with knapsack capacity w . We are interested in determining f ( n,W ). It is easy to see that f ( j + 1 ,w ) = max f ( j,w ) ,v j +1 + f ( j,w- s j +1 ) . (The second term exists only if w ≥ s j +1 ; otherwise it is taken to be zero.) To justify this, consider the following argument. If we are given a knapsack problem with j + 1 items and knapsack capacity w , an optimal packing will either exclude the last item or include it; in the former case, we are left with a knapsack problem involving the first j items and knapsack capacity w , whereas in the latter case we are left with a knapsack problem involving the first j items and knapsack capacity w- s j +1 , but we also pick up an additional value v j +1 . We can now solve the recursion backwards: clearly f (1 ,w ) is trivial to determine, for all 0 ≤ w ≤ W ; using this and the recursion described above, we can determine f (2 ,w ) for all 0 ≤ w ≤ W , etc. There are, etc....
View Full Document

This note was uploaded on 01/26/2011 for the course IEOR 4004 taught by Professor Sethuraman during the Fall '10 term at Columbia.

Page1 / 5

dp - IEOR E4004: Introduction to OR: Deterministic Models 1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online