# fleets

Pools of vehicles that carry entities on the network; a fleet is a resource under its own name.

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

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

## Typical uses

These sections describe things that move and the floor they move on. `network` is a path network of nodes and segments. `fleets` are pools of vehicles or workers that carry entities on it. `chargers` recharge batteries. `motion_profiles` and `zones` describe robots and their safety areas. Use them when distances and travel times matter.

## Behaviour and rules

Travel time is exact geometry: the shortest path on the network divided by the speed. A segment can limit the speed. The `length_factor` scales straight-line distances for a segment with no length of its own. A node is named by a STATION through its `node`.

A fleet is a resource under its own name. A TRANSPORT block requests one of its vehicles, which drives empty to the entity, loads, drives loaded to the destination and unloads. `dispatch` decides whose request is served when a vehicle frees, and `select` decides which idle vehicle serves it. With `park` set to `home`, an idle vehicle drives back to its `home` node.

A fleet with `kind` set to `worker` supplies people to PROCESS and SEIZE blocks through `worker_fleet`. A fleet with a `battery` drains it at its power draw and recharges at a charger when its job is done. A fleet with `motion` set to `gantry` ignores the network. A motion profile gives a robot its speed, acceleration, payload derating and a collaborative speed. A zone slows a robot to that speed when a worker is inside.

## Fields

| Field | Type | Required | Default | Unit | Description |
|---|---|---|---|---|---|
| `name` | string | yes |  |  | The fleet's name; it is also the name of the resource its vehicles form. |
| `description` | string |  |  |  | What the fleet carries; the run does not read it. |
| `count` | integer |  | `1` | count | How many vehicles the fleet has. |
| `kind` | choice |  | `"vehicle"` |  | "worker" lets a SEIZE/PROCESS summon a unit with `worker_fleet`; the pool is unchanged. One of `vehicle`, `worker`. |
| `motion` | choice |  | `"network"` |  | "gantry" travels directly between two nodes' coordinates (`speed_x`/`speed_y`/`hoist_time`), ignoring the path network and segment capacity; cannot be kind "worker". One of `network`, `gantry`. |
| `speed_x` | number |  |  | speed (`speed_unit`) | Gantry only: speed along x, distance per model time unit. |
| `speed_y` | number |  |  | speed (`speed_unit`) | Gantry only: speed along y, distance per model time unit. |
| `hoist_time` | number |  | `0.0` | time (`time_unit`) | Gantry only: fixed time added to every hop (raising and lowering the load), in `time_unit`. |
| `units` | list of object |  |  |  | Named units, replacing `count` when given. |
| `loads` | integer |  | `1` | count | Entities one vehicle may carry on a tour: up to loads - 1 waiting TRANSPORTs ride with the one granted the vehicle. 1 on a worker fleet. |
| `arm` | string |  |  |  | Name of a `motion_profiles` record: the fleet is a mobile cobot, which loads and unloads a STATION that declares `tending` with its arm. Empty or absent: an ordinary fleet. Needs kind "vehicle", motion "network" and loads 1. |
| `exchange` | boolean |  | `false` |  | Arm fleets only: a second holding place, so a cobot arriving loaded at a machine that holds a finished part picks it, places its own and carries the finished one on. |
| `speed` | number | yes |  | speed (`speed_unit`) | Loaded speed, distance per model time unit. |
| `speed_unit` | string |  | `"base"` |  | Unit of every speed of the fleet. |
| `speed_empty` | number |  |  | speed (`speed_unit`) | Speed when driving to a pick-up; defaults to `speed`. |
| `load_time` | number or string |  | `"0"` | time (`time_unit`) | Number or expression, in `time_unit`. |
| `unload_time` | number or string |  | `"0"` | time (`time_unit`) | Number or expression, in `time_unit`. |
| `time_unit` | choice |  | `"base"` |  | Unit the load and unload times are in. One of `base`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `weeks`, `months`, `years`. |
| `home` | string |  |  |  | Node the vehicles start at, and return to under `park: "home"`. |
| `park` | choice |  | `"stay"` |  | Where an idle vehicle waits: "stay" where it is, "home" back at its home node. One of `stay`, `home`. |
| `capacity_schedule` | string |  |  |  | A "capacity"-kind schedule: how many vehicles are on shift. |
| `dispatch` | choice |  | `"fifo"` |  | Whose request is served when a vehicle frees. Priority is the primary key under both. One of `fifo`, `nearest`. |
| `select` | choice |  | `"nearest"` |  | Which idle vehicle serves a granted request. One of `nearest`, `longest_idle`, `cyclic`. |
| `cost_busy` | number |  | `0.0` | rate (`cost_time_unit`) | Cost per time unit (see `cost_time_unit`) for a vehicle that is carrying. |
| `cost_idle` | number |  | `0.0` | rate (`cost_time_unit`) | Cost per time unit (see `cost_time_unit`) for a vehicle that is waiting. |
| `cost_per_use` | number |  | `0.0` | money | Cost added each time a vehicle is seized for a trip. |
| `cost_time_unit` | choice |  | `"hours"` |  | The time unit `cost_busy` and `cost_idle` are per. One of `base`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `weeks`, `months`, `years`. |
| `power` | object |  |  |  | kW per vehicle while busy/idle/blocked/down/off_shift; absent keys are 0, "blocked" defaults to "busy" (a blocked vehicle is seized). |
| `graphic` | string |  |  |  | Inline SVG vehicle picture (24 x 24 artboard, facing east) drawn for each unit on the floor plan; the editor's generic vehicle when absent. |
| `length_m` | number |  |  | length | Vehicle length in metres for the floor-plan marker (default 2.4). |
| `battery` | object |  |  |  | Each unit (vehicle, worker or gantry crane) carries a battery: it drains at the fleet's `power` kW per state and recharges at a charger once its job is done. State of charge (SoC) values are fractions, 0 to 1. |

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
{"network": {"nodes": [{"name": "A", "x": 0, "y": 0}, {"name": "B", "x": 20, "y": 0}], "segments": [{"from": "A", "to": "B"}]}}
```

The fragment:

```json
{"fleets": [{"name": "Forklifts", "count": 2, "speed": 1.5}]}
```

In the Python builder:

```python
from nagasim import build as nb
m = nb.Model()
m.add_fleet(name='Forklifts', count=2, speed=1.5)
```

## Used in

Bundled models: [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), [Warehouse with forklifts (floor plan)](../../gallery/logistics.md), [Order-driven warehouse (library assets)](../../gallery/logistics.md) and 2 more.

Guides: [Coming from AnyLogic](../../coming-from/anylogic.md), [Coming from Arena](../../coming-from/arena.md), [Digital twin](../../digital-twin.md), [Layout, paths and vehicles](../../modelling-guide/layout-paths-vehicles.md), [Semantic diff](../../semantic-diff.md).

## See also

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