Dynamic Programming: The Basics
Dynamic Programming: The Basics
Dynamic Programming: The Basics
The Basics
Shortest Path Problem
1st Problem
SHORTEST PATH PROBLEM
Stage 5
What is the shortest distance from node
10 to itself?
f5(10) = 0!
Stage 4
What is the shortest distance from node
8 to node 10?
f4(8) = 300 + 0 = 300. r4(8) = (8,10).
What is the shortest distance from node
9 to node 10?
f4(9) = 350 + 0 = 350. r4(9) = (9,10).
Stage 3
What is the shortest distance from node 5 to node
10?
f3(5) = Min {780+300, 600+350} = 950. r3(5) = (5,9).
What is the shortest distance from node 6 to node
10?
f3(6) = Min {240+300, 360+350} = 540. r3(6) = (6,8).
What is the shortest distance from node 7 to node
10?
f3(7) = Min {250+300, 600+350} = 550. r3(7) = (7,8).
Stage 2
What is the shortest distance from node 2 to node
10?
f2(2) = 1360. r2(2) = (2,6).
What is the shortest distance from node 3 to node
10?
f2(3) = 990. r2(3) = (3,6).
What is the shortest distance from node 4 to node
10?
f2(4) = 950. r2(4) = (4,7).
Stage 1
What is the shortest distance from node
1 to node 10?
f1(1) = Min {510+1360, 600+990,
1000+950} = 1590.
r1(1) = (1,3).
Computational Advantage of
DP
If you were to enumerate all paths, how many are
there?
18 (How?)
What is the total computational effort with total
enumeration?
54 additions and 17 comparisons (How?)
What is the total computational effort with DP?
18 additions, 11 comparisons (How?)
Supposing that the shortest path problem had 11
stages, with 10 states each in stages 2 to 10.
How do the 2 approaches now compare?
Characteristics of DP
Problem can be divided into stages with a
decision required at each stage.
Each stage has a number of states
associated with it.
A decision chosen at the current stage
transforms a state in the current stage to
some other state in the next stage.
Characteristics of DP
Given the current state in stage t, the optimal
decision in each of the remaining stages does
not depend on previously reached states or
previously chosen decisions.
PRINCIPLE OF OPTIMALITY
A recursion relates the cost (reward) in stage t
to the cost (reward) earned from stages t+1 to
T.
ft(i) = Min j{cij + ft+1(j)}
Other DP Problems
We will now solve each of the remaining
problems
INVENTORY PLANNING AT XYZ INC. -
Deterministic Case
INVENTORY PLANNING AT XYZ INC. - Stochastic
Case
OPTIMAL REPLACEMENT POLICY AT BHARAT
TOOLS – finite time horizon
OPTIMAL TIMING OF LIQUIDATION OF STOCK