Skip to main content

EtdDispatch

Struct EtdDispatch 

Source
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: f64

Weight for travel time to reach the calling stop.

§delay_weight: f64

Weight for delay imposed on existing riders.

§door_weight: f64

Weight for door open/close overhead at intermediate stops.

§wait_squared_weight: f64

Weight 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: f64

Weight 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

Source

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.

Source

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.

Source

pub fn with_delay_weight(delay_weight: f64) -> Self

Create with a single delay weight (backwards-compatible shorthand).

Source

pub fn with_weights( wait_weight: f64, delay_weight: f64, door_weight: f64, ) -> Self

Create with fully custom weights.

Source

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.

Source

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

Source§

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

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl DispatchStrategy for EtdDispatch

Source§

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 rank(&mut self, ctx: &RankContext<'_>) -> Option<f64>

Score the cost of sending car to stop. Lower is better. Read more
Source§

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 more
Source§

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 more
Source§

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 more
Source§

fn prepare_car( &mut self, _car: EntityId, _car_position: f64, _group: &ElevatorGroup, _manifest: &DispatchManifest, _world: &World, )

Optional hook called once per candidate car, before any rank calls for that car in the current pass. Read more
Source§

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)

Notify the strategy that an elevator has been removed. Read more
Source§

impl Serialize for EtdDispatch

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,