pyrddlgym
A toolkit for auto-generation of OpenAI Gym environments from RDDL description files.
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.1%) to scientific vocabulary
Keywords
Repository
A toolkit for auto-generation of OpenAI Gym environments from RDDL description files.
Basic Info
- Host: GitHub
- Owner: pyrddlgym-project
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://pyrddlgym.readthedocs.io/
- Size: 72.8 MB
Statistics
- Stars: 83
- Watchers: 7
- Forks: 22
- Open Issues: 6
- Releases: 6
Topics
Metadata Files
README.md
pyRDDLGym
Purpose | Installation | Example Scripts | Usage | Status | Citing
[!WARNING]
As of Feb 9, 2024, the pyRDDLGym API has been updated to version 2.0, and is no longer backwards compatible with the previous stable version 1.4.4. While we strongly recommend that you update to 2.0, in case you require the old API, you can install the last stable version with pip:pip install pyRDDLGym==1.4.4, or directly from githubpip install git+https://github.com/pyrddlgym-project/pyRDDLGym@version_1.4.4_stable.
A Python toolkit for auto-generation of OpenAI Gym environments from Relational Dynamic Influence Diagram Language (RDDL) description files.
This is currently the official parser, simulator and evaluation system for RDDL in Python, with new features and enhancements to the RDDL language.

Purpose and Benefits
- Describe your environment in RDDL (web-based intro), (full tutorial), (language spec) and use it with your existing workflow for OpenAI gym environments
- Compact, easily modifiable representation language for discrete time control in dynamic stochastic environments
- e.g., a few lines of RDDL for CartPole vs. 200 lines in direct Python for Gym
- Object-oriented relational (template) specification allows easy scaling of model instances from 1 object to 1000's of objects without changing the domain model
- Customizable visualization and recording tools facilitate domain debugging and plan interpretation
- e.g., a student course project visualizing Jax plans in a sailing domain
- Runs out-of-the-box in Python or within Colab (RDDL Playground)
- Compiler tools to extract Dynamic Bayesian Networks (DBNs) and Extended Algebraic Decision Diagrams (XADDs) for symbolic analysis of causal dependencies and transition distributions
- Ready to use with out-of-the-box planners:
- JaxPlan: Planning through autodifferentiation
- GurobiPlan: Planning through mixed discrete-continuous optimization
- PROST: Monte Carlo Tree Search (MCTS)
- Deep Reinforcement Learning (DQN, PPO, etc.): Popular Reinforcement Learning (RL) algorithms from Stable Baselines and RLlib
- Symbolic Dynamic Programming: Exact Symbolic regression-based planning and policy evaluation
Installation
To install via pip:
shell
pip install pyRDDLGym
To install the pre-release version via git:
shell
git clone https://github.com/pyRDDLGym-project/pyRDDLGym.git
Since pyRDDLGym does not come with any premade environments, you can either load RDDL documents from your local file system, or install rddlrepository for easy access to preexisting domains:
shell
pip install rddlrepository
Example Scripts
The best source of pyRDDLGym related examples is the example gallery of Jupyter notebooks hosted on our documentation site.
Several example scripts are packaged with pyRDDLGym to highlight the core usage: * run_gym.py launches a pyRDDLGym environment and evaluates the random policy * run_gym2.py is similar to the above but illustrates the environment interaction explicitly * run_ground.py illustrates grounding a domain and instance * run_intervals.py computes lower and upper bounds on the policy value using interval arithmetic * run_server.py illustrates how to set up pyRDDLGym to send and receive messages through TCP
Usage
This section outlines some of the basic python API functions of pyRDDLGym.
Loading an Environment
Instantiation of an existing environment is nearly identical to OpenAI gym (i.e., to load instance 0 of the CartPole domain):
python
import pyRDDLGym
env = pyRDDLGym.make("CartPole_Continuous_gym", "0")
You can also load your own domain and instance files:
python
import pyRDDLGym
env = pyRDDLGym.make("/path/to/domain.rddl", "/path/to/instance.rddl")
Both versions above instantiate env as an OpenAI gym environment, so that the usual reset() and step() calls work as intended.
You can also pass custom settings to make (i.e., to validate actions at each step):
python
import pyRDDLGym
env = pyRDDLGym.make("CartPole_Continuous_gym", "0", enforce_action_constraints=True, ...)
Interacting with an Environment
Agents map states to actions through the sample_action(obs) function, and can be used to interact with an environment.
For example, to initialize a random agent:
python
from pyRDDLGym.core.policy import RandomAgent
agent = RandomAgent(action_space=env.action_space, num_actions=env.max_allowed_actions)
All agent instances support one-line evaluation in a given environment:
python
stats = agent.evaluate(env, episodes=1, verbose=True, render=True)
which returns a dictionary of summary statistics (e.g. "mean", "std", etc...) and also visualizes the interaction in real time. Of course, you can also use a loop as customary in OpenAI gym:
python
total_reward = 0
state, _ = env.reset()
for step in range(env.horizon):
env.render()
action = agent.sample_action(state)
next_state, reward, terminated, truncated, _ = env.step(action)
total_reward += reward
state = next_state
done = terminated or truncated
if done:
break
env.close() # close visualizer and release resources
[!NOTE]
All observations (for a POMDP), states (for an MDP) and actions are represented bydictobjects, whose keys correspond to the appropriate fluents as defined in the RDDL description. Here, the syntax ispvar-name___o1__o2..., wherepvar-nameis the pvariable name, followed by 3 underscores, and object parameterso1,o2... are separated by 2 underscores.[!WARNING] There are two known issues not documented with RDDL: 1. the minus (-) arithmetic operation must have spaces on both sides, otherwise there is ambiguity whether it refers to a mathematical operation or to variables 2. aggregation-union-precedence parsing requires for encapsulating parentheses around aggregations, e.g., (sum_{}[]).
Creating your Own Visualizer
You can design your own visualizer by subclassing pyRDDLGym.core.visualizer.viz.BaseViz and overriding the render(state) method.
Then, changing the visualizer of the environment is easy:
python
viz_class = ... # the class name of your custom viz
env.set_visualizer(viz_class)
Recording Movies
You can record an animated gif or movie when interacting with an environment.
Simply pass a MovieGenerator object to the set_visualizer method:
```python from pyRDDLGym.core.visualizer.movie import MovieGenerator moviegen = MovieGenerator("/path/where/to/save", "envname") env.setvisualizer(vizclass, moviegen=moviegen)
continue with normal interaction
```
Status
A complete archive of past and present RDDL problems, including all IPPC problems, is also available to clone\pip
* rddlrepository (pip install rddlrepository)
Software for related simulators: * rddlsim * rddlgym * pddlgym
The parser used in this project is based on the parser from Thiago Pbueno's pyrddl (used in rddlgym).
Citing pyRDDLGym
Please see our paper describing pyRDDLGym. If you found this useful, please consider citing us:
@article{taitler2022pyrddlgym,
title={pyRDDLGym: From RDDL to Gym Environments},
author={Taitler, Ayal and Gimelfarb, Michael and Gopalakrishnan, Sriram and Mladenov, Martin and Liu, Xiaotian and Sanner, Scott},
journal={arXiv preprint arXiv:2211.05939},
year={2022}}
License
This software is distributed under the MIT License.
Owner
- Name: pyrddlgym-project
- Login: pyrddlgym-project
- Kind: organization
- Repositories: 1
- Profile: https://github.com/pyrddlgym-project
The official pyRDDLGym Simulator, and everything RDDL related
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Taitler"
given-names: "Ayal"
- family-names: "Gimelfarb"
given-names: "Michael"
- family-names: "Jeong"
given-names: "Jihwan"
- family-names: "Gopalakrishnan"
given-names: "Sriram"
- family-names: "Mladenov"
given-names: "Martin"
- family-names: "Liu"
given-names: "Xiaotian"
- family-names: "Sanner"
given-names: "Scott"
title: "pyRDDLGym"
version: 2.0
date-released: 2024-01-01
preferred-citation:
type: conference-paper
authors:
- family-names: "Taitler"
given-names: "Ayal"
- family-names: "Gimelfarb"
given-names: "Michael"
- family-names: "Jeong"
given-names: "Jihwan"
- family-names: "Gopalakrishnan"
given-names: "Sriram"
- family-names: "Mladenov"
given-names: "Martin"
- family-names: "Liu"
given-names: "Xiaotian"
- family-names: "Sanner"
given-names: "Scott"
title: "pyRDDLGym: From RDDL to Gym Environments"
journal: "PRL Workshop – Bridging the Gap Between AI Planning and Reinforcement Learning"
url: "https://arxiv.org/abs/2211.05939"
month: 11
day: 11
year: 2022
GitHub Events
Total
- Create event: 13
- Issues event: 7
- Release event: 2
- Watch event: 18
- Issue comment event: 15
- Push event: 191
- Pull request review event: 2
- Pull request event: 16
- Fork event: 5
Last Year
- Create event: 13
- Issues event: 7
- Release event: 2
- Watch event: 18
- Issue comment event: 15
- Push event: 191
- Pull request review event: 2
- Pull request event: 16
- Fork event: 5
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 2
- Total pull requests: 6
- Average time to close issues: 21 days
- Average time to close pull requests: 4 days
- Total issue authors: 2
- Total pull request authors: 2
- Average comments per issue: 3.0
- Average comments per pull request: 0.0
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 6
- Average time to close issues: 21 days
- Average time to close pull requests: 4 days
- Issue authors: 2
- Pull request authors: 2
- Average comments per issue: 3.0
- Average comments per pull request: 0.0
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- mike-gimelfarb (5)
- MFaisalZaki (3)
- kasanari (2)
- GMMDMDIDEMS (2)
- nhuet (2)
- Zhennan-Wu (1)
- zdx3578 (1)
- keep9oing (1)
Pull Request Authors
- mike-gimelfarb (9)
- ataitler (3)
- danielbdias (1)
- GMMDMDIDEMS (1)
- jihwan-jeong (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 417 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 23
- Total maintainers: 2
pypi.org: pyrddlgym
pyRDDLGym: RDDL automatic generation tool for OpenAI Gym
- Homepage: https://github.com/pyrddlgym-project/pyRDDLGym
- Documentation: https://pyrddlgym.readthedocs.io/
- License: MIT License
-
Latest release: 1.4.4
published about 2 years ago
Rankings
Maintainers (2)
Dependencies
- gym >=0.24.0
- matplotlib >=3.5.0
- numpy >=1.22
- pillow >=9.2.0
- ply *
- pygame *
- dm-haiku >=0.0.9
- gym >=0.24.0
- jax >=0.3.25
- matplotlib >=3.5.0
- numpy *
- optax >=0.1.4
- pillow >=9.2.0
- ply *
- pygame *
- tensorflow >=2.11.0
- tensorflow-probability >=0.19.0
- tqdm *
- gym >=0.24.0
- matplotlib >=3.5.0
- numpy >=1.22
- pillow >=9.2.0
- ply *
- pygame *