All revision notes topics

Dynamic programmingEdexcel A-Level Further Maths: Revision notes

Section 1

Stages, states and Bellman's principle

Dynamic programming solves a problem by splitting it into stages, solving the last stage first and working backwards. At each stage the state variable describes where you are (for example, the vertex, or the number of units left), and the action is the decision made there (for example, the next vertex, or how many units to use). Bellman's principle of optimality: any part of an optimal route is itself optimal. For example, any part of the shortest (or longest) route from source to sink is itself a shortest (or longest) route between its end points. So the best way onward from a state does not depend on how you reached it, and we can store one best value for each state.

Key termsstagestate variableactionBellman's principle
Common mistake

Treating dynamic programming as a greedy method. Choosing the shortest next arc at each step does not always give the shortest route.

Section 2

Tabulation for a minimum route

Work backwards from the sink. For each state, the value is the minimum over the actions of (arc length ++ value of the next state). Record each stage in a table with columns stage, state, action, value, then read the route forwards from the start. Example: arcs SA 6, SB 5, AC 3, AD 8, BC 5, BD 4, CT 7, DT 3. Stage 1: C 77, D 33. Stage 2: A =min⁡(3+7, 8+3)=10=\min(3+7,\,8+3)=10 via C; B =min⁡(5+7, 4+3)=7=\min(5+7,\,4+3)=7 via D. Stage 3: S =min⁡(6+10, 5+7)=12=\min(6+10,\,5+7)=12 via B. Shortest route S, B, D, T, length 1212.

Key termstabulationvalue
Exam tip

State which way you number the stages. Then work backwards from the sink, one stage at a time, and only then read the route forwards.

Section 3

Maximum, minimax and maximin

The same method works with other ways of combining arcs.

  • Maximum route (longest, or greatest profit): value =max⁡(arc+next value)=\max(\text{arc}+\text{next value}).
  • Minimax route: the largest arc used is as small as possible. Value =min⁡(max⁡(arc, next value))=\min\big(\max(\text{arc},\,\text{next value})\big).
  • Maximin route: the smallest arc used is as large as possible. Value =max⁡(min⁡(arc, next value))=\max\big(\min(\text{arc},\,\text{next value})\big). Example (minimax, same network as above): C 77, D 33; A =min⁡(max⁡(3,7),max⁡(8,3))=7=\min(\max(3,7),\max(8,3))=7 via C; B =min⁡(max⁡(5,7),max⁡(4,3))=4=\min(\max(5,7),\max(4,3))=4 via D; S =min⁡(max⁡(6,7),max⁡(5,4))=5=\min(\max(6,7),\max(5,4))=5 via B. The route S, B, D, T has largest arc 55.
Key termsminimaxmaximin
Common mistake

Adding the arc and the next value in a minimax or maximin problem. Use the larger (minimax) or smaller (maximin) of the two.

Section 4

Table format: allocation problems

Dynamic programming is not only for networks. To share NN units between several activities, take the activities one at a time. The stage is the number of activities considered so far, the state is the number of units available, and the action is the number given to the current activity. Stage 1 is the last activity, which takes all the units left. For later stages the value of a state ss is max⁡k(profit(k)+value of the previous stage with s−k units)\max_k\big(\text{profit}(k)+\text{value of the previous stage with }s-k\text{ units}\big). Example with three projects and 4 engineers: if Project 3 gives 1818 for 4 engineers and 1414 for 3, and Project 2 gives 66 for 1 engineer, then giving 1 engineer to Project 2 with 4 available gives 6+14=206+14=20. The final stage gives the best total, and the actions are read back to give the allocation.

Key termsallocation
Exam tip

Keep the columns in the order stage, state, action, value so that each line can be checked from the previous stage.

Section 5

Setting out a solution

  1. State the stages and what state and action mean.
  2. Work backwards: complete each stage's table before the next.
  3. For each state, list every action and its total so that a marker can see the minimum, maximum, minimax or maximin chosen.
  4. At the first stage, read the answer, then trace the actions forwards to give the route or allocation.
  5. Quote the final answer in the units of the question.

That's the notes covered.

Carry on to the next subtopic.

Exam questions on Dynamic programming

  1. A network of roads joins S to T through junctions A, B, C and D. The roads and their lengths, in km, are: SA 5, SB 3, AC 4, AD 7, BC 6, BD 2, CT 5 and DT 6. Dynamic programming is used to find the shortest route from S to T, working backwards from T. Stage 1 is the final step into T (from C or D), stage 2 is the step from A or B, and stage 3 is the step from S. The state is the vertex and the action is the next vertex.
    Given that the shortest distance from A to T is 99 km, complete the dynamic programming to find the shortest route from S to T and its length.2 marks
  2. Messages are sent from S to T through routers A, B, C and D. The speed of a link is its capacity in Mbps, and the speed of a route is the speed of its slowest link. The links and capacities are: SA 8, SB 6, AC 4, AD 7, BC 9, BD 4, CT 6 and DT 5. The manager wants a route whose speed is as large as possible and uses dynamic programming, working backwards from T.
    Given that the best speed from A to T is 55 Mbps, complete the dynamic programming to find the best route from S to T and its speed.2 marks
  3. A firm has 5 engineers to share between three projects, and all five must be used. The profit, in £ thousand, when a project is given 0, 1, 2, 3, 4 or 5 engineers is: Project 1: 0, 7, 9, 10, 11, 17. Project 2: 0, 6, 9, 13, 15, 16. Project 3: 0, 1, 7, 14, 18, 25. The firm uses dynamic programming to maximise the total profit. Stage 1 is Project 3, stage 2 is Projects 2 and 3 together, and stage 3 is all three projects. The state is the number of engineers available at that stage and the action is the number given to the project being considered.
    Find the value of the best allocation of 4 engineers to Projects 2 and 3 together, and say how many go to Project 2, showing the options you compare.3 marks
See the full worksheet

Written by the Exaim team, led by Shaun Daswani (Head of Upper Secondary, Improve ME Institute; MSc Financial Mathematics, Imperial College London; BSc, UCL) and Jason Daswani (operational lead, Improve ME Institute; LSE).