Skip to main content

A safe reinforcement library for providing a common interface for different constraints and environments

Project description

MASA-Safe-RL

title card


Welcome to MASA-Safe-RL, the Multi and Single Agent (MASA) Safe Reinforcement Learning library. The primary goal of this library is to develop a set of common constraints and environments for safe reinforcement learning research, built on top of the popular gymnasium interface. We span, CMPDs, probabilistic constraints, Reach-Avoid and LTL-Safety (DFA) properties.

The library is in very early stage development and we greatly appreciate and encourage feedback from the community about what they would like to see implemented. Currently we provide a set of basic tabular algroithms for safe RL, but we provide a modular and resuable framework for developing more complex algorithms and constraints.

If you use MASA-Safe-RL in your research please cite it in your publications.

@misc{Goodall2025MASASafeRL,
  title        = {{MASA-Safe-RL}: Multi and Single Agent Safe Reinforcement Learning},
  author       = {Goodall, Alexander W. and Adalat, Omar and Hamel De-le Court, Edwin and Belardinelli, Francesco},
  year         = {2025},
  howpublished = {\url{https://github.com/sacktock/MASA-Safe-RL/}},
  note         = {GitHub repository}
}

Quick Start

Installation

Prequisites

Python 3.10+ is required (3.10 recommonded), later versions may be supported.

Installation with conda

  • Install conda, e.g., via anaconda.
  • Clone the repo:
git clone https://github.com/sacktock/MASA-Safe-RL.git
cd MASA-Safe-RL
  • Create a conda virtual environment:
conda env create --name masa --file conda-environment.yaml
conda activate masa
  • Install dependencies:
pip install -e .

Installation with uv

uv sync installs the base package from the repository root.

  • For building docs, use uv sync --group docs from the repository root.
  • Adding GPU support for Jax: uv sync --group cuda12 (or cuda13 if supported by your device)
  • All groups (docs and GPU support): uv sync --all-groups.

Installation with PyPI

MASA-Safe-RL is now available on PyPI: MASA-Safe-RL.

pip install -U MASA-Safe-RL

Enabling GPU Acceleration with JAX (Optional)

MASA-Safe-RL relies on JAX for GPU acceleration. If you are only interested in the gymnasium wrappers and constraints API then you do not need to complete the following steps.

Mac and Windows

MAC and Windows: we recommend JAX with CPU. No further action is required if you correctly followed the earlier steps.

pip

  • Linux x86_64/aarch64 and Windows WSL2 x86_64: W+we strongly recommend using Ubuntu 22.04 or similar, jax and jaxlib should already be installed via the requirements.txt. You need to reinstall JAX based on your cuda driver compatibility. Do not use the -U option here as it may break earlier dependencies!
pip install "jax[cuda13]"
pip install "jax[cuda12]"

uv

Alternatively with uv,

uv sync --group cuda12
uv sync --group cuda13

How to run MASA

  • You can run masa with the prebuilt CLI:
masa run --env-id bridge_crossing --algo ppo --seed 0
  • You can run examples from the \examples folder via:
masa example prob_shield_example

Editing documentation

Documentation uses the root pyproject.toml and uv.lock, so you can build and serve it directly from the repository root.

uv sync --group docs
uv run --locked --group docs sphinx-build -b html docs docs/_build/html

The built site will be available at docs/_build/html/index.html.

For live reload while editing, run:

uv run --locked --group docs sphinx-autobuild docs docs/_build/html

Getting in Touch

MASA-Safe-RL is primarliy managed by Alex Goodall and Omar Adalat. For correspondence in the early stages of the library we prefer you contact us directly via email (a.goodall22@imperial.ac.uk), rather than raising issues on GitHub directly.

License

MASA-Safe-RL is released under Apache License 2.0.

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

masa_safe_rl-0.2.3.tar.gz (166.4 kB view details)

Uploaded Source

Built Distribution

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

masa_safe_rl-0.2.3-py3-none-any.whl (266.5 kB view details)

Uploaded Python 3

File details

Details for the file masa_safe_rl-0.2.3.tar.gz.

File metadata

  • Download URL: masa_safe_rl-0.2.3.tar.gz
  • Upload date:
  • Size: 166.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for masa_safe_rl-0.2.3.tar.gz
Algorithm Hash digest
SHA256 1bdbb73d1df884c897828f4d33bb20d9b66a4f2e7c9e0e23baca94f79de7e758
MD5 b690c9070a746bdab6a6a2ddb51a3eea
BLAKE2b-256 0c5fef19bdd5e814915913fd0e45b8eac871edd0d3427f9905f423c72e0ffd37

See more details on using hashes here.

File details

Details for the file masa_safe_rl-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: masa_safe_rl-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 266.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for masa_safe_rl-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 772c648a44f6bd3e15ae81226d0a728a8db127522f0e5d94a963bf428a562b23
MD5 bc9390e1fbe2f947cf3aedb551ad6586
BLAKE2b-256 f2cf8f69acb26cb5e232b0500d1620789cf49ff24b97f8b15723100312b8e645

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