# ROUTE

Sends a part or job to the next station on its own routing sequence (a job-shop or multi-step route) instead of along a fixed link.

Send the entity to the next station of its `sequence`, applying that step's attribute values and advancing its `step` index; once the sequence is finished, forward along the block's own outgoing link instead.

Family: control. Python builder: `m.route(...)`.

## Typical uses

Use ROUTE for job shops and multi-step routings where each entity carries its own list of stations. The entity jumps to the next station in its sequence, with no drawn link. For a fixed route that every entity follows, ordinary links are simpler. To pick a link by chance or condition, use [DECIDE](decide.md). To carry the entity with a vehicle, use [TRANSPORT](transport.md).

## Behaviour and rules

The entity must carry a `sequence`, a name from the `sequences` section, and a `step` index. Set the sequence on the CREATE block or with an ASSIGN to `entity.sequence`. An entity with no sequence, or one with an unknown name, stops the run with an error. A step that names a station without a STATION block does too.

At each visit, the block copies the step's `values` onto the entity, advances `step` and sends the entity to the step's STATION. It then continues from that station's link. When the sequence is finished, the entity leaves ROUTE by its own outgoing link, so a DISPOSE can follow.

In `time` travel mode, the transfer time is the block's distribution, which can read `from_station` and `to_station`, for example from a distance table. In `network` travel mode, the time is the shortest path on the path network at the `speed`. The destination station needs a `node`, and the speed must be above 0. An entity with no station yet arrives at once.

## Ports

- Inputs: any number of incoming links.
- Outputs: one outgoing link.

## Parameters

| Parameter | Type | Default | Required | Quantity | Unit key | Description |
|---|---|---|---|---|---|---|
| `distribution` | str | `'Constant'` |  |  |  | Name of a registered distribution (see the distribution reference). |
| `dist_params` | dict | `{'value': 0.0}` |  | time | `time_unit` | Parameters for `distribution`, by name (e.g. {"rate": 0.5} for Exponential). |
| `time_unit` | str | `'base'` |  |  |  | Unit the sampled duration is expressed in: "base" (the model's own unit, no conversion) or one of seconds/minutes/hours/days. |
| `travel` | str | `'time'` |  |  |  | How the transfer time is found: "time" uses the distribution above, "network" divides the shortest path between the two stations' nodes by `speed`. |
| `speed` | str | `''` |  | speed | `speed_unit` | Travel speed for `travel = "network"`, an expression in distance per time unit (e.g. 1.2, or `entity.walk_speed`). Empty means 1. |
| `speed_unit` | str | `'base'` |  |  |  | Unit of `speed`: "base" (the model's) or one of its quantity's units. |

## Statistics

Every run fills `system` and `entity_summary` (see the [KPI reference](../kpis.md)). The example below also fills:

| Frame | Columns |
|---|---|
| [`resource_summary`](../kpis.md#resource_summary) | `Run`, `Resource`, `Total Seizes`, `Usage % (snapshot)`, `Idle %`, `Scheduled Capacity Avg`, `Down %`, `Busy Cost`, `Idle Cost`, `Usage Cost`, `Total Cost`, `Queue Length Avg`, `Queue Length Max`, `Queue Length at End`, `Queue Length Mode`, `Queue Length Mode %`, `Queue Len P95`, `Queue Len P99`, `Queue Len Std`, `Time in Queue Avg`, `Time in Queue Avg (incl. waiting)`, `Time in Queue Max`, `Time in Queue Mode`, `Time in Queue Mode %`, `Wait P95`, `Wait P99`, `Wait Std`, `Bottleneck Score`, `Bottleneck %` |
| `material_flow_summary` | `Run`, `From`, `To`, `Entities` |

## Problem codes

A check of the model reports these about this block:

| Code | Meaning |
|---|---|
| `E_ROUTE_NO_SEQUENCES` | A ROUTE block exists but the model declares no stations or sequences. |
| `E_TRAVEL_MODE` | A ROUTE/TRANSPORT travel mode is unknown, or needs a network the model does not declare. |

## Example

The snippet seeds itself; its output is from a run made when this page was generated.

```python
from nagasim import build as nb

m = nb.Model(time_limit=500)
m.add_resource(name="Saw")
m.add_resource(name="Drill")
m.add_sequence(name="Bracket", steps=[
    {"station": "Cutting", "values": {"process_time": 2.0}},
    {"station": "Drilling", "values": {"process_time": 3.0}},
])
route = m.route()
cutting = m.station("Cutting")
drilling = m.station("Drilling")
saw = m.process(resource_name="Saw", distribution=nb.Constant(value="entity.process_time"))
drill = m.process(resource_name="Drill", distribution=nb.Constant(value="entity.process_time"))
m.create(distribution=nb.Exponential(rate=0.2), sequence="Bracket") >> route
cutting >> saw >> route
drilling >> drill >> route
route >> m.dispose()

results = m.run(seed=1)
print(int(results.kpi("resource/Saw/Total Seizes")), "parts cut,", int(results.kpi("resource/Drill/Total Seizes")), "drilled")
print(round(results.kpi("system/Avg Throughput Time"), 2), "time units from start to finish, on average")
```

```text
100 parts cut, 99 drilled
6.68 time units from start to finish, on average
```

## Used in

Bundled models: [Warehouse with forklifts (floor plan)](../../gallery/logistics.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), [Order shop ranked by priority](../../gallery/manufacturing.md), [Emergency department: bedside scan (film template)](../../gallery/services.md).

Guides: [Layout, paths and vehicles](../../modelling-guide/layout-paths-vehicles.md), [Model file format](../../model-file-format.md), [Coming from Arena](../../coming-from/arena.md), [Event log to model](../../event-log-to-model.md), [Finite buffers and blocking after service](../../modelling-guide/finite-buffers.md), [Planning and scheduling](../../modelling-guide/planning.md) and 1 more.

## See also

- [All blocks](index.md), [KPI reference](../kpis.md), [Model file keys](../schema.md), [Model file format](../../model-file-format.md)
- Same family (control): [DECIDE](decide.md), [HOLD](hold.md), [LOGIC](logic.md), [SEND](send.md), [SIGNAL](signal.md)
