Expand description
Pluggable dispatch strategies (SCAN, LOOK, nearest-car, ETD). Pluggable dispatch strategies for assigning elevators to stops.
Strategies express preferences as scores on (car, stop) pairs via
[DispatchStrategy::rank]. The dispatch system then runs an optimal
bipartite assignment (Kuhn–Munkres / Hungarian algorithm) so coordination
— one car per hall call — is a library invariant, not a per-strategy
responsibility. Cars left unassigned are handed to
[DispatchStrategy::fallback] for per-car policy (idle, park, etc.).
§Example: custom dispatch strategy
use elevator_core::prelude::*;
use elevator_core::dispatch::{
DispatchDecision, DispatchManifest, ElevatorGroup,
};
struct AlwaysFirstStop;
impl DispatchStrategy for AlwaysFirstStop {
fn rank(
&mut self,
_car: EntityId,
car_position: f64,
stop: EntityId,
stop_position: f64,
group: &ElevatorGroup,
_manifest: &DispatchManifest,
_world: &elevator_core::world::World,
) -> Option<f64> {
// Prefer the group's first stop; everything else is unavailable.
if Some(&stop) == group.stop_entities().first() {
Some((car_position - stop_position).abs())
} else {
None
}
}
}
let sim = SimulationBuilder::demo()
.dispatch(AlwaysFirstStop)
.build()
.unwrap();Re-exports§
pub use destination::AssignedCar;pub use destination::DestinationDispatch;pub use etd::EtdDispatch;pub use look::LookDispatch;pub use nearest_car::NearestCarDispatch;pub use scan::ScanDispatch;
Modules§
- destination
- Hall-call destination dispatch algorithm. Hall-call destination dispatch (“DCS”).
- etd
- Estimated Time to Destination dispatch algorithm. Estimated Time to Destination (ETD) dispatch algorithm.
- look
- LOOK dispatch algorithm. LOOK dispatch algorithm — reverses at the last request, not the shaft end.
- nearest_
car - Nearest-car dispatch algorithm. Nearest-car dispatch — assigns each call to the closest idle elevator.
- reposition
- Built-in repositioning strategies. Built-in repositioning strategies for idle elevators.
- scan
- SCAN dispatch algorithm. SCAN (elevator) dispatch algorithm — sweeps end-to-end before reversing.
Structs§
- Assignment
Result - Resolution of a single dispatch assignment pass for one group.
- Dispatch
Manifest - Full demand picture for dispatch decisions.
- Elevator
Group - Runtime elevator group: a set of lines sharing a dispatch strategy.
- Line
Info - Per-line relationship data within an
ElevatorGroup. - Rider
Info - Metadata about a single rider, available to dispatch strategies.
Enums§
- Builtin
Reposition - Serializable identifier for built-in repositioning strategies.
- Builtin
Strategy - Serializable identifier for built-in dispatch strategies.
- Dispatch
Decision - Decision returned by a dispatch strategy.
- Hall
Call Mode - How hall calls expose rider destinations to dispatch.
Traits§
- Dispatch
Strategy - Pluggable dispatch algorithm.
- Reposition
Strategy - Pluggable strategy for repositioning idle elevators.