Skip to main content

pyRDDLGym-rl: Wrappers for reinforcement learning algorithms (i.e. stable baselines 3) to work with pyRDDLGym.

Project description

pyRDDLGym-rl

Author: Mike Gimelfarb

This repository provides wrappers for deep reinforcement learning algorithms (i.e. Stable Baselines 3 and RLlib) to work with pyRDDLGym.

[!NOTE]
If your environment has differentiable dynamics and a differentiable reward, try the gradient-based JAX planner.

Contents

Installation

To run the basic examples you will need pyRDDLGym>=2.0, rddlrepository>=2.0 and one of the supported reinforcement learning frameworks:

  • stable-baselines3>=2.2.1
  • ray[rllib]>=2.9.2

You can install this package, together with all of its requirements via pip:

pip install stable-baselines3  # need one of these two
pip install -U "ray[rllib]"
pip install rddlrepository pyRDDLGym-rl

Running the Basic Examples

Stable Baselines 3

To run the stable-baselines3 example, navigate to the install directory of pyRDDLGym-rl, and type:

python -m pyRDDLGym_rl.examples.run_stable_baselines <domain> <instance> <method> <steps> <learning_rate>

where:

  • <domain> is the name of the domain in rddlrepository, or a path pointing to a domain.rddl file
  • <instance> is the name of the instance in rddlrepository, or a path pointing to an instance.rddl file
  • <method> is the RL algorithm to use [a2c, ddpg, dqn, ppo, sac, td3]
  • <steps> is the (optional) number of samples to generate from the environment for training, and
  • <learning_rate> is the (optional) learning rate to specify for the algorithm.

RLLib

To run the RLlib example, from the install directory of pyRDDLGym-rl, type:

python -m pyRDDLGym_rl.examples.run_rllib <domain> <instance> <method> <iters>

where:

  • <domain> is the name of the domain in rddlrepository, or a path pointing to a domain.rddl file
  • <instance> is the name of the instance in rddlrepository, or a path pointing to an instance.rddl file
  • <method> is the RL algorithm to use [dqn, ppo, sac]
  • <iters> is the (optional) number of iterations of training

Creating an Environment

You can create an environment wrapper to use with your own RL implementations, or a package that is not currently supported by us:

import pyRDDLGym
from pyRDDLGym_rl.core.env import SimplifiedActionRDDLEnv
env = pyRDDLGym.make("domain name", "instance name", base_class=SimplifiedActionRDDLEnv)

This creates an instance of gymnasium.Env in which the action space is simplified by concatenating all continuous, discrete and boolean action fluents into single tensors. You can then use this environment as you would in pyRDDLGym.

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

pyrddlgym_rl-0.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

pyRDDLGym_rl-0.2-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file pyrddlgym_rl-0.2.tar.gz.

File metadata

  • Download URL: pyrddlgym_rl-0.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.0

File hashes

Hashes for pyrddlgym_rl-0.2.tar.gz
Algorithm Hash digest
SHA256 e54c6b0cdc41c4cb8234bb59fdc28ee7d88bd66f33db75dc9248c67190a21a93
MD5 0d5ee8118ea0c81a5af9c78046ae836e
BLAKE2b-256 03be1b527c4a70c731759a16ea1f449b4d61beb33d45f6b12f6de4284cfeffb2

See more details on using hashes here.

File details

Details for the file pyRDDLGym_rl-0.2-py3-none-any.whl.

File metadata

  • Download URL: pyRDDLGym_rl-0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.0

File hashes

Hashes for pyRDDLGym_rl-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6e68b204f69e50d067541a45461bb42901f1785526784825a04f84d718a4bcbb
MD5 d49d627a32f37c4619959b57ee100ad3
BLAKE2b-256 6e03b74de55c52a937164a3971c839088096cbca4676455d1989d105d61d33d3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page