Coder Social home page Coder Social logo

valarzz / mpc_template-model_predictive_control_for_reinforcement_learning Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liuzuxin/mpc_template-model_predictive_control_for_reinforcement_learning

0.0 0.0 0.0 2.57 MB

Pytorch version of the MPC in model-based reinforcement learning (MBRL), currently only test in the CartPole-swing-up environment

Python 95.83% Jupyter Notebook 4.17%

mpc_template-model_predictive_control_for_reinforcement_learning's Introduction

MPC

This repo contains the implementation of Pytorch version of the MPC algorithm and the evaluation on the CartPole Swingup environment.

The MPC implementation is partly followed in this paper here and its repo

All the hyper-parameters and experiment setting are stored in the ./config folder.

All the results (figure and model) will be stored in the ./storage folder by default.

The training and testing scripts are stored in the ./scripts folder.

Requirements

  • pytorch
  • OpenAI gym

How to run

For the Cartpole swingup environment, simply go to the script folder and run

cd script && python train.py

The script will load the configurations in the ./config/config.yml file and begin to train.

By default, I only implemented the reward function for CartPole Swingup. Alternatively, you can train a NN-based reward model according to the needs of your environment. To do so, first run:

python train.py --train_reward_model 1

Then the reward model will be saved in the ./storage folder by default. Then you can run:

python train.py --use_reward_model 1

The MPC controller will use the learned reward function to perform optimizations.

Configuration explanation

In the config.yml file, there are 4 sets of configuration.

The model_config  part is the configuration of the parameters which determines the neural network architecture and the environment basis.

The training_config part is the configuration of the training process parameters.

The mpc_config part is the configuration of the MPC algorithm parameters, where you can choose to use the CEM optimizer or the Random optimizer.

If you want to train your model from scratch, then set the load_model parameter to False. If set to True, the trainer will load the model from model_path.

mpc_template-model_predictive_control_for_reinforcement_learning's People

Contributors

liuzuxin avatar yzx-oikawa avatar

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.