Skip to main content

A Python package for System Dynamics Modeling

Project description

asdm

Agile System Dynamics Modelling

ASDM is a Python library that enables users to create and simulate System Dynamics (SD) models. It also supports SD models saved in the XMILE format, including advanced features such as arrays and conveyors. The support is being continuously improved.

ASDM's Contribution & Impact

Check out this presentation: Project Care Home Demand, created by Sally Thompson, Senior Healthcare Analyst at The Strategy Unit (part of NHS Midlands and Lancashire CSU). The presentation highlights the role of ASDM in developing an online SD model-based simulator, specifically here.

Library Structure

  • asdm/asdm.py contains the main functionalities, including the lexer, parser, and interpreter.
  • asdm/utilities.py provides a data visualisation tool.
  • asdm/inference/ consists of tools for model calibration.
  • asdm/simulator/ provides a web-based simulation interface for easy model execution, result downloading, and visualisation.

Installation

Install from PyPi

pip install asdm

ASDM and its required dependencies will be automatically installed.


Basic Usage

To create a new SD model using ASDM:

from asdm import sdmodel

model = sdmodel()

sdmodel is the core class for System Dynamics models.

Alternatively, you can load an SD model saved in XMILE format, including .stmx models:

model = sdmodel(from_xmile='example_model.stmx')

Run the simulation:

model.simulate()

Export simulation results:

  • As a pandas DataFrame:
    result = model.export_simulation_result(format='df')
    
  • As a Python dictionary:
    result = model.export_simulation_result(format='dict')
    

Web-Based Simulation Interface

ASDM now includes a web-based simulation interface that allows users to:

  • Upload .stmx or .xmile models for simulation.
  • Download simulation results as a CSV file.
  • Select variables and visualise them on an interactive chart.

ASDM Simulator

Quick Start

Run the ASDM web simulator with:

asdm.simulator

By default, this starts a local server at http://127.0.0.1:8080. If port 8080 is unavailable, specify a different port, for example:

asdm.simulator --port 8081

You can also bind to all network interfaces to allow access from others:

asdm.simulator --host 0.0.0.0

Once started, the browser will automatically open the simulator page.

Features

  • Drag-and-drop file upload: Upload your .stmx or .xmile model file.
  • Simulation results in a table: Automatically display after the model runs.
  • CSV download: You can download simulation results as a CSV file.
  • Interactive charting:
    • Select variables from a dropdown list.
    • Automatically detects the time column name (e.g., "Years", "Months", etc.).
    • Uses Plotly.js to generate interactive line charts.

Functionalities

Please refer to Documentation for detailed function descriptions.


Tutorial Jupyter Notebooks

Jupyter Notebooks demonstrate ASDM's functionalities:

SD Modelling

  • Creating an SD model from scratch:
    • Adding stocks, flows, auxiliaries.
    • Support for nonlinear and stochastic functions.
  • Running simulations.
  • Exporting and examining simulation results.
  • Visualising results.

Support for .stmx Models

  • Load and simulate .stmx models.
  • Support for arrays.
  • Modify equations and re-run simulations.

More tutorial notebooks will be added.
Feel free to contribute your own via pull requests—please ensure they do not contain sensitive data.


Licence

ASDM is open-source and released under the MIT licence.


Contributors

Wang Zhao (main author)

Matt Stammers (contributor)

  • Consultant Gastroenterologist & open-source developer at University Hospital Southampton, UK.
  • Developed Streamlit-powered web apps using ASDM for healthcare modelling.
  • Part of the Really Useful Models initiative: Learn More.
  • GitHub: Matt's Homepage.

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

asdm-0.4.0.tar.gz (41.9 kB view details)

Uploaded Source

Built Distribution

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

asdm-0.4.0-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file asdm-0.4.0.tar.gz.

File metadata

  • Download URL: asdm-0.4.0.tar.gz
  • Upload date:
  • Size: 41.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for asdm-0.4.0.tar.gz
Algorithm Hash digest
SHA256 8836a129b2074d92bb6d43aae4695e0fdf263dd0377b56f714b8d30a5fa7d5f6
MD5 ea7819cd871bcef302fc3dc4fe65fa30
BLAKE2b-256 c1f33769851f3683ff8b602a6da4e5c18e18e0e241eecd53fc7130533632212f

See more details on using hashes here.

File details

Details for the file asdm-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: asdm-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for asdm-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5025b637cb6ad55d369081b19615613ec8ad23304a33ad56f838dc88369e3456
MD5 1e48b7cddadb990293295ab72e3bc48d
BLAKE2b-256 a36b198a6412e4ba94bc1f8e9acd7e311383d1965aca7eb67cfd87f9ea8ed847

See more details on using hashes here.

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