Loading in 5 sec....

Dynamic Programming and the Knapsack ProblemPowerPoint Presentation

Dynamic Programming and the Knapsack Problem

- 87 Views
- Uploaded on
- Presentation posted in: General

Dynamic Programming and the Knapsack Problem

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Dynamic Programming and the Knapsack Problem

Paul Dohmen

Roshnika Fernando

- Dynamic programming is a method of solving complex problems by breaking them down into sub-problems that can be solved by working backwards from the last stage.
- Coined by Richard Bellman who described dynamic programming as the way of solving problems where you need to find the best decisions one after another

Dynamic programming is a simple method of solving complex real world problems, such as

- Traveling salesman problem
- Fibonacci sequence
- Stagecoach problem
- Knapsack problem
Numerous other applications exist

- Every problem is divided into stages
- Each stage requires a decision
- Decisions are made to determine the state of the next stage
- The solution procedure is to find an optimal solution at each stage for every possible state
- This solution procedure often starts at the last stage and works its way forward

You are a mischievous child camping in the woods. You would like to steal items from other campers, but you can only carry so much mass in your knapsack. You see seven items worth stealing. Each item has a certain mass and monetary value. How do you maximize your profit so you can buy more video games later?

- Value and mass of each item is given
- Maximize profit
- Subject to mass constraint of knapsack: 15 kg
- Being a smart kid, you apply dynamic programming

- There are potentially 7 stages to this dynamic programming problem.
- When an item is placed in the knapsack, a decision, F(m), is made to choose the next optimal item, i.
- Start at the end of the problem, assuming that the knapsack has an unknown mass, m.
- Recurrence relation:
F(i,m) = max (F(i-1,m-mi) + fi, F(i-1, m))

- Use recursion and iterate through the problem, eventually coming up with the optimal solution.

- Now imagine you, the mischievous smart thief kid, brought your laptop to the camping trip. How would you solve the equation? MATLAB!
- Matlab Solution:
- Profit: $21
- Mass: 15kg
- Not enough to buy a new video game

- Valuables are not very valuable when camping, pick richer people to steal from.
- Suddenly a valuable item of $15 that weighs 11kg is available, will the optimal solution change?
Yes, the maximum profit becomes $23

- Using MatLab, it is easy to change the variables on the program for specific sensitivity analysis

- Petter. "MATLAB Central - File detail - 0-1 Knapsack." The MathWorks - MATLAB and Simulink for Technical Computing. Web. 03 Dec. 2009. <http://www.mathworks.com/matlabcentral/fileexchange/22783-0-1-knapsack>.
- "Dynamic Programming Algorithms." Web. 03 Dec. 2009. <http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/Dynamic/knapsackdyn.htm>.
- "Dynamic programming ." Wikipedia, the free encyclopedia. Web. 03 Dec. 2009. <http://en.wikipedia.org/wiki/Dynamic_programming>.
- "Dynamic Programming: Definition and additional resources from BNET." Glossary of Business Dictionary Terms | A | BNET. Web. 02 Dec. 2009. <http://dictionary.bnet.com/definition/dynamic+programming.html>.