Git Product home page Git Product logo

blackbox_mpc's Introduction

BlackBox MPC (Model Predictive Control)

license GitHub release Documentation Status Maintenance PR Open Source Love png2

Description

This package provides a framework of different derivative-free optimizers (powered by Tensorflow 2.0.0) which can be used in conjuction with an MPC (model predictive controller) and an analytical/ learned dynamics model to control an agent in a gym environment.

Derivative-Free Optimizer BlackBox MPC
Cross-Entropy Method (CEM) ✔️
Covariance Matrix Adaptation Evolutionary-Strategy (CMA-ES) ✔️
Path Intergral Method (PI2) ✔️
Particle Swarm Optimizer (PSO) ✔️
Random Search (RandomSearch) ✔️
Simultaneous Perturbation Stochastic Approximation (SPSA) ✔️

The package features other functionalities to aid in model-based reinforcement learning (RL) research such as:

  • Parallel implementation of the different optimizers using Tensorflow 2.0
  • Loading/ saving system dynamics model.
  • Monitoring progress using tensorboard.
  • Learning dynamics functions.
  • Recording videos.
  • A modular and flexible interface design to enable research on different trajectory evaluation methods, optimizers, cost functions, system dynamics network architectures or even training algorithms.

Optimizers references:

Iterative MPC

Installation

Install as a pip package from latest release

pip install blackbox_mpc

Install from source

git clone https://github.com/ossamaAhmed/blackbox_mpc.git
cd blackbox_mpc
pip install -e .

To use GPU (recommended for faster inference)

pip install tensorflow_gpu==2.0.0

Usage

The easiest way to get familiar with the framework is to run through the tutorials provided. An example is shown below:

from blackbox_mpc.policies.mpc_policy import \
    MPCPolicy
from blackbox_mpc.utils.pendulum import PendulumTrueModel, \
    pendulum_reward_function
import gym

env = gym.make("Pendulum-v0")
mpc_policy = MPCPolicy(reward_function=pendulum_reward_function,
                       env_action_space=env.action_space,
                       env_observation_space=env.observation_space,
                       true_model=True,
                       dynamics_function=PendulumTrueModel(),
                       optimizer_name='RandomSearch',
                       num_agents=1)

current_obs = env.reset()
for t in range(200):
    action_to_execute, expected_obs, expected_reward = mpc_policy.act(
        current_obs, t)
    current_obs, reward, _, info = env.step(action_to_execute)
    env.render()

Documentation

An API specification and explanation of the code components can be found here.

Visualize Training

Authors

blackbox_mpc is work done by Ossama Ahmed (ETH Zürich), Jonas Rothfuss (ETH Zürich) and Prof. Andreas Krause (ETH Zurich).

This package was developed at the Learning and Adaptive Systems Lab @ETH Zurich.

If you use the package, please cite blackbox_mpc

@misc{blackbox_mpc,
   author = {Ahmed, Ossama and Rothfuss, Jonas and Krause, Andreas},
   year = {2020},
   publisher = {GitHub},
   journal = {GitHub repository},
   howpublished = {\url{https://github.com/ossamaAhmed/blackbox_mpc}},
}

License

The code is licenced under the MIT license and free to use by anyone without any restrictions.

TODO

  • Add bayesian neural networks (BNN) and graph neural networks (GNN) support.
  • Add different trajectory evaluators to propagate uncertainities support.

blackbox_mpc's People

Contributors

ossamaahmed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

blackbox_mpc's Issues

Compatability with newer versions of Tensor Flow

Hi, I get an error when trying to install this package using pip because it depends on tensorflow 2.0.0

ERROR: Cannot install blackbox-mpc==0.2 and blackbox-mpc==0.3 because these package versions have conflicting dependencies.

The conflict is caused by:
blackbox-mpc 0.3 depends on tensorflow==2.0.0

While the current version of tensorflow at the time I am writing this is 2.15. I could not even downgrade easily to anything below 2.5

I hope you can fix this issue.

Thank you

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.