LegBidPriceArrayTracer¶
-
class passengersim.tracers.bid_price.LegBidPriceArrayTracer(leg_ids: list[int], *, priority: int =
1)[source]¶ Bases:
GenericTracerA 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:
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
Identifier used to store results in
SimulationTables.callback_data.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.
- bid_price_arrays : dict[int, Welford]¶
Mapping of leg-ID → Welford accumulator over the full bid-price array.
- 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 attrsn_trialsandaggregation_processare set for downstream aggregation.