SlideShare a Scribd company logo
Dynamic Programming
In this handout
• A shortest path example
• Deterministic Dynamic Programming
• Inventory example
• Resource allocation example
Dynamic Programming
• Dynamic programming is a widely-used mathematical
technique for solving problems that can be divided into
stages and where decisions are required in each
stage.
• The goal of dynamic programming is to find a
combination of decisions that optimizes a certain
amount associated with a system.
A typical example: Shortest Path
• Ben plans to drive from NY to LA
• Has friends in several cities
• After 1 day’s driving can reach Columbus, Nashville, or
Louisville
• After 2 days of driving can reach Kansas City, Omaha, or
Dallas
• After 3 days of driving can reach Denver or San Antonio
• After 4 days of driving can reach Los Angeles
• The actual mileages between cities are given in the figure
(next slide)
• Where should Ben spend each night of the trip to minimize
the number of miles traveled?
Shortest Path: network figure
New York
1
Columbus
2
Kansas City
5
Denver
8
Los
Angeles
10
Omaha
6
Dallas
7
Nashville
3
Louisville
4
San
Antonio
9
Stage 1
Stage 2 Stage 3
Stage 4
Stage 5
550
680
610
1030
1390
270
790
940
540
790
790
1050
580
660
510
830
700
770
900 760
Shortest Path problem: Solution
• The problem is solved recursively by working
backward in the network
• Let cij be the mileage between cities i and j
• Let ft(i) be the length of the shortest path from city i
to LA (city i is in stage t)
Stage 4 computations are obvious:
• f4(8) = 1030
• f4(9) = 1390
Stage 3 computations
Work backward one stage (to stage 3 cities) and find the
shortest path to LA from each stage 3 city.
To determine f3(5), note that the shortest path from city 5 to LA
must be one of the following:
• Path 1: Go from city 5 to city 8 and then take the shortest
path from city 8 to city 10.
• Path 2: Go from city 5 to city 9 and then take the shortest
path from city 9 to city 10.

f3(5)  min
c58  f4 (8)  610 1030 1640 *
c59  f4 (9)  790 1390  2180



f3(6)  min
c68  f4 (8)  540 1030 1570 *
c69  f4 (9)  940 1390  2330



f3(7)  min
c78  f4 (8)  790 1030 1820
c79  f4 (9)  270 1390 1660 *



Similarly,
Stage 2 computations
Work backward one stage (to stage 2 cities) and find the
shortest path to LA from each stage 2 city.

f2(2)  min
c25  f3(5)  6801640  2320*
c26  f3(6)  7901570  2360
c27  f3(7) 10501660  2710






f2(3)  min
c35  f3(5)  5801640  2220*
c36  f3(6)  7601570  2330
c37  f3(7)  6601660  2320





f2(4)  min
c45  f3(5)  5101640  2150*
c46  f3(6)  7001570  2270
c47  f3(7)  8301660  2490





Stage 1 computations
Now we can find f1(1), and the shortest path from NY to LA.
Checking back our calculations, the shortest path is
1 – 2 – 5 – 8 – 10
that is,
NY – Columbus – Kansas City – Denver – LA
with total mileage 2870.

f1(1)  min
c12  f2(2)  5502320  2870*
c13  f2(3)  9002220  3120
c14  f2(4)  7702150  2920





