Skip to content

variables

Model-level variables, read and written by expressions; reset to initial each replication.

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

A scenario, an experiment or an optimizer can set a field by the path variables.<name>.<field>. A data binding can write a field.

Typical uses

These sections hold the values that expressions read. variables are numbers that a model changes while it runs. tables are fixed lookups by one or two keys. timeseries_inputs are profiles over time, such as a tariff or a demand curve. entities describe the entity types: how they look and what holding them costs.

Behaviour and rules

A variable is read as a bare name in an expression and written by an ASSIGN block. Its initial value is restored at the start of every replication. A table is read with TABLE("name", key) or with two keys for a 2-D table. The key_mode decides what happens between keys: exact, step or linear. A missing exact key is a run-time error unless the table has a default.

A time series is read with TS("name") for now, or with a second argument for another time. Its interpolation is step by default, which is exact for a rate. Past the last sample, beyond decides whether the last value holds, the series repeats, or the run stops with an error. Sample times must increase.

An entity type is named by the e_type of a CREATE block. A holding_cost charges each entity for the time it spends in the system, from its creation to its disposal, and only time after the warm-up counts.

Fields

Field Type Required Default Unit Description
name string yes The variable's name; expressions read it as a bare name.
initial number or string or boolean 0 Its value at the start of each replication: a number, a boolean or an expression.
trace boolean Written by flattening for a variable an asset's picture follows; not authored by hand.

A field of a nested object is described in the JSON Schema (naga schema).

Example

{"variables": [{"name": "batch_size", "initial": 5}]}

In the Python builder:

from nagasim import build as nb
m = nb.Model()
m.add_variable(name='batch_size', initial=5)

Used in

Bundled models: Berth: shore power, Biogas digester, holder and CHP, Biogas plant (library assets), PV + battery sizing and dispatch, PV + battery site (library assets), Emergency department: staffing game and 8 more.

Guides: Digital twin, Model file format, Coming from Arena, How do I stop a ratio dividing by zero?, Expressions and variables, Semantic diff.

See also