# orders

Released jobs with a due date, emitted by a CREATE block in "Orders" arrival mode.

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

A scenario, an experiment or an optimizer can set a field by the path `orders.<id>.<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 |
|---|---|---|---|---|---|
| `id` | string | yes |  |  | Unique; the KPI frames report the order under it. |
| `description` | string |  |  |  | A note on the job; the run does not read it. |
| `release` | number or string |  | `0.0` | time (`time_unit`) | When the order is released into the model. An ISO timestamp instead of a number needs a calendar. |
| `due` | number or string or null |  |  | time (`time_unit`) | Absolute due time, not a lead time; null = no due date. May be an ISO timestamp. |
| `time_unit` | choice |  | `"base"` |  | Unit `release` and `due` are in (a dated value ignores it). One of `base`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `weeks`, `months`, `years`. |
| `quantity` | integer |  | `1` |  | Entities this order releases. |
| `entity_type` | string |  |  |  | Overrides the CREATE block's own e_type. |
| `sequence` | string |  |  |  | Name of a declared routing the entities follow. |
| `priority` | number |  |  |  | Carried as entity.priority. |
| `source` | string |  |  |  | CREATE block that releases it; omit for the first CREATE in "Orders" mode. |
| `attributes` | object |  |  |  | Further attributes assigned onto every entity of this order. |
| `plan` | object |  |  |  | {station: planned start}, carried as entity.plan and read by the "Plan" queue discipline (cpsat.propose writes it). |

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

## Example

```json
{"orders": [{"id": "J1", "release": 0, "due": 120}]}
```

In the Python builder:

```python
from nagasim import build as nb
m = nb.Model()
m.add_order(id='J1', release=0, due=120)
```

## Used in

Bundled models: [Berth: shore power](../../gallery/energy.md), [Hub day: electrifying the ground support equipment](../../gallery/logistics.md), [Container terminal: electrification](../../gallery/logistics.md), [Container terminal: quay to yard](../../gallery/logistics.md), [Hub day: turnaround workload (crews, ground equipment, on-time departures)](../../gallery/logistics.md), [Job shop with MES digital twin](../../gallery/manufacturing.md) and 2 more.

Guides: [Model file format](../../model-file-format.md), [Live data](../../live-data.md), [Dates and calendars](../../modelling-guide/dates-and-calendars.md), [Semantic diff](../../semantic-diff.md).

## See also

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