smif.modelrun module

The Model Run collects scenarios, timesteps, narratives, and model collection into a package which can be built and passed to the ModelRunner to run.

The ModelRunner is responsible for running a ModelRun, including passing in the correct data to the model between timesteps and calling to the DecisionManager to obtain decisions.

ModeRun has attributes: - id - description - sosmodel - timesteps - scenarios - narratives - strategy - status

Summary

Exceptions:

ModelRunError Raise when model run requirements are not satisfied

Classes:

ModelRun Collects timesteps, scenarios , narratives and a SosModel together
ModelRunBuilder Builds the ModelRun object from the configuration
ModelRunner Runs a ModelRun

Reference

class smif.modelrun.ModelRun[source]

Bases: object

Collects timesteps, scenarios , narratives and a SosModel together

name

str – The unique name of the model run

timestamp

datetime.datetime – An ISO8601 compatible timestamp of model run creation time

description

str – A friendly description of the model run

sos_model

smif.model.sos_model.SosModel – The contained SosModel

scenarios

dict – For each scenario set, a mapping to a valid scenario within that set

narratives

list – A list of smif.parameters.Narrative objects

strategies

dict

status

str

logger

logging.Logger

results

dict

as_dict()[source]

Serialises smif.modelrun.ModelRun

Returns a dictionary definition of a ModelRun which is equivalent to that required by smif.modelrun.ModelRunBuilder to construct a new model run

Returns:
Return type:dict
model_horizon

Returns the list of timesteps

Returns:A list of timesteps, distinct and sorted in ascending order
Return type:list
run(store, warm_start_timestep=None)[source]

Builds all the objects and passes them to the ModelRunner

The idea is that this will add ModelRuns to a queue for asychronous processing

class smif.modelrun.ModelRunner[source]

Bases: object

Runs a ModelRun

solve_model(model_run, store)[source]

Solve a ModelRun

This method first calls smif.model.SosModel.before_model_run() with parameter data, then steps through the model horizon, calling smif.model.SosModel.simulate() with parameter data at each timestep.

Parameters:model_run (smif.modelrun.ModelRun) –
class smif.modelrun.ModelRunBuilder[source]

Bases: object

Builds the ModelRun object from the configuration

construct(model_run_config)[source]

Set up the whole ModelRun

Parameters:model_run_config (dict) – A valid model run configuration dictionary
finish()[source]

Returns a configured model run ready for operation

exception smif.modelrun.ModelRunError[source]

Bases: Exception

Raise when model run requirements are not satisfied