General characteristics of Dynamic
Programming
• The problem structure is divided into stages
• Each stage has a number of states associated with it
• Making decisions at one stage transforms one state
of the current stage into a state in the next stage.
• Given the current state, the optimal decision for each
of the remaining states does not depend on the
previous states or decisions. This is known as the
principle of optimality for dynamic programming.
• The principle of optimality allows to solve the problem
stage by stage recursively.
Division into stages
The problem is divided into smaller subproblems each of
them represented by a stage.
The stages are defined in many different ways depending on
the context of the problem.
If the problem is about long-time development of a system
then the stages naturally correspond to time periods.
If the goal of the problem is to move some objects from
one location to another on a map then partitioning the
map into several geographical regions might be the
natural division into stages.
Generally, if an accomplishment of a certain task can be
considered as a multi-step process then each stage can
be defined as a step in the process.
States
Each stage has a number of states associated with
it. Depending what decisions are made in one
stage, the system might end up in different states
in the next stage.
If a geographical region corresponds to a stage
then the states associated with it could be some
particular locations (cities, warehouses, etc.) in
that region.
In other situations a state might correspond to
amounts of certain resources which are essential
for optimizing the system.
Decisions
Making decisions at one stage transforms one state
of the current stage into a state in the next stage.
In a geographical example, it could be a decision to
go from one city to another.
In resource allocation problems, it might be a decision
to create or spend a certain amount of a resource.
For example, in the shortest path problem three
different decisions are possible to make at the state
corresponding to Columbus; these decisions
correspond to the three arrows going from
Columbus to the three states (cities) of the next
stage: Kansas City, Omaha, and Dallas.
Optimal Policy and Principle of Optimality
The goal of the solution procedure is to find an optimal policy
for the overall problem, i.e., an optimal policy decision at
each stage for each of the possible states.
Given the current state, the optimal decision for each of the
remaining states does not depend on the previous states or
decisions. This is known as the principle of optimality for
dynamic programming.
For example, in the geographical setting the principle works as
follows: the optimal route from a current city to the final
destination does not depend on the way we got to the city.
A system can be formulated as a dynamic programming
problem only if the principle of optimality holds for it.
Recursive solution to the problem
The principle of optimality allows to solve the
problem stage by stage recursively.
The solution procedure first finds the optimal policy
for the last stage. The solution for the last stage
is normally trivial.
Then a recursive relationship is established
which identifies the optimal policy for stage t,
given that stage t+1 has already been solved.
When the recursive relationship is used, the
solution procedure starts at the end and moves
backward stage by stage until it finds the optimal
policy starting at the initial stage.
Solving Inventory Problems by DP
Main characteristics:
1.Time is broken up into periods. The demands for all
periods are known in advance.
2.At the beginning of each period, the firm must
determine how many units should be produced.
3.Production and storage capacities are limited.
4.Each period’s demand must be met on time from
inventory or current production.
5.During any period in which production takes place,
a fixed cost of production as well as a variable per-
unit cost is incurred.
6.The firm’s goal is to minimize the total cost of
meeting on time the demands.
Inventory Problems: Example
• Producing airplanes
• 3 production periods
• No inventory at the beginning
• Can produce at most 3 airplanes in each period
• Can keep at most 2 airplanes in inventory
• Set-up cost for each period is 10
Determine a production schedule to minimize the
total cost (the DP solution on the board).
Period 1 2 3
Demand 1 2 1
Unit cost 3 5 4
Resource Allocation Problems
• Limited resources must be allocated to different
activities
• Each activity has a benefit value which is
variable and depends on the amount of the
resource assigned to the activity
• The goal is to determine how to allocate the
resources to the activities such that the total
benefit is maximized
Resource Allocation Problems: Example
• A college student has 6 days remaining before final exams
begin in his 4 courses
• He wants allocate the study time as effectively as possible
• Needs at least 1 day for each course and wants to
concentrate on just one course each day. So 1, 2, or 3 days
should be allocated to each course
• He estimates that the alternative allocations for each course
would yield the number of grade points shown in the
following table:
How many days should be allocated to each course?
(The DP solution on the board).
Courses
Days 1 2 3 4
1 3 4 3 4
2 5 5 6 7
3 7 6 7 9
Ad

More Related Content

What's hot (20)

Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Yıldırım Tam
 
Unit 7 dynamic programming
Unit 7   dynamic programmingUnit 7   dynamic programming
Unit 7 dynamic programming
Nageswara Rao Thots
 
Operation research complete note
Operation research  complete noteOperation research  complete note
Operation research complete note
kabul university
 
NON LINEAR PROGRAMMING
NON LINEAR PROGRAMMING NON LINEAR PROGRAMMING
NON LINEAR PROGRAMMING
karishma gupta
 
Operation research and its application
Operation research and its applicationOperation research and its application
Operation research and its application
priya sinha
 
Linear Programming
Linear ProgrammingLinear Programming
Linear Programming
Pulchowk Campus
 
PRIMAL & DUAL PROBLEMS
PRIMAL & DUAL PROBLEMSPRIMAL & DUAL PROBLEMS
PRIMAL & DUAL PROBLEMS
MayuR Khambhayata
 
Game Theory Operation Research
Game Theory Operation ResearchGame Theory Operation Research
Game Theory Operation Research
R A Shah
 
Integer Linear Programming
Integer Linear ProgrammingInteger Linear Programming
Integer Linear Programming
SukhpalRamanand
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
hodcsencet
 
