Learning, and the capstone · University · about 30 min
What learning buys over a hand-written rule, what it costs, and the smallest honest example.
position() in this module[1 mark]Which three things must be present for there to be anything to learn?
Tick every answer that is true.
[1 mark]The data sheet says 20 cm/s at command 100. The robot drives at command 60 for 4 s and travels 44.2 cm. What does this print?
nominal = 20.0 * 60 / 100.0 * 4.0 measured = 44.2 print(nominal, measured, round(measured / nominal, 3))
48.0 44.2 0.921
The data sheet predicts 12 cm/s for 4 s, 48 cm. The robot's gain is 44.2 / 48 = 0.921.
[1 mark]What is the name for the family of candidate answers a learner chooses between, such as all straight lines with a slope and an intercept?
[1 mark]A robot tries lateral offsets on short trials and keeps whichever scores best. Which setting is this?
[1 mark]Which of these is a poor use of learning?
[1 mark]In this module position() is available. What is the rule for using it?
[1 mark]The single gain from one 4 s run predicts the robot's travel better than the data sheet. What is still missing?
Print nominal: the travel the data sheet predicts at command 60 for 4 seconds, measured: what this robot actually did, and gain: the ratio.
from bugbot import * connect() CMD = 60 SECONDS = 4.0 V_MAX = 20.0
The hint students can ask for: The data sheet says 20 cm/s at command 100, so command 60 for 4 seconds should be 48 cm. Drive it, measure what happened with the lab's camera, and divide. That ratio is a model of this robot with one parameter in it, fitted from one run.
from bugbot import *
connect()
CMD = 60
SECONDS = 4.0
V_MAX = 20.0 # the data sheet: cm/s at command 100
nominal = V_MAX * CMD / 100.0 * SECONDS
print("nominal:", round(nominal, 1))
# the lab's overhead camera, which the robot itself does not have
x0, y0 = position()
forward(CMD)
wait(SECONDS)
stop()
wait(0.5)
x1, y1 = position()
measured = ((x1 - x0) ** 2 + (y1 - y0) ** 2) ** 0.5
print("measured:", round(measured, 1))
print("gain:", round(measured / nominal, 3))
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.