Skip to main content

immunosim

Gymnasium environments for reinforcement learning in cancer immunotherapy optimization

Python 3.10+ License: MIT Tests PyPI version


ImmunoSim provides four Gymnasium-compatible reinforcement learning environments for optimizing cancer immunotherapy treatment schedules. Each environment wraps validated mathematical models from the tumor immunology literature, enabling RL agents to discover dosing strategies that outperform standard clinical protocols.

The package implements ODE-based tumor-immune dynamics from Kuznetsov-Taylor (1994), checkpoint inhibitor pharmacodynamics from Nikolopoulou (2018, 2021), CAR-T cell kinetics from Barros CARTmath (2021), and cytokine release syndrome modeling from Santurio (2025).

Installation

pip install immunosim              # Core (numpy, scipy, gymnasium)
pip install immunosim[train]       # + SB3, PyTorch for RL training
pip install immunosim[all]         # Everything

Development install:

git clone https://github.com/HassDhia/immunosim.git
cd immunosim
pip install -e ".[all]"

Quick Start

import gymnasium as gym
import immunosim

env = gym.make("immunosim/CheckpointInhibitor-v0")
obs, info = env.reset(seed=42)
for _ in range(100):
    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 Observation Action Key Challenge
CheckpointInhibitor-v0 Anti-PD-1 monotherapy Box(5) Discrete(3) Balance tumor control vs. cumulative drug exposure
CombinationTherapy-v0 Dual PD-1 + CTLA-4 Box(7) MultiDiscrete([3,3]) Exploit synergy while managing CTLA-4 dose-dependent toxicity
CARTCell-v0 CAR-T cell infusion Box(6) Discrete(4) Maximize tumor kill while preventing grade 4 CRS
AdaptiveDosing-v0 Adaptive response-based Box(6) Discrete(4) Distinguish pseudo-progression from true progression

Architecture

immunosim/
  models/
    tumor_immune.py      -- Kuznetsov-Taylor (1994) 2-ODE base model
    checkpoint_inhibitor.py -- Anti-PD-1, Anti-CTLA-4, Dual checkpoint modules
    cart_cell.py         -- CARTmath (Barros 2021) + CRS (Santurio 2025)
    patient.py           -- Domain randomization + pseudo-progression detection
  envs/
    checkpoint_inhibitor.py  -- CheckpointInhibitorEnv-v0
    combination_therapy.py   -- CombinationTherapyEnv-v0
    cart_cell.py             -- CARTCellEnv-v0
    adaptive_dosing.py       -- AdaptiveDosingEnv-v0
  agents/
    random_agent.py      -- Random baseline
    heuristic_agent.py   -- Clinical protocol heuristics
    ppo.py               -- PPO via stable-baselines3
  training/
    configs.py           -- Shared ENV_CONFIGS
    train_all.py         -- Train all environments
  benchmarks/
    runner.py            -- Performance benchmarking

Paper

The accompanying paper is available at:

Citation

If you use immunosim in your research, please cite:

@software{dhia2026immunosim,
  author = {Dhia, Hass},
  title = {ImmunoSim: Gymnasium Environments for Reinforcement Learning in Cancer Immunotherapy Optimization},
  year = {2026},
  publisher = {Smart Technology Investments Research Institute},
  url = {https://github.com/HassDhia/immunosim}
}

License

MIT License. See LICENSE for details.

Contact

Hass Dhia -- Smart Technology Investments Research Institute

Metadata

Release files for immunosim 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for immunosim 0.1.0
File Size Uploaded Provenance
immunosim-0.1.0.tar.gz 868.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for immunosim 0.1.0
File Interpreter ABI Platform
immunosim-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 905.6 kB

Release files / immunosim-0.1.0.tar.gz

Download URL immunosim-0.1.0.tar.gz
Size 868.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d71761884fc75f15383a4738ca00077989579ddb409974dcc479159dbd1426f6
BLAKE2b-256 checksum
How to use checksums
93703f3c17bf21af45e7d9972d46f925b2db72e84426ed887a29858ceb303318
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Release files / immunosim-0.1.0-py3-none-any.whl

Download URL immunosim-0.1.0-py3-none-any.whl
Size 37.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
738303553f784b089c59aa86c521c6065feb1ae34014eef424f989486dd2cf69
BLAKE2b-256 checksum
How to use checksums
4f26eb45b37ec0848be6c3a01e304420e7808bcf424a9c70b3f3cf9ac19c7f0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Security for immunosim 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page