PathBidPriceTracer

class passengersim.tracers.bid_price.PathBidPriceTracer(path_ids: list[int], *, priority: int = 1)[source]

Bases: _BidPriceTracer

A daily tracer that records the bid prices for specified paths.

At each day, the total bid price for each tracked path is captured and accumulated using a Welford online estimator, so that the mean and standard deviation across simulation samples can be computed efficiently.

Initialize the tracer.

Parameters:
path_ids : list[int]

IDs of the paths whose bid prices should be tracked.

priority : int, optional

Callback priority. Lower values run first. Defaults to 1.

Methods

__init__(path_ids, *[, priority])

Initialize the tracer.

attach(sim)

Attach a fresh instance of this tracer to sim as a daily callback.

finalize()

Aggregate accumulated Welford statistics into a tidy DataFrame.

fresh()

Return a new, empty tracer of the same type and configuration.

reset()

Reset all accumulated bid-price data to empty Welford accumulators.

Attributes

name

Identifier used to store results in SimulationTables.callback_data.

bid_prices

Nested mapping of entity-ID → days-prior → Welford accumulator.

name : str = 'path_bid_prices'

Identifier used to store results in SimulationTables.callback_data.

__init__(path_ids: list[int], *, priority: int = 1)[source]

Initialize the tracer.

Parameters:
path_ids : list[int]

IDs of the paths whose bid prices should be tracked.

priority : int, optional

Callback priority. Lower values run first. Defaults to 1.

attach(sim: Simulation) None

Attach a fresh instance of this tracer to sim as a daily callback.

Parameters:
sim : Simulation

The simulation to attach the callback to.

finalize() DataFrame

Aggregate accumulated Welford statistics into a tidy DataFrame.

Returns:

pd.DataFrame – A DataFrame with a MultiIndex of (statistic, days_prior) containing mean and sample standard deviation bid prices for each tracked entity. The DataFrame attrs n_trials and aggregation_process are set for downstream aggregation.

fresh() _BidPriceTracer

Return a new, empty tracer of the same type and configuration.

Returns:

_BidPriceTracer – A freshly initialized tracer of the same concrete type, with the same IDs and priority but no accumulated data.

reset() None

Reset all accumulated bid-price data to empty Welford accumulators.

bid_prices : dict[int, dict[int, Welford]]

Nested mapping of entity-ID → days-prior → Welford accumulator.