Skip to content

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 for how they fit together.

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