Week 4 Lab: Running the race loop
Implement a deterministic lap transition, preserve physical-set age, and reproduce a supplied trace and finishing time
15 March 2027
Two hours, worth 2%, completed and submitted inside the session. The codebase is standalone. It receives every parameter and correct prior output it needs; it does not import your week 2 fit or week 3 code.
What leaves the room is a deterministic evaluator for one supplied strategy: a validated state transition, a lap trace, a finishing time and a stated boundary on what that result answers.
Before the session#
Install the supplied codebase and run its tests. Read the strategy schema, where each stint names a physical set ID and an inclusive end lap, and the parameter schema, where every time is in seconds. Run the five-lap fixture. It may fail at the unimplemented transition; no earlier failure is preparation.
Hand-trace its first two laps before you arrive. Mark the tyre age before
each lap: 0 for lap 1 and 1 for lap 2. A fresh set has completed no laps.
What is supplied#
The SlopU race has one car, 30 dry uninterrupted laps and fixed parameters. It contains no traffic, overtaking, hazards or random draw. Identical input must produce an identical result on every run.
In the session#
- Make state explicit (20 minutes). Implement a state record containing the current lap, active physical set, laps already completed on every set, next scheduled stop and cumulative time. Before lap 1, validate that stint lengths cover exactly 30 laps, stop laps increase, every named set is in the supplied inventory, and the compound sequence appears in the supplied Week 3 legal set. Reject an illegal row before timing it.
- Implement one lap and one stop (35 minutes). For lap
l, compoundcand the active set’s agea, applyfresh_pace[c] - fuel_gain * (l - 1) + wear[c] * a. Add the lap time, increment that physical set’s age, then fire a scheduled stop after the lap: add pit loss once and fit the next set. A refitted set resumes its accumulated age. Do not add another in-lap or out-lap penalty; the supplied pit loss has already priced them against ordinary laps. - Run the race (35 minutes). Evaluate the supplied strategy end to end and
emit
lap,set,age_before_lap,lap_time,eventandcumulative_timefor every row. Sweep the suppliedM2 → H1strategy over its stop laps. Report the minimum-time row and at least one neighbouring row; the expected minimum is a stop after lap 12 at 2804.500 s. - Validate and state the boundary (30 minutes). Match every row of the five-lap trace and its 502.7 s total, then match the supplied full-race check. Make one illegal fixture fail for the stated reason. Finish with two sentences: the objective that finishing time answers, and the first omitted effect that could change its recommendation.
The four time boxes total two hours.
What you hand over#
A marker checks four things in the room:
- the state transition and validator, including preserved physical-set age across a refit;
- the exact five-lap trace and
502.7 stotal; - the 30-lap trace, stop-lap comparison and
2804.500 scheck; - the rejected illegal fixture and the two-sentence model boundary.
The objective in this evaluator is fastest elapsed time for one car. It says nothing about finishing order. Assignment 1 asks the same model-fitness questions with the omissions no longer held outside the room.
The spec
What you bring to the session. Written so a reader can tell whether it has been met without asking you.
- the supplied codebase installs and its own test suite passes on your machine
- the strategy and parameter schemas have been read, including physical set IDs and end-lap meaning
- the five-lap fixture runs to the unimplemented transition and its expected trace is open beside it
- the first two fixture laps have been hand-traced, with age before each lap marked
Teaching team
- Tobias Wren — Tutor, leading this week
- Naila Sorge — Tutor
- Kwame Ferriter — Tutor