# scenarios

Named parameter-override sets, run and compared by `nagasim.experiments`.

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

## Typical uses

These sections control how a model is run and compared. `simulation` sets the run length, the warm-up, the replications, the units and the optional step grid and calendar. `outputs` switches on extra collection. `scenarios` are named sets of parameter overrides. `reality_checks` test a stock-and-flow model against an input and a constraint.

## Behaviour and rules

The `time_unit` is the model's base unit. Every duration without its own unit is in it. Statistics are reset at `warmup`. Each of the `replications` is an independent run with its own seed. The `deterministic` mode samples every distribution at its mean and forces one replication. Without a `time_limit`, a run ends when the model drains, which only works for a model that can drain.

`record_logs` set to false empties the three event logs and keeps every summary exact. This is what a large study wants. The `outputs` options cost memory or time, so each is off by default.

A scenario is a list of overrides applied in order to the base model. An override is a path and a value, for example `resources.Server.capacity`. An override with a missing path or value is an error. The experiments run each scenario and compare them.

## Fields

| Field | Type | Required | Default | Unit | Description |
|---|---|---|---|---|---|
| `name` | string | yes |  |  | The scenario's name, as the comparison table lists it. |
| `description` | string |  |  |  | What the scenario changes and why; shown beside it in the editor. |
| `goal` | string |  |  |  | Optional: the question this scenario answers, in a sentence. Shown in Present mode and the editor. |
| `overrides` | list of object |  |  |  | The changes this scenario makes to the base model, applied in order. |

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": "process_1", "type": "PROCESS", "position": [200, 0], "params": {"distribution": "Exponential", "dist_params": {"rate": 1.25}, "resource_name": "Server"}}, {"name": "dispose_1", "type": "DISPOSE", "position": [400, 0]}], "links": [{"source": "create_1", "target": "process_1"}, {"source": "process_1", "target": "dispose_1"}], "resources": [{"name": "Server", "capacity": 1}]}
```

The fragment:

```json
{"scenarios": [{"name": "Two servers", "overrides": [{"path": "resources.Server.capacity", "value": 2}]}]}
```

In the Python builder:

```python
from nagasim import build as nb
m = nb.Model()
m.add_scenario(name='Two servers', overrides=[{'path': 'resources.Server.capacity', 'value': 2}])
```

## Used in

Bundled models: [Berth: shore power](../../gallery/energy.md), [Biogas digester, holder and CHP](../../gallery/energy.md), [Biogas plant (library assets)](../../gallery/energy.md), [Depot: PV, EV charging and heat pump](../../gallery/energy.md), [PV + battery sizing and dispatch](../../gallery/energy.md), [PV + battery site (library assets)](../../gallery/energy.md) and 14 more.

Guides: [Run a study with an assistant](../../ai-study.md), [Model file format](../../model-file-format.md), [Investment case](../../modelling-guide/investment.md), [Python API](../../python-api.md), [Semantic diff](../../semantic-diff.md).

## See also

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