# Python entry points

The functions and classes a script calls most. Each page is its docstring: parameters, return value, a runnable example and related entry points. Before 1.0 the Python API may change between minor versions; each such change has a changelog line. See the [Python API guide](../../python-api.md) for how they fit together.

| Entry point | What it does |
|---|---|
| [`nagasim.api.run_model`](run_model.md) |  |
| [`nagasim.experiments.run_scenarios`](run_scenarios.md) | Run every named scenario (all of them by default) and return the results. |
| [`nagasim.experiments.run_until_precision`](run_until_precision.md) | Keep adding replications until the confidence interval on a KPI is tight enough. |
| [`nagasim.experiments.suggest_warmup`](suggest_warmup.md) | Suggest a warm-up length from a run's entity log with MSER-5. |
| [`nagasim.experiments.flatten_kpis`](flatten_kpis.md) | Flatten the scalar KPI frames of a results dict into one long table. |
| [`nagasim.optimize.optimize`](optimize.md) | Search the factor space for the best response within a replication budget. |
| [`nagasim.calibrate.calibrate`](calibrate.md) | Tune factors until the model reproduces observed targets. |
| [`nagasim.forecast.forecast`](forecast.md) | Run a short terminating horizon from the system's current state. |
| [`nagasim.inputfit.best_fit`](best_fit.md) | Fit candidate distributions to a sample and return the winner. |
| [`nagasim.modelcheck.assert_model`](assert_model.md) | Assert, in a test, that a model passes its own assertions, reality and path checks. |
| [`nagasim.modelschema.build_json_schema`](build_json_schema.md) | Return the current model file format as a draft 2020-12 JSON Schema. |
| [`nagasim.build.Model`](Model.md) | A model written in Python; the file it produces is the model. |
| [`nagasim.results.Results`](Results.md) | What a run returns: KPI frames by name, with notebook conveniences. |
| [`nagasim.build.export_python`](export_python.md) | Return builder code for a model. |
| [`nagasim.modelfmt.minimal`](minimal.md) | Return the shortest form of a model that migrates to the same model. |
| [`nagasim.core.document.ModelDocument`](ModelDocument.md) | An in-memory model, edited only through this API. |
| [`nagasim.core.session.SimSession`](SimSession.md) | One replication of a model, driven from outside in chunks. |
| [`nagasim.rl.SimEnv`](SimEnv.md) | One RL episode = one replication of *layout*, paused at every decision of *policy*. Gymnasium-shaped but does not require gymnasium installed. |
| [`nagasim.laws.checks`](checks.md) | Every computable law and guardrail for one run (see the module docstring). |
| [`nagasim.state.take`](take.md) | The state document of *layout* at model time *at* of the run with *seed*. |
| [`nagasim.state.start`](start.md) | The model with a state document's state as its `initial_state`. |
| [`nagasim.uncertainty.input_uncertainty`](input_uncertainty.md) | Each KPI's run-to-run interval, its interval with the inputs' uncertainty, and the inputs' share of the spread. |
| [`nagasim.uncertainty.input_uncertainty_frame`](input_uncertainty_frame.md) | Each KPI's run-to-run interval, its interval with the inputs' uncertainty, and the inputs' share of the spread, as a DataFrame with one row per KPI. |
| [`nagasim.twin.forecast_from_state`](forecast_from_state.md) | The default runner: *horizon* from the clock the model's state starts at. |
| [`nagasim.twin.read_result`](read_result.md) | The latest result a twin wrote into *directory*. |
| [`nagasim.investment.investment_case`](investment_case.md) | One row per scenario of *result*, the baseline first (COLUMNS). |
