NivaarExam PrepOfficial exam papers ↗

23-Ind-A1 Operations Research · May 2017

Question 2 of 8: Dynamic Programming — Shortest Path Through a Street Grid

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)

Notes on this paper

National Exams — May 2017 — 98-Ind-A1 Operations Research. Three-hour, open-book exam (any non-communicating calculator permitted); the paper totals 160 marks across 8 questions (each worth 20) and only 100 marks are required, so a candidate would normally answer 5 — all eight are solved below for completeness.

Reference texts: Hillier & Lieberman, Introduction to Operations Research (11th ed., McGraw-Hill) — linear programming formulation & the simplex method (ch. 3–4), duality & sensitivity analysis (ch. 6), network optimization models (ch. 9), deterministic dynamic programming (ch. 11), integer programming (ch. 12), Markov chains (ch. 16), decision analysis (ch. 15).

Question 2: Dynamic Programming — Shortest Path Through a Street Grid (20 marks)

Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.

Given. A $5\times4$ street grid (5 vertical streets × 4 horizontal streets) with the block travel times (minutes) shown in the figure below; start = King & Bathurst, destination = College & Yonge; the rat moves only rightward (increasing street number) or upward (toward College), never backtracking, consistent with heading toward the destination.

Find. The minimum total travel time from King & Bathurst to College & Yonge, and the shortest route.

5223833262225314322223232465124Bath0Spad0Univ0Bay0Yong0Bath1Spad1Univ1Bay1Yong1Bath2Spad2Univ2Bay2Yong2Bath3Spad3Univ3Bay3Yong3
Street grid, node label = street + row (row 0 = King, 1 = Queen, 2 = Dundas, 3 = College; columns left→right = Bathurst, Spadina, University, Bay, Yonge). Numbers on each block are the travel time in minutes. Start = Bath0 (King&Bathurst); destination = Yong3 (College&Yonge).

Approach. Index intersections by (column, row); define $f(x,y)$ as the minimum time from the start to intersection $(x,y)$, and apply the DP recursion $f(x,y)=\min\{f(x{-}1,y)+h(x{-}1,y),\ f(x,y{-}1)+v(x,y{-}1)\}$ sweeping outward from the start, since only rightward/upward moves can reach the destination without wasted travel.

  1. Stage-by-stage DP fill (minutes to reach each intersection). Rows are King(0), Queen(1), Dundas(2), College(3); columns are Bathurst(0), Spadina(1), University(2), Bay(3), Yonge(4). Boundary $f(0,0)=0$.
    DP table — minimum minutes from Bath0 to each intersection
    BathurstSpadinaUniversityBayYonge
    College712131418
    Dundas59111315
    Queen3791213
    King057912
    Each cell is the smaller of (cell to its left + that horizontal block time) and (cell below it + that vertical block time); e.g. $f(\text{Spadina},\text{Queen})=\min\big(f(\text{Bathurst},\text{Queen})+8,\ f(\text{Spadina},\text{King})+2\big)=\min(3+8,\ 5+2)=7$, matching the table.
  2. Trace the optimal path backward from the destination by following whichever predecessor achieved the minimum at each step: $$\boxed{f(\text{Yonge},\text{College})=18\text{ minutes}}$$ Path: Bathurst&King $\xrightarrow{5}$ Spadina&King $\xrightarrow{2}$ Spadina&Queen $\xrightarrow{2}$ Spadina&Dundas $\xrightarrow{2}$ University&Dundas $\xrightarrow{2}$ University&College $\xrightarrow{1}$ Bay&College $\xrightarrow{4}$ Yonge&College. Check: $5+2+2+2+2+1+4=18$, matching the DP table value, and this is exactly the chain of predecessors the recursion selected at each stage.
Final results — Question 2
ItemValue
Shortest travel time18 minutes
Shortest route (one optimal path)Bath&King → Spad&King → Spad&Queen → Spad&Dundas → Univ&Dundas → Univ&College → Bay&College → Yonge&College