subscripts¶
Dimensions: a record with "dims" is flattened into one record per element.
In the model file this key holds a list of subscript entries, each named by its name.
Typical uses¶
These sections add the rest of a stock-and-flow model to the levels and flows. auxiliaries are named expressions. delays are material or information delays with a delay time. subscripts are dimensions that repeat a record once for each element, such as regions or age groups. System dynamics models use them together with simulation.sd.
Behaviour and rules¶
An auxiliary is read with AUX("name") and is computed on each read. Auxiliaries that read each other in a cycle are an error. A delay is read with DELAY("name"). Its kind is material, information or pipeline. A material delay conserves the quantity, an information delay smooths a signal, and a pipeline returns the input exactly delay_time later.
Material and information delays need the step grid in simulation.sd. A pipeline does not. A delay time of 0 or less is an error. The inline forms such as SMOOTH and DELAY3 write the same records for you, and they are allowed only in a flow rate, an auxiliary or a delay input.
A record with dims is expanded into one record for each element, named Pop[north]. Inside it, a name with the dimension in brackets reads the same element. SUM(x) and MEAN(x) over x[*] aggregate across the elements. A record can give elements to replace its first expression for chosen elements.
Fields¶
| Field | Type | Required | Default | Unit | Description |
|---|---|---|---|---|---|
name |
string | yes | An identifier, written as "[name]" in a lookup. | ||
description |
string | What the dimension stands for; the run does not read it. | |||
elements |
list of string or integer | yes | Element names, in output order. | ||
parent |
string | Makes this a subrange of that dimension: its elements are a subset of the parent's. "x[North]" reads the owner's element inside an owner over North or its parent; SUM(x[North*]) sums the subset. | |||
map_to |
object | Maps this dimension element-wise onto another : inside an owner over this one, "x[dim]" reads the corresponding element (and the reverse when it is one-to-one). |
A field of a nested object is described in the JSON Schema (naga schema).
Example¶
{"subscripts": [{"name": "Region", "elements": ["north", "south"]}]}
In the Python builder:
from nagasim import build as nb
m = nb.Model()
m.add_subscript(name='Region', elements=['north', 'south'])
Used in¶
Guides: How do I total a subscripted value and remember a past one?, Semantic diff.