palaestrai_mosaik.mosaikpatch package¶
Submodules¶
palaestrai_mosaik.mosaikpatch.scenario module¶
This module contains a patch for mosaik’s world object.
Needs to be updated when the mosaik API changes.
Tested with mosaik version 2.6.0.
-
palaestrai_mosaik.mosaikpatch.scenario.
modify_world
(world)¶ Modify the world object for the use with palaestrAI.
A new method
trigger_actuators()
is installed, which is called by theget_input_data()
function of the modifiedscheduler
. Furthermore, themosaik.scenario.World.run()
method is overwritten by the modifiedrun()
version below.- Parameters
world (
mosaik.scenario.World
) – The world object to be modified.
-
palaestrai_mosaik.mosaikpatch.scenario.
run
(self, until, rt_factor=None, rt_strict=False, print_progress=True)¶ A modified version of the
mosaik.scenario.World.run()
method of mosaik’s world object.This
run()
method works exactly like the original one except that a different scheduler is used. Indeed, it is nearly the same code but since a modified scheduler is imported, this specific scheduler is called instead.Furthermore, the prints are replaced by logging outputs.
See the mosaik documentation https://mosaik.readthedocs.io/en/latest/api_reference/mosaik.scenario.html
mosaik.scenario.World.run()
for the regular features of this method.
palaestrai_mosaik.mosaikpatch.scheduler module¶
This module contains a modified version of the mosaik scheduler.
Since the scheduler is not a class but a collection of functions, each function of the scheduler needs to be present. For most of them, calls can be directed to the regular scheduler function. However, as soon as the mosaik scheduler changes, these changes need to be reflected here and new functions need a forward call in this module.
The only function with a modification is the
mosaik.scheduler.get_input_data()
function (and there is added
only one line of code). But to make use of this modified function, it
is required to provide copies of mosaik.scheduler.run()
and
mosaik.scheduler.sim_process()
, as well. They should be updated
on a new mosaik version.
See https://mosaik.readthedocs.io/en/latest/api_reference/mosaik.scheduler.html for the docs of the original functions.
Tested with mosaik version 2.6.0
-
palaestrai_mosaik.mosaikpatch.scheduler.
get_input_data
(world, sim)¶ Return a dictionary with the input data for sim.
The original function
mosaik.scheduler.get_input_data()
is called. Afterwards, thetrigger_actuators()
method of the modified world object is called.
-
palaestrai_mosaik.mosaikpatch.scheduler.
get_keep_running_func
(world, sim, until)¶ Return the keep_running_func.
See
mosaik.scheduler.get_keep_running_func()
.
-
palaestrai_mosaik.mosaikpatch.scheduler.
get_outputs
(world, sim)¶ Get outputs for a simulator.
See
mosaik.scheduler.get_outputs()
.
-
palaestrai_mosaik.mosaikpatch.scheduler.
get_progress
(sims, until)¶ Get simulation progress.
See
mosaik.scheduler.get_progress()
.
-
palaestrai_mosaik.mosaikpatch.scheduler.
rt_check
(rt_factor, rt_start, rt_strict, sim)¶ Check the time for real time simulation.
See
mosaik.scheduler.rt_check()
.
-
palaestrai_mosaik.mosaikpatch.scheduler.
rt_sleep
(rt_factor, rt_start, sim, world)¶ Sleep for real time simulation.
See
mosaik.scheduler.rt_sleep()
.
-
palaestrai_mosaik.mosaikpatch.scheduler.
run
(world, until, rt_factor=None, rt_strict=False, print_progress=True)¶ Run the simulation.
This is an exact copy of the current
mosaik.scheduler.run()
method.
-
palaestrai_mosaik.mosaikpatch.scheduler.
sim_process
(world, sim, until, rt_factor, rt_strict, print_progress)¶ SimPy simulation process for a certain simulator sim.
This method is an exact copy of the current
mosaik.scheduler.sim_process()
method.
-
palaestrai_mosaik.mosaikpatch.scheduler.
step
(world, sim, inputs)¶ Step the scheduler.
See
mosaik.scheduler.step()
.
-
palaestrai_mosaik.mosaikpatch.scheduler.
step_required
(world, sim)¶ Return if another step is required.
See
mosaik.scheduler.step_required()
.
-
palaestrai_mosaik.mosaikpatch.scheduler.
wait_for_dependencies
(world, sim)¶ Wait for dependencies of sim.
See
mosaik.scheduler.wait_for_dependencies()
.
Module contents¶
This module contains modified versions of some mosaik components.