This repository contains code for the following papers
- "Finite-Sample-Based Reachability for Safe Control with Gaussian Process Dynamics", preprint available on arXiv.
- "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.
- Create new
workspacefolder. This is used as a base directory for the following steps. - Clone the main repository
git clone https://github.com/manish-pra/sampling-gpmpc.git
- Clone auxiliary repositories
git clone https://github.com/manish-pra/safe-exploration-koller.git git clone https://github.com/befelix/plotting_utilities.git - Install dependencies
- Download and install acados (does not need to be in
workspace). - Install acados Python interface.
- Install Python requirements
cd sampling-gpmpc pip install -r requirements.txt
- Download and install acados (does not need to be in
-
To run the code, run the following Python script from your base directory:
python sampling-gpmpc/main.py -i $i -param $param_filewhere,
$param_file: Name of the param file, either "params_pendulum1D_samples" or "params_car_residual" $i : Experiment number, e.g. "1" -
For visualizations/videos use the following script once the experiment is completed:
python sampling-gpmpc/visu_main.py -i $i -param $param_fileThis will generate a video of the simulation in the folder corresponding to the
$param_fileand the instance$i.
- Set experiment index and params file:
param_file=params_pendulum1D_samples i=1 - Run closed-loop simulation by running main script:
python sampling-gpmpc/main.py -i $i -param $param_file
- Generate video by running visualizer script:
python sampling-gpmpc/visu_main.py -i $i -param $param_file
To simulate different reachable set approximations, run the following scripts (here we choose $i=1):
-
Set experiment index and params file:
param_file=params_car_residual i=1 -
Generate control input sequence and sampling-based predictions (
data.pkl) by running main script:python sampling-gpmpc/main.py -i $i -param $param_file
-
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
-
Generate robust tube-based predictions (
koller_ellipse_data.pkl,koller_ellipse_center_data.pkl) andpython sampling-gpmpc/benchmarking/robust_tube_based_GPMPC_koller.py -i $i -param $param_file
-
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
The final result should look similar to this:
To simulate different reachable set approximations, run the following scripts (here we choose $i=1):
-
Set experiment index and params file:
param_file=params_pendulum i=1 -
Generate control input sequence and sampling-based predictions (
data.pkl) by running main script:python sampling-gpmpc/main.py -i $i -param $param_file
-
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_samplesinparams_pendulum.yaml - number of repeats can be set by
num_repeatin script file
- number of samples per repeat is given by
-
Run plotting script:
python sampling-gpmpc/extra/cdc_plt.py -i $i -param $param_file
The final result should look similar to this:
- Set experiment index and params file:
param_file=params_car i=1 - Run closed-loop simulation by running main script:
python sampling-gpmpc/main.py -i $i -param $param_file
- Generate video by running visualizer script:
python sampling-gpmpc/visu_main.py -i $i -param $param_file
The final result should look similar to this:
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}}



