# simulation

Run settings: time_limit, warmup, replications, time_unit, currency, entity_log_limit, and the optional real-date calendar.

Run settings; every one can be overridden per run.

In the model file this key holds an object.

## 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 |
|---|---|---|---|---|---|
| `time_limit` | number or null |  |  | time (`time_unit`) | Run length in base time units; null/0 means "run until the model drains", which only works for a model that can drain. |
| `warmup` | number |  | `0.0` | time (`time_unit`) | Statistics are reset at this time. |
| `replications` | integer |  | `1` | count | How many independent runs to make, each with its own seed. |
| `deterministic` | boolean |  | `false` |  | Deterministic run mode: every distribution samples its mean, DECIDE-by-chance uses largest-remainder allocation, a failure's TTF/TTR use their mean, and replications are forced to 1. A mean-value model, not a fluid limit; agent-based and system-dynamics parts are unaffected. |
| `time_unit` | choice |  | `"minutes"` |  | The model's BASE unit; every duration without its own unit is already in it. One of `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `weeks`, `months`, `years`. |
| `length_unit` | choice |  | `"meters"` |  | The model's length unit: default unit of new length fields and of reported lengths. One of `millimeters`, `centimeters`, `meters`, `kilometers`. |
| `currency` | string |  | `"EUR"` |  | Cost label only; never enters the arithmetic. |
| `energy_price` | number or string |  | `0` | money | Money per kWh, a number or an expression, evaluated once at run start. Prices every resource/fleet's "power". |
| `entity_log_limit` | integer or null |  |  | count | Cap on retained entity-log rows. |
| `log_level` | choice |  |  |  | What a run records: kpi (summaries only), series (plus the time series and dashboard), full (plus the entity, resource and store logs), or a profile: study (kpi), explore and replay (full). Beats record_logs and timeseries_points; a caller's level beats it. Absent: those two settings decide. One of `kpi`, `series`, `full`, `study`, `explore`, `replay`. |
| `record_logs` | boolean |  | `true` |  | Record the per-EVENT entity/resource/store logs . False returns the three flat log frames empty and leaves every summary statistic exact -- what a big study wants. |
| `strict_checks` | boolean |  | `false` |  | Stop the run on a conveyor check: an open port, overlapping or unsnapped pieces, a part handed to nothing or routed against its rule become errors with the same code. Off: they are warnings. |
| `entity_waits` | boolean |  | `false` |  | Sum each entity's queue time over every seize into a "Total Wait" column of the entity log (what a tail goal on Total Wait reads). Off: no column. |
| `timeseries_points` | integer or null |  | `200` | count | How many samples the time-series OUTPUT sampler takes over a time-limited run (default 200). |
| `timeseries_interval` | number or null |  |  | time (`time_unit`) | Fixed sampling interval for a draining run, which has no horizon to divide. |
| `timeseries_counts` | list of string |  |  |  | Blocks whose departures the sampler counts, as the series block/&lt;name&gt;/out (flattened names). What a twin compares a plant counter with; none by default. |
| `sd` | object |  |  |  | OPTIONAL system-dynamics step grid. Absent, rates change only at events. Present, every rate reading LEVEL(), FRACTION() or TNOW is re-integrated at each multiple of "dt"; static rates and events inside a step stay exact. |
| `calendar` | object |  |  |  | OPTIONAL real dates. Absent, the clock is a plain number and nothing changes. Present, model time 0 is "start" and weekday schedules, dated series and dated orders resolve against it. |

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

## Example

```json
{"simulation": {"time_limit": 480, "warmup": 60, "replications": 10, "time_unit": "minutes"}}
```

In the Python builder the section is a keyword of `Model`:

```python
from nagasim import build as nb
m = nb.Model(simulation={'time_limit': 480, 'warmup': 60, 'replications': 10, 'time_unit': 'minutes'})
```

## Used in

Bundled models: [Boids flock (continuous, heading)](../../gallery/agent-based.md), [Nagel-Schreckenberg traffic (ring)](../../gallery/agent-based.md), [Schelling segregation (grid)](../../gallery/agent-based.md), [SIR on a small-world network](../../gallery/agent-based.md), [Sugarscape with regrowth (grid, patches)](../../gallery/agent-based.md), [Wolf-Sheep predation with grass (grid)](../../gallery/agent-based.md) and 56 more.

Guides: [Agent-based modelling](../../agent-based-modelling.md), [Coming from SimPy](../../coming-from/simpy.md), [Python API](../../python-api.md), [Model file format](../../model-file-format.md), [Dates and calendars](../../modelling-guide/dates-and-calendars.md), [Quick start](../../quickstart.md) and 1 more.

## See also

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