Dynamic Programming algorithm

Source: Internet
Author: User



1. Basic Concepts

Dynamic planning process is: multi-stage optimization decision-making process , each decision dependent on the current state, and then cause the state of the transfer (that is, the state recurrence equation), a decision-making sequence is in the changing state of the production, and ultimately get the most optimized decision.

2. Basic ideas and strategies

The algorithm is usually based on a recursive formula (state transition equation, i.e. problem and sub-problem relationship) and one or more initial states. The solution of the current sub-problem is introduced by the solution of the last sub-problem. The use of dynamic programming to solve problems requires only polynomial time complexity.

The basic idea is similar to the divide-and-conquer method, and the problem to be solved is decomposed into several sub-problems (stages), and the solution of the sub-stage is solved in order, which provides useful information for the solution of the latter sub-problem. When solving any sub-problem, the various possible local solutions are listed, and the local solutions that are likely to achieve the best are preserved by decision, and other local solutions are discarded. Solve each sub-problem in turn, the last sub-problem is the solution of the initial problem.

Because the problem of dynamic planning solves most overlapping sub-problems, in order to reduce the repetition, we only solve each sub-problem once and save the different states of different stages in a two-dimensional array.

The biggest difference between the division and the method is: suitable for the problem solved by the dynamic programming method, the sub-problems obtained after decomposition are often not independent of each other (that is, the next sub-stage solution is based on the solution of the previous sub-stage, and further solution).

3. where applicable

( 1 ) Optimal substructure properties

When the optimal solution of a problem contains the optimal solution of its sub-problem, it is said that the problem has the optimal substructure property ( implicit a recursive relation between the optimal solution and a recursive equation can be introduced ). That is, if the optimal solution of the problem is decomposed (dividing two or more parts, or deleting the first or last component), then the sub-solution is the optimal solution of the specific sub-problem. The best substructure properties are usually proved by the method of proving the absurdity . Dynamic programming, the optimal sub-structure property of the problem is used, and the optimal solution of the whole problem is constructed by the optimal solution of the recursive sub-problem from the bottom-up way.

( 2 ) Overlapping sub-problem properties

dynamic programming, bypassing recursion, repeats the process of computing the same sub-problem (by recursive knowledge), only once for each sub-problem, and then saves it in a table (perhaps a high-dimensional table), and when needed again, It is simple to look at the results with constant time and achieve a bottom-up solution. It is also possible to implement a top-down recursive solution by means of the memo method. This property is not a necessary condition for dynamic programming, but without this property, the dynamic programming algorithm has no advantage over other algorithms .

( 3 no effect: When a stage state is determined, it is not affected by the decision after that state. In other words, the subsequent process of a State does not affect the previous state, only the current state.

3. Dynamic Planning Solution steps

The problem that dynamic programming deals with is a multi-stage decision-making problem , which usually starts from the initial state and reaches the end state through the choice of the intermediate stage decision. These decisions form a sequence of decisions, while defining an active route ( usually the optimal activity route )to complete the process. The design of dynamic planning has a certain pattern, which usually goes through the following steps.

   initial state →│decision Making 1│→│Decision Making 2│→... ..→│Decision N│→ end Status

( 1 ) analysis of Optimal substructure properties (by using contradiction proof)

Sub-decomposition method: Based on the partitioning method, the problem is divided into two or more sub-problems, but the location can not be determined (generally using enumerations); Based on the reduction of the nature of the problem, the first or last component of the optimal solution is reduced, Get the sub-solution of a unit of small scale;

( 2 ) determine the state representation and the state recurrence equation , and recursively define the optimal value

The state representation is essentially a representation of a sub-problem (expressed in mathematical form), which is used to describe the solution to the sub-problem of the problem, which is the core of the dynamic programming and the planning process of the optimal solution, thus constructing the algorithm , the decision method and the state transition equation are determined based on the relationship between the states of the adjacent two phases. State transition equation, which describes how states are transferred.

( 3 ) determine the order of state transitions to calculate the optimal value from the bottom up

This step embodies the process of dynamic programming, that is, from easy to difficult to solve the process (in order to solve the phase by stage), sub-problem to the original problem of the solution process;

( 4 The optimal solution is constructed according to the information obtained when the optimal value is calculated.


Resources

Http://www.360doc.com/content/14/1207/01/20831910_430949704.shtml

Http://www.cnblogs.com/bourbon/archive/2011/08/23/2151044.html

Http://www.cnblogs.com/steven_oyj/archive/2010/05/22/1741374.html




Dynamic Programming algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.