Skip to main content

Gymnasium environments for reinforcement learning in mechanical ventilation

Project description

ventisim

Gymnasium Environments for Reinforcement Learning in Mechanical Ventilation

Python 3.10+ License: MIT Tests PyPI

VentiSim provides standardized Gymnasium environments for developing and benchmarking reinforcement learning algorithms applied to mechanical ventilation management. The environments model lung mechanics, gas exchange, and PEEP-dependent alveolar recruitment with physiologically grounded parameters derived from the ARDS literature.

Installation

pip install ventisim

With training dependencies (stable-baselines3, PyTorch):

pip install ventisim[train]

Full development install:

pip install ventisim[all]

Quick Start

import gymnasium as gym
import ventisim  # registers environments

env = gym.make("ventisim/TidalVolumeControl-v0")
obs, info = env.reset(seed=42)

for step in range(200):
    action = env.action_space.sample()
    obs, reward, terminated, truncated, info = env.step(action)
    if terminated or truncated:
        obs, info = env.reset()

env.close()

Environments

Environment Paradigm Obs Dim Act Dim Key Challenge
ventisim/TidalVolumeControl-v0 Pressure control 7 1 Deliver target VT (6 mL/kg IBW) while keeping plateau < 30 cmH2O
ventisim/PEEPOptimization-v0 PEEP titration 8 1 Balance recruitment vs. overdistension for optimal PaO2
ventisim/FullVentilatorManagement-v0 Multi-parameter 10 4 Simultaneously optimize oxygenation, ventilation, and lung protection

All environments support three difficulty tiers (easy, medium, hard) controlling inter-patient variability, compliance drift, and measurement noise.

Architecture

Models Layer
  SingleCompartmentLung  -- RC-circuit lung mechanics (compliance, resistance)
  GasExchangeModel       -- Alveolar gas equation + shunt + PEEP recruitment
  VirtualPatient         -- ARDS severity profiles (Berlin definition)

Environments Layer (Gymnasium API)
  TidalVolumeControl-v0         -- 1D action: inspiratory pressure
  PEEPOptimization-v0           -- 1D action: PEEP change
  FullVentilatorManagement-v0   -- 4D action: FiO2, PEEP, RR, P_insp

Agents Layer
  Random                 -- Uniform random sampling (lower bound)
  Heuristic              -- Clinical protocol baselines (proportional control)
  PPO                    -- Proximal Policy Optimization via stable-baselines3

Training

Train all agents and generate results:

python train_all.py

Train a single environment:

ventisim-train --env ventisim/TidalVolumeControl-v0

Run benchmarks (random + heuristic):

ventisim-benchmark

Paper

If you use VentiSim in your research, please cite:

@software{dhia2026ventisim,
  author    = {Dhia, Hass},
  title     = {VentiSim: Gymnasium Environments for Reinforcement Learning
               in Mechanical Ventilation},
  year      = {2026},
  publisher = {Smart Technology Investments Research Institute},
  url       = {https://github.com/HassDhia/ventisim},
}

License

MIT License. See LICENSE for details.

Contact

Hass Dhia -- Smart Technology Investments Research Institute

partners@smarttechinvest.com

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

ventisim-0.1.0.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

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

ventisim-0.1.0-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file ventisim-0.1.0.tar.gz.

File metadata

  • Download URL: ventisim-0.1.0.tar.gz
  • Upload date:
  • Size: 31.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for ventisim-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c3a5fed81bdf40044e12b9629a333befb52668a80d07e0fd2ea5edf7f03484d3
MD5 bc891a01ea9a0c0be09c3e77407b78a3
BLAKE2b-256 38b47471c5c3829ba1aa5dfdf1b5230aefb04378c862e1eb862ad96d86665742

See more details on using hashes here.

File details

Details for the file ventisim-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ventisim-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for ventisim-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ac8aa211d2ee9bcc689d808f90131f0f4da48895b8d5550853332d81ecad6ed
MD5 6a96a1ca1d2d593a900a5d4f0d27c482
BLAKE2b-256 ce09ca9a41edda69eee6c4939f22edd0af859af27ad14889334e0cb07110146a

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