LegBidPriceArrayTracer

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

Bases: GenericTracer

A begin-sample tracer that records the entire bid-price arrays for specified legs.

The full bid-price array (seats-sold × days-prior) is captured at the start of each simulation sample and accumulated using a Welford online estimator. Note that because this tracer is called at the beginning of each sample, it does not reflect bid-price updates that occur during the sample (e.g., due to changes in displacement costs).

Initialize the tracer.

Parameters:
leg_ids : list[int]

IDs of the legs whose bid-price arrays should be tracked.

priority : int, optional

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

Methods

__init__(leg_ids, *[, priority])

Initialize the tracer.

attach(sim)

Attach a fresh instance of this tracer to sim as a begin-sample 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 array data to empty Welford accumulators.

Attributes

hook

Lifecycle hook shared by manual and configured attachment.

name

Identifier used to store results in SimulationTables.callback_data.

options_version

Configured-callback implementation version; bump when results change meaning.

bid_price_arrays

Mapping of leg-ID → Welford accumulator over the full bid-price array.

name : str = 'leg_bid_price_arrays'

Identifier used to store results in SimulationTables.callback_data.

options_model

Configured-callback options; fields mirror the constructor.

alias of LegBidPriceArrayTracerOptions

bid_price_arrays : dict[int, Welford]

Mapping of leg-ID → Welford accumulator over the full bid-price array.

hook : ClassVar[Literal['begin_sample', 'daily', 'end_sample']] = 'begin_sample'

Lifecycle hook shared by manual and configured attachment.

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

Initialize the tracer.

Parameters:
leg_ids : list[int]

IDs of the legs whose bid-price arrays should be tracked.

priority : int, optional

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

options_version : ClassVar[str] = '1'

Configured-callback implementation version; bump when results change meaning.

reset() → None[source]

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

fresh() → LegBidPriceArrayTracer[source]

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

Returns:

LegBidPriceArrayTracer – A freshly initialised tracer with the same leg IDs and priority but no accumulated data.

attach(sim: Simulation) → None[source]

Attach a fresh instance of this tracer to sim as a begin-sample callback.

Parameters:
sim : Simulation

The simulation to attach the callback to.

finalize() → DataFrame[source]

Aggregate accumulated Welford statistics into a tidy DataFrame.

Returns:

pd.DataFrame – A DataFrame indexed by (leg_id, SeatsSold) with columns representing days-prior values, containing the mean bid price at each cell. The DataFrame attrs n_trials and aggregation_process are set for downstream aggregation.