mosaik.scheduler — Coordinate and execute simulators

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

mosaik.scheduler.run(world, until, rt_factor=None, rt_strict=False)

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.

mosaik.scheduler.sim_process(world, sim, until, rt_factor, rt_strict)

SimPy simulation process for a certain simulator sim.

mosaik.scheduler.step_required(world, sim)

Return an Event that is triggered when sim needs to perform its next step.

The event will already be triggered if the simulator is a “sink” (no other simulator depends on its outputs) or if another simulator is already waiting for it.

world is a mosaik World.

mosaik.scheduler.wait_for_dependencies(world, sim)

Return an event (simpy.events.AllOf) that is triggered when all dependencies can provide input data for sim.

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

world is a mosaik World.

mosaik.scheduler.get_input_data(world, sim)

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 aggreate that data (sum, max, ...?).

world is a mosaik World.

mosaik.scheduler.step(world, sim, inputs)

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()).

mosaik.scheduler.get_outputs(world, sim)

Get all required output data from a simulator sim, notify all simulators that are waiting for that data and prune the data flow cache. Return an event that is triggered when all output data is received.

world is a mosaik World.

mosaik.scheduler.get_progress(sims, until)

Return the current progress of the simulation in percent.