Giter Site home page Giter Site logo

thiagopbueno / tf-rddlsim Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 6.0 259 KB

A RDDL simulator running in TensorFlow.

Home Page: https://tf-rddlsim.readthedocs.io/

License: GNU General Public License v3.0

Python 99.48% Makefile 0.52%
rddl tensorflow mdp simulator

tf-rddlsim's Introduction

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: [email protected].

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/.

tf-rddlsim's People

Contributors

dependabot[bot] avatar thiagopbueno avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tf-rddlsim's Issues

Define simulator API

Define common API for invoking simulations carried out in modules tfrddlsim.simulation.transition_simulator.py and tfrddlsim.simulation.policy_simulator.py.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.