GenericTracer

class passengersim.tracers.generic.GenericTracer[source]

Bases: ABC

Base class for tracers that collect detail while a simulation runs.

Subclasses that can be enabled from a configuration declare, beside their constructor, everything a configured-callback registration needs: name, hook, options_model, and options_version. Then passengersim.callbacks.register_tracer_factory() registers the class without restating any of them.

Methods

__init__()

attach(sim)

Attach this tracer to a Simulation, which will be traced as it runs.

finalize()

Convert the internal counters on this tracer to a dataframe.

fresh()

Return a fresh copy of this tracer, tracing the same targets but not sharing state.

reset()

Reset the internal counters on this tracer to a null state.

Attributes

name

Canonical result key in callback_data.

options_model

Pydantic model of the constructor's keyword options, for configured callbacks.

options_version

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

hook

Lifecycle hook at which the tracer runs, for manual and configured attachment.

name : str = 'generic_tracer'

Canonical result key in callback_data.

hook : ClassVar[Literal['initialize_sample', 'begin_sample', 'daily', 'end_sample', 'finalize_sample']]

Lifecycle hook at which the tracer runs, for manual and configured attachment.

options_model : ClassVar[type[BaseModel] | None] = None

Pydantic model of the constructor’s keyword options, for configured callbacks.

Its fields and defaults must match the constructor’s arguments.

options_version : ClassVar[str] = '1'

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

abstractmethod reset() → None[source]

Reset the internal counters on this tracer to a null state.

abstractmethod fresh() → GenericTracer[source]

Return a fresh copy of this tracer, tracing the same targets but not sharing state.

abstractmethod attach(sim: Simulation) → None[source]

Attach this tracer to a Simulation, which will be traced as it runs.

abstractmethod finalize() → pd.DataFrame[source]

Convert the internal counters on this tracer to a dataframe.