register_begin_sample_callback

passengersim.callbacks.register_begin_sample_callback(callback: Callable[[CallbackMixin], dict | None] | GenericTracer | None = None, *, priority: int | None = None, skip_burn: bool | None = None, name: str | None = None) → Callable[[CallbackMixin], dict | None] | GenericTracer

Deprecated global registration for the begin_sample hook.

For a reusable callback, register it with register_callback (a function) or register_tracer (a tracer class) and select it in config.callbacks; those do not attach it to every simulation. For development and testing, use sim.begin_sample_callback(...) or an explicit CallbackMixin bundle with bundle.apply_callback_functions(sim). Calls emit DeprecationWarning.

Register a function to be triggered at the beginning of each sample.

The callback function will be triggered after initial setup including all RM steps for the initial DCP, but before any customers can arrive.

It runs at an offset, in seconds, from the trigger time of the first DCP. The offset is the priority option if given, else the callback’s own priority attribute if it has one, and otherwise one second, which is after the first DCP’s RM systems (-1) and bookkeeping (0). A negative priority runs it before that bookkeeping, or, below -1, before the first DCP’s RM steps as well. No customer arrives within five seconds of a DCP, so a priority from 1 to 4 always runs before the first arrival; a larger one may not. A priority of zero is not allowed, as for a daily callback.

callbackCallable[[Simulation], dict | None] or GenericTracer, optional

The callback function to register. It should accept a single argument, which will be the Simulation object, and return a dictionary of interesting things to store, or nothing. Omit it to use this method as a decorator with options.

priorityint, optional

Offset in seconds from the first DCP’s trigger time; see above.

skip_burnbool, optional

If True, the callback is not called during burn-in samples.

namestr, optional

Store returned dictionaries under callback_data.<name> instead of the shared hook key; for a tracer, its result name.

Callable or GenericTracer

The callback, or the fresh copy of a tracer. Without callback, a decorator that registers the function it decorates.