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, print_progress=True, lazy_stepping=True)¶
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, print_progress, lazy_stepping)¶
SimPy simulation process for a certain simulator sim.
- mosaik.scheduler.has_next_step(world, sim)¶
Return an
Event
that is triggered when sim has a next step.world is a mosaik
World
.
- mosaik.scheduler.wait_for_dependencies(world, sim, lazy_stepping)¶
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 aggregate that data (sum, max, …?).
world is a mosaik
World
.
- mosaik.scheduler.step(world, sim, inputs, max_advance)¶
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.
- mosaik.scheduler.get_outputs(world, sim)¶
Get all required output data from a simulator sim. Yield 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.