pub struct AdaptiveParking { /* private fields */ }Expand description
Mode-gated reposition: dispatches to an inner strategy chosen
by the current TrafficMode.
Closes the playground-reported “chaotic repositioning” complaint:
the single-strategy defaults either lock cars to the lobby
(ReturnToLobby) or shuttle them toward the hottest stop
(PredictiveParking) regardless of traffic shape. Adaptive
picks per mode:
| Mode | Inner |
|---|---|
UpPeak | ReturnToLobby |
InterFloor | PredictiveParking |
DownPeak | PredictiveParking |
Idle | no-op (stay put) |
DownPeak reuses PredictiveParking intentionally: during a down
peak, upper floors are the high-arrival stops (riders spawn there
heading to the lobby), and PredictiveParking scores stops by
ArrivalLog counts — so it correctly biases idle cars upward
without needing a destination-aware variant. Falls back to
InterFloor routing if the detector is missing from World
(e.g. hand-built tests bypassing Simulation).
Implementations§
Source§impl AdaptiveParking
impl AdaptiveParking
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create with defaults: ReturnToLobby::new() (home = stop 0)
and PredictiveParking::new() (default rolling window).
Sourcepub const fn with_home(self, index: usize) -> Self
pub const fn with_home(self, index: usize) -> Self
Override the home stop used during UpPeak. Same semantics as
ReturnToLobby::with_home.
Sourcepub const fn with_window_ticks(self, window_ticks: u64) -> Self
pub const fn with_window_ticks(self, window_ticks: u64) -> Self
Override the window used for InterFloor / DownPeak
predictive parking. Same semantics as
PredictiveParking::with_window_ticks.
§Panics
Panics on window_ticks = 0, matching PredictiveParking.
Trait Implementations§
Source§impl Default for AdaptiveParking
impl Default for AdaptiveParking
Source§impl RepositionStrategy for AdaptiveParking
impl RepositionStrategy for AdaptiveParking
Source§fn reposition(
&mut self,
idle_elevators: &[(EntityId, f64)],
stop_positions: &[(EntityId, f64)],
group: &ElevatorGroup,
world: &World,
out: &mut Vec<(EntityId, EntityId)>,
)
fn reposition( &mut self, idle_elevators: &[(EntityId, f64)], stop_positions: &[(EntityId, f64)], group: &ElevatorGroup, world: &World, out: &mut Vec<(EntityId, EntityId)>, )
Source§fn builtin_id(&self) -> Option<BuiltinReposition>
fn builtin_id(&self) -> Option<BuiltinReposition>
Simulation::set_reposition
callers don’t have to pass a separate BuiltinReposition id
that might drift from the dispatcher’s actual type. Read moreSource§fn min_arrival_log_window(&self) -> u64
fn min_arrival_log_window(&self) -> u64
ArrivalLog retention
(in ticks) the strategy needs to function. Strategies that read
the log directly with a custom rolling window must override this
so Simulation::set_reposition
can widen
ArrivalLogRetention
to keep the data alive long enough for the query. Read more