CallbackMixin

class passengersim.callbacks.base.CallbackMixin[source]

Bases: object

Methods

__init__()

add_callback_events()

Add callback events to the simulation event queue.

apply_callback_functions(sim)

begin_sample_callback(callback)

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

callback_functions()

Get all callback functions.

daily_callback(callback)

Register a function to be triggered each day during a sample.

end_sample_callback(callback)

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

use_registered_callbacks()

Adopt all globally registered callbacks.

end_sample_callback(callback: Callable[[CallbackMixin], dict | None] | GenericTracer)[source]

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

The callback function will be triggered before counters are reset or history buffers are rolled over.

Parameters:
callback : Callable[[Simulation], None]

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.

begin_sample_callback(callback: Callable[[CallbackMixin], dict | None] | GenericTracer)[source]

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.

Parameters:
callback : Callable[[Simulation], dict | None]

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.

daily_callback(callback: collections.abc.Callable[[CallbackMixin, int], dict | None] | GenericTracer | RmSys)[source]

Register a function to be triggered each day during a sample.

The callback function will be triggered after all RM steps when the day coincides with a DCP.

Parameters:
callback : Callable[[Simulation, int], dict | None]

The callback function to register. It should accept two arguments, which will be the Simulation object and the days_prior, and return None.

callback_functions() dict[str, list[Callable]][source]

Get all callback functions.

apply_callback_functions(sim: CallbackMixin)[source]
use_registered_callbacks()[source]

Adopt all globally registered callbacks.

add_callback_events()[source]

Add callback events to the simulation event queue.