smif.model.model_set module

Wrap and solve a set of interdependent models

Given a directed graph of dependencies between models, any cyclic dependencies are contained within the strongly-connected components of the graph.

A ModelSet corresponds to the set of models within a single strongly- connected component. This class provides the machinery necessary to find a solution to each of the interdependent models.

The current implementation first estimates the outputs for each model in the set, guaranteeing that each model will then be able to run, then begins iterating, running every model in the set at each iteration, monitoring the model outputs over the iterations, and stopping at timeout, divergence or convergence.

Summary

Classes:

ModelSet Wraps a set of interdependent models

Reference

class smif.model.model_set.ModelSet(models, max_iterations=25, relative_tolerance=1e-05, absolute_tolerance=1e-08)[source]

Bases: smif.model.CompositeModel

Wraps a set of interdependent models

Parameters:
  • models (dict) – A dict of model_name str => model smif.model.Model
  • max_iterations (int, default=25) – The maximum number of iterations that the model set will run before returning results
  • relative_tolerance (float, default=1e-05) – Used to calculate when the model interations have converged
  • absolute_tolerance (float, default=1e-08) – Used to calculate when the model interations have converged
max_iterations

int – The maximum number of iterations

models

list – The list of smif.model.Model subclasses

simulate(data_handle)[source]

Runs a set of one or more models

Parameters:
  • timestep (int) –
  • data (dict, default=None) –
max_iteration

The maximum iteration reached before convergence