Operations research-an-introduction
Operations research-an-introductionOperations research-an-introduction
Operations research-an-introduction
Manoj Bhambu
 
Assignment Problem
Assignment ProblemAssignment Problem
Assignment Problem
Nakul Bhardwaj
 
Transportation Problem In Linear Programming
Transportation Problem In Linear ProgrammingTransportation Problem In Linear Programming
Transportation Problem In Linear Programming
Mirza Tanzida
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Melaku Bayih Demessie
 
Sequencing problems in Operations Research
Sequencing problems in Operations ResearchSequencing problems in Operations Research
Sequencing problems in Operations Research
Abu Bashar
 
Linear programing
Linear programingLinear programing
Linear programing
Aniruddh Tiwari
 
Job shop scheduling
Job shop schedulingJob shop scheduling
Job shop scheduling
Sujeet TAMBE
 
Optimization problems and algorithms
Optimization problems and  algorithmsOptimization problems and  algorithms
Optimization problems and algorithms
Aboul Ella Hassanien
 
Big-M Method Presentation
Big-M Method PresentationBig-M Method Presentation
Big-M Method Presentation
Nitesh Singh Patel
 
Solving Degenaracy in Transportation Problem
Solving Degenaracy in Transportation ProblemSolving Degenaracy in Transportation Problem
Solving Degenaracy in Transportation Problem
mkmanik
 
Operation research complete note
Operation research  complete noteOperation research  complete note
Operation research complete note
kabul university
 
NON LINEAR PROGRAMMING
NON LINEAR PROGRAMMING NON LINEAR PROGRAMMING
NON LINEAR PROGRAMMING
karishma gupta
 
Operation research and its application
Operation research and its applicationOperation research and its application
Operation research and its application
priya sinha
 
Game Theory Operation Research
Game Theory Operation ResearchGame Theory Operation Research
Game Theory Operation Research
R A Shah
 
Integer Linear Programming
Integer Linear ProgrammingInteger Linear Programming
Integer Linear Programming
SukhpalRamanand
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
hodcsencet
 
Operations research-an-introduction
Operations research-an-introductionOperations research-an-introduction
Operations research-an-introduction
Manoj Bhambu
 
Transportation Problem In Linear Programming
Transportation Problem In Linear ProgrammingTransportation Problem In Linear Programming
Transportation Problem In Linear Programming
Mirza Tanzida
 
Sequencing problems in Operations Research
Sequencing problems in Operations ResearchSequencing problems in Operations Research
Sequencing problems in Operations Research
Abu Bashar
 
Job shop scheduling
Job shop schedulingJob shop scheduling
Job shop scheduling
Sujeet TAMBE
 
Optimization problems and algorithms
Optimization problems and  algorithmsOptimization problems and  algorithms
Optimization problems and algorithms
Aboul Ella Hassanien
 
Solving Degenaracy in Transportation Problem
Solving Degenaracy in Transportation ProblemSolving Degenaracy in Transportation Problem
Solving Degenaracy in Transportation Problem
mkmanik
 

Viewers also liked (20)

Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Shakil Ahmed
 
Dynamic pgmming
Dynamic pgmmingDynamic pgmming
Dynamic pgmming
Dr. C.V. Suresh Babu
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
paramalways
 
Approximate Dynamic Programming: A New Paradigm for Process Control & Optimiz...
Approximate Dynamic Programming: A New Paradigm for Process Control & Optimiz...Approximate Dynamic Programming: A New Paradigm for Process Control & Optimiz...
Approximate Dynamic Programming: A New Paradigm for Process Control & Optimiz...
height
 
Shortest Path Search in Real Road Networks with pgRouting
Shortest Path Search in Real Road Networks with pgRoutingShortest Path Search in Real Road Networks with pgRouting
Shortest Path Search in Real Road Networks with pgRouting
Daniel Kastl
 
Shortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRoutingShortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRouting
antonpa
 
2
22
2
Deng Zhenzhou
 
SECURITY OPTIMIZATION OF DYNAMIC NETWORKS WITH PROBABILISTIC GRAPH MODELING A...
SECURITY OPTIMIZATION OF DYNAMIC NETWORKS WITH PROBABILISTIC GRAPH MODELING A...SECURITY OPTIMIZATION OF DYNAMIC NETWORKS WITH PROBABILISTIC GRAPH MODELING A...
SECURITY OPTIMIZATION OF DYNAMIC NETWORKS WITH PROBABILISTIC GRAPH MODELING A...
I3E Technologies
 
Probabilistic programming2
Probabilistic programming2Probabilistic programming2
Probabilistic programming2
bredelings
 
A Multiple-Shooting Differential Dynamic Programming Algorithm
A Multiple-Shooting Differential Dynamic Programming AlgorithmA Multiple-Shooting Differential Dynamic Programming Algorithm
A Multiple-Shooting Differential Dynamic Programming Algorithm
Etienne Pellegrini
 
Mean Variance Analysis
Mean Variance AnalysisMean Variance Analysis
Mean Variance Analysis
merzak emerzak
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programming
Tafhim Islam
 
Dynamic programming - fundamentals review
Dynamic programming - fundamentals reviewDynamic programming - fundamentals review
Dynamic programming - fundamentals review
ElifTech
 
Dynamic programming class 16
Dynamic programming class 16Dynamic programming class 16
Dynamic programming class 16
Kumar
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
Subrata Kumer Paul
 
Discrete Mathematics Presentation
Discrete Mathematics PresentationDiscrete Mathematics Presentation
Discrete Mathematics Presentation
Salman Elahi
 
Shortest path problem
Shortest path problemShortest path problem
Shortest path problem
Ifra Ilyas
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1Dynamic Programming - Part 1
Dynamic Programming - Part 1
Amrinder Arora
 
Integer Programming, Gomory
Integer Programming, GomoryInteger Programming, Gomory
Integer Programming, Gomory
AVINASH JURIANI
 
Transportation problem
Transportation problemTransportation problem
Transportation problem
A B
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Shakil Ahmed
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
paramalways
 
Approximate Dynamic Programming: A New Paradigm for Process Control & Optimiz...
Approximate Dynamic Programming: A New Paradigm for Process Control & Optimiz...Approximate Dynamic Programming: A New Paradigm for Process Control & Optimiz...
Approximate Dynamic Programming: A New Paradigm for Process Control & Optimiz...
height
 
Shortest Path Search in Real Road Networks with pgRouting
Shortest Path Search in Real Road Networks with pgRoutingShortest Path Search in Real Road Networks with pgRouting
Shortest Path Search in Real Road Networks with pgRouting
Daniel Kastl
 
Shortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRoutingShortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRouting
antonpa
 
SECURITY OPTIMIZATION OF DYNAMIC NETWORKS WITH PROBABILISTIC GRAPH MODELING A...
SECURITY OPTIMIZATION OF DYNAMIC NETWORKS WITH PROBABILISTIC GRAPH MODELING A...SECURITY OPTIMIZATION OF DYNAMIC NETWORKS WITH PROBABILISTIC GRAPH MODELING A...
SECURITY OPTIMIZATION OF DYNAMIC NETWORKS WITH PROBABILISTIC GRAPH MODELING A...
I3E Technologies
 
Probabilistic programming2
Probabilistic programming2Probabilistic programming2
Probabilistic programming2
bredelings
 
A Multiple-Shooting Differential Dynamic Programming Algorithm
A Multiple-Shooting Differential Dynamic Programming AlgorithmA Multiple-Shooting Differential Dynamic Programming Algorithm
A Multiple-Shooting Differential Dynamic Programming Algorithm
Etienne Pellegrini
 
Mean Variance Analysis
Mean Variance AnalysisMean Variance Analysis
Mean Variance Analysis
merzak emerzak
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programming
Tafhim Islam
 
Dynamic programming - fundamentals review
Dynamic programming - fundamentals reviewDynamic programming - fundamentals review
Dynamic programming - fundamentals review
ElifTech
 
Dynamic programming class 16
Dynamic programming class 16Dynamic programming class 16
Dynamic programming class 16
Kumar
 
Discrete Mathematics Presentation
Discrete Mathematics PresentationDiscrete Mathematics Presentation
Discrete Mathematics Presentation
Salman Elahi
 
Shortest path problem
Shortest path problemShortest path problem
Shortest path problem
Ifra Ilyas
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1Dynamic Programming - Part 1
Dynamic Programming - Part 1
Amrinder Arora
 
Integer Programming, Gomory
Integer Programming, GomoryInteger Programming, Gomory
Integer Programming, Gomory
AVINASH JURIANI
 
Transportation problem
Transportation problemTransportation problem
Transportation problem
A B
 
Ad

Similar to Dynamic Programming (20)

dynamic-programming unit 3 power point presentation
dynamic-programming unit 3 power point presentationdynamic-programming unit 3 power point presentation
dynamic-programming unit 3 power point presentation
Shrinivasa6
 
Pintu ram
Pintu ramPintu ram
Pintu ram
pinturam2
 
DynamicProgramming.pptx
DynamicProgramming.pptxDynamicProgramming.pptx
DynamicProgramming.pptx
SaimaShaheen14
 
unit 5 dynamic programming.pptx
unit 5 dynamic programming.pptxunit 5 dynamic programming.pptx
unit 5 dynamic programming.pptx
LEELAKUMARKONDA
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
Bhavin Darji
 
Unit 4- Dynamic Programming.pdf
Unit 4- Dynamic Programming.pdfUnit 4- Dynamic Programming.pdf
Unit 4- Dynamic Programming.pdf
MaryJacob24
 
Chapter 12 Dynamic programming.pptx
Chapter 12 Dynamic programming.pptxChapter 12 Dynamic programming.pptx
Chapter 12 Dynamic programming.pptx
MdSazolAhmmed
 
ADA Unit 2.pptx
ADA Unit 2.pptxADA Unit 2.pptx
ADA Unit 2.pptx
AmanKumar879992
 
Module 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer methodModule 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer method
JyoReddy9
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Lec37
Lec37Lec37
Lec37
Nikhil Chilwant
 
Amit ppt
Amit pptAmit ppt
Amit ppt
amitp26
 
Transportation model
Transportation modelTransportation model
Transportation model
msn007
 
Algorithm Design Techiques, divide and conquer
Algorithm Design Techiques, divide and conquerAlgorithm Design Techiques, divide and conquer
Algorithm Design Techiques, divide and conquer
Minakshee Patil
 
The Art of Problem Solving
The Art of Problem SolvingThe Art of Problem Solving
The Art of Problem Solving
Acquate
 
Lecture11
Lecture11Lecture11
Lecture11
Nv Thejaswini
 
AAC ch 3 Advance strategies (Dynamic Programming).pptx
AAC ch 3 Advance strategies (Dynamic Programming).pptxAAC ch 3 Advance strategies (Dynamic Programming).pptx
AAC ch 3 Advance strategies (Dynamic Programming).pptx
HarshitSingh334328
 
L21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer ScienceL21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer Science
priyanshukumarbt23cs
 
Reading Materials for Operational Research
Reading Materials for Operational Research Reading Materials for Operational Research
Reading Materials for Operational Research
Derbew Tesfa
 
Elak3 need of greedy for design and analysis of algorithms.ppt
Elak3 need of greedy for design and analysis of algorithms.pptElak3 need of greedy for design and analysis of algorithms.ppt
Elak3 need of greedy for design and analysis of algorithms.ppt
Elakkiya Rajasekar
 
dynamic-programming unit 3 power point presentation
dynamic-programming unit 3 power point presentationdynamic-programming unit 3 power point presentation
dynamic-programming unit 3 power point presentation
Shrinivasa6
 
DynamicProgramming.pptx
DynamicProgramming.pptxDynamicProgramming.pptx
DynamicProgramming.pptx
SaimaShaheen14
 
unit 5 dynamic programming.pptx
unit 5 dynamic programming.pptxunit 5 dynamic programming.pptx
unit 5 dynamic programming.pptx
LEELAKUMARKONDA
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
Bhavin Darji
 
Unit 4- Dynamic Programming.pdf
Unit 4- Dynamic Programming.pdfUnit 4- Dynamic Programming.pdf
Unit 4- Dynamic Programming.pdf
MaryJacob24
 
Chapter 12 Dynamic programming.pptx
Chapter 12 Dynamic programming.pptxChapter 12 Dynamic programming.pptx
Chapter 12 Dynamic programming.pptx
MdSazolAhmmed
 
Module 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer methodModule 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer method
JyoReddy9
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Amit ppt
Amit pptAmit ppt
Amit ppt
amitp26
 
Transportation model
Transportation modelTransportation model
Transportation model
msn007
 
Algorithm Design Techiques, divide and conquer
Algorithm Design Techiques, divide and conquerAlgorithm Design Techiques, divide and conquer
Algorithm Design Techiques, divide and conquer
Minakshee Patil
 
The Art of Problem Solving
The Art of Problem SolvingThe Art of Problem Solving
The Art of Problem Solving
Acquate
 
AAC ch 3 Advance strategies (Dynamic Programming).pptx
AAC ch 3 Advance strategies (Dynamic Programming).pptxAAC ch 3 Advance strategies (Dynamic Programming).pptx
AAC ch 3 Advance strategies (Dynamic Programming).pptx
HarshitSingh334328
 
L21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer ScienceL21_L27_Unit_5_Dynamic_Programming Computer Science
L21_L27_Unit_5_Dynamic_Programming Computer Science
priyanshukumarbt23cs
 
Reading Materials for Operational Research
Reading Materials for Operational Research Reading Materials for Operational Research
Reading Materials for Operational Research
Derbew Tesfa
 
Elak3 need of greedy for design and analysis of algorithms.ppt
Elak3 need of greedy for design and analysis of algorithms.pptElak3 need of greedy for design and analysis of algorithms.ppt
Elak3 need of greedy for design and analysis of algorithms.ppt
Elakkiya Rajasekar
 
Ad

Recently uploaded (20)

WHITE PAPER-Best Practices in Syngas Plant Optimization.pdf
WHITE PAPER-Best Practices in Syngas Plant Optimization.pdfWHITE PAPER-Best Practices in Syngas Plant Optimization.pdf
WHITE PAPER-Best Practices in Syngas Plant Optimization.pdf
Floyd Burgess
 
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Journal of Soft Computing in Civil Engineering
 
vtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdfvtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdf
RaghavaGD1
 
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Journal of Soft Computing in Civil Engineering
 
UNIT 3 Software Engineering (BCS601) EIOV.pdf
UNIT 3 Software Engineering (BCS601) EIOV.pdfUNIT 3 Software Engineering (BCS601) EIOV.pdf
UNIT 3 Software Engineering (BCS601) EIOV.pdf
sikarwaramit089
 
22PCOAM16 Unit 3 Session 23 Different ways to Combine Classifiers.pptx
22PCOAM16 Unit 3 Session 23  Different ways to Combine Classifiers.pptx22PCOAM16 Unit 3 Session 23  Different ways to Combine Classifiers.pptx
22PCOAM16 Unit 3 Session 23 Different ways to Combine Classifiers.pptx
Guru Nanak Technical Institutions
 
PYTHON--QUIZ-1_20250422_002514_0000.pptx
PYTHON--QUIZ-1_20250422_002514_0000.pptxPYTHON--QUIZ-1_20250422_002514_0000.pptx
PYTHON--QUIZ-1_20250422_002514_0000.pptx
rmvigram
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
Guru Nanak Technical Institutions
 
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
Pierre Celestin Eyock
 
Urban Transport Infrastructure September 2023
Urban Transport Infrastructure September 2023Urban Transport Infrastructure September 2023
Urban Transport Infrastructure September 2023
Rajesh Prasad
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
AI Chatbots & Software Development Teams
AI Chatbots & Software Development TeamsAI Chatbots & Software Development Teams
AI Chatbots & Software Development Teams
Joe Krall
 
A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...
A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...
A Study of Bank Line Shifting of the Selected Reach of Jamuna River Using Mul...
Journal of Soft Computing in Civil Engineering
 
Python Functions, Modules and Packages
Python Functions, Modules and PackagesPython Functions, Modules and Packages
Python Functions, Modules and Packages
Dr. A. B. Shinde
 
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
ssuserd9338b
 
WHITE PAPER-Best Practices in Syngas Plant Optimization.pdf
WHITE PAPER-Best Practices in Syngas Plant Optimization.pdfWHITE PAPER-Best Practices in Syngas Plant Optimization.pdf
WHITE PAPER-Best Practices in Syngas Plant Optimization.pdf
Floyd Burgess
 
vtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdfvtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdf
RaghavaGD1
 
UNIT 3 Software Engineering (BCS601) EIOV.pdf
UNIT 3 Software Engineering (BCS601) EIOV.pdfUNIT 3 Software Engineering (BCS601) EIOV.pdf
UNIT 3 Software Engineering (BCS601) EIOV.pdf
sikarwaramit089
 
22PCOAM16 Unit 3 Session 23 Different ways to Combine Classifiers.pptx
22PCOAM16 Unit 3 Session 23  Different ways to Combine Classifiers.pptx22PCOAM16 Unit 3 Session 23  Different ways to Combine Classifiers.pptx
22PCOAM16 Unit 3 Session 23 Different ways to Combine Classifiers.pptx
Guru Nanak Technical Institutions
 
PYTHON--QUIZ-1_20250422_002514_0000.pptx
PYTHON--QUIZ-1_20250422_002514_0000.pptxPYTHON--QUIZ-1_20250422_002514_0000.pptx
PYTHON--QUIZ-1_20250422_002514_0000.pptx
rmvigram
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
860556374-10280271.pptx PETROLEUM COKE CALCINATION PLANT
Pierre Celestin Eyock
 
Urban Transport Infrastructure September 2023
Urban Transport Infrastructure September 2023Urban Transport Infrastructure September 2023
Urban Transport Infrastructure September 2023
Rajesh Prasad
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
AI Chatbots & Software Development Teams
AI Chatbots & Software Development TeamsAI Chatbots & Software Development Teams
AI Chatbots & Software Development Teams
Joe Krall
 
Python Functions, Modules and Packages
Python Functions, Modules and PackagesPython Functions, Modules and Packages
Python Functions, Modules and Packages
Dr. A. B. Shinde
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
IPC-7711D-7721D_ EN 2023 TOC Rework, Modification and Repair of Electronic As...
ssuserd9338b
 

Dynamic Programming

  • 1. Dynamic Programming In this handout • A shortest path example • Deterministic Dynamic Programming • Inventory example • Resource allocation example
  • 2. Dynamic Programming • Dynamic programming is a widely-used mathematical technique for solving problems that can be divided into stages and where decisions are required in each stage. • The goal of dynamic programming is to find a combination of decisions that optimizes a certain amount associated with a system.
  • 3. A typical example: Shortest Path • Ben plans to drive from NY to LA • Has friends in several cities • After 1 day’s driving can reach Columbus, Nashville, or Louisville • After 2 days of driving can reach Kansas City, Omaha, or Dallas • After 3 days of driving can reach Denver or San Antonio • After 4 days of driving can reach Los Angeles • The actual mileages between cities are given in the figure (next slide) • Where should Ben spend each night of the trip to minimize the number of miles traveled?
  • 4. Shortest Path: network figure New York 1 Columbus 2 Kansas City 5 Denver 8 Los Angeles 10 Omaha 6 Dallas 7 Nashville 3 Louisville 4 San Antonio 9 Stage 1 Stage 2 Stage 3 Stage 4 Stage 5 550 680 610 1030 1390 270 790 940 540 790 790 1050 580 660 510 830 700 770 900 760
  • 5. Shortest Path problem: Solution • The problem is solved recursively by working backward in the network • Let cij be the mileage between cities i and j • Let ft(i) be the length of the shortest path from city i to LA (city i is in stage t) Stage 4 computations are obvious: • f4(8) = 1030 • f4(9) = 1390
  • 6. Stage 3 computations Work backward one stage (to stage 3 cities) and find the shortest path to LA from each stage 3 city. To determine f3(5), note that the shortest path from city 5 to LA must be one of the following: • Path 1: Go from city 5 to city 8 and then take the shortest path from city 8 to city 10. • Path 2: Go from city 5 to city 9 and then take the shortest path from city 9 to city 10.  f3(5)  min c58  f4 (8)  610 1030 1640 * c59  f4 (9)  790 1390  2180    f3(6)  min c68  f4 (8)  540 1030 1570 * c69  f4 (9)  940 1390  2330    f3(7)  min c78  f4 (8)  790 1030 1820 c79  f4 (9)  270 1390 1660 *    Similarly,
  • 7. Stage 2 computations Work backward one stage (to stage 2 cities) and find the shortest path to LA from each stage 2 city.  f2(2)  min c25  f3(5)  6801640  2320* c26  f3(6)  7901570  2360 c27  f3(7) 10501660  2710       f2(3)  min c35  f3(5)  5801640  2220* c36  f3(6)  7601570  2330 c37  f3(7)  6601660  2320      f2(4)  min c45  f3(5)  5101640  2150* c46  f3(6)  7001570  2270 c47  f3(7)  8301660  2490     
  • 8. Stage 1 computations Now we can find f1(1), and the shortest path from NY to LA. Checking back our calculations, the shortest path is 1 – 2 – 5 – 8 – 10 that is, NY – Columbus – Kansas City – Denver – LA with total mileage 2870.  f1(1)  min c12  f2(2)  5502320  2870* c13  f2(3)  9002220  3120 c14  f2(4)  7702150  2920     
  • 9. General characteristics of Dynamic Programming • The problem structure is divided into stages • Each stage has a number of states associated with it • Making decisions at one stage transforms one state of the current stage into a state in the next stage. • Given the current state, the optimal decision for each of the remaining states does not depend on the previous states or decisions. This is known as the principle of optimality for dynamic programming. • The principle of optimality allows to solve the problem stage by stage recursively.
  • 10. Division into stages The problem is divided into smaller subproblems each of them represented by a stage. The stages are defined in many different ways depending on the context of the problem. If the problem is about long-time development of a system then the stages naturally correspond to time periods. If the goal of the problem is to move some objects from one location to another on a map then partitioning the map into several geographical regions might be the natural division into stages. Generally, if an accomplishment of a certain task can be considered as a multi-step process then each stage can be defined as a step in the process.
  • 11. States Each stage has a number of states associated with it. Depending what decisions are made in one stage, the system might end up in different states in the next stage. If a geographical region corresponds to a stage then the states associated with it could be some particular locations (cities, warehouses, etc.) in that region. In other situations a state might correspond to amounts of certain resources which are essential for optimizing the system.
  • 12. Decisions Making decisions at one stage transforms one state of the current stage into a state in the next stage. In a geographical example, it could be a decision to go from one city to another. In resource allocation problems, it might be a decision to create or spend a certain amount of a resource. For example, in the shortest path problem three different decisions are possible to make at the state corresponding to Columbus; these decisions correspond to the three arrows going from Columbus to the three states (cities) of the next stage: Kansas City, Omaha, and Dallas.
  • 13. Optimal Policy and Principle of Optimality The goal of the solution procedure is to find an optimal policy for the overall problem, i.e., an optimal policy decision at each stage for each of the possible states. Given the current state, the optimal decision for each of the remaining states does not depend on the previous states or decisions. This is known as the principle of optimality for dynamic programming. For example, in the geographical setting the principle works as follows: the optimal route from a current city to the final destination does not depend on the way we got to the city. A system can be formulated as a dynamic programming problem only if the principle of optimality holds for it.
  • 14. Recursive solution to the problem The principle of optimality allows to solve the problem stage by stage recursively. The solution procedure first finds the optimal policy for the last stage. The solution for the last stage is normally trivial. Then a recursive relationship is established which identifies the optimal policy for stage t, given that stage t+1 has already been solved. When the recursive relationship is used, the solution procedure starts at the end and moves backward stage by stage until it finds the optimal policy starting at the initial stage.
  • 15. Solving Inventory Problems by DP Main characteristics: 1.Time is broken up into periods. The demands for all periods are known in advance. 2.At the beginning of each period, the firm must determine how many units should be produced. 3.Production and storage capacities are limited. 4.Each period’s demand must be met on time from inventory or current production. 5.During any period in which production takes place, a fixed cost of production as well as a variable per- unit cost is incurred. 6.The firm’s goal is to minimize the total cost of meeting on time the demands.
  • 16. Inventory Problems: Example • Producing airplanes • 3 production periods • No inventory at the beginning • Can produce at most 3 airplanes in each period • Can keep at most 2 airplanes in inventory • Set-up cost for each period is 10 Determine a production schedule to minimize the total cost (the DP solution on the board). Period 1 2 3 Demand 1 2 1 Unit cost 3 5 4
  • 17. Resource Allocation Problems • Limited resources must be allocated to different activities • Each activity has a benefit value which is variable and depends on the amount of the resource assigned to the activity • The goal is to determine how to allocate the resources to the activities such that the total benefit is maximized
  • 18. Resource Allocation Problems: Example • A college student has 6 days remaining before final exams begin in his 4 courses • He wants allocate the study time as effectively as possible • Needs at least 1 day for each course and wants to concentrate on just one course each day. So 1, 2, or 3 days should be allocated to each course • He estimates that the alternative allocations for each course would yield the number of grade points shown in the following table: How many days should be allocated to each course? (The DP solution on the board). Courses Days 1 2 3 4 1 3 4 3 4 2 5 5 6 7 3 7 6 7 9
  翻译: