Skip to content

auxiliaries

Named expressions read by AUX("name"), evaluated on read.

In the model file this key holds a list of auxiliary entries, each named by its name.

A scenario, an experiment or an optimizer can set a field by the path auxiliaries.<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 auxiliary's name, the argument of AUX("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 auxiliary computes; the run does not read it.
expr number or string yes "0" A number, or any flow-rate expression; may call AUX() of another auxiliary (no cycles) and the inline delays.
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

{"auxiliaries": [{"name": "Demand", "expr": "10 + 2"}]}

In the Python builder:

from nagasim import build as nb
m = nb.Model()
m.add_auxiliary(name='Demand', expr='10 + 2')

Used in

Bundled models: Supply line: order-rate management game, Bass diffusion, Inventory with lead time, Population (logistic), SIR epidemic, Training pipeline with attrition and 1 more.

Guides: Coming from AnyLogic, Coming from Vensim, How do I turn a heading and a distance into x and y?, How do I add a daily or weekly cycle to a rate?, How do I discount a stream of cash?, How do I add a first-order information delay to a forecast? and 7 more.

See also