Skip to main content

Module loop_schedule

Module loop_schedule 

Source
Expand description

Fixed-dwell timetable for closed-loop topologies. LoopSchedule — fixed-dwell timetable for LineKind::Loop groups.

Where crate::dispatch::LoopSweepDispatch lets each Loop car carry whatever per-car door_open_ticks the config specified (so dwell tracks the rider load at each stop), LoopSchedule overrides every Loop car in the group to a single dwell_ticks value. The resulting timetable is predictable — every car spends the same amount of time at every stop on every lap — which is what people-mover lines, gondolas, and timetabled shuttle services want.

§What this strategy does

  • Fixed dwell: every Loop car in the group has its door_open_ticks rewritten to the schedule’s dwell_ticks once per pass via pre_dispatch. Idempotent — the same value is written unconditionally each tick, so re-applying the strategy leaves car state unchanged.
  • Hold-recovery: when a car arrives at a stop sooner than target_headway_ticks after the preceding car arrived at the same stop, the strategy issues a DoorCommand::HoldOpen extending the dwell by min(target_headway_ticks - gap, hold_cap_ticks). This pushes the bunched follower back to its schedule slot rather than letting it tailgate the leader.
    • The cap prevents indefinite hold if the leader is stuck (e.g. stopped indefinitely for heavy boarding) — the follower waits at most hold_cap_ticks extra per stop, then resumes patrol.
    • Crucially, hold-recovery never speeds a car up: an early-arriving follower can only delay itself, never overtake.
    • A leader that runs late is not held — only followers running ahead of their schedule are held.
  • Snapshot round-trip: builtin_id returns BuiltinStrategy::LoopSchedule and snapshot_config / restore_config carry all three tunable fields. Per-pass bookkeeping (last-arrival ticks, in-loading set) is #[serde(skip)] — restored sims rebuild it on the first tick where each car next enters Loading.

Bunching under heavy load is largely mitigated by hold-recovery but not eliminated: a leader that takes an unusually long time to board may exceed hold_cap_ticks of follower hold, and the follower then catches up before recovering. Tune hold_cap_ticks to the worst-case boarding burst your line expects.

Structs§

LoopScheduleDispatch
Dispatch strategy that holds Loop cars to a uniform dwell at every stop, with hold-recovery to keep the timetable stable under load.

Constants§

DEFAULT_HOLD_CAP_TICKS
Default hold-recovery cap.