Skip to main content

RDDL2TensorFlow parser, compiler, and simulator.

Project description

tf-rddlsim Build Status Documentation Status License

RDDL2TensorFlow compiler and trajectory simulator in Python3.

Quickstart

$ pip3 install tfrddlsim

Usage

tf-rddlsim can be used as a standalone script or programmatically.

Script mode

$ tfrddlsim --help

usage: tfrddlsim [-h] [--policy {default,random}] [--viz {generic,navigation}]
                 [-hr HORIZON] [-b BATCH_SIZE] [-v]
                 rddl

RDDL2TensorFlow compiler and simulator

positional arguments:
  rddl                  path to RDDL file or rddlgym problem id

optional arguments:
  -h, --help            show this help message and exit
  --policy {default,random}
                        type of policy (default=random)
  --viz {generic,navigation}
                        type of visualizer (default=generic)
  -hr HORIZON, --horizon HORIZON
                        number of timesteps of each trajectory (default=40)
  -b BATCH_SIZE, --batch_size BATCH_SIZE
                        number of trajectories in a batch (default=75)
  -v, --verbose         verbosity mode
$ tfrddlsim Navigation-v1 --policy random --viz navigation -hr 50 -b 32 -v
$ tfrddlsim Reservoir-8 --policy default --viz generic -hr 20 -b 128 -v

Programmatic mode

import rddlgym
from rddl2tf.compilers import DefaultCompiler as Compiler
from tfrddlsim.policy import RandomPolicy
from tfrddlsim.simulation.policy_simulator import PolicySimulator
from tfrddlsim.viz import GenericVisualizer

# parameters
horizon = 40
batch_size = 32

# parse and compile RDDL
rddl = rddlgym.make('Reservoir-8', mode=rddlgym.AST)
compiler = Compiler(rddl, batch_size)
compiler.init()

# run simulations
policy = RandomPolicy(compiler)
simulator = PolicySimulator(compiler, policy)
trajectories = simulator.run(horizon)

# visualize trajectories
viz = GenericVisualizer(compiler, verbose=True)
viz.render(trajectories)

Simulator

The tfrddlsim.Simulator implements a stochastic Recurrent Neural Net (RNN) in order to sample state-action trajectories. Each RNN cell encapsulates a tfrddlsim.Policy module generating actions for current states and comprehends the transition (specified by the CPFs) and reward functions. Sampling is done through dynamic unrolling of the RNN model with the embedded tfrddlsim.Policy.

Note that the tfrddlsim package only provides a tfrddlsim.RandomPolicy and a tfrddlsim.DefaultPolicy (constant policy with all action fluents with default values).

Documentation

Please refer to https://tf-rddlsim.readthedocs.io/ for the code documentation.

Support

If you are having issues with tf-rddlsim, please let me know at: thiago.pbueno@gmail.com.

License

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

tf-rddlsim 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.

tf-rddlsim 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 tf-rddlsim. 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

tfrddlsim-0.8.1.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

tfrddlsim-0.8.1-py3-none-any.whl (45.0 kB view details)

Uploaded Python 3

File details

Details for the file tfrddlsim-0.8.1.tar.gz.

File metadata

  • Download URL: tfrddlsim-0.8.1.tar.gz
  • Upload date:
  • Size: 17.3 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 tfrddlsim-0.8.1.tar.gz
Algorithm Hash digest
SHA256 931741a10cb3d4b9578a395c84a8c8e486ab1da875bf10fdd87c661b851a3902
MD5 1e73d73e787b5a6a12de168cfe636654
BLAKE2b-256 f65fe15df95cbf5b9e65572d581508f85a9539371b1601bed2461a6324c05c0e

See more details on using hashes here.

File details

Details for the file tfrddlsim-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: tfrddlsim-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 45.0 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 tfrddlsim-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f3cfa3443114602d62b6bfcc2650977e9dd7b9cad88a821120805180e0c7407
MD5 07d35b0922ac2ef5e6fe190543d35a2b
BLAKE2b-256 8ab5e426d865666af469481b38858762dc51d4d68bd3f179429d066cbd8f4e6b

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