banner
Rick Sanchez

Rick Sanchez

OS && DB 爱好者,深度学习炼丹师,蒟蒻退役Acmer,二刺螈。

The essence of dynamic programming

FjnPxuTVsAAWXIJ

Core of Dynamic Programming: Definition of State and Definition of State Transition Equation

As for other common discussions about overlapping subproblems, no aftereffect, and optimal substructure, they all revolve around these two core contents.

In the state transition equation mentioned above, the values with subscripts greater than the left side ii or kk will not be used on the right side of the equation. This is the colloquial mathematical definition of "no aftereffect." States that meet this definition can be said to have the property of "optimal substructure." What we need to do in dynamic programming is to find this "optimal substructure."

In the process of defining states and state transition equations, satisfying "optimal substructure" is an implicit condition (otherwise, it cannot be defined at all).

It is important to note that a problem may have multiple different definitions of states and state transition equations. The existence of a definition with aftereffects does not mean that the problem is not suitable for dynamic programming. This is also a logical misconception that appears in several other answers: The dynamic programming method seeks to find definitions of states and state transition equations that meet "optimal substructure." Once found, the problem can be solved using the method of "memoized recursive formulation." The definitions found are the essence of dynamic programming.

Each stage has only one state -> Recursion;
The optimal state of each stage is obtained from the optimal state of the previous stage -> Greedy;
The optimal state of each stage is obtained from the combination of states of all previous stages -> Search;
The optimal state of each stage can be directly obtained from a certain state or states of a previous stage, regardless of how that state was obtained -> Dynamic Programming.

The property that the optimal state of each stage can be directly obtained from a certain state or states of a previous stage is called optimal substructure;
and regardless of how that state was obtained, this property is called no aftereffect.

Note: In fact, the term optimal state in dynamic programming can be misleading, leading one to think that it is sufficient to calculate only the optimal state. This is indeed the case for the LIS problem, where only the states "chosen" at each stage are used during transitions. However, in reality, some problems often require calculating an optimal value for all states at each stage, and then finding the optimal state based on these optimal values. For example, the knapsack problem requires calculating the maximum value for the first ii bags (stages) with a capacity of jj (state). Then, the optimal value is found among all states in the last stage.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.