Lec11 Dynamic Programming
Lec11 Dynamic Programming
n Simple subproblems
q We should be able to break the original problem to smaller
subproblems that have the same structure
n Overlapping sub-problems
q there exist some places where we solve the same subproblem
more than once.
Steps to Designing a Dynamic Programming
Algorithm
1. Characterize optimal substructure
q The jth station on line 1 (S1,j) performs the same function as the jth
station on line 2 (S2,j ).
q The time required at each station varies, even between stations at the
same position on the two different lines, as each assembly line has
different technology.
q There is also an entry time (ei) for the chassis to enter assembly line i
and an exit time (xi) for the completed auto to exit assembly line i.
Ex1:Assembly-line scheduling
n After going through station Si,j, can either
13
Ex1:Assembly-line scheduling
•(Time between adjacent stations are nearly 0).
Problem Definition
n Problem: Given all these costs, what stations
should be chosen from line 1 and from line 2 for
minimizing the total time for car assembly.
n àOptimal Substructure.
Example
Step 2: Recursive Solution
n Define the value of an optimal solution recursively in
terms of the optimal solution to sub-problems
n Sub-problem here
q finding the fastest way through station j on both lines (i=1,2)
q Let fi [j] be the fastest possible time to go from starting point
through Si,j
n We also define
q l*: the line whose station n is used in a fastest way
through the entire factory
Step 2: Recursive Solution
n Using the values of l* and li[j] shown in Figure (b) in next
slide, we would trace a fastest way through the factory
shown in part (a) as follows
2
Step 3: Optimal Solution Value
2
Step 3: Optimal Solution Value