{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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 n ( W + 1) entries to find, each of which can be determined in O (1)
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern