midas.scenario package

Subpackages

Submodules

midas.scenario.configurator module

This module contains the configurator for midas scenarios.

class midas.scenario.configurator.Configurator(inipath=None, datapath=None, autocfg=False)

Bases: object

This is the main configurator for midas scenarios.

The configurator takes at least a scenario name to create a fully- configured mosaik scenario.

Parameters
  • scenario_name (str) – A str containing the name of the scenario_name which should be run.

  • params (dict) – A dict with the pre-configuration for the scenario. Can be empty.

  • config (str) – A string containing the path to a custom config file.

custom_cfg

Stores the path to the custom configuration if provided

Type

str

params

A dict containing the configuration of the scenario. The dict is extended during the configuration.

Type

dict

scenario

A dict containing references to everything that is created during the configuration of the senario.

Type

dict

scenario_name

The name of the scenario created

Type

str

_apply_modules(scenario, params)

Apply all required modules in the correct order.

_organize_params(configs)

Sort params in correct order.

_save_config(name, params)

Save a copy of the current config.

configure(scenario_name, params, custom_cfgs=None, no_script=False, no_yaml=False)

Configure the midas scenario.

Will use the information provided during initialization.

Parameters
  • scenario_name (str) – The name of the scenario to run. This is a toplevel key in a scenario file.

  • params (dict) – A dict containing parameters that should overwrite values from the scenario file.

  • custom_cfgs (List[str], optional) – A list containing paths to additional scenario files.

  • no_script (bool, optional) – If set to True, no autoscript file will be generated.

  • no_yaml (bool, optional) – If set to True, the full configuration will not be saved as new yaml file.

Returns

A dict containing everything that was defined during configuration.

Return type

dict

run()

Run the scenario configured before.

midas.scenario.upgrade_module module

This module contains the abstract base class for all upgrade modules. Provides a basic workflow for the definition of new upgrades.

class midas.scenario.upgrade_module.UpgradeModule(name, log=None)

Bases: abc.ABC

Base class for upgrade modules.

_start_simulator()

Start a certain simulator instance.

abstract check_module_params()

Is called from within the upgrade method.

abstract check_sim_params(module_params, **kwargs)

Is called from within the upgrade method.

abstract connect()
connect_entities(from_entity, to_entity, attrs, **kwargs)

Connect the attrs of two entities.

connect_entities2(from_ent_key, to_ent_key, attrs, **kwargs)
abstract connect_to_db()
get_actuators()
get_sensors()
start_model(mod_key, mod_name, params)
abstract start_models()
upgrade(scenario, params)

Upgrade the scenario with this module.

Adds the functionality provided by this upgrade to the scenario, i.e., define and start a simulator in the mosaik world, instantiate models, and add connections to other existing models.

Parameters
  • scenario (dict) – The scenario dict containing reference to everything created in former upgrades.

  • params (dict) – A dict containing the content of the config files and additional information generated during other upgrades.

Module contents