pub trait RepositionStrategy: Send + Sync {
// Required method
fn reposition(
&mut self,
idle_elevators: &[(EntityId, f64)],
stop_positions: &[(EntityId, f64)],
group: &ElevatorGroup,
world: &World,
out: &mut Vec<(EntityId, EntityId)>,
);
// Provided methods
fn builtin_id(&self) -> Option<BuiltinReposition> { ... }
fn min_arrival_log_window(&self) -> u64 { ... }
}Expand description
Pluggable strategy for repositioning idle elevators.
After the dispatch phase, elevators that remain idle (no pending assignments) are candidates for repositioning. The strategy decides where each idle elevator should move to improve coverage and reduce expected response times.
Implementations receive the set of idle elevator positions and the
group’s stop positions, then return a target stop for each elevator
(or None to leave it in place).
Required Methods§
Sourcefn 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)>, )
Decide where to reposition idle elevators.
Push (elevator_entity, target_stop_entity) pairs into out.
The buffer is cleared before each call — implementations should
only push, never read prior contents. Elevators not pushed remain idle.
Provided Methods§
Sourcefn builtin_id(&self) -> Option<BuiltinReposition>
fn builtin_id(&self) -> Option<BuiltinReposition>
If this strategy is a known built-in variant, return it so
Simulation::set_reposition
callers don’t have to pass a separate BuiltinReposition id
that might drift from the dispatcher’s actual type.
Mirrors the pattern introduced for DispatchStrategy::builtin_id
in #410: the runtime impl identifies itself so the snapshot
identity always matches the executing behaviour, instead of
depending on the caller to keep two parameters consistent.
Default None — custom strategies should override to return
BuiltinReposition::Custom with a stable name for snapshot
fidelity.
Sourcefn min_arrival_log_window(&self) -> u64
fn min_arrival_log_window(&self) -> u64
Minimum 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.
Default 0 — strategies that don’t read the arrival log (or that
only consume it through DispatchManifest::arrivals_at, which
already tracks retention) impose no requirement.