Lite / Intelligent Robotic Systems / Week 9
Project: measure the cost, plot it honestly
Your planner works on a 10 × 10 map. Will it still answer in time on a 200 × 200 warehouse? Don't guess: measure, model and plot.
Why should I care?
The second half of the term project turns your planner into evidence. You'll run a fair experiment, fit what you see against what big-O predicts, and present it the way an engineering team would: plots that don't mislead, numbers with units, and limits stated plainly.
- Measure runtime and cells expanded for two planners on at least four map sizes.
- Compare measured growth with the expected big-O and explain any difference.
- Present results in two honest, labelled plots and a one-page interpretation.
Predict
On open square maps, BFS from corner to corner expands every cell. If the side doubles from 50 to 100, roughly how do cells expanded change?
- Double
- Quadruple
- Stay the same
- Increase by 50
Guess first, then reveal
Quadruple: cells = side², so 2,500 → 10,000. BFS is O(V) in the number of cells V, which is O(side²). If you plot against side length you'll see a curve; against cell count, a straight line.
Discover
In the Code Lab, run your planners on open and obstacle maps with sides 25, 50, 100 and 200. For each, record cells expanded and the best of five times. Compute the time ratio for each doubling of the side. Which planner's growth is closer to what you predicted, and why might Dijkstra's be a little steeper?
What the interactive shows (text version)
The Code Lab experiment can be followed from the worked numbers: on open maps with sides 25, 50, 100 and 200, BFS corner to corner expands 625, 2,500, 10,000 and 40,000 cells, an exponent of 1.0 against the number of cells. Times are measured as the best of five runs; plots use cells on the x-axis so linear growth appears straight.
Understand
Design the experiment
Question: how do runtime and cells expanded grow with map size for BFS and Dijkstra? Change only the size; fix the obstacle density, the start and goal positions, the random seed and the machine. Repeat each run and record the best or median time.
Choose honest axes
Plot against the number of cells V (not just side length) so linear growth looks linear. A log–log plot turns power laws into straight lines whose slope you can read. Label units, mark each measured point, and never join points you didn't measure with a smooth curve that implies more data.
Interpret, don't decorate
State the expected big-O, the measured exponent and the gap. Dijkstra's heap adds a log V factor and larger constants; Python overheads can dominate small maps. Finish with limits: one machine, one obstacle pattern, simplified robot (no size, turning cost or uncertainty).
Explain it another way
Intuitive
You're the scientist now: your planner is the thing being tested, and the plots are your lab notebook.
Technical
Expected: BFS O(V); Dijkstra O(V log V) with a binary heap. Over a 64× range in V, log₂ V grows only from about 9 to 15, so Dijkstra's measured exponent should be a little above 1, not 2.
Mathematical
Estimate the exponent p from the slope of log T against log V; for one doubling of V, p ≈ log₂(T₂/T₁). Doubling the side quadruples V, so p ≈ log₄(T₂/T₁) per side-doubling.
Applied
Before deploying a planner on a real robot, teams benchmark it on maps larger than the target site, because the real environment is always bigger and messier than the test one.
Worked example 1
Count cells expanded by BFS on open maps and estimate the growth exponent against the cell count.
import math
from collections import deque
def bfs_expanded(side):
start, goal = (0, 0), (side - 1, side - 1)
queue, seen, expanded = deque([start]), {start}, 0
while queue:
r, c = queue.popleft()
expanded += 1
if (r, c) == goal:
return expanded
for n in [(r - 1, c), (r, c + 1), (r + 1, c), (r, c - 1)]:
if 0 <= n[0] < side and 0 <= n[1] < side and n not in seen:
seen.add(n)
queue.append(n)
return expanded
sides = [25, 50, 100, 200]
counts = [bfs_expanded(s) for s in sides]
print(counts) # [625, 2500, 10000, 40000]
for (s1, e1), (s2, e2) in zip(zip(sides, counts), zip(sides[1:], counts[1:])):
p = math.log(e2 / e1) / math.log((s2 * s2) / (s1 * s1))
print(s1, "->", s2, "exponent vs cells:", round(p, 2)) # 1.0 each timeCommon mix-ups
Bigger numbers on the y-axis are more impressive, so zoom in.
✓ Choose axes that show the growth truthfully. Readers should judge the result, not the styling.If the measured exponent isn't exactly 1 or 2, something is broken.
✓ Constants, log factors and noise shift it. Explain the gap rather than forcing a round number.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
Term project, part 2 (deliverables). (1) Timing and cells-expanded measurements for BFS and Dijkstra on at least four map sizes. (2) Two plots: time against cells, and path cost (BFS vs Dijkstra) on obstacle maps; labelled, with units, all measured points shown. (3) A one-page interpretation: expected big-O, measured exponents, the gap, and the limits of your model.
Reflect
Which result in your experiment surprised you, and what explanation did you test for it?
Write your answer on paper or in your own notes. Lite never stores what you write.