ENG 401 · Engineering Mathematics VI (Mathematical Modelling and Operation Research)
Our notes
2 min readDynamic programming (DP)
Solves problems that can be split into stages, each with a decision, linked by states.
Bellman's principle of optimality: an optimal policy has the property that, whatever the first decision, the remaining decisions form an optimal policy for the state that results.
The method
- Define stages, states and decisions.
- Write the recursive relation: f(state) = best over decisions of [cost of decision + f(next state)].
- Solve backward (or forward) from a known end.
Routing: the shortest path problem
Find the least-cost route through a network: pipelines, roads, cables.
Worked example
A pipeline route from node 1 to node 6 (lengths in km):
| Link | Length |
|---|---|
| 1-2 | 7 |
| 1-3 | 3 |
| 3-2 | 2 |
| 2-4 | 2 |
| 3-4 | 6 |
| 3-5 | 9 |
| 4-5 | 1 |
| 4-6 | 5 |
| 5-6 | 2 |
Dijkstra's algorithm (forward, permanent labels):
- Node 1: 0.
- From 1: node 2 = 7, node 3 = 3. Smallest: 3 (3).
- From 3: node 2 = min(7, 3 + 2) = 5; node 4 = 9; node 5 = 12. Smallest: 2 (5).
- From 2: node 4 = min(9, 5 + 2) = 7. Smallest: 4 (7).
- From 4: node 5 = min(12, 7 + 1) = 8; node 6 = 12. Smallest: 5 (8).
- From 5: node 6 = min(12, 8 + 2) = 10.
Shortest route: 1 → 3 → 2 → 4 → 5 → 6 = 10 km.
Check with backward DP: f(6) = 0; f(5) = 2; f(4) = min(5 + 0, 1 + 2) = 3; f(2) = 2 + 3 = 5; f(3) = min(2 + 5, 6 + 3, 9 + 2) = 7; f(1) = min(7 + 5, 3 + 7) = 10. Same answer.
Other network problems
| Problem | Finds | Method |
|---|---|---|
| Minimum spanning tree | Cheapest way to connect all nodes (a cable network) | Kruskal's or Prim's algorithm |
| Maximum flow | Most flow from source to sink (water, gas) | Ford-Fulkerson |
| Travelling salesman | Shortest tour visiting every node once (a maintenance round) | Heuristics, branch and bound |
DP for resource allocation
Allocating a budget among projects stage by stage: each stage is a project, the state is the money left, and the recursion picks the best amount for each. DP also handles equipment replacement and production planning over time.
Sequencing
Ordering jobs on machines. For n jobs on two machines in the same order, Johnson's rule minimises the total time: list the shortest times; if on machine 1, schedule that job as early as possible; if on machine 2, as late as possible; repeat.
Exams usually ask
- Find a shortest route by Dijkstra's method or DP.
- State Bellman's principle of optimality.
Common mistake
Picking the cheapest link at each step (greedy) without keeping the running totals. Dijkstra compares total distances, not single links.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Dynamic programming
(opens en.wikipedia.org in a new tab)
Wikipedia, Dynamic programming, CC BY-SA 4.0 · licence
-
Shortest path problem
(opens en.wikipedia.org in a new tab)
Wikipedia, Shortest path problem, CC BY-SA 4.0 · licence
-
Dijkstra's algorithm
(opens en.wikipedia.org in a new tab)
Wikipedia, Dijkstra's algorithm, CC BY-SA 4.0 · licence
-
Bellman equation
(opens en.wikipedia.org in a new tab)
Wikipedia, Bellman equation, CC BY-SA 4.0 · licence
Watch
-
Best pick Operations Research--The Shortest Path Problem Part 1--Model Formulation
16 min · ≈ 72 MB · about ₦40
(opens youtube.com in a new tab)
-
Operations Research 08C: Shortest Path & Dijkstra’s Algorithm - Directed Networks
4 min · ≈ 18 MB · about ₦10
(opens youtube.com in a new tab)
-
Finding Shortest path using Dynamic Programming by Backward Recursion Process
28 min · ≈ 126 MB · about ₦71
(opens youtube.com in a new tab)
-
Lecture 19: Dynamic Programming I: Fibonacci, Shortest Paths
52 min · ≈ 234 MB · about ₦131
(opens youtube.com in a new tab)
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.