pub struct EtdDispatch {
pub wait_weight: f64,
pub delay_weight: f64,
pub door_weight: f64,
pub wait_squared_weight: f64,
pub age_linear_weight: f64,
/* private fields */
}Expand description
Estimated Time to Destination (ETD) dispatch algorithm.
For each (car, stop) pair the rank is a cost estimate combining
travel time, delay imposed on riders already aboard, door-overhead
for intervening stops, and a small bonus for cars already heading
toward the stop. The dispatch system runs an optimal assignment
across all pairs so the globally best matching is chosen.
Fields§
§wait_weight: f64Weight for travel time to reach the calling stop.
delay_weight: f64Weight for delay imposed on existing riders.
door_weight: f64Weight for door open/close overhead at intermediate stops.
wait_squared_weight: f64Weight for the squared-wait “group-time” fairness bonus. Each
candidate stop’s cost is reduced by this weight times the sum
of wait_ticks² across waiting riders at the stop, so stops
hosting older calls win ties. Defaults to 0.0 (no bias);
positive values damp the long-wait tail (Aalto EJOR 2016
group-time assignment model).
age_linear_weight: f64Weight for the linear waiting-age fairness term. Each candidate
stop’s cost is reduced by this weight times the sum of
wait_ticks across waiting riders at the stop, so stops hosting
older calls win ties without the quadratic blow-up of
wait_squared_weight. Defaults to
0.0 (no bias); positive values implement the linear
collective-group-control fairness term from Lim 1983 /
Barney–dos Santos 1985 CGC.
Composes additively with wait_squared_weight: users wanting
the full CGC shape can set both (k·Σw + λ·Σw²).
Implementations§
Source§impl EtdDispatch
impl EtdDispatch
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new EtdDispatch with the baseline weights.
Defaults: wait_weight = 1.0, delay_weight = 1.0,
door_weight = 0.5, wait_squared_weight = 0.0,
age_linear_weight = 0.0.
This is the baseline constructor — the fairness terms
(wait_squared_weight, age_linear_weight) are off, so behaviour
matches ETD as originally shipped. Mutant/unit tests that
measure a single term in isolation (new().with_age_linear_weight(…))
rely on this contract.
For the opinionated “pick ETD from the dropdown” configuration
used by BuiltinStrategy::Etd,
call EtdDispatch::default instead — that ships the
linear-age fairness term active to bound the max-wait tail
under sustained peak traffic.
Sourcepub fn tuned() -> Self
pub fn tuned() -> Self
Return the opinionated tuned configuration — equivalent to
Default::default.
Same dispatch shape as new but with the linear
waiting-age fairness term active:
age_linear_weight = 0.005 (seconds of cost-reduction per
waiting-tick summed across riders at the stop). That value is
calibrated against the playground_audit harness: a stop
hosting three 30-second waiters sees a ≈27s fairness bonus,
roughly equal to a short-trip ETA, which is strong enough to
break ties toward older waiters without overriding travel
dominance on fresh demand.
Without the age term, ETD’s rank is age-agnostic and a stream
of fresh lobby-side demand can indefinitely preempt a single
old waiter on an upper floor — exactly the tail-starvation
pattern showing up as ETD’s max_wait lagging SCAN’s by
40-50% in the playground_audit. The linear term (from the
Lim 1983 / Barney–dos Santos CGC lineage) is the established
fix for that shape.
Sourcepub fn with_delay_weight(delay_weight: f64) -> Self
pub fn with_delay_weight(delay_weight: f64) -> Self
Create with a single delay weight (backwards-compatible shorthand).
Sourcepub fn with_weights(
wait_weight: f64,
delay_weight: f64,
door_weight: f64,
) -> Self
pub fn with_weights( wait_weight: f64, delay_weight: f64, door_weight: f64, ) -> Self
Create with fully custom weights.
Sourcepub fn with_wait_squared_weight(self, weight: f64) -> Self
pub fn with_wait_squared_weight(self, weight: f64) -> Self
Turn on the squared-wait fairness bonus. Higher values prefer
older waiters more aggressively; 0.0 (the default) disables.
§Panics
Panics on non-finite or negative weights. A NaN weight would
propagate through mul_add and silently disable every dispatch
rank; a negative weight would invert the fairness ordering.
Either is a programming error rather than a valid configuration.
Sourcepub fn with_age_linear_weight(self, weight: f64) -> Self
pub fn with_age_linear_weight(self, weight: f64) -> Self
Turn on the linear waiting-age fairness term. Higher values
prefer older waiters more aggressively; 0.0 (the default)
disables. Composes additively with
with_wait_squared_weight.
§Panics
Panics on non-finite or negative weights, for the same reasons
as with_wait_squared_weight.
Trait Implementations§
Source§impl Default for EtdDispatch
impl Default for EtdDispatch
Source§fn default() -> Self
fn default() -> Self
The opinionated “pick ETD from the dropdown” configuration.
Defaults to EtdDispatch::tuned — the baseline weights plus
an active linear-age fairness term. See the tuned docstring
for the calibration rationale.
Source§impl<'de> Deserialize<'de> for EtdDispatch
impl<'de> Deserialize<'de> for EtdDispatch
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl DispatchStrategy for EtdDispatch
impl DispatchStrategy for EtdDispatch
Source§fn pre_dispatch(
&mut self,
group: &ElevatorGroup,
manifest: &DispatchManifest,
world: &mut World,
)
fn pre_dispatch( &mut self, group: &ElevatorGroup, manifest: &DispatchManifest, world: &mut World, )
Source§fn builtin_id(&self) -> Option<BuiltinStrategy>
fn builtin_id(&self) -> Option<BuiltinStrategy>
Simulation::new can stamp the
correct BuiltinStrategy into the group’s snapshot identity. Read moreSource§fn snapshot_config(&self) -> Option<String>
fn snapshot_config(&self) -> Option<String>
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>
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 more