pub struct PoissonSource { /* private fields */ }Expand description
Poisson-arrival traffic generator with time-varying patterns.
Uses an exponential inter-arrival time model: each tick, the generator
checks whether enough time has elapsed since the last spawn. The mean
interval comes from
PassengerSpawnConfig::mean_interval_ticks.
Origin/destination pairs are sampled from a TrafficSchedule that
selects the active TrafficPattern based on the current tick.
§Example
use elevator_core::traffic::PoissonSource;
// From a SimConfig (reads stops and spawn parameters).
let mut source = PoissonSource::from_config(&config);
// Or build manually.
let mut source = PoissonSource::new(
stops,
TrafficSchedule::office_day(3600),
120, // mean_interval_ticks
(60.0, 90.0), // weight_range
);Implementations§
Source§impl PoissonSource
impl PoissonSource
Sourcepub fn new(
stops: Vec<StopId>,
schedule: TrafficSchedule,
mean_interval_ticks: u32,
weight_range: (f64, f64),
) -> Self
pub fn new( stops: Vec<StopId>, schedule: TrafficSchedule, mean_interval_ticks: u32, weight_range: (f64, f64), ) -> Self
Create a new Poisson traffic source.
stops should be sorted by position (lowest first) to match
TrafficPattern expectations (first stop = lobby).
If weight_range.0 > weight_range.1, the values are swapped.
Sourcepub fn from_config(config: &SimConfig) -> Self
pub fn from_config(config: &SimConfig) -> Self
Create a Poisson source from a SimConfig.
Reads stop IDs from the building config and spawn parameters from
passenger_spawning. Uses a constant TrafficPattern::Uniform schedule
by default — call with_schedule to override.
Sourcepub fn with_schedule(self, schedule: TrafficSchedule) -> Self
pub fn with_schedule(self, schedule: TrafficSchedule) -> Self
Replace the traffic schedule.
Sourcepub const fn with_mean_interval(self, ticks: u32) -> Self
pub const fn with_mean_interval(self, ticks: u32) -> Self
Replace the mean arrival interval.
Sourcepub const fn with_weight_range(self, range: (f64, f64)) -> Self
pub const fn with_weight_range(self, range: (f64, f64)) -> Self
Replace the weight range.
If range.0 > range.1, the values are swapped.