smif.model.sos_model module

This module coordinates the software components that make up the integration framework.

A system of systems model contains simulation and scenario models, and the dependencies between the models.

Summary

Classes:

SosModel Consists of the collection of models joined via dependencies
SosModelBuilder Constructs a system-of-systems model

Reference

class smif.model.sos_model.SosModel(name)[source]

Bases: smif.model.CompositeModel

Consists of the collection of models joined via dependencies

This class is populated at runtime by the SosModelBuilder and called from smif.cli.run_model(). SosModel inherits from smif.composite.Model.

Parameters:name (str) – The unique name of the SosModel
as_dict()[source]

Serialize the SosModel object

Returns:
Return type:dict
add_model(model)[source]

Adds a sector model to the system-of-systems model

Parameters:model (smif.sector_model.SectorModel) – A sector model wrapper
before_model_run(data_handle)[source]

Initialise each model (passing in parameter data only)

simulate(data_handle)[source]

Run the SosModel

Parameters:data_handle (smif.data_layer.DataHandle) – Access state, parameter values, dependency inputs
Returns:results – Access model outputs
Return type:smif.data_layer.DataHandle
make_dependency_graph()[source]

For each contained model, compare dependency list against list of available models and build the dependency graph

timestep_before(timestep)[source]

Returns the timestep previous to a given timestep, or None

Parameters:timestep (str) –
Returns:
Return type:str
timestep_after(timestep)[source]

Returns the timestep after a given timestep, or None

Parameters:timestep (str) –
Returns:
Return type:str
intervention_names

Names (id-like keys) of all known asset type

sector_models

Sector model objects contained in the SosModel

Returns:A dict of sector model objects
Return type:dict
scenario_models

Scenario model objects contained in the SosModel

Returns:A dict of scenario model objects
Return type:dict
class smif.model.sos_model.SosModelBuilder(name='global')[source]

Bases: object

Constructs a system-of-systems model

Builds a SosModel.

Parameters:name (str, default='') – The unique name of the SosModel

Examples

Call SosModelBuilder.construct() to populate a SosModel object and SosModelBuilder.finish() to return the validated and dependency-checked system-of-systems model.

>>> builder = SosModelBuilder('test_model')
>>> builder.construct(config_data, timesteps)
>>> sos_model = builder.finish()
construct(sos_model_config)[source]

Set up the whole SosModel

Parameters:sos_model_config (dict) – A valid system-of-systems model configuration dictionary
add_dependencies(dependency_list)[source]

Add dependencies between models

Parameters:dependency_list (list) – A list of dicts of dependency configuration data

Examples

>>> dependencies = [{'source_model': 'raininess',
                     'source_model_output': 'raininess',
                     'sink_model': 'water_supply',
                     'sink_model_input': 'raininess'}]
>>> builder.add_dependencies(dependencies)
set_max_iterations(config_data)[source]

Set the maximum iterations for iterating class::smif.ModelSet to convergence

set_convergence_abs_tolerance(config_data)[source]

Set the absolute tolerance for iterating class::smif.ModelSet to convergence

set_convergence_rel_tolerance(config_data)[source]

Set the relative tolerance for iterating class::smif.ModelSet to convergence

load_models(model_list)[source]

Loads the sector models into the system-of-systems model

Parameters:model_list (list) – A list of SectorModel objects
load_scenario_models(scenario_list)[source]

Loads the scenario models into the system-of-systems model

Parameters:scenario_list (list) – A list of ScenarioModel objects
check_dependencies()[source]

For each contained model, compare dependency list against list of available models

finish()[source]

Returns a configured system-of-systems model ready for operation

Includes validation steps, e.g. to check dependencies