delays¶
Delays read by DELAY("name"): input, delay time, kind and order.
In the model file this key holds a list of delay entries, each named by its name.
A scenario, an experiment or an optimizer can set a field by the path delays.<name>.<field>.
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 | The delay's name, the argument of DELAY("name"). | ||
dims |
list of string | Subscripts this record runs over: it is flattened into one record per element, named "Name[north]" ("Name[north,young]" for two). Inside, "x[dim]" in a LEVEL/FLOW/AUX/DELAY name reads the same element, and SUM(x)/MEAN(x) aggregate over "x[*]". | |||
elements |
object | Per-element equations: {"north": "2", "a,x": "3"} replaces the record's first expression (a level's initial, a flow's rate, an auxiliary's expr, a delay's input) for those elements; the shared one covers the rest. Keys join one element per dim with a comma. | |||
description |
string | What the delay stands for; the run does not read it. | |||
input |
string or number | "0" |
What is delayed: a rate for a material delay, a value otherwise; the sampled value for "sample" (required for every kind but "noise"). | ||
delay_time |
string or number | "1" |
time (delay_time_unit) |
tau, in the model's base time unit (> 0); a pipeline reads it once at run start. Required for material/information/pipeline only. | |
delay_time_unit |
choice | "base" |
Unit delay_time is in. One of base, milliseconds, seconds, minutes, hours, days, weeks, months, years. |
||
kind |
choice | "material" |
The kind of delay; the section's description says what each one does. One of material, information, pipeline, sample, noise. |
||
order |
integer | 1 |
count | Number of stages (material/information). | |
initial |
string or number | 0 |
The output at t=0 (not "noise", which has none). | ||
condition |
string or number | "sample" only: sampled again whenever true. | |||
mean |
string or number | "noise" only. | |||
sd |
string or number | "noise" only. | |||
lo |
string or number | "noise" only: clip floor. | |||
hi |
string or number | "noise" only: clip ceiling. | |||
unit |
string | Label only. | |||
diagram |
object | Position in the stock-and-flow view; ignored by the engine. | |||
locals |
object | Submodel parameter bindings, written by flattening; not authored by hand. |
A field of a nested object is described in the JSON Schema (naga schema).
Example¶
{"delays": [{"name": "Shipping", "kind": "pipeline", "input": "5", "delay_time": "3"}]}
In the Python builder:
from nagasim import build as nb
m = nb.Model()
m.add_delay(name='Shipping', kind='pipeline', input='5', delay_time='3')
Used in¶
Guides: How do I total a subscripted value and remember a past one?, Semantic diff.