mosaik.scheduler
— Coordinate and execute simulators¶
This module is responsible for performing the simulation of a scenario.
- mosaik.scheduler.run(world: World, until: int, rt_factor: Optional[float] = None, rt_strict: bool = False, lazy_stepping: bool = True) → Iterator[Event]¶
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: World, sim: SimProxy, until: int, rt_factor: Optional[float], rt_strict: bool, lazy_stepping: bool) → Iterator[Event]¶
SimPy simulation process for a certain simulator sim.
- mosaik.scheduler.has_next_step(world: World, sim: SimProxy) → Iterable[Event]¶
Return an
Event
that is triggered when sim has a next step.world is a mosaik
World
.
- mosaik.scheduler.wait_for_dependencies(world: World, sim: SimProxy, lazy_stepping: bool) → Event¶
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: World, sim: SimProxy) → 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
.
- mosaik.scheduler.step(world: World, sim: SimProxy, inputs: InputData, max_advance: int) → Generator[Event, 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.