Skip to content

blocks

Every block in the model: name, type, position (centre, scene units), params.

In the model file this key holds a list of blocks. The type picks the block type and params holds that type's parameters (see the block reference).

A scenario, an experiment or an optimizer can set a field by the path blocks.<name>.params.<parameter>.

Typical uses

These sections describe the discrete flow of entities. blocks lists the steps and links joins them. sequences gives entities their own routes through stations. orders is a book of jobs, with release times and due dates, that a CREATE block releases. A simple model needs only blocks and links.

Behaviour and rules

The order of links is the branch order. The first link out of a DECIDE is branch 0, and a link out of a PROCESS with balking is index 1 for the entities that leave. Several links may join the same pair of blocks. A link can carry a delay, sampled for each entity that crosses it.

A sequence is a list of steps, each naming a STATION and the attributes to set there. An entity starts a sequence at step 0 when its CREATE block names it, or when an ASSIGN writes entity.sequence. A ROUTE block then walks the steps. A step that names a station without a STATION block is an error.

Orders only take effect when a CREATE block is in the Orders arrival mode. Each order releases quantity entities at its release time. The due time is absolute, not a lead time. An order may override the entity type, the sequence and the priority.

A scenario can override a block parameter with the path blocks.<name>.params.<parameter>. Every flow needs a CREATE and a DISPOSE, and a check reports a model that lacks one.

Fields

Field Type Required Default Unit Description
name string yes Unique block name; the model's identifier for it.
description string Label shown on the canvas.
type choice yes The block type; it decides which parameters the block takes. One of ASSIGN, BATCH, BUFFER, CHARGE, CONVEYOR, CONVEYOR_TRANSFER, CREATE, DECIDE, DELAY, DISPOSE, DUPLICATE, HOLD, LOGIC, MATCH, MOTION, PROCESS, RECORD, RELEASE, ROUTE, SEIZE, SEND, SEPARATE, SIGNAL, STATION, SUBMODEL, SUB_ENTRY, SUB_EXIT, TRANSFER, TRANSPORT.
position point Block CENTRE in scene units.
layout_position point Where the block sits on the FLOOR PLAN, in layout units. Absent for a block that has never been placed in layout mode, and unnecessary for one attached to a network node.
layout_rotation number How the block is turned on the FLOOR PLAN, in degrees CLOCKWISE as seen on screen (+x east, +y south); 0 or absent means unturned. Layout view only -- the schematic is never rotated. An asset's own network nodes are stored already turned.
asset_3d string The library mesh the 3D view draws for this block, written "library/asset" (for example "automation/irb6700"). Display only: a run never reads it. Absent means the view draws its own default shape.
label_offset point Where the block's NAME label was dragged to , in scene units from its default anchor, measured in the UNROTATED frame. Absent means the default position. Editor-only.
counter_offsets object Where the block's counters were dragged to, keyed out, exit:<branch> or entry:<port>, in scene units from each counter's default place. Absent means every counter is home. Editor-only.
queue_row object A placed asset's own queue row: where its waiting entities line up past its seats, over the picture's queue_anchor and queue_direction, so a row can be turned away from a neighbour. Absent means the asset's own row. It never changes a run; with slots the run counts the arrivals that find them full (the slot_summary frame).
locals object Submodel parameter bindings, written by flattening; not authored by hand.
instance_place list of number Written when a model is flattened, never by hand: [x, y, rotation] of the placed asset instance the block came from, on the floor plan; one written by hand is ignored.
params object The block type's parameters, by name (see the block reference).

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:

{"links": [{"source": "create_1", "target": "dispose_1"}]}

The fragment:

{"blocks": [{"name": "create_1", "type": "CREATE", "position": [0, 0], "params": {"distribution": "Exponential", "dist_params": {"rate": 1.0}}}, {"name": "dispose_1", "type": "DISPOSE", "position": [400, 0]}]}

In the Python builder each block type is a method named after it:

from nagasim import build as nb
m = nb.Model()
arrive = m.create(distribution=nb.Exponential(rate=1.0))
leave = m.dispose()
arrive >> leave        # links the two blocks

Used in

Bundled models: Boids flock (continuous, heading), Nagel-Schreckenberg traffic (ring), Schelling segregation (grid), SIR on a small-world network, Sugarscape with regrowth (grid, patches), Wolf-Sheep predation with grass (grid) and 52 more.

Guides: Submodels, Model file format, A plant as a timeline, Semantic diff, Coming from SimPy, Quick start.

See also