2. Dynamic Program (DP)
๏ง Dynamic programming is a mathematical technique
dealing with the optimization of multistage decision
process.
๏ง Original decisions problem is divided into small sub-
problem (stages) and stages are optimized rather
than simultaneously.
๏ง In contrast to linear programming, there does not
exist a standard mathematical formulation of โthe
dynamic programming problemโ.
๏ง Dynamic programming is applicable when the sub-
problems are not independent.
3. Recursive Nature of Dynamic
Programming
๏ง Computations are then carried out recursively
where the optimum solution of one sub-problem is
used as an input to the next sub-problem.
๏ง The optimum solution for the entire problem is at
hand when the last sub-problem is solved.
๏ง The manner in which the recursive computations
are carried out depends on how the original
problem is decomposed.
4. Shortest Route Problem
Suppose that we want to select the shortest highway route
between two cities. The network in Figure below provides the
possible routes between the starting city at node 1 and the
destination city at node 7. Where the number on the line
shows distance from one node to another.
5. First decompose it into stages as delineated by the
vertical dashed lines in Figure. Next, carry out the
computations for each stage separately.
6. Stage 1
Shortest distance from node 1 to node 2 = 7 miles (from node 1)
Shortest distance from node 1 to node 3 = 8 miles (from node 1)
Shortest distance from node 1 to node 4 = 5 miles (from node 1)
7. Stage 2 (n=2)
Node 5 can be reached from nodes 2, 3, and 4. Thus โ
shortest distance
to node x5
= min
j=2,3,4
{ distance from
node xj to x5
+ shortest distance
to node xj
}
Let,
f*n(xi) be the shortest distance to node xi at stage n
d(xj, xi) as the distance from node xj to node xi.
๐ฅ๐ = all possible routes to node xi.
Now above eqn. can be mathematically expressed as
f*2(x5) = min
j=2,3,4
{d(xj, x5) + (f1(xj)}
8. Thus,
shortest distance
to node x5
= min
12 + 7 = 19
8 + 8 = 16
7 + 5 = 12
= 12 miles (from node 4)
Node 6 can be reached from nodes 3 and 4. Thus โ
shortest distance
to node x6
= min
j=3,4
{ distance from
node xj to x6
+ shortest distance
to node xj
}
= min
9 + 8 = 17
13 + 5 = 18
= 17 miles (from node 3)
9. Stage 3
The destination node 7 can be reached from either node 5
or 6.
shortest distance
to node x7
= min
j=5,6
distance from
node xj to x7
+ shortest distance
to node xj
= min
9 + 12 = 21
6 + 17 = 23
= 21 miles (from node 5)
Shortest distance from node 1 to node 7 = 21 miles.
Thus, the shortest route is 1 โ 4 โ 5 โ 7.
10. Recursive equation
The DP recursive equation is defined as โ
๐0 ๐ฅ1 = 0
๐๐
โ ๐ฅ๐ = min ๐ ๐ฅ๐, ๐ฅ๐ + ๐๐โ1
โ
(๐ฅ๐) , for ๐ = 2, 3,โฆ
11. Principle of optimality
The principle of optimality is the basic principle of
dynamic programming, which was developed by
Richard Bellman that:
โAn optimal policy has the property that whatever
the initial conditions and decisions are the remaining
stages constitute an optimal policy regardless of the
policy adopted in all preceding stagesโ
12. Capital budgeting problem
Consider the capital budgeting problem where three
existing factories, each being considered for possible
expansion. Factories 1, 2 and 3 have three, four and
two alternative plans for expansion respectively. The
expected additional costs and the corresponding
revenues for jth plan of the nth factory are given by cnj
and Rnj. The objective of the decision problem is to
select a plan j for each factory n which will maximize
the total revenue. The cost of the selected set of
plans should not exceed the total available capital, C.
13. The data of the problem is tabulated below. All costs
and revenue are scaled by 10-3.
Assume the total capital available is C = 10.
Factory, n n = 1 n = 2 n = 3
Plan, j c1j R1j c2j R2j c3j R3j
1 0 0 0 0 0 0
2 2 5 5 8 1 3
3 4 6 6 9 โ โ
4 โ โ 8 12 โ โ
14. Recursive equation:
๐๐
โ ๐ = ๐๐๐ฅ
0โค ๐๐๐โค ๐
{๐ ๐๐ ๐๐๐ + ๐๐โ1
โ
(๐ โ ๐๐๐)}
Where
X = amounts available for allocation.
๐๐
โ
๐ = the maximum return from allocating X
dollars at nth stage.
๐๐๐ = the decision variable, denote the amount
allocated to jth plan of nth stage.
๐ ๐๐ ๐๐๐ = return from the jth plan on the nth stage.
19. Example
(Liberman)
The owner of a chain of three grocery stores has
purchased five crates of fresh strawberries. The
estimated probability distribution of potential sales
of the strawberries before spoilage differs among the
three stores. Therefore, the owner wants to know
how to allocate five crates to the three stores to
maximize expected profit. For administrative
reasons, the owner does not wish to split crates
between stores. However, he is willing to distribute
no crates to any of his stores.
20. The following table gives the estimated expected
profit at each store when it is allocated various
numbers of crates:
Use dynamic programming to determine how many
of the five crates should be assigned to each of the
three stores to maximize the total expected profit.
21. Solution
Let , The decision variables xn (n = 1, 2, 3) are the
number of crates to allocate to stage (store) n.
X = number of crates available for allocation to different
stores.
pn(xn) = be the profit from allocating xn crates to store n.
๐๐ ๐ = profit from allocating X crates to store, n
๐๐
โ
๐ = Optimal profit from allocating X crates to store, n
22. Now get,
๐๐ ๐ = ๐๐ ๐ฅ๐ + ๐๐โ1
โ
๐ โ ๐ฅ๐
Consequently, the recursive relationship is
for n = 1, 2, 3
๐ฅ๐ = 0, 1, 2 โฆ . ๐
where ๐๐
โ ๐ = max ๐๐
โ ๐ โ ๐ฅ๐
๐๐
โ ๐ = max { ๐๐ ๐ฅ๐ + ๐๐โ1
โ
๐ โ ๐ฅ๐ }
๐ฅ๐ = 0, 1, 2 โฆ . ๐