mosaik.scheduler — Coordinate and execute simulators

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

async mosaik.scheduler.run(world, until, rt_factor=None, rt_strict=False, lazy_stepping=True)[source]

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

Return the final simulation time.

See mosaik.scenario.World.run for a detailed description of the rt_factor and rt_strict arguments.

Parameters:
  • world (World) –

  • until (int) –

  • rt_factor (Optional[float]) –

  • rt_strict (bool) –

  • lazy_stepping (bool) –

async mosaik.scheduler.sim_process(world, sim, until, rt_factor, rt_strict, lazy_stepping)[source]

Coroutine running the simulator sim.

Parameters:
async mosaik.scheduler.rt_sleep(sim, world)[source]

If in real-time mode, check if to sleep and do so if necessary.

Parameters:
Return type:

None

async mosaik.scheduler.wait_for_dependencies(sim, lazy_stepping)[source]

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.

Parameters:
Return type:

None

mosaik.scheduler.get_input_data(world, sim)[source]

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.

Parameters:
Return type:

InputData

mosaik.scheduler.get_max_advance(world, sim, until)[source]

Checks how far sim can safely advance its internal time during next step without causing a causality error.

Parameters:
Return type:

int

async mosaik.scheduler.step(world, sim, inputs, max_advance)[source]

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.

Parameters:
mosaik.scheduler.rt_check(rt_factor, rt_start, rt_strict, sim)[source]

Check if simulation is fast enough for a given real-time factor.

Parameters:
async mosaik.scheduler.get_outputs(world, sim)[source]

Wait for all required output data from a simulator sim.

world is a mosaik World.

Parameters:
mosaik.scheduler.notify_dependencies(sim)[source]

Notify all simulators waiting for us.

Parameters:

sim (SimRunner) –

Return type:

None

mosaik.scheduler.prune_dataflow_cache(world)[source]

Prunes the dataflow cache.

Parameters:

world (World) –

mosaik.scheduler.get_progress(sims, until)[source]

Return the current progress of the simulation in percent.

Parameters:
Return type:

float

mosaik.scheduler.get_avg_progress(sims, until)[source]

Get the average progress of all simulations (in time steps).

Parameters:
Return type:

int