# sequences

Named routings: ordered steps through STATION blocks, walked by a ROUTE block.

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

A scenario, an experiment or an optimizer can set a field by the path `sequences.<name>.<field>`.

## 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 |  |  | The routing's name, the value of an entity's `sequence` attribute. |
| `description` | string |  |  |  | What the routing is for; the run does not read it. |
| `steps` | list of object | yes |  |  | The operations in order: each names a station and the attributes to assign there. |

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:

```json
{"blocks": [{"name": "create_1", "type": "CREATE", "position": [0, 0], "params": {"distribution": "Exponential", "dist_params": {"rate": 1.0}}}, {"name": "Lathe", "type": "STATION", "position": [200, 0], "params": {}}, {"name": "dispose_1", "type": "DISPOSE", "position": [400, 0]}], "resources": [{"name": "Server", "capacity": 1}]}
```

The fragment:

```json
{"sequences": [{"name": "Part A", "steps": [{"station": "Lathe"}]}]}
```

In the Python builder:

```python
from nagasim import build as nb
m = nb.Model()
m.add_sequence(name='Part A', steps=[{'station': 'Lathe'}])
```

## Used in

Bundled models: [Warehouse with forklifts (floor plan)](../../gallery/logistics.md), [Order-driven warehouse (library assets)](../../gallery/logistics.md), [Automation floor (robot cells, AMR, palletiser)](../../gallery/manufacturing.md), [Job shop (routed, per-product sequences)](../../gallery/manufacturing.md), [Job shop with MES digital twin](../../gallery/manufacturing.md), [Orders, due dates and tardiness](../../gallery/manufacturing.md) and 2 more.

Guides: [A plant as a timeline](../../plant-timeline.md), [Coming from Arena](../../coming-from/arena.md), [Model file format](../../model-file-format.md), [Semantic diff](../../semantic-diff.md).

## See also

- [All sections](index.md), [Model file keys](../schema.md), [Model file format](../../model-file-format.md)
