Five algorithms-Dynamic Planning

Source: Internet
Author: User

Major common algorithm 2: Dynamic Planning Algorithm

I. Basic Concepts

The dynamic planning process is: each decision depends on the current state, and then causes the state transfer. A decision sequence is generated in a changed state. Therefore, this multi-stage optimization decision-making process is called dynamic planning.

Ii. Basic ideas and strategies

Similar to the divide and conquer method, the basic idea is to break down the problem to be solved into several subproblems (stages) and solve the subproblems in sequence, it provides useful information for solving the next subproblem. When solving any subproblem, list various possible local solutions, reserve the local solutions that may reach the optimum through decision-making, and discard other local solutions. Solve each sub-problem in sequence. the last sub-problem is the solution of the initial problem.

Most of the problems solved by Dynamic Planning overlap subproblems. To reduce repeated computing, each subproblem is resolved only once, save different States of different stages in a two-dimensional array.

The biggest difference from the divide and conquer method is that it is suitable for the problem solved by dynamic programming, subproblems obtained after decomposition are often not independent of each other (that is, the next substage is based on the solutions of the previous substage for further solving ).

 

 

Iii. Applicable situations

A problem that can be solved using dynamic planning generally has three properties:

(1) Optimization Principle: if the solution of the subproblem included in the optimal solution of the problem is also optimal, it is said that the problem has the optimal sub-structure, that is, to meet the optimization principle.

(2) No aftereffect: once the status of a stage is determined, it will not be affected by the decision-making after the status. That is to say, the process after a State does not affect the previous state, but is only related to the current state.

(3) Overlapping subproblems: subproblems are not independent. A subproblem may be used multiple times in the next stage of decision-making. (This nature is not a necessary condition for dynamic planning, but without it, dynamic planning algorithms do not have advantages over other algorithms)

 

4. Basic Steps

The problem solved by dynamic planning is a multi-stage decision-making problem. Generally, it starts from the initial state and ends with the decision-making in the intermediate stage. These decisions form a decision sequence and determine an activity route to complete the entire process (usually the Optimal Activity route ).. The Design of dynamic planning has a certain pattern. The following steps are generally taken.

Initial status → │ Decision 1 │ → │ Decision 2 │ →... →│ Decision N │ → end status

Figure 1 dynamic planning and decision-making process

(1)Division phase: The problem is divided into several stages based on the temporal or spatial characteristics of the problem. During the division phase, note that the division phase must be orderly or sortable. Otherwise, the problem cannot be solved.

(2)Determine status and status variables: Express the objective situations at various stages of the problem in different States. Of course, the selection of status must be ineffective.

(3)Determine the decision and write the state transition equation: Because decision-making and state transfer have a natural relationship, state transfer is to export the state of this phase based on the status and decision of the previous stage. Therefore, if the decision is determined, the state transition equation can be written. However, in fact, it is often done in turn to determine the decision-making method and state transition equation based on the relationship between the states of the adjacent two stages.

(4)Search for Boundary ConditionsThe state transition equation is a recursive equation that requires a recursive termination condition or boundary condition.

Generally, a state transition equation (including Boundary Conditions) can be written as long as the stage, State, and state transfer decision for solving the problem is determined ).

In actual application, you can follow the following simplified steps:

(1) analyze the nature of the optimal solution and portray its structural characteristics.

(2) recursively define the optimal solution.

(3) Calculate the optimal value through bottom-up or top-down memory (memorandum method)

(4) construct the optimal solution of the problem based on the information obtained when the optimal value is calculated.

 

5. Algorithm Implementation

The main difficulty of dynamic planning lies in the theoretical design, that is, the determination of the above four steps. Once the design is completed, the implementation part will be very simple.

To solve a problem using dynamic planning, the most important thing is to determine the three elements of dynamic planning:

(1) stage of the problem (2) status of each stage

(3) recursive relationship between the previous phase and the next phase.

The recursive relationship must be a conversion from a small problem to a large problem. From this perspective, dynamic planning can often be implemented using recursive Programs, however, because recursion can take full advantage of the solutions of the previously stored sub-problems to reduce repeated computing, there is an incomparable advantage of recursion for large-scale problems, which is also the core of Dynamic Planning Algorithms.

After determining the three elements of dynamic planning, an optimal decision table can be used to describe the entire solution process. The optimal decision table is a two-dimensional table, with rows representing the decision stage and columns representing the problem status, the data to be filled in the table usually corresponds to the optimal value (such as the shortest path, Longest Common subsequence, and maximum value) of the problem in a certain stage ), the table filling process starts from one row and one column according to the recursive relationship, and forms are filled in order of row or column priority, finally, the optimal solution is obtained through simple trade-offs or operations based on the data in the entire table.

F (n, m) = max {f (n-1, m), F (n-1, M-W [N]) + P (n, m )}

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.