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 fromsmif.cli.run_model()
. SosModel inherits fromsmif.composite.Model
.Parameters: name (str) – The unique name of the SosModel -
add_model
(model)[source]¶ Adds a sector model to the system-of-systems model
Parameters: model ( smif.sector_model.SectorModel
) – A sector model wrapper
-
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
-
-
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 aSosModel
object andSosModelBuilder.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
-