Skip to main content

Run, sweep, and analyze JuPedSim scenarios from the web-app JSON schema.

Project description

jupedsim-scenarios

CI PyPI version Python versions Downloads Ruff Checked with mypy License: MIT

Python toolkit for running, sweeping, and analyzing JuPedSim scenarios authored in the Web-Based JuPedSim editor.

Intro video (3 min): Watch the intro

Install

pip install jupedsim-scenarios

For development from a clone:

pip install -e ".[dev]"

Single-run usage

from jupedsim_scenarios import load_scenario, run_scenario

scenario = load_scenario("my_scenario.zip")
result = run_scenario(scenario, seed=42)
print(result.evacuation_time)
df = result.trajectory_dataframe()
result.cleanup()

load_scenario accepts a ZIP archive, a directory containing <name>.json + <name>.wkt, or a single self-contained JSON file (geometry embedded as walkable_area_wkt).

To build a Scenario in pure Python — without going through a web-app export — see examples/howtos/08_build_from_scratch.ipynb.

Quick CLI: run a ZIP and bundle the trajectory

examples/run_zip.py loads a scenario ZIP, runs it, prints summary metrics (evacuation time, wall-clock time, agent counts), and writes <name>_run.zip containing the original config.json + geometry.wkt plus trajectory.sqlite — ready to drop back into the web app for visualization.

python examples/run_zip.py my_scenario.zip [seed]

Mutating a scenario — copy first, then assign

Scenario is a mutable object. Direct assignments and add_* / remove_* / set_* calls all change the instance in place:

base = load_scenario(...)
base.seed = 99            # this mutates `base` — every later use sees seed=99

That's fine when you only want one variant. For sweeps or any time you want to keep the original intact, call .copy() first and edit the clone:

trial = base.copy()
trial.seed = 99
trial.max_simulation_time = 60
# base is untouched

run_sweep does this for you per trial. The pattern only matters when you build variants manually (see examples/howtos/10_sweep_via_copy.ipynb).

Monte Carlo sweep

from jupedsim_scenarios import load_scenario, run_sweep

base = load_scenario("faster_is_slower.zip")

sweep = run_sweep(
    base,
    axes={"v0": [0.8, 1.2, 1.6, 1.8]},
    apply={"v0": lambda s, v: s.set_agent_params(0, desired_speed=v)},
    seeds=range(40, 50),
    workers=4,
)

df = sweep.to_dataframe()
print(df.groupby("v0")["evacuation_time"].agg(["mean", "std"]))
sweep.cleanup()

run_sweep walks the cartesian product of axes, applies each axis's mutator to an isolated .copy() of the base, and runs the trials. workers=0 uses one worker per CPU. For sweeps that need a different scenario shape per trial — geometry that depends on the parameters, journeys that vary — use run_sweep_from_factory instead.

For deeper coverage see the how-to notebooks:

Command line

jps-scenarios run scenario.json --seed 42 --out trajectory.sqlite

Runs a single scenario and prints a one-line JSON summary (evacuation_time, agent counts, sqlite_file) to stdout. Useful in CI or scripted pipelines; notebook workflows should stay on the Python API.

Documentation

API reference, bottleneck tutorial, and how-tos are built with Sphinx and deployed on every push to main via GitHub Pages.

To build locally:

pip install -e .
pip install -r docs/requirements.txt
sphinx-build -b html docs/source docs/build/html

Roadmap

Shipped: see CHANGELOG.md. Current release: 0.6.2.

On the table for future releases:

  • Greenfield Scenario() constructor — a builder shape that doesn't require pre-loading a JSON template (R3.7 in docs/dev/api-design-cleanup.md).
  • Typed Zone / Stage view classes with property setters, replacing the set_zone_speed_factor / set_checkpoint_waiting_time wrappers (R3.10).
  • Removal of the v0 / v0_std / v0_distribution deprecated kwargs (currently still accepted with DeprecationWarning).

Concrete proposals are tracked under issues.

Citation

If jupedsim-scenarios supports work you publish, please cite the upstream JuPedSim project and link to this repository. A dedicated DOI for this toolkit will be added once a Zenodo deposit is in place.

Contributing

See CONTRIBUTING.md for the dev install, local checks, and PR conventions.

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupedsim_scenarios-0.6.3.tar.gz (78.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupedsim_scenarios-0.6.3-py3-none-any.whl (59.6 kB view details)

Uploaded Python 3

File details

Details for the file jupedsim_scenarios-0.6.3.tar.gz.

File metadata

  • Download URL: jupedsim_scenarios-0.6.3.tar.gz
  • Upload date:
  • Size: 78.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jupedsim_scenarios-0.6.3.tar.gz
Algorithm Hash digest
SHA256 b8200587eae00716f5f8ca9e31b4b543d496ca0221da9b606fee2770a5297b6e
MD5 65482bead48cd65101b138fde8891615
BLAKE2b-256 54d5ede768ca39c94c7bc3b68e6a88eb2968d97cc224e84afced2b75e37eaa7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupedsim_scenarios-0.6.3.tar.gz:

Publisher: workflow.yml on PedestrianDynamics/jupedsim-scenarios

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jupedsim_scenarios-0.6.3-py3-none-any.whl.

File metadata

File hashes

Hashes for jupedsim_scenarios-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3c82918b58e7f31b2e6ddc5b3bb0a94f4eb320b74c516fefc5d06c095c571467
MD5 32b507775793d43c05de71a50d46acde
BLAKE2b-256 63b5e62b363b0a0f71407f0b427ec3899ffbdec6f7a27b2c1e5affe44120eea2

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupedsim_scenarios-0.6.3-py3-none-any.whl:

Publisher: workflow.yml on PedestrianDynamics/jupedsim-scenarios

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page