Dynamic Programming and the Knapsack Problem

Slides:



Advertisements
Similar presentations
MCS 312: NP Completeness and Approximation algorithms Instructor Neelima Gupta
Advertisements

Dynamic Programming Rahul Mohare Faculty Datta Meghe Institute of Management Studies.
Analysis of Algorithms
Problem Solving Dr. Andrew Wallace PhD BEng(hons) EurIng
Dynamic Programming and the Knapsack Problem Paul Dohmen Roshnika Fernando.
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Chapter 7 Dynamic Programming 7.
0-1 Knapsack Problem A burglar breaks into a museum and finds “n” items Let v_i denote the value of ith item, and let w_i denote the weight of the ith.
The Stagecoach Problem
Design and Analysis of Algorithms - Chapter 81 Dynamic Programming Dynamic Programming is a general algorithm design technique Dynamic Programming is a.
© 5/7/2002 V.S. Subrahmanian1 Knapsack Problem Notes V.S. Subrahmanian University of Maryland.
The Knapsack Problem The classic Knapsack problem is typically put forth as: A thief breaks into a store and wants to fill his knapsack with as much value.
7 -1 Chapter 7 Dynamic Programming Fibonacci sequence (1) 0,1,1,2,3,5,8,13,21,34,... Leonardo Fibonacci ( ) 用來計算兔子的數量 每對每個月可以生產一對 兔子出生後,
KNAPSACK PROBLEM A dynamic approach. Knapsack Problem  Given a sack, able to hold K kg  Given a list of objects  Each has a weight and a value  Try.
Dynamic Programming 0-1 Knapsack These notes are taken from the notes by Dr. Steve Goddard at
Dynamic Programming A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 8 ©2012 Pearson Education, Inc. Upper Saddle River,
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 8 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
IT 60101: Lecture #201 Foundation of Computing Systems Lecture 20 Classic Optimization Problems.
7 -1 Chapter 7 Dynamic Programming Fibonacci sequence Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, … F i = i if i  1 F i = F i-1 + F i-2 if.
Dynamic Programming. Well known algorithm design techniques:. –Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic programming.
Recursion and Dynamic Programming. Recursive thinking… Recursion is a method where the solution to a problem depends on solutions to smaller instances.
Dynamic Programming Sequence of decisions. Problem state. Principle of optimality. Dynamic Programming Recurrence Equations. Solution of recurrence equations.
7 -1 Chapter 7 Dynamic Programming Fibonacci sequence Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, … F i = i if i  1 F i = F i-1 + F i-2 if.
8 -1 Dynamic Programming Fibonacci sequence Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, … F i = i if i  1 F i = F i-1 + F i-2 if i  2 Solved.
CSC401: Analysis of Algorithms CSC401 – Analysis of Algorithms Chapter Dynamic Programming Objectives: Present the Dynamic Programming paradigm.
Topic 25 Dynamic Programming "Thus, I thought dynamic programming was a good name. It was something not even a Congressman could object to. So I used it.
CS 3343: Analysis of Algorithms Lecture 18: More Examples on Dynamic Programming.
Dynamic Programming.  Decomposes a problem into a series of sub- problems  Builds up correct solutions to larger and larger sub- problems  Examples.
Prepared by Dr.Osman Taylan
CS 3343: Analysis of Algorithms Lecture 19: Introduction to Greedy Algorithms.
Dynamic Programming … Continued 0-1 Knapsack Problem.
8 -1 Dynamic Programming Fibonacci sequence Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, … F i = i if i  1 F i = F i-1 + F i-2 if i  2 Solved.
Introduction and Preliminaries D Nagesh Kumar, IISc Water Resources Planning and Management: M4L1 Dynamic Programming and Applications.
Dynamic Programming. What is Dynamic Programming  A method for solving complex problems by breaking them down into simpler sub problems. It is applicable.
Divide and Conquer. Problem Solution 4 Example.
GOOD MORNING CLASS! In Operation Research Class, WE MEET AGAIN WITH A TOPIC OF :
Dynamic Programming Sequence of decisions. Problem state.
Water Resources Planning and Management Daene McKinney
CS 3343: Analysis of Algorithms
Dynamic Programming Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
The Knapsack Problem.
Topic 25 Dynamic Programming
Algorithm Design Methods
DYNAMIC PROGRAMMING.
Prepared by Chen & Po-Chuan 2016/03/29
CS 188: Artificial Intelligence
CS 3343: Analysis of Algorithms
Dynamic Programming General Idea
Chapter 3 Dynamic Programming.
Unit 4: Dynamic Programming
CAP 5636 – Advanced Artificial Intelligence
Unit-4: Dynamic Programming
Advanced Algorithms Analysis and Design
Merge Sort Dynamic Programming
Dynamic Programming.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Dynamic Programming General Idea
Dynamic Programming.
Dynamic Programming.
Lecture 4 Dynamic Programming
Lecture 6 Greedy Algorithms
Dynamic Programming Sequence of decisions. Problem state.
Lecture 5 Dynamic Programming
Advanced Analysis of Algorithms
0-1 Knapsack problem.
Dynamic Programming.
Dynamic Programming Sequence of decisions. Problem state.
Knapsack Problem A dynamic approach.
Presentation transcript:

Dynamic Programming and the Knapsack Problem Paul Dohmen Roshnika Fernando

What is Dynamic Programming 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 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

Steps to Dynamic Programming 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

Knapsack Problem 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?

Knapsack Problem 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

Smart Kids Write Equations 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.

Smart Kids Use MatLab 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

Solution

Sensitivity Analysis 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

Questions?

Sources 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/fileexchang e/22783-0-1-knapsack>. "Dynamic Programming Algorithms." Web. 03 Dec. 2009. <http://www.personal.kent.edu/~rmuhamma/Algorithm s/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+progra mming.html>.