Skip to content

Python entry points

The signature and summary of the functions a script calls most, read from the source. Before 1.0 the Python API may change between minor versions; each such change has a changelog line. See Python API for how they fit together.

nagasim.api.run_model

run_model(path, *, replications: int | None=None, seed: int=0, warmup: float | None=None, run_length: float | None=None, workers: int | str=1, on_progress=None, should_stop=None, trace=None, bind_data: bool=False, base_dir=None, network=None, confine_to=None, feed=None, controllers: dict | None=None, pool=None, record_logs: bool | None=None, deterministic: bool | None=None) -> Results | None

Run replications replications with seeds seed, seed+1, ...

nagasim.experiments.run_scenarios

run_scenarios(layout, scenario_names=None, *, replications: int | None=None, seed: int=0, run_length: float | None=None, warmup: float | None=None, crn: bool=True, workers: int | str=1, on_progress=None, should_stop=None, pool=None) -> ExperimentResult

Run every named scenario (all of them by default) and return the results.

nagasim.experiments.run_until_precision

run_until_precision(layout, kpi: str, *, relative: float | None=0.05, absolute: float | None=None, confidence: float=0.95, n0: int=10, max_replications: int=200, seed: int=0, run_length: float | None=None, warmup: float | None=None, workers: int=1, on_progress=None, should_stop=None)

Keep adding replications until the CI half-width on kpi is small enough.

nagasim.experiments.suggest_warmup

suggest_warmup(source, *, batch: int=5) -> WarmupSuggestion

MSER-5 warm-up suggestion from a run's entity log.

nagasim.experiments.flatten_kpis

flatten_kpis(results: dict) -> pd.DataFrame

The scalar KPI frames (system/resource/store/entity/user -- everything but "timeseries", a curve rather than one number) as one long Run / KPI / Value frame, numbers only.

nagasim.optimize.optimize

optimize(layout, factors, *, response: str, goal: str='min', constraints=(), budget: int=300, replications_per_point: int=5, method: str='auto', seed: int=0, confidence: float=0.95, indifference: float | None=None, workers: int=1, run_length=None, warmup=None, max_replications_per_point=None, select_top: int=3, on_progress=None, should_stop=None, evaluator=None, warm_start_points: list[dict] | None=None, pool=None, min_improvement: float=_MIN_IMPROVEMENT, record_logs=None) -> OptimizationResult

Search the factor space for the best response within a replication budget, then confirm the winner with select_best.

nagasim.calibrate.calibrate

calibrate(layout, targets, factors, *, budget: int=200, replications_per_point: int=5, seed: int=0, workers: int=1, run_length=None, warmup=None, confidence: float=0.95, evaluator=None, on_progress=None, should_stop=None, record_logs=None) -> CalibrationResult

Tune factors until the model reproduces targets.

nagasim.forecast.forecast

forecast(layout, *, horizon: float, replications: int=100, kpis=None, events=(), bind_data: bool=True, base_dir=None, network=None, confine_to=None, seed: int=0, workers: int | str=1, confidence: float=0.95, quantiles=(0.05, 0.95), on_progress=None, should_stop=None) -> ForecastResult

Run a short terminating horizon from the system's current state.

nagasim.inputfit.best_fit

best_fit(values, *, candidates: list[str] | None=None, shift: bool=False)

The winner of fit_candidates -- best AIC, ties broken by KS -- or None when no family could be fit at all.

nagasim.modelcheck.assert_model

assert_model(path_or_layout, strict: bool=False) -> None

pytest helper: nagasim.modelcheck.assert_model("model.json") raises AssertionError naming every failed assertion/reality check, so a normal pytest failure report shows what went wrong. An inconclusive result (an assertion's CI straddles the bound) does not raise by default -- it is reported through warnings.warn instead -- unless strict=True, which treats it as a failure too.

nagasim.modelschema.build_json_schema

build_json_schema() -> dict

The current model file format as a draft 2020-12 JSON Schema.

nagasim.core.document.ModelDocument

class ModelDocument(layout: dict | None=None)

(no summary)