Skip to content

manish-pra/sampling-gpmpc

Repository files navigation

iterative_gp_conditioning

Sampling-based Gaussian Process Model Predictive Control

License: MIT

This repository contains code for the following papers

  1. "Finite-Sample-Based Reachability for Safe Control with Gaussian Process Dynamics", preprint available on arXiv.
  2. "Towards safe and tractable Gaussian process-based MPC: Efficient sampling within a sequential quadratic programming framework", accepted for publication at the 63rd IEEE Conference on Decision and Control (CDC 2024).

The code is licensed under the MIT license.

Installation

  1. Create new workspace folder. This is used as a base directory for the following steps.
  2. Clone the main repository
        git clone https://github.com/manish-pra/sampling-gpmpc.git
  3. Clone auxiliary repositories
        git clone https://github.com/manish-pra/safe-exploration-koller.git
        git clone https://github.com/befelix/plotting_utilities.git
  4. Install dependencies
    1. Download and install acados (does not need to be in workspace).
    2. Install acados Python interface.
    3. Install Python requirements
          cd sampling-gpmpc
          pip install -r requirements.txt

Usage

  1. To run the code, run the following Python script from your base directory:

        python sampling-gpmpc/main.py -i $i -param $param_file
    

    where,

        $param_file: Name of the param file, either "params_pendulum1D_samples" or "params_car_residual"
        $i         : Experiment number, e.g. "1"
    
  2. For visualizations/videos use the following script once the experiment is completed:

        python sampling-gpmpc/visu_main.py -i $i -param $param_file
    

    This will generate a video of the simulation in the folder corresponding to the $param_file and the instance $i.

Numerical results from Finite-sample-based reachability paper

Pendulum example

Instructions

  1. Set experiment index and params file:
        param_file=params_pendulum1D_samples
        i=1
  2. Run closed-loop simulation by running main script:
        python sampling-gpmpc/main.py -i $i -param $param_file
  3. Generate video by running visualizer script:
        python sampling-gpmpc/visu_main.py -i $i -param $param_file
    

Car example

Instructions

To simulate different reachable set approximations, run the following scripts (here we choose $i=1):

  1. Set experiment index and params file:

        param_file=params_car_residual
        i=1
  2. Generate control input sequence and sampling-based predictions (data.pkl) by running main script:

        python sampling-gpmpc/main.py -i $i -param $param_file
  3. Generate forward sampling result around the above generated input sequence (data_X_traj_0.pkl, ..., data_X_traj_<num_files>.pkl) by recursively using:

        python sampling-gpmpc/benchmarking/forward_sampling_euler.py

    Running it recursively can done similar to the following script:

        ./benchmarking/euler_job.sh
  4. Generate robust tube-based predictions (koller_ellipse_data.pkl, koller_ellipse_center_data.pkl) and

        python sampling-gpmpc/benchmarking/robust_tube_based_GPMPC_koller.py -i $i -param $param_file
  5. Run plotting script:

        python sampling-gpmpc/extra/plot_car_reachable_sets.py -i $i -param $param_file

    This script requires "data_convex_hull_dim_N{N}.pkl" file in 'i' folder which can be generated by running:

        python sampling-gpmpc/benchmarking/generate_convex_hull.py -i $i -param $param_file

Result

The final result should look similar to this:

Sampling-based-predictions-pendulum

CDC 2024 Experiments

Pendulum example

Instructions

To simulate different reachable set approximations, run the following scripts (here we choose $i=1):

  1. Set experiment index and params file:

        param_file=params_pendulum
        i=1
  2. Generate control input sequence and sampling-based predictions (data.pkl) by running main script:

        python sampling-gpmpc/main.py -i $i -param $param_file
  3. Generate linearization-based predictions (cautious_ellipse_data.pkl, cautious_ellipse_center_data.pkl), robust tube-based predictions (koller_ellipse_data.pkl, koller_ellipse_center_data.pkl) and true reachable set (X_traj_list_0.pkl, ..., X_traj_list_<num_files>.pkl):

        python sampling-gpmpc/benchmarking/linearization_based_predictions.py -i $i -param $param_file
        python sampling-gpmpc/benchmarking/robust_tube_based_GPMPC_koller.py -i $i -param $param_file
        python sampling-gpmpc/benchmarking/simulate_true_reachable_set.py -i $i -param $param_file

    Important script parameters:

    • simulate_true_reachable_set.py:
      • number of samples per repeat is given by num_samples in params_pendulum.yaml
      • number of repeats can be set by num_repeat in script file
  4. Run plotting script:

        python sampling-gpmpc/extra/cdc_plt.py -i $i -param $param_file

Result

The final result should look similar to this:

Sampling-based-predictions-pendulum

Car example

Instructions

  1. Set experiment index and params file:
        param_file=params_car
        i=1
  2. Run closed-loop simulation by running main script:
        python sampling-gpmpc/main.py -i $i -param $param_file
  3. Generate video by running visualizer script:
        python sampling-gpmpc/visu_main.py -i $i -param $param_file

Result

The final result should look similar to this:

CDC_car_video

Citing us

If you use results from the paper and/or code, please cite the following papers:

@article{prajapat2025finite,
      title={Finite-Sample-Based Reachability for Safe Control with Gaussian Process Dynamics}, 
      author={Manish Prajapat and Johannes Köhler and Amon Lahr and Andreas Krause and Melanie N. Zeilinger},
      year={2025},
      journal={arXiv preprint arXiv:2505.07594},
      eprint={2505.07594},
      archivePrefix={arXiv},
      primaryClass={eess.SY},
      url={https://arxiv.org/abs/2505.07594}, 
}

@INPROCEEDINGS{prajapat2024towards,
  author={Prajapat, Manish and Lahr, Amon and Köhler, Johannes and Krause, Andreas and Zeilinger, Melanie N.},
  booktitle={Proc. IEEE 63rd Conference on Decision and Control (CDC)}, 
  title={Towards safe and tractable Gaussian process-based MPC: Efficient sampling within a sequential quadratic programming framework}, 
  year={2024},
  volume={},
  number={},
  pages={7458-7465},
  keywords={Uncertainty;Computational modeling;Real-time systems;Trajectory;Computational efficiency;Safety;Quadratic programming;Automobiles;Vehicle dynamics;Predictive control},
  doi={10.1109/CDC56724.2024.10886350}}

About

Sampling based GP MPC

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages