mosaik.scheduler — Coordinate and execute simulators

This module is responsible for performing the simulation of a scenario.

async World, until: int, rt_factor: Optional[float] = None, rt_strict: bool = False, lazy_stepping: bool = True)

Run the simulation for a World until the simulation time until has been reached.

Return the final simulation time.

See for a detailed description of the rt_factor and rt_strict arguments.

async mosaik.scheduler.sim_process(world: World, sim: SimRunner, until: int, rt_factor: Optional[float], rt_strict: bool, lazy_stepping: bool)

Coroutine running the simulator sim.

async mosaik.scheduler.wait_for_dependencies(world: World, sim: SimRunner, lazy_stepping: bool)None

Wait until all simulators that can provide input for this simulator have run for this step.

Also notify any simulator that is already waiting to perform its next step.

world is a mosaik World.

mosaik.scheduler.get_input_data(world: World, sim: SimRunner)InputData

Return a dictionary with the input data for sim.

The dict will look like:

    'eid': {
        'attrname': {'src_eid_0': val_0, ... 'src_eid_n': val_n},

For every entity, there is an entry in the dict and each entry is itself a dict with attributes and a list of values. This is, because we may have inputs from multiple simulators (e.g., different consumers that provide loads for a node in a power grid) and cannot know how to aggregate that data (sum, max, …?).

world is a mosaik World.

async mosaik.scheduler.step(world: World, sim: SimRunner, inputs: InputData, max_advance: int)int

Advance (step) a simulator sim with the given inputs. Return an event that is triggered when the step was performed.

inputs is a dictionary, that maps entity IDs to data dictionaries which map attribute names to lists of values (see get_input_data()).

max_advance is the simulation time until the simulator can safely advance it’s internal time without causing any causality errors.

async mosaik.scheduler.get_outputs(world: World, sim: SimRunner, progress: int)int

Wait for all required output data from a simulator sim.

world is a mosaik World.

mosaik.scheduler.get_progress(sims: Dict[SimId, SimRunner], until: int)float

Return the current progress of the simulation in percent.