Read the paper - "dynamic programming" by Fang Qi

Key words: phase   state   decision-making   function recursive

Dynamic programming: refers to a method of optimization problems to solve multi-stage decision making, dynamic refers to the decision-making in every situation that may arise cause a state transition.

Example 1: A map of existing, each node on behalf of the city, the connection between two nodes on behalf of the road, the line numbers indicate the distance between cities. As shown in FIG. 1, the test to find out from node 1 to node shortest path 10.

 

 

  1.  This problem can directly use brute-force method, all nodes have walked the route 1--10, recorded a minimum
  2. FIG wave look carefully, it can be found in FIG divided into five layers: 1,23,456,789,10 (each point is not connected, except the first and fifth layers, and other layers can only be reached on and lower)
  • Hierarchical analysis, it can be seen that each layer of the middle three layers of each node can be used as a layer on the focus and starting point for this layer.
  • This time the question becomes: find the minimum distance from the first layer to the fifth layer. And because each layer are relatively independent, decision-making each layer of a node, it depends only on the results on the floor, so the success of the issue is divided into several stages
  • Suppose now in the third layer, the first layer is from 4 to 5, from 5 to 6, from 6 to 5, from the following requirement min (6 + 5,5 + 5 4 layer 8 ) = 10
  • This greatly reduces the amount of computation.

Dynamic planning some terms:

  1. Stage: The issue is divided into several interrelated aspects of the order of a few of these links is called phase.
  2. Status: starting position at some stage. (2,3 point is the state of the second stage in FIG. 1 above)
  3. Decision: The Evolution from one state to a state of a stage of the next stage of selection
  4. Strategy: From the beginning of the sequence to the end of each segment consisting of decision-making strategy called
  5. State transition equation: the decision to run formula, a state may make the previous stage as such a state becomes the next stage.
  6. The objective function and optimization concepts: criterion objective function is a measure of the merits of the decision-making process of multi-stage. Optimization concept is to find a way under certain conditions, the specific nature of the subject through the press after the determined operation, bringing the total benefit of the whole process optimal.

Using dynamic programming premise:

  1. Meet the optimization principle: that the global optimum can be derived by the optimal derivation in each state.
  2. No after-effect: a decision made by the previous decision will not affect the back, the last step can only affect the future development of the state by now. The current decision has nothing to do with the subsequent decisions. A state occurs in any location strategies can be implemented the same policy.

Calculation method of dynamic programming:

  1. Analysis of questions intended to determine whether to meet the above two conditions
  2. Trying to determine the status, stage, constraints and boundary conditions
  3. Derivation state transition equation

2 examples:

 Queue up for tickets

    Problem Description: a concert to be held. Existing N ( O < N < = 200) a fans queue up for tickets, a person bought one, and the provisions of the ticket office, a person can only buy a maximum of two tickets. Assume that the first bit I fans buy a ticket required time T I ( . 1 < = I < = n-), two adjacent ranks of fans (of j individuals and j + 1 person) may be by one of two people to buy tickets, while another can not line up, and the two fans to buy two tickets in time becomes R J, if R J < T J + T J + 1, then to do so would be to shorten the waiting fans behind time, speed up the entire ticketing process. We are now given N, T J and R & lt J, so that everyone seeking to buy tickets minimum time and method.

First determine whether the above conditions are satisfied: When the owner of the fastest ticket, apparently n-1 individual ticket must have the fastest, n-2 is also the fastest personal. And how to buy tickets in front of people buy a ticket regardless of how the people behind

Then the stage is also very good and the state of division, the stage is to buy a ticket order, the state is the first person i buy a ticket. Then remember s [i] is the minimum time after the person i spent buying tickets

Then the person can buy tickets themselves, and may be in front of people to buy their own together, s [i] = min (s [i-1] + Ti, s [i-2], Ri-1);

这样从前往后进行遍历就可以求出时间,初始化s[1]=T1;

 

 

Guess you like

Origin www.cnblogs.com/XLINYIN/p/11504101.html