Skip to content

gympn

Welcome to the official documentation for gympn, a Python library for decision-making in Petri Nets.

Overview

GymPN is a Python library designed for creating and training reinforcement learning (RL) agents in environments based on Action-Evolution Petri Nets (AEPN). It provides tools for defining simulation problems, environments, and agents, making it easier to experiment with RL algorithms in Petri Net-based systems.

  • Action-Evolution Petri Nets (AEPN): Define and simulate A-E PN environments.
  • Customizable RL Agents: Train agents using Proximal Policy Optimization (PPO), with optional net-factored credit (NF-GAE) for nets with independent parts.
  • Postponement: Let the agent wait, globally or per independent part of the net.
  • Graph Observations: Generate graph-based observations for RL agents using PyTorch Geometric.
  • Integration with Gymnasium: Seamless integration with Gym environments.
  • Flexible Simulation Framework: Define custom events, actions, and reward functions.

Installation

GymPN requires Python 3.10 or newer:

pip install gympn

Optional features are extras: gympn[tensorboard] for training curves in TensorBoard, gympn[wandb] for Weights & Biases logging, gympn[viz] for plotting the graph observations, and gympn[all] for all three. Training and testing work without any of them.

PyTorch publishes CPU-only and CUDA-specific wheels on its own index; to get a specific build, install torch first by following https://pytorch.org/get-started/locally/ and then run pip install gympn.

For development, clone the repository and install it in editable mode with every extra (see Contributing):

git clone https://github.com/bpogroup/gympn.git
cd gympn
pip install -e ".[dev]"

Documentation

Start Here

Getting Started

Core Concepts

  • Algorithms - Overview of PPO-Clip, PPO-Penalty and PG algorithms with hyperparameter tuning
  • Net-Factored Credit (NF-GAE) - Per-component credit assignment for nets with independent parts: what it computes, when it applies, how to use it
  • Agents Guide - Detailed guide on PPOAgent and custom solvers
  • Advanced Features - GNNs, parallelization

Advanced Topics

Reference

Contributing