MCPcopy Index your code
hub / github.com/LeCAR-Lab/model-based-diffusion

github.com/LeCAR-Lab/model-based-diffusion @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
107 symbols 360 edges 22 files 25 documented · 23%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Model-Based Diffusion for Trajectory Optimization

[Website] [PDF] [Arxiv]

License

This repository contains the code for the paper "Model-based Diffusion for Trajectory Optimization".

Model-based diffusion (MBD) is a novel diffusion-based trajectory optimization framework that employs a dynamics model to approximate the score function. MBD outperforms existing methods (including RL) in terms of sample efficiency and generalization.

Installation

To install the required packages, run the following command:

git clone --depth 1 git@github.com:LeCAR-Lab/model-based-diffusion.git
pip install -e .

Usage

Model-based Diffusion for Trajectory Optimization

To run model-based diffusion to optimize a trajectory, run the following command:

cd mbd/planners
python mbd_planner.py --env_name $ENV_NAME

where $ENV_NAME is the name of the environment, you can choose from hopper, halfcheetah, walker2d, ant, humanoidrun, humanoidstandup, humanoidtrack, car2d, pushT.

To run model-based diffusion combined with demonstrations, run the following command:

cd mbd/planners
python mbd_planner.py --env_name $ENV_NAME --enable_demos

Currently, only the humanoidtrack, car2d support demonstrations.

To run multiple seeds, run the following command:

cd mbd/scripts
python run_mbd.py --env_name $ENV_NAME

To visualize the diffusion process, run the following command:

cd mbd/scripts
python vis_diffusion.py --env_name $ENV_NAME

Please make sure you have run the planner first to generate the data.

Model-based Diffusion for Black-box Optimization

To run model-based diffusion for black-box optimization, run the following command:

cd mbd/blackbox
python mbd_opt.py

Other Baselines

To run RL-based baselines, run the following command:

cd mbd/rl
python train_brax.py --env_name $ENV_NAME

To run other zeroth order trajectory optimization baselines, run the following command:

cd mbd/planners
python path_integral.py --env_name $ENV_NAME --mode $MODE

where $MODE is the mode of the planner, you can choose from mppi, cem, cma-es.

Acknowledgements

  • This codebase's environment and RL implementation is built on top of Brax.

BibTeX

@misc{pan2024modelbaseddiffusiontrajectoryoptimization,
      title={Model-Based Diffusion for Trajectory Optimization}, 
      author={Chaoyi Pan and Zeji Yi and Guanya Shi and Guannan Qu},
      year={2024},
      eprint={2407.01573},
      archivePrefix={arXiv},
      primaryClass={cs.RO},
      url={https://arxiv.org/abs/2407.01573}, 
}

Core symbols most depended-on inside this repo

objective_function
called by 4
mbd/notebooks/01_1d_demo.py
render
called by 4
mbd/envs/car2d.py
_get_reward
called by 3
mbd/envs/pushT.py
reverse_once
called by 2
mbd/blackbox/mbd_opt.py
_partial_flatten
called by 2
mbd/blackbox/mbd_mnist.py
_one_hot
called by 2
mbd/blackbox/mbd_mnist.py
parse_labels
called by 2
mbd/blackbox/mbd_mnist.py
parse_images
called by 2
mbd/blackbox/mbd_mnist.py

Shape

Method 50
Function 43
Class 14

Languages

Python100%

Modules by API surface

mbd/blackbox/mbd_mnist.py14 symbols
mbd/envs/car2d.py13 symbols
mbd/envs/pushT.py10 symbols
mbd/planners/path_integral.py7 symbols
mbd/envs/humanoidtrack.py7 symbols
mbd/envs/walker2d.py6 symbols
mbd/envs/humanoidstandup.py6 symbols
mbd/envs/humanoidrun.py6 symbols
mbd/envs/hopper.py6 symbols
mbd/envs/cartpole.py6 symbols
mbd/blackbox/mbd_opt.py5 symbols
mbd/utils.py4 symbols

For agents

$ claude mcp add model-based-diffusion \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact