pub struct NearestCarDispatch;Expand description
Scores (car, stop) by absolute distance between the car and the stop.
Paired with the Hungarian assignment in the dispatch system, this yields the globally minimum-total-distance matching across the group — no two cars can be sent to the same hall call.
Two guards are applied on top of the raw distance, both via the
shared pair_is_useful predicate:
- The
(car, stop)pair must be serviceable — at least one aboard rider can exit, or at least one waiting rider can fit. A full car at a pickup stop it cannot serve otherwise self-assigns at zero cost (doors cycle open → reject → close forever). - A car carrying riders refuses pickups that would pull it backward (off the path to every aboard rider’s destination). Without this, a stream of closer-destination boarders can indefinitely preempt a farther aboard rider’s delivery — the reported “never reaches the passenger’s desired stop” loop.
Implementations§
Trait Implementations§
Source§impl Default for NearestCarDispatch
impl Default for NearestCarDispatch
Source§impl DispatchStrategy for NearestCarDispatch
impl DispatchStrategy for NearestCarDispatch
Source§fn builtin_id(&self) -> Option<BuiltinStrategy>
fn builtin_id(&self) -> Option<BuiltinStrategy>
If this strategy is a known built-in variant, return it so
Simulation::new can stamp the
correct BuiltinStrategy into the group’s snapshot identity. Read moreSource§fn pre_dispatch(
&mut self,
_group: &ElevatorGroup,
_manifest: &DispatchManifest,
_world: &mut World,
)
fn pre_dispatch( &mut self, _group: &ElevatorGroup, _manifest: &DispatchManifest, _world: &mut World, )
Optional hook called once per group before the assignment pass. Read more
Source§fn prepare_car(
&mut self,
_car: EntityId,
_car_position: f64,
_group: &ElevatorGroup,
_manifest: &DispatchManifest,
_world: &World,
)
fn prepare_car( &mut self, _car: EntityId, _car_position: f64, _group: &ElevatorGroup, _manifest: &DispatchManifest, _world: &World, )
Source§fn fallback(
&mut self,
_car: EntityId,
_car_position: f64,
_group: &ElevatorGroup,
_manifest: &DispatchManifest,
_world: &World,
) -> DispatchDecision
fn fallback( &mut self, _car: EntityId, _car_position: f64, _group: &ElevatorGroup, _manifest: &DispatchManifest, _world: &World, ) -> DispatchDecision
Decide what an idle car should do when no stop was assigned to it. Read more
Source§fn notify_removed(&mut self, _elevator: EntityId)
fn notify_removed(&mut self, _elevator: EntityId)
Notify the strategy that an elevator has been removed. Read more
Source§fn snapshot_config(&self) -> Option<String>
fn snapshot_config(&self) -> Option<String>
Serialize this strategy’s tunable configuration to a string
that
restore_config can apply to a
freshly-instantiated instance. Read moreSource§fn restore_config(&mut self, _serialized: &str) -> Result<(), String>
fn restore_config(&mut self, _serialized: &str) -> Result<(), String>
Restore tunable configuration from a string previously produced
by
snapshot_config on the same
strategy variant. Called by
crate::snapshot::WorldSnapshot::restore immediately after
BuiltinStrategy::instantiate builds the default instance,
so the restore writes over the defaults. Read moreAuto Trait Implementations§
impl Freeze for NearestCarDispatch
impl RefUnwindSafe for NearestCarDispatch
impl Send for NearestCarDispatch
impl Sync for NearestCarDispatch
impl Unpin for NearestCarDispatch
impl UnsafeUnpin for NearestCarDispatch
impl UnwindSafe for NearestCarDispatch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more