Skip to main content

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

  1. 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.
  2. Implement one lap and one stop (35 minutes). For lap l, compound c and the active set’s age a, apply fresh_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.
  3. Run the race (35 minutes). Evaluate the supplied strategy end to end and emit lap, set, age_before_lap, lap_time, event and cumulative_time for every row. Sweep the supplied M2 → H1 strategy 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.
  4. 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 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.

Teaching team