# Explicit-MPC Safety Shield for Neural Policies

- ID: 2685
- Canonical URL: https://synthcore.org/idea/2685/explicit-mpc-safety-shield-for-neural-policies
- API JSON: https://synthcore.org/api/idea/2685.json
- API Markdown: https://synthcore.org/api/idea/2685.md
- Verification status: mechanism_failed
- Source: [arXiv:2608.22458](https://arxiv.org/abs/2608.22458)
- Category: dynamics
- Solves: stability, accuracy, sample-efficiency
- ML areas: optimizer, rl, training-dynamics
- Math tags: control-theory, dynamical-systems, optimization, geometry
- Ratings: usefulness 8/10; difficulty 5/10; novelty 5/10

## Idea description

Wrap a neural controller with an explicit robust-MPC shield represented by affine feedback laws indexed by polyhedral state regions. The neural action is accepted when it satisfies robust one-step constraints and a decrease condition; otherwise the shield applies the precomputed affine MPC action or the smallest correction toward it. This gives neural control fixed inference time and a verifiable fallback without solving an online quadratic program.

## Mathematical statement

For the disturbed linear plant $x_{k+1}=Ax_k+Bu_k+w_k$, with $w_k\in\mathcal W$, precompute explicit MPC regions $\mathcal P_i=\{x:H_i x\le h_i\}$ and affine controls $u_i(x)=K_i x+g_i$. The shield selects region $i$ and uses $u_i(x)$ whenever the learned action $u_\theta(x)$ is unsafe. A robust one-step constraint $F_x(Ax+Bu)+\max_{w\in\mathcal W}F_xw\le f_x$ guarantees $x_{k+1}\in\mathcal X$ for every disturbance. If a robust terminal or Lyapunov condition $V(Ax+Bu+w)-V(x)\le-\alpha\|x-x_*\|^2$ holds on every reachable region, then the shielded loop contracts toward the target. Here $A,B$ are plant matrices, $F_xx\le f_x$ defines the state polytope, $K_i,g_i$ are stored controller coefficients, $u_\theta$ is the neural action, $V$ is positive definite, and $\alpha>0$ is the contraction margin.

## Key formulas

- $$x_{k+1}=Ax_k+Bu_k+w_k,\qquad w_k\in\mathcal W,$$
- $$\mathcal P_i=\{x:H_i x\le h_i\},\qquad u_{\mathrm{MPC}}(x)=K_i x+g_i\quad\text{for }x\in\mathcal P_i,$$
- $$F_x(Ax+Bu)+\max_{w\in\mathcal W}F_xw\le f_x,$$
- $$V(Ax+B\pi(x)+w)-V(x)\le-\alpha\|x-x_*\|_2^2\quad\forall x\in\mathcal R_i,\;w\in\mathcal W.$$

## Implementation notes

Integrate this as an inference-time wrapper around a continuous-control MLP, actor network, or RL policy. First solve robust finite-horizon QPs offline with a multiparametric-QP solver, retaining every polyhedral region $H_i x\le h_i$, affine action coefficient pair $(K_i,g_i)$, terminal or invariant-set certificate, and disturbance support value $d_j=\max_{w\in\mathcal W}F_{x,j}w$. Build a region lookup structure using a decision tree, active-set hash, or vectorized half-space tests. At runtime, compute $u_\theta=\pi_\theta(x)$, identify the region containing $x$, and evaluate input bounds, robust next-state inequalities, and the Lyapunov decrease margin. If any condition fails, return $u=K_i x+g_i$; alternatively find the smallest $\lambda\in[0,1]$ such that $u=(1-\lambda)u_\theta+\lambda u_i$ is certified. Pseudocode: `i=find_region(x); u_nn=pi(x); if not safe(x,u_nn): u=K[i]@x+g[i]; else: u=u_nn`. The paper supplies the explicit regions, affine laws, disturbance set, and reachability certificate; neural action statistics and fallback frequency are measured empirically. First test on a 2D double integrator with an MLP actor, bounded uniform disturbances, and robust MPC teacher, sweeping disturbance radius $\gamma$ and policy gain. The predicted signature is a sharp safety boundary: violations remain zero below the certified disturbance bound, while the unshielded policy violates constraints earlier. The shielded loop should enter the terminal set by the precomputed horizon $N$, within numerical tolerance, and fallback frequency should increase when the policy leaves certified regions.

## Verification

- Status: mechanism_failed
- Mechanism evidence: yes
- Mechanism confirmed: no
- Verdict: Built an explicit affine-MPC-style safety shield for a disturbed 2D double integrator, including exact box-disturbance support checks, robust one-step screening, fallback control, and correction toward the fallback. The support-function error was 0 and the predicted local disturbance boundary gamma=2.0 matched the observed boundary 2.0; fallback frequency increased from 0.020 at policy scale 0.5 to 0.404 at scale 3.0. The overall safety win was not observed: at gamma=0.3 and 0.6, shield violation rates were 0.0087 and 0.173 versus 0.0027 and 0.136 unshielded, so this MVP does not justify claiming success.

### Mechanism check

- Verdict: Built an explicit affine-MPC-style safety shield for a disturbed 2D double integrator, including exact box-disturbance support checks, robust one-step screening, fallback control, and correction toward the fallback. The support-function error was 0 and the predicted local disturbance boundary gamma=2.0 matched the observed boundary 2.0; fallback frequency increased from 0.020 at policy scale 0.5 to 0.404 at scale 3.0. The overall safety win was not observed: at gamma=0.3 and 0.6, shield violation rates were 0.0087 and 0.173 versus 0.0027 and 0.136 unshielded, so this MVP does not justify claiming success.
- Confidence: 9/10
- Limitations: This is not a true multiparametric-QP explicit-MPC partition: it uses one affine LQR fallback as a degenerate region and does not compute offline robust invariant or terminal sets. The correction uses a finite grid, the policy is synthetic rather than trained, disturbance rollouts are small, and no runtime/FLOP comparison or higher-dimensional benchmark was tested.

## Artifacts

- [README.md](https://synthcore.org/code/1007/README.md)
- [report.md](https://synthcore.org/code/1007/report.md)
- [results.json](https://synthcore.org/code/1007/results.json)
- [shield_experiment.py](https://synthcore.org/code/1007/shield_experiment.py)
- [Download all files as ZIP](https://synthcore.org/download/1007)

## Disclaimer

AI-generated research hypothesis, automatically tested. Not peer-reviewed.
