This repository contains the implementation of a Safe Hierarchical Inference for Lightweight Duality-Screened MPC (SHIELD) algorithm.
Hansung Kim (hansung@berkeley.edu) Siddharth Nair (siddharth_nair@berkeley.edu) Francesco Borrelli
We propose a hierarchical learning-and-verification architecture that rethinks how learning interacts with optimization. Instead of learning to predict the entire optimizer, our approach learns to predict the relevant structure of the optimization problem itself. A deep neural network (DNN) maps the current system state and environmental features to a reduced set of constraints and decision variables that are likely to be active or influential for the current control step. This yields a smaller, problem-specific MPC instance (SHIELD MPC) that captures only the essential local dynamics. Leveraging strong duality and convex sensitivity analysis, we derive a priori screening conditions that guarantee when such DNN-based eliminations are safe—that is, when removing a constraint or decision variable does not change the optimal cost or feasibility beyond a user-specified tolerance.
Proposed: SHIELD MPC
|
Baseline: Full MPC
|
Proposed: SHIELD MPC
|
Baseline: Full MPC
|
> x35 Improvement in the total computation time!
This implementation is built on nuPlan for simulation. Furthermore, for uncertain, multi-modal forecast generation, we use the opensource Wayformer implementation by UniTraj.
- Go to https://www.nuscenes.org/nuplan and download nuPlan mini v1.1 dataset.
- Follow the instructions in nuplan-devkit to set up the dataset
Conda:
conda env create -f environment.yml
conda activate shield
UniTraj:
- Install UniTraj and its dependencies from here: https://github.com/vita-epfl/UniTraj?tab=readme-ov-file
- Do the data preparation step in UniTraj installation using ScenarioNet
Create a folder named /expert_data in which the collected data and evaluation results will be saved.
export NUPLAN_ROOT_DIR="<directory of nuplan-devkit>"
Run ALL of the scripts from the tutorials directory
cd tutorials
python nuplan_data_collection.py
python nuplan_process_data.py --filepath <dir to collected data>
python nuplan_RAIDNET_train_joint.py
python nuplan_RAIDNET_evaluate_binary_joint.py
python nuplan_closedloop_evaluate.py
After each simulation is completed, it saves the video and time snapshots in expert_data/video and
saves a simulation log to expert_data folder
python nuplan_closedloop_eval_stats.py --filename <dir to the simulation log>



