pub trait DispatchStrategy: Send + Sync {
// Required method
fn decide(
&mut self,
elevator: EntityId,
elevator_position: f64,
group: &ElevatorGroup,
manifest: &DispatchManifest,
world: &World,
) -> DispatchDecision;
// Provided methods
fn decide_all(
&mut self,
elevators: &[(EntityId, f64)],
group: &ElevatorGroup,
manifest: &DispatchManifest,
world: &World,
) -> Vec<(EntityId, DispatchDecision)> { ... }
fn notify_removed(&mut self, _elevator: EntityId) { ... }
}Expand description
Pluggable dispatch algorithm.
Receives a manifest with per-rider metadata grouped by stop. Convenience methods provide aggregate counts; implementations can also iterate individual riders for priority/weight-aware dispatch.
Required Methods§
Sourcefn decide(
&mut self,
elevator: EntityId,
elevator_position: f64,
group: &ElevatorGroup,
manifest: &DispatchManifest,
world: &World,
) -> DispatchDecision
fn decide( &mut self, elevator: EntityId, elevator_position: f64, group: &ElevatorGroup, manifest: &DispatchManifest, world: &World, ) -> DispatchDecision
Decide for a single elevator.
Provided Methods§
Sourcefn decide_all(
&mut self,
elevators: &[(EntityId, f64)],
group: &ElevatorGroup,
manifest: &DispatchManifest,
world: &World,
) -> Vec<(EntityId, DispatchDecision)>
fn decide_all( &mut self, elevators: &[(EntityId, f64)], group: &ElevatorGroup, manifest: &DispatchManifest, world: &World, ) -> Vec<(EntityId, DispatchDecision)>
Decide for all idle elevators in a group.
Default: calls decide() per elevator.
Sourcefn notify_removed(&mut self, _elevator: EntityId)
fn notify_removed(&mut self, _elevator: EntityId)
Notify the strategy that an elevator has been removed.
Implementations with per-elevator state (e.g., direction tracking) should clean up here to prevent unbounded memory growth. Default: no-op.