xsimlab.Model

class xsimlab.Model(processes)

An immutable collection of process units that together form a computational model.

This collection is ordered such that the computational flow is consistent with process inter-dependencies.

Ordering doesn’t need to be explicitly provided ; it is dynamically computed using the processes interfaces.

Processes interfaces are also used for automatically retrieving the model inputs, i.e., all the variables that require setting a value before running the model.

__init__(processes)
Parameters

processes (dict) – Dictionnary with process names as keys and classes (decorated with process()) as values.

Raises

NoteAProcessClassError – If values in processes are not classes decorated with process().

Methods

__init__(processes)

param processes

Dictionnary with process names as keys and classes (decorated with

clone()

Clone the Model.

drop_processes(keys)

Drop processe(s) from this model.

execute(stage, runtime_context[, hooks, …])

Run one stage of a simulation.

get(k[,d])

items()

keys()

update_cache(var_key)

Update the model’s cache for a given model variable.

update_processes(processes)

Add or replace processe(s) in this model.

update_state(input_vars[, validate, …])

Update the model’s state (only input variables) with new values.

validate([p_names])

Run the variable validators of all or some of the processes in the model.

values()

visualize([show_only_variable, show_inputs, …])

Render the model as a graph using dot (require graphviz).

Attributes

active

all_vars

Returns all variables in the model as a list of (process_name, var_name) tuples (or an empty list).

all_vars_dict

Returns all variables in the model as a dictionary of lists of variable names grouped by process.

cache

Returns a mapping of model variables and some of their (meta)data cached for fastpath access.

dependent_processes

Returns a dictionary where keys are process names and values are lists of the names of dependent processes.

index_vars

Returns all index variables in the model as a list of (process_name, var_name) tuples (or an empty list).

index_vars_dict

Returns all index variables in the model as a dictionary of lists of variable names grouped by process.

input_vars

Returns all variables that require setting a value before running the model.

input_vars_dict

Returns all variables that require setting a value before running the model.

state

Returns a mapping of model variables and their current value.