run_scenarios¶
Python reference for nagasim.experiments.run_scenarios.
Run every named scenario (all of them by default) and return the results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout
|
dict
|
The model, with a |
required |
scenario_names
|
list of str
|
A subset to run. The baseline runs too, unless baseline is False. |
None
|
replications
|
optional
|
Fall back to the model's own |
None
|
run_length
|
optional
|
Fall back to the model's own |
None
|
warmup
|
optional
|
Fall back to the model's own |
None
|
seed
|
int
|
Base seed. |
0
|
crn
|
bool
|
Common random numbers: replication |
True
|
workers
|
int or 'auto'
|
|
1
|
on_progress
|
callable
|
|
None
|
should_stop
|
callable
|
Stops between replications and leaves |
None
|
pool
|
ProcessPoolExecutor
|
A pool the caller owns and reuses across studies (best built with
|
None
|
baseline
|
bool
|
False skips the baseline, for a caller that keeps the baseline's results from an earlier run; the result then has nothing to compare against until the caller adds it. |
True
|
logic
|
str or module
|
The caller's LOGIC module, as |
None
|
controllers
|
dict
|
|
None
|
keep_empty
|
bool
|
Also keep each scenario's frames with no rows, as |
False
|
log_level
|
str
|
The run log level of every scenario, as |
None
|
Returns:
| Type | Description |
|---|---|
ExperimentResult
|
Per-scenario results and |
Notes
The unit of parallel work is one (scenario, replication), so five scenarios of one replication each fill five workers.
See Also
nagasim.api.run_model : One model, no scenarios. nagasim.optimize.optimize : Search the space instead of naming the points.
Examples:
>>> import json
>>> from pathlib import Path
>>> import nagasim
>>> from nagasim import experiments
>>> path = Path(nagasim.__file__).parent / "models" / "single_server.json"
>>> layout = json.loads(path.read_text(encoding="utf-8"))
>>> layout["scenarios"] = [{"name": "Faster server", "overrides": [
... {"path": "blocks.process_1.params.dist_params.rate", "value": 1.6}]}]
>>> experiment = experiments.run_scenarios(layout, replications=3, run_length=200, warmup=20, seed=0)
>>> sorted(experiment.results)
['Baseline', 'Faster server']