Gymnasium environments for reinforcement learning in cancer immunotherapy optimization
Project description
immunosim
Gymnasium environments for reinforcement learning in cancer immunotherapy optimization
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file immunosim-0.1.0.tar.gz.
File metadata
- Download URL: immunosim-0.1.0.tar.gz
- Upload date:
- Size: 868.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d71761884fc75f15383a4738ca00077989579ddb409974dcc479159dbd1426f6
|
|
| MD5 |
d633ce14f73707c375212e574a4f7ea7
|
|
| BLAKE2b-256 |
93703f3c17bf21af45e7d9972d46f925b2db72e84426ed887a29858ceb303318
|
File details
Details for the file immunosim-0.1.0-py3-none-any.whl.
File metadata
- Download URL: immunosim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 37.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
738303553f784b089c59aa86c521c6065feb1ae34014eef424f989486dd2cf69
|
|
| MD5 |
3c6c128152caf8827e96bf40634301ac
|
|
| BLAKE2b-256 |
4f26eb45b37ec0848be6c3a01e304420e7808bcf424a9c70b3f3cf9ac19c7f0c
|