LegBidPriceVectorTracer

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

Bases: GenericTracer

A daily tracer that records the entire bid-price vector for specified legs.

At each day prior to departure, the current bid-price vector (one entry per seats-sold level) is captured for each tracked leg and accumulated using a Welford online estimator.

Initialize the tracer.

Parameters:
leg_ids : list[int]

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

priority : int, optional

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

Methods

__init__(leg_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 vector data to empty Welford accumulators.

Attributes

name

Identifier used to store results in SimulationTables.callback_data.

bid_price_vectors

Nested mapping of leg-ID → days-prior → Welford accumulator over the bid-price vector.

name : str = 'leg_bid_price_vectors'

Identifier used to store results in SimulationTables.callback_data.

bid_price_vectors : dict[int, dict[int, Welford]]

Nested mapping of leg-ID → days-prior → Welford accumulator over the bid-price vector.

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

Initialize the tracer.

Parameters:
leg_ids : list[int]

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

priority : int, optional

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

reset() None[source]

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

fresh() LegBidPriceVectorTracer[source]

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

Returns:

LegBidPriceVectorTracer – 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 daily 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, days_prior, SeatsSold) with a single column containing the mean bid price at each cell. The DataFrame attrs n_trials and aggregation_process are set for downstream aggregation.