Skip to content

initial_state

Warm start: entities already in blocks, variable values and resource states the run begins with.

Warm start: what is already in the system at t=0.

In the model file this key holds an object.

Typical uses

These sections connect a model to data. data_sources declare where data lives: a CSV or Excel file, a database, a web address, or a live plant connection. data_bindings read a column from a source, reduce it, and write the result into a model parameter. initial_state starts a run from a snapshot of a real system instead of an empty one.

Behaviour and rules

A binding names a source, a column, an optional filter and a transform, such as mean, last, table or fit. Its target is an override path such as resources.Nurse.capacity. A binding whose target does not exist is an error. A disabled binding leaves the parameter at its file value. A filter holds comparisons only, never code.

A model never holds an address or a credential. For a live source, connection names an entry in the connections file of whoever runs the model. A file path is relative to the model file. Network access, redirects and the size of what is read are limited, and the caller, not the file, decides whether the network may be used.

An initial_state places entities in blocks, sets variables, levels and resource states, and sets the clock. Statistics then cover the run from that clock, as after a warm-up of that length. A state that names a block the model does not have is an error. The schedule_offset makes a mid-shift start resume the shift.

Fields

Field Type Required Default Unit Description
time number time (time_unit) Timestamp of the snapshot this state came from; recorded for the report, never shifts the clock.
time_unit choice "base" Unit time is in. One of base, milliseconds, seconds, minutes, hours, days, weeks, months, years.
clock number The model time the run's clock starts at (default 0): the time a state was taken at. Statistics cover the run from there, as after a warm-up of that length.
schedule_offset number How far into its own cycle the calendar already is at model time 0, in base time units. Every schedule and every repeating time-series input is read at t + this, so a mid-shift warm start resumes the shift instead of restarting it.
arrivals object Per CREATE block: the arrivals already made and the absolute time of the next one.
orders object Per declared order released before the clock: the entities it released and completed, and when the last one completed.
resource_sets object Per resource set: the index of the member a Cyclical set picked last (-1: none yet).
blocks object Per block, what it carries: a changeover's setup key its last job left; a BATCH's running maximum wait, the time it falls due; a CONVEYOR's next free entry slot and when the last part left each of its points and its end; for a slot row that frees at move_end, when each load still moving out of it frees its slot.
variables object Model variable values to start from.
fleets object Where each vehicle of a fleet is: one record per unit, in unit order. Times are absolute.
levels object Level values to start from: the state of charge of a battery, the stock on hand in a warehouse.
used list of string The resources, sets and stores something happened to before the clock: they keep their report row.
entities list of object The entities already in the system at time 0, with the block each one starts in.
resources object The state of resources at time 0, by resource name.
order_book list of object The orders the run releases instead of the model's "orders" section: the plant's book, by id. A state from a plant writes it.
tended list of list of string The tending stations at the take: [station, fleet] pairs. A taken state writes it.

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

Example

The fragment refers to entries that are defined elsewhere in the same file:

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

The fragment:

{"initial_state": {"variables": {"batch_size": 3}}}

In the Python builder the section is a keyword of Model:

from nagasim import build as nb
m = nb.Model(initial_state={'variables': {'batch_size': 3}})

Used in

Bundled models: Walk-in clinic digital twin.

Guides: Digital twin, Agent-based modelling, Model file format, Dates and calendars.

See also