Models

This is the SimKit models module that contains definitions for the Model class.

The SimKit model contains five layers: Data, Formulas, Calculations, Outputs and Simulations. The Data layer organizes Data Sources by providing methods to add and load data for SimKit. The Formulas layer loads Formulas used by Calculations calculations. The Outputs layer organizes the calculated outputs for use in other calculations. Finally the Simulations layer organizes options such as how long the simulation should run and takes care of actually running the simulation.

Model Parameter

class simkit.core.models.ModelParameter(*args, **kwargs)[source]
Parameters
  • layer (str) – name of the layer class of these parameters, optional

  • module (str) – module that the sources are defined in, optional

  • package (str) – package that the source module is contained in, optional

  • path (str) – path to source package if not on PYTHONPATH, optional

  • sources (list) – name of classes with each layers parameters

Model Base

class simkit.core.models.ModelBase[source]

Base model meta class. If model has class attributes “modelpath” and “modelfile” then layer class names and model configuration will be read from the file on that path. Otherwise layer class names will be read from the class attributes.

Model

class simkit.core.models.Model(modelfile=None)[source]

A class for models. SimKit is a subclass of the Model class.

Parameters

modelfile (str) – The name of the JSON file with model data.

add(layer, items)[source]

Add items in model.

command(cmd, progress_hook=None, *args, **kwargs)[source]

Execute a model command.

Parameters
  • cmd – Name of the command.

  • progress_hook – A function to which progress updates are passed.

delete(layer, items)[source]

Delete items in model.

edit(layer, item, delete=False)[source]

Edit model.

Parameters
  • layer (str) – Layer of model to edit

  • item (dict) – Items to edit.

  • delete (bool) – Flag to return Layer to delete item.

layers = None

dictionary of model layer classes

load(modelfile, layer=None)[source]

Load or update a model or layers in a model.

Parameters
  • modelfile (str) – The name of the json file to load.

  • layer (str) – Optionally load only specified layer.

param_file = None

model file

save(modelfile, layer=None)[source]

Save a model file.

Parameters
  • modelfile (str) – The name of the json file to save.

  • layer (str) – Optionally save only specified layer.

property state

current state of the model