# resource_sets

Named groups of resources with a selection rule, seized as one pseudo-resource.

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

A scenario, an experiment or an optimizer can set a field by the path `resource_sets.<name>.<field>`. A data binding can write a field.

## Typical uses

These sections define what entities wait for and when it is available. `resources` are the machines, staff and spaces that SEIZE and PROCESS blocks request. `resource_sets` group resources so that a request takes any one of them. `schedules` give a resource a shift pattern or give a CREATE block a changing arrival rate. `failures` break resources down and repair them.

## Behaviour and rules

A resource has a `capacity` of units, a queue discipline and optional costs. The discipline is `FIFO` by default. The ranked disciplines `LowestValueFirst` and `HighestValueFirst` need a `ranking_expr`. With `rerank` on, the rank is re-evaluated before every grant.

A resource set is seized by its own name. The `rule` picks one member for each request. `PreferredOrder` tries the members in the listed order, and `Cyclical` takes turns. The member that was chosen is the one that is released later.

A schedule is a list of `[duration, value]` points. The value holds for the duration. With `repeat`, the pattern starts over, and without it the last value holds for ever. For a `capacity` schedule the value is a number of units. For an `arrival` schedule it is a rate per time unit. A weekly grid needs `simulation.calendar`.

A schedule or a failure never interrupts a job in service. The unit goes out of service when the job frees it. A resource is built at its full `capacity`, which must cover the highest value its schedule asks for. Each failure draws its own uptime and downtime for each resource it lists.

## Fields

| Field | Type | Required | Default | Unit | Description |
|---|---|---|---|---|---|
| `name` | string | yes |  |  | The set's name; a block seizes the set by this name. |
| `members` | list of string | yes |  |  | The resources in the set, in the order the rule "PreferredOrder" tries them. |
| `rule` | choice |  | `"PreferredOrder"` |  | How the set picks a member when a request arrives. One of `PreferredOrder`, `Cyclical`, `Random`, `SmallestNumberBusy`, `LargestRemainingCapacity`. |

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
{"resources": [{"name": "A"}, {"name": "B"}]}
```

The fragment:

```json
{"resource_sets": [{"name": "Pair", "members": ["A", "B"], "rule": "Cyclical"}]}
```

In the Python builder:

```python
from nagasim import build as nb
m = nb.Model()
m.add_resource_set(name='Pair', members=['A', 'B'], rule='Cyclical')
```

## Used in

Bundled models: [Job shop (Jackson network)](../../gallery/manufacturing.md), [Job shop (routed, per-product sequences)](../../gallery/manufacturing.md), [Two tellers (resource set)](../../gallery/teaching.md).

Guides: [Coming from AnyLogic](../../coming-from/anylogic.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)
