Chapter 4 Dynamic Planning
Summary: This chapter introduces the problem of dynamic planning through the assembly line scheduling and matrix chain multiplication, and discusses the longest common subsequence and the optimal binary search tree.
1.Dynamic Planning Basics
Dynamic Planning is mainly used to solve the optimization problem. The steps are as follows:
1) Describe the Optimal Solution Structure
2) recursively define the value of the Optimal Solution
3) calculate the value of the optimal solution from the bottom up
4) construct an optimal solution based on the calculated results
The idea of dynamic planning is to divide the problem into several sub-problems. The key to obtaining the optimal solution is to find the optimal sub-structure.
The running time of the dynamic planning algorithm depends on the product of two factors: the total number of subproblems and the number of choices for each subproblem.
Can two marks of dynamic planning be adopted: optimal sub-structure and overlapping sub-Problems?
Optimal sub-structure:The optimal solution of a problem includes an optimal solution of a subproblem.
Dynamic Planning uses the optimal sub-structure in a bottom-up manner
Condition for applying the optimal sub-structure: the sub-problem must be independent, that is, the solution of a sub-problem does not affect the solution of another sub-Problem of the same problem. If the sub-Problems of the same problem do not share resources, they are independent.
Overlapping subproblems:Recursive Algorithms used to solve the original problem can repeatedly solve the same subproblem.
Memorandum
A kind of deformation of Dynamic Planning adopts a top-down strategy. Maintain a table that records sub-problem solutions, but the control structure for table filling is more like a recursive algorithm.
Comparison between dynamic planning and Memorandum:
If all sub-problems must be calculated at least once, a bottom-up dynamic planning algorithm generates a constant factor better than a top-down memorandum algorithm, because the former does not require recursion, and table maintenance costs are lower. If there is no need to solve some subproblems In the subproblem space, the memorandum method has the advantages of solving only those subproblems that must be solved.