Skip to main content

rddlgym: A toolkit for working with RDDL domains in Python3.

Project description

rddlgym Py Versions PyPI version Build Status Documentation Status License: GPL v3

A toolkit for working with RDDL domains in Python3. Its main purpose is to wrap a RDDL domain/instance planning problem as an OpenAI gym environment.

Quickstart

$ pip3 install -U rddlgym

Usage

rddlgym can either be used as a standalone CLI app or it can be integrated with your code in order to implement customized agent-environment interaction loops.

CLI

$ rddlgym --help
Usage: rddlgym [OPTIONS] COMMAND [ARGS]...

  rddlgym: A toolkit for working with RDDL domains in Python3.

Options:
  --help  Show this message and exit.

Commands:
  info   Print metadata for a `rddl` domain/instance.
  ls     List all RDDL domains and instances available.
  parse  Check RDDL file parsing.
  run    Run random policy in `rddl` domain/instance.
  show   Print `rddl` file.

API

# create RDDLGYM environment
rddl = "Navigation-v3" # see available RDDL with "$ rddlgym ls" command
env = rddlgym.make(rddl, mode=rddlgym.GYM)

# define random policy
pi = lambda state, t: env.action_space.sample()

# initialize environament
state, t = env.reset()
done = False

# create a trajectory container
trajectory = rddlgym.Trajectory(env)

# sample an episode and store trajectory
while not done:

    action = pi(state, t)
    next_state, reward, done, info = env.step(action)

    trajectory.add_transition(t, state, action, reward, next_state, info, done)

    state = next_state
    t = env.timestep

print(f"Total Reward = {trajectory.total_reward}")
print(f"Episode length = {len(trajectory)}")

filepath = f"/tmp/rddlgym/{rddl}/data.csv"
df = trajectory.save(filepath) # dump episode data as csv file
print(df) # display dataframe

License

Copyright (c) 2018-2020 Thiago Pereira Bueno All Rights Reserved.

rddlgym is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

rddlgym is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with rddlgym. If not, see http://www.gnu.org/licenses/.

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

rddlgym-0.5.14.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

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

rddlgym-0.5.14-py3-none-any.whl (64.1 kB view details)

Uploaded Python 3

File details

Details for the file rddlgym-0.5.14.tar.gz.

File metadata

  • Download URL: rddlgym-0.5.14.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.8

File hashes

Hashes for rddlgym-0.5.14.tar.gz
Algorithm Hash digest
SHA256 944e008ac2707e8c9a2b4bcb10e8be854c25979d4ee03218364fc40562fa9c93
MD5 b930924a2453cdb358b375d8262b4548
BLAKE2b-256 bf382934cf2d8b8f81b2430d1fba2a23700870faf4373ea26770a3b4b50c1bbc

See more details on using hashes here.

File details

Details for the file rddlgym-0.5.14-py3-none-any.whl.

File metadata

  • Download URL: rddlgym-0.5.14-py3-none-any.whl
  • Upload date:
  • Size: 64.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.8

File hashes

Hashes for rddlgym-0.5.14-py3-none-any.whl
Algorithm Hash digest
SHA256 51331de0c23db5fabfa910391920e4c8b53ceb784b630bc7046056a840b2e612
MD5 c4628a5141d6687246e983be3ed961f6
BLAKE2b-256 2147b78737c4dc2bfc0d806e5efd3f12c92ab1001014a90a7b449f056d6a5ef2

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