A Level Further Mathematics · Chapter 74 · Decision Mathematics · Decision 2
Many decisions come in stages, and the best plan is found by starting at the end and working backwards, one stage at a time.
A lorry driver chooses a route through several towns, a hiker chooses a path over several ridges, and a charity decides how to share its funds between projects. This chapter solves such multi-stage problems by working backwards from the end, so that every decision is made knowing the best way to finish.
In this chapter · jump to a section
Start here
Your route through this chapter
By the end of this chapter you will be able to:
- describe a multi-stage problem in terms of stages, states, actions and values
- state and use Bellman's principle of optimality
- find shortest and longest routes through a staged network by working backwards
- set out dynamic programming in a table and recover the optimal route
- solve minimax and maximin problems
- allocate resources between projects using dynamic programming
Time: two sessions, about 3 hours, plus the practice ladder and the exam workshop.
You need first: minimum spanning trees and shortest paths, especially Dijkstra's algorithm, for comparison.
The big idea
The big idea
In a multi-stage problem, each decision moves the system from one state to another, and the total value depends on every decision. Instead of trying every combination, dynamic programming finds the best way to finish from each state, starting with the states nearest the end.
This chapter's main example is the staged network below, with routes from S to T through one of A, B, C and then one of D, E, F.
The shortest route starts with the longest first arc, SA of 10. A driver who chose the shortest first arc would end up on a worse route. Dynamic programming avoids that trap by looking ahead from the end.
Stages
A stage is a step in the decision process. Here there are three stages: choosing the first arc out of S, choosing the arc from A, B or C, and choosing the final arc to T. Dynamic programming numbers stages backwards from the end.
States
A state describes where the system is at a given stage. At the stage nearest T, the states are D, E and F. At the next stage back, they are A, B and C. The initial state is S.
Actions and values
An action is a choice made in a state, such as going from B to E. Each action has a value, here the arc length. The value of a route combines the values of its actions, usually by adding them.
Bellman's principle of optimality
Bellman's principle says that any part of an optimal route, from some state to the end, is itself optimal. So the best way to finish from each state can be found once and reused. This is what makes working backwards so efficient.
Why work backwards?
Working backwards, every state's best continuation is already known when it is needed. Working forwards, a choice that looks good now may lead into a poor continuation, as the shortest-first-arc trap shows.
Other kinds of objective
The same method finds longest routes, by maximising. It also solves minimax problems, where the worst single arc is to be as small as possible. And it solves maximin problems, where the weakest arc is to be as strong as possible.
Where dynamic programming is used
Dynamic programming is used for route planning, stock control, machine replacement, investment over several years and scheduling production month by month. In each case a sequence of decisions is made, and each decision changes the situation in which the next is made.
The origin of the name
Richard Bellman developed the method in the 1950s. He chose the word dynamic to suggest decisions made over time, and programming in its old sense of planning. The name has nothing to do with writing computer programs.
Section 1
Stages, states and actions
Describing a problem
Before calculating, describe the problem in dynamic programming language: what the stages are, what the states are at each stage, and what actions are possible from each state. A clear description makes the calculation straightforward.
Common mistake: confusing the stage with the state, so that where you are is mixed up with how far through the problem you are. The stage counts how many decisions remain; the state says where you are now. Several states share each stage.
Problems without a drawn network
Many dynamic programming problems are given as tables rather than networks. The stages might be months, the states might be the stock held, and the actions might be how much to produce. Drawing a small network of states can help to see the structure.
Stage, state and action in the resource problem
In the charity problem, stage 1 is P3, the last project considered, and the state is the number of units left for it. The action is the number of units given to the current project. These labels match the network language exactly.
Choosing a sensible state
A state must contain everything needed to make the remaining decisions. If knowing the current vertex is enough, the vertex is the state. If the amount of money left also matters, the state must include it. Choosing the state well is the key modelling step.
Numbering stages
Stages are usually numbered backwards: stage 1 is the last decision, stage 2 the one before, and so on. With this numbering, the calculation proceeds from stage 1 upwards, matching the direction of working.
States at each stage
At stage 1, the states are D, E and F, since from each the only action is to go to T. At stage 2, the states are A, B and C. At stage 3, the only state is S.
Actions from a state
From B there are three actions: to D, E or F. From A there are two, and from C two. The number of actions can differ between states, and the method handles this without difficulty.
Counting routes
The total number of routes is found by multiplying choices along each branch and adding. Here there are 7 routes from S to T. In larger problems the number grows quickly, while dynamic programming's work grows only with the number of arcs.
Value of a route
For a shortest route problem, the value of a route is the sum of its arc lengths. The route S, C, F, T has value . Dynamic programming finds the route with the best value without listing them all.
Stages of different sizes
Not every stage needs the same number of states. A problem might start from one state, spread to five, and narrow to two before the end. The backward method handles this naturally, since it only ever looks at the actions out of each state.
Worked example 1: counting routes
How many routes are there from S to T?
| Working | Reason |
|---|---|
| Via A: 2 routes; via B: 3; via C: 2 | Count the onward choices from each |
| Each continues to T in one way | D, E and F each lead only to T |
| Total routes | Add the routes through each state |
Why not list every route?
With seven routes, listing them all is quick. With ten stages and five states at each, there would be millions of routes. Dynamic programming handles such problems easily, because it only ever compares the actions out of one state at a time.
Worked example 2: the value of one route
Find the length of the route S, C, F, T.
| Working | Reason |
|---|---|
| Arcs SC 5, CF 4, FT 7 | Read each arc on the route |
| Length | Add the arc lengths |
| Not the shortest, since 15 exists | Compare with S, A, E, T |
Check yourself. Add up the arcs of the route S, B, E, T.
Show the answer
The arcs are SB 5, BE 8 and ET 3, so the length is , longer than the shortest route of 15.
Section 2
Working backwards: shortest routes
The method
Label T with 0. At stage 1, each state's value is its arc to T. At each earlier stage, each state's value is the least, over its actions, of the arc length plus the value of the state it leads to. Continue back to S.
Common mistake: choosing the best arc at each stage while working forwards, instead of comparing complete continuations from the end. The cheapest first step can lead to an expensive continuation. Only by combining each arc with the best value from its destination can the whole route be judged.
Working backwards
- Optimal value
- 15
- Optimal route
- S, A, E, T
- Routes in total
- 7
Figure 74.1 labels the states stage by stage, working back from T. The wrong-model switch shows where a greedy forward choice leads.
The value of the end
The end state T has value 0 for shortest and longest route problems, because no more arcs remain to be added. For minimax and maximin problems the end has no arcs either, so the stage 1 values are simply the arcs into T.
Stage 1
From D, E and F the only action is to go to T, so their values are 4, 3 and 7. These are the shortest distances from each state to T.
A closer look at state B
State B has three actions, and the shortest-looking arc, BE of 8, is in fact the best, because E's onward value of 3 is the smallest. But that is a coincidence: the best action is decided by the total of arc and onward value, never by the arc alone.
Stage 2
From A, the options are via D and via E, so A's value is 5. From B, the options are 14, 11 and 16, so B's value is 11. From C, the options are 12 and 11, so C's value is 11.
A closer look at state S
From S, the arcs to B and C are short, but B and C both have value 11, so those routes total 16. The arc to A is long, but A's value is only 5, so that route totals 15. The comparison must always include the onward values.
Stage 3
From S, the options are via A, via B and via C. So the shortest route has length 15, and it goes from S to A.
Derivation: why working backwards needs far fewer calculations
With stages and states per stage, each with actions, listing every route needs about
route totals. Working backwards, each state examines its actions once, so the work is about
which grows far more slowly as the number of stages increases.
Recovering the route
Follow the best actions forwards from S: S to A, then A's best action, to E, then E to T. The shortest route is S, A, E, T, of length .
Looking ahead without listing
Dynamic programming looks ahead in a clever way. It does not explore every future route from each state; it uses the single number already found for each next state. That number summarises everything that matters about the future.
A check by listing
For a small network, the answer can be checked by listing every route. Here the seven routes have lengths 15, 16, 16, 17, 17, 19 and 21, and the shortest is 15, confirming the dynamic programming result.
Why the greedy route fails
The cheapest arcs out of S, SB and SC, both have length 5. But B and C each have value 11, while A has value 5. Paying 10 to reach A is worth it, because A's continuation is so short.
Proof: Bellman's principle of optimality
Suppose an optimal route from S passes through state X, and its part from X to T has length . If some other route from X to T had length , replacing the part would give a total
contradicting optimality. So the part from X must be optimal, and the optimal value from any state satisfies
which is exactly the backward working rule.
The meaning of each value
Each state's value has a clear meaning: it is the best possible result from that state to the end. So the value of B, 11, means that a traveller who has somehow reached B can still finish with 11 more, and no less.
Labels as a summary of the future
Once a state is labelled, everything beyond it can be forgotten. The label is a complete summary of the best possible future from that state, which is why the method saves so much work.
Worked example 3: stage 1
Find the values of D, E and F.
| Working | Reason |
|---|---|
| D to T: 4 | The only action from D |
| E to T: 3 | The only action from E |
| F to T: 7 | The only action from F |
Writing values on the network
A quick way to work by hand is to write each state's value beside it on the network, starting from T. Then each new value needs only the arcs out of that state and the numbers already written. The figure in this section shows this layout.
Worked example 4: completing the calculation
Complete stages 2 and 3 and find the shortest route.
| Working | Reason |
|---|---|
| A: ; B: | Arc plus value of the destination |
| C: ; S: | Continue back to S |
| Route S, A, E, T of length 15 | Follow the best actions forwards |
Check yourself. In the shortest route calculation, which value does state C receive?
Show the answer
From C, going to E costs and going to F costs . The value of C is the smaller, 11, via F.
Section 3
Setting out the table
The dynamic programming table
Exam answers set out the calculation in a table with columns for stage, state, action, value of action, and value of state. Each row is one action from one state. The best value for each state is marked, usually with an asterisk.
Common mistake: recording only the best value at each state, without the action that achieves it, so the route cannot be recovered. The table must show which action gives each state's best value. Without it, the optimal route has to be reworked from scratch.
Columns of the table
The standard columns are: stage, state, action, value of the action, and value of the state. The value of an action combines the arc with the value of the state it leads to. The value of the state is the best of its actions' values, marked with an asterisk.
Keeping the table tidy
Write states in the same order at every stage, such as alphabetically. Leave a line between stages. A clear layout makes it easy for an examiner to find each value and award the method marks.
Laying out each stage
Group the rows by stage, starting with stage 1 at the top. Within each stage, group by state. For each action, write the arc length plus the destination's value, then mark the best.
Shortcuts in the table
When a state has only one action, its value is simply that action's value, and there is nothing to compare. Write the single row anyway, so the table is complete and the route can be traced back through it.
An example row
At stage 2, state B, the action to E has value . The other actions from B, to D and F, have values 14 and 16. So the row for E is marked as best, and B's value is 11.
Reading the route from the table
Start at the row for S marked best, which gives the action to A. Then find the best row for A, which gives the action to E. Continue until T is reached. The marked actions give the route.
Ties in the table
If two actions from a state give the same best value, mark both. There are then several optimal routes, and either can be given unless the question asks for all of them.
Several optimal routes
If a state has two equally good actions, both should be marked. Then there may be several optimal routes, which can be found by following each marked branch. Exam questions often say whether one or all optimal routes are wanted.
Checking the table
The value of S should equal the length of the recovered route. Add the arc lengths along the route to check. A mismatch shows an arithmetic slip somewhere in the table.
Reading a row aloud
The row for B to E reads: at stage 2, in state B, the action go to E has value 8 plus E's value 3, giving 11. Saying rows aloud like this is a good check that each entry has been calculated from the right numbers.
Worked example 5: the rows for state B
Write the table rows for state B at stage 2.
| Working | Reason |
|---|---|
| B to D: | Arc plus D's value |
| B to E: , marked best | Arc plus E's value |
| B to F: | Arc plus F's value |
Forwards and backwards together
The calculation goes backwards, from the end, but the route is read forwards, from the start. This two-way pattern is typical of dynamic programming: values flow back from the end, and decisions are then made forwards using those values.
Worked example 6: recovering the route
Use the table to recover the shortest route.
| Working | Reason |
|---|---|
| S: best action to A, value 15 | The marked row at stage 3 |
| A: best action to E, value 5 | The marked row for A |
| E to T; route S, A, E, T | Check that the arcs add to 15 |
Check yourself. In the longest route problem of section 4, what is the value of state C?
Show the answer
From C, going to E gives and going to F gives . For the longest route the value is the larger, 12.
Section 4
Longest routes
Maximising instead of minimising
To find the longest route, use the same method but take the greatest value at each state instead of the least. Longest routes model problems where the arcs are profits or scores to be maximised.
Common mistake: taking the smallest value at a state when the problem asks for the greatest. The rule at each state must match the objective. For a maximisation, mark the action with the largest value.
Reusing stage 1
The stage 1 values for a longest route match those for a shortest route. Each of D, E and F has only one way to reach T. The difference between the two problems appears only when a state has a choice.
Stage 2 for the longest route
From A: . From B: . From C: . The stage 1 values are unchanged: 4, 3 and 7.
Stage 3 for the longest route
From S: . The longest route goes from S to B, then F, then T.
Greedy fails again
A greedy driver maximising would take SA, the longest first arc, then AD, then DT, for a total of 17. The longest route, 21, starts with a short arc. Looking ahead matters as much for maximising as for minimising.
Mixed objectives
Some problems combine costs and profits, such as a route where each leg earns a fee but costs fuel. Use the net value of each arc, profit minus cost, and maximise. The method does not change; only the numbers on the arcs do.
Negative values
Arc values can be negative, for example a loss on some leg. Dynamic programming still works, because it simply adds values and compares totals. This is an advantage over Dijkstra's algorithm, which needs non-negative weights.
Profits as arc values
If arc values are profits from each decision, the longest route is the most profitable plan. Dynamic programming treats profit and distance in the same way, so any staged decision with additive values can be solved like this.
When to use a longest route
Longest routes answer questions such as the most profitable sequence of jobs, the route that collects the most points, or the longest time a project could take. Whenever bigger totals are better, take maxima at every state.
Worked example 7: the longest route
Find the longest route from S to T.
| Working | Reason |
|---|---|
| A: 7; B: ; C: 12 | Largest value from each state |
| S: | Arc plus the destination's value |
| Route S, B, F, T of length 21 | Follow the best actions |
Longest routes and critical paths
Finding the longest route through a staged network is exactly what the forward pass of critical path analysis does for an activity network. There, the longest path gives the project duration; here it gives the most profitable plan.
Worked example 8: the greedy longest route
A student always takes the longest available arc. Find the student's total and compare.
| Working | Reason |
|---|---|
| S to A 10, A to D 3, D to T 4 | Longest arc at each step |
| Total | Add the arcs chosen |
| Less than the optimal 21 | Greedy choices ignore what follows |
Check yourself. Find the total of the arcs on the route S, A, D, T.
Show the answer
The arcs are SA 10, AD 3 and DT 4, giving . This is the greedy route, well short of the longest, 21.
Section 5
Minimax and maximin
Everyday minimax
A traveller choosing flights to avoid the longest single wait, or an engineer choosing a cable route to avoid the hottest section, is solving a minimax problem. The total does not matter; only the worst part does.
Minimax problems
In a minimax problem, the value of a route is its largest arc, and the aim is to make this as small as possible. A hiker wanting the lowest highest point on a walk, or a lorry needing the least steep climb, faces a minimax problem.
Common mistake: adding the arc values along a route in a minimax problem, instead of taking the largest arc. In minimax, the value of a route is its worst single arc, not its total. Combining an arc with the value onwards uses the maximum, not the sum.
Minimax and maximin routes
- Optimal value
- 7
- Route
- S, C, F, T
- Total length of this route
- 16
Figure 74.2 labels each state with its minimax or maximin value. The minimax route is not the shortest route.
Why take the larger?
The value of a route from a state is its worst arc. Going from X to Y, the worst arc is either the arc XY itself or the worst arc of the best continuation from Y. So the larger of the two is the value of that action.
The minimax rule
At each state, for each action, take the larger of the arc value and the destination's value. Then choose the action that makes this as small as possible. That smallest value is the state's value.
The minimax calculation
Stage 1 values are 4, 3 and 7. A: . B: . C: . S: , via C.
Maximin problems
In a maximin problem, the value of a route is its smallest arc, to be made as large as possible. A lorry choosing a route with the highest lowest bridge, or a cable with the strongest weakest link, faces a maximin problem.
Why take the smaller?
In a maximin problem the value of a route is its weakest arc. The weakest arc of a route through XY is either XY itself or the weakest arc from Y onwards. So the smaller of the two is the value of that action, and the best action makes this as large as possible.
The maximin rule
At each state, for each action, take the smaller of the arc value and the destination's value. Then choose the action that makes this as large as possible. Work back to S in the usual way.
Interpreting the maximin route
The maximin route S, B, F, T has smallest arc 5, the arc SB. A lorry using this route never meets a bridge lower than 5 units. Every other route has a bridge of 4 or lower, so this is the best a tall lorry can do.
The maximin calculation
A: . B: . C: . S: , via B, so the route is S, B, F, T.
Minimax values at the end
At stage 1 the minimax value of each state is just its arc to T, because that arc is the only one remaining. So D, E and F have values 4, 3 and 7, exactly as in the shortest route problem.
Worked example 9: a minimax route
Find the minimax route from S to T.
| Working | Reason |
|---|---|
| A: 3; B: ; C: | Larger of arc and onward value |
| S: via C | Smallest of the three options |
| Route S, C, F, T; largest arc 7 | FT is the largest arc |
Comparing the four answers
On the same network, the shortest route is S, A, E, T and the longest is S, B, F, T. The minimax route is S, C, F, T and the maximin route is S, B, F, T. Each objective picks a different route, so reading the question carefully is essential.
Ties in minimax and maximin
Ties are common in these problems, because many routes can share the same worst arc. When two actions give the same value, mark both and check whether the question wants every optimal route or just one of them.
Worked example 10: a maximin route
Find the maximin route from S to T.
| Working | Reason |
|---|---|
| A: 3; B: ; C: | Smaller of arc and onward value |
| S: via B | Largest of the three options |
| Route S, B, F, T; smallest arc 5 | SB is the smallest arc |
Check yourself. What is the maximin value of state B?
Show the answer
From B, the options are , and . The largest is 7, via F, so B's value is 7.
Section 6
Allocating resources
Other resource problems
The same method decides how many staff to put on each shift, how much stock to order each month, or how to split an advertising budget between media. Wherever a fixed total is shared out and returns depend on each share, dynamic programming applies.
Resources as states
Dynamic programming also solves problems with no network drawn. When a fixed amount of resource is shared between projects, the projects are the stages and the amount of resource left is the state. Each action gives some units to the current project.
Common mistake: giving each unit of resource to whichever project gains most from it immediately, without looking ahead. A project that gains a lot from its first unit may gain little from later ones. Dynamic programming compares whole allocations, not single units.
Allocating resources
- Best total
- 12
- Units to P1, P2, P3
- 0, 2, 1
Figure 74.3 shows a charity sharing up to 4 units between three projects. The best plan is not the one that greedy choices give.
The example
A charity has 4 units of funding for three projects, P1, P2 and P3. The benefits from 0 to 4 units are P1: 0, 4, 7, 9, 10; P2: 0, 3, 7, 8, 9; and P3: 0, 5, 6, 8, 11.
Working backwards through projects
Start with P3 alone: its value with units is just its table entry. Then consider P2 and P3 together: for each , try every split and keep the best. Finally add P1 with all 4 units available.
A table for each stage
Set out a small table for each stage. For each number of units available, list every way of splitting them between the current project and those already considered, with the total benefit of each. Mark the best total for each number of units.
P2 and P3 together
With 0 to 4 units, the best totals for P2 and P3 together are 0, 5, 8, 12 and 13. For example, with 3 units, giving 2 to P2 and 1 to P3 earns .
Why the order of projects does not matter
The projects could be taken in any order as stages, and the best total would be the same. Starting from the last project is a convention that matches the backward working of network problems.
Adding P1
With 4 units, giving to P1 leaves for the others: , , , and . The best is 16, with 1 unit to P1.
Diminishing returns
The greedy method fails here because benefits do not grow evenly with units. P3's first unit is worth 5, but its second adds only 1. P2's second unit, by contrast, adds 4. Dynamic programming accounts for these uneven gains automatically.
The greedy alternative
Giving each unit to the biggest immediate gain sends the first to P3, which gains 5, then units to P1 and P2 as gains shrink. This reaches only 15. The optimal plan gives 1, 2 and 1 units for 16.
Recovering the plan
The best total, 16, came from giving 1 unit to P1, leaving 3 for P2 and P3. Looking back at the table for P2 and P3, the best use of 3 units was 2 to P2 and 1 to P3. So the full plan is 1, 2 and 1.
Checking the plan
Add the benefits from the original table: P1 with 1 unit gives 4, P2 with 2 gives 7 and P3 with 1 gives 5. The total, 16, matches the dynamic programming value, confirming the plan.
Worked example 11: the optimal allocation
Find the best way to share 4 units between the three projects.
| Working | Reason |
|---|---|
| Best for P2 and P3 with 0 to 4 units: 0, 5, 8, 12, 13 | Try every split for each amount |
| With P1: best is | 1 unit to P1, 3 to the others |
| Plan: P1 1, P2 2, P3 1; total 16 | Recover the splits stage by stage |
Lessons from the greedy plan
The greedy plan is not foolish: it makes a sensible choice at every step. Its weakness is that it never reconsiders. Dynamic programming effectively reconsiders every possibility, but organises the work so that none of it is repeated.
Worked example 12: the greedy allocation
Find the total from giving each unit to the biggest immediate gain.
| Working | Reason |
|---|---|
| Unit 1 to P3 gains 5; unit 2 to P1 gains 4 | Largest gain each time |
| Units 3 and 4 gain 3 and 3 | Gains shrink as units are added |
| Total 15, less than 16 | Greedy choices miss the best plan |
Check yourself. If only 3 units are available, what is the best total benefit?
Show the answer
With 3 units, giving 0, 1, 2 or 3 to P1 earns , , or . The best total is 12.
Reference
Results in this chapter
| Result | What it says | When to use it | In the formula booklet? |
|---|---|---|---|
| Bellman's principle | Parts of optimal routes are optimal | Justifying backward working | No, derive it |
| Shortest route rule | Minimisation | No, learn it | |
| Longest route rule | Maximisation | No, learn it | |
| Minimax rule | Smallest worst arc | No, learn it | |
| Maximin rule | Largest weakest arc | No, learn it | |
| Projects as stages, units left as states | Resource allocation | Sharing a fixed resource | No, learn it |
Reasoning
Modelling task: planning a hill walk
The situation
A walking group must cross from a car park at S to a viewpoint at T. On the way it passes one of three huts, A, B or C, and then one of three cairns, D, E or F. Each leg of the walk has a height of climb, in tens of metres, given by the arc values in the big idea. The group wants a route whose steepest leg is as gentle as possible.
Assumptions
The difficulty of a route is set by its hardest single leg, not by the total climb. Each leg can be walked only in the direction shown. Weather and path conditions are the same on every leg.
These assumptions make the problem a minimax problem on the staged network.
The model
Working backwards, the stage 1 values are 4, 3 and 7. The huts have minimax values 3, 8 and 7, and the car park has value 7, via hut C. The route is S, C, F, T.
Results
The group should walk via hut C and cairn F. The hardest leg is FT, a climb of 70 metres. Every other route has a leg of at least 80 metres.
Evaluating the model
The minimax route has a total climb of 160 metres, more than the shortest route's 150. A group that cares about total effort, not the hardest leg, would choose differently. The model's answer depends entirely on choosing the right objective.
The model also ignores descents, distances and the time each leg takes. A fuller model might combine several objectives, perhaps minimising total time subject to no leg being too steep.
Your turn
The group's leader changes her mind: the worst leg matters less than the total climb. Which route should the group now take, and what is the total climb?
Show a model answer
Minimising the total climb is a shortest route problem. Working backwards gives S, A, E, T with total , a climb of 150 metres, although it includes the steep first leg SA of 100 metres.
Practice
Practice ladder
Rung 1: Recall and fluency
Q1. State the number of routes from S to T in the staged network.
Worked solution to Q1
Through A there are 2 routes, through B 3 and through C 2, and each finishes at T in one way. So there are routes.
Q2. Write down the shortest-route value of state A.
Worked solution to Q2
From A, going to D costs and going to E costs . The value of A is the smaller, 5, via E.
Q3. Give the length of the route S, C, F, T.
Worked solution to Q3
The route uses the arcs SC 5, CF 4 and FT 7. Adding them gives a length of , one more than the shortest route.
Rung 2: Application
Q4. Working backwards from T, find the length of the shortest route from S.
Worked solution to Q4
The stage 2 values are A 5, B 11 and C 11. From S the options are 15, 16 and 16, so the shortest route has length 15, along S, A, E, T.
Q5. Determine the longest route from S to T and its length.
Worked solution to Q5
The stage 2 values for the longest route are A 7, B 16 and C 12. From S the options are 17, 21 and 17, so the longest route is S, B, F, T, of length 21.
Q6. Calculate the longest-route value of state B.
Worked solution to Q6
From B the options are , and . The largest is 16, via F, so B's value is 16.
Rung 3: Analysis
Q7. Find the minimax value from S to T and the route that achieves it.
Worked solution to Q7
The minimax values are A 3, B 8 and C 7. From S the options are , and , so the minimax value is 7, along S, C, F, T.
Q8. Find the maximin value from S to T.
Worked solution to Q8
The maximin values are A 3, B 7 and C 4. From S the options are , and , so the maximin value is 5, along S, B, F, T.
Q9. Using the charity's table, calculate the best total benefit from 4 units and the allocation that achieves it.
Worked solution to Q9
The best totals for P2 and P3 together are 0, 5, 8, 12 and 13. Adding P1, the best is , from 1 unit to P1, 2 to P2 and 1 to P3.
Rung 4: Stretch
Q10. A driver always takes the shortest arc available. Find the driver's total and explain why it is not optimal.
Worked solution to Q10
The driver goes S to B (5), B to E (8) and E to T (3), a total of 16. The shortest route, S, A, E, T of length 15, starts with a longer arc that leads to a much shorter continuation.
Q11. A student solves the minimax problem by finding the shortest route and reporting its largest arc. Find their answer and explain the error.
Worked solution to Q11
The shortest route S, A, E, T has largest arc SA of 10, so the student reports 10. Minimax compares largest arcs, not totals, and the route S, C, F, T has largest arc only 7.
Q12. A student gives each unit of funding to whichever project gains most from it immediately. Find their total and compare with the optimum.
Worked solution to Q12
The units go to P3 (5), P1 (4), and then two more each gaining 3, for a total of 15. The optimal plan, 1, 2 and 1 units, earns 16, because P2's second unit gains 4.
Exam practice
Exam technique and worked answer workshop
How these questions are marked
M1 marks go to working backwards from the end, combining each action with the destination's value using the right rule, and recovering the route. A1 marks go to correct state values, optimal values and routes. B1 marks go to stating Bellman's principle and explaining why greedy methods fail.
Use the table layout with stage, state, action, value of action and value of state. Mark the best action at every state, and state the route and its value clearly at the end.
Exam question 1 (7 marks · Paper 4 · about 10 minutes)
Use dynamic programming, set out in a table, to find the shortest route from S to T in the staged network, and state its length. (7)
Mark scheme for exam question 1
Stage 1 values D 4, E 3, F 7 B1
Works backwards with arc plus value M1
A 5 A1
B 11 A1
C 11 A1
S 15 A1
Route S, A, E, T A1
Exam question 2 (6 marks · Paper 4 · about 8 minutes)
Use dynamic programming to find the longest route from S to T and its length. (6)
Mark scheme for exam question 2
Uses maximum at each state M1
A 7 A1
B 16 A1
C 12 A1
S 21 A1
Route S, B, F, T A1
Exam question 3 (5 marks · Paper 4 · about 7 minutes)
A driver always chooses the shortest arc out of the current vertex. Find the length of the driver's route and explain why dynamic programming does better. (5)
Mark scheme for exam question 3
Route S, B, E, T M1
Length 16 A1
Optimal length 15 A1
Greedy ignores the continuation B1
Dynamic programming compares whole continuations B1
Exam question 4 (7 marks · Paper 4 · about 10 minutes)
The arc values give the heights of climb on each leg of a walk. Use dynamic programming to find the route whose greatest single climb is as small as possible. (7)
Mark scheme for exam question 4
Recognises a minimax problem B1
Uses the larger of arc and onward value M1
A 3 A1
B 8 A1
C 7 A1
S 7 A1
Route S, C, F, T A1
Exam question 5 (6 marks · Paper 4 · about 8 minutes)
Instead, suppose the arc values give the heights of bridges on each road. Use dynamic programming to find the route whose lowest bridge is as high as possible. (6)
Mark scheme for exam question 5
Uses the smaller of arc and onward value M1
A 3 A1
B 7 A1
C 4 A1
S 5 A1
Route S, B, F, T A1
Exam question 6 (7 marks · Paper 4 · about 10 minutes)
A charity has 4 units to share between projects P1, P2 and P3. The benefits are P1: 0, 4, 7, 9, 10; P2: 0, 3, 7, 8, 9; P3: 0, 5, 6, 8, 11. Use dynamic programming to find the best allocation and its total benefit. (7)
Mark scheme for exam question 6
Projects as stages, units left as states B1
P3 values from its table M1
P2 and P3 together: 0, 5, 8, 12, 13 A1
Tries every split with P1 M1
Best 16 A1
1 unit to P1 A1
2 to P2 and 1 to P3 A1
Exam question 7 (5 marks · Paper 4 · about 7 minutes)
State Bellman's principle of optimality and use it to explain why the shortest route from B to T is needed when finding the shortest route from S. (5)
Mark scheme for exam question 7
Any part of an optimal route is optimal B1
From any state to the end B1
Shortest from B is 11 A1
S via B costs 5 + 11 M1
Compared with other options at S A1
Exam question 8 (5 marks · Paper 4 · about 7 minutes)
A student finds the shortest route and gives its largest arc as the answer to the minimax problem. Find the student's answer and explain the error. (5)
Mark scheme for exam question 8
Shortest route S, A, E, T M1
Largest arc 10 A1
Minimax answer is 7 A1
Minimax compares largest arcs B1
Not totals B1
Annotated model answer: exam question 1
At stage 1, D, E and F have values 4, 3 and 7. B1. At stage 2, each action's value is the arc plus the destination's value. M1. A has options 7 and 5, so A is 5. A1. B has options 14, 11 and 16, so B is 11. A1. C has options 12 and 11, so C is 11. A1.
At stage 3, S has options 15, 16 and 16, so S is 15. A1. Following the best actions forwards gives the route S, A, E, T. A1.
Annotated model answer: exam question 6
Treat the projects as stages and the units left as the state. B1. With P3 alone, the values are its table entries. M1. For P2 and P3 together the best totals for 0 to 4 units are 0, 5, 8, 12 and 13. A1.
Adding P1 with 4 units, the options are 13, 16, 15, 14 and 10, M1, so the best total is 16, A1, with 1 unit to P1. A1. The remaining 3 units go 2 to P2 and 1 to P3. A1.
Connections
Synoptic link
Minimum spanning trees and shortest paths found shortest routes with Dijkstra's algorithm, which works forwards from the start. Dynamic programming works backwards and also handles longest, minimax and maximin routes. Critical path analysis found longest paths through activity networks, another staged problem.
Game theory, next, also involves choosing the best option while anticipating what follows, though there the other side is an opponent rather than the network.
Synoptic question 1. Explain why the forward pass of critical path analysis is a dynamic programming calculation.
Answer to synoptic question 1
Each event's early time is the largest, over arcs into it, of the earlier event's time plus the activity duration. This is a longest-route rule applied stage by stage, so it is dynamic programming working forwards.
Recap
Recap and next step
- A multi-stage problem has stages, states, actions and values; stages are numbered back from the end.
- Bellman's principle: any part of an optimal route from a state to the end is optimal.
- Work backwards: each state's value is the best over its actions of the arc combined with the destination's value.
- For longest routes use the maximum; for minimax and maximin combine with max or min instead of adding.
- Set out a table and mark the best action at each state to recover the route.
- For resource allocation, the projects are stages and the units left are states.
Next chapter: Game theory, which finds the best strategies for two players competing against each other.
For your exam board
This chapter covers Pearson Edexcel A Level Further Mathematics (9FM0) Decision Mathematics 2 section 4: dynamic programming, including stages, states and actions, Bellman's principle of optimality, shortest, longest, minimax and maximin problems in network and table form, and resource allocation. It is assessed on Paper 4D, Decision Mathematics 2. Similar content appears in AQA (7367) and OCR (H245) discrete options.