Abstract
This paper introduces a "differentiable-by-design" regularization technique for Nonlinear Programming (NLP) that enables the computation of gradients through complex controllers, such as Nonlinear Model Predictive Control (NMPC). By creating a smooth surrogate of the optimization problem, the proposed method facilitates gradient-based policy optimization even when standard mathematical assumptions for differentiability are violated.
Introduction
In modern robotics and control, Model Predictive Control (MPC) is widely utilized for its ability to handle constraints and nonlinear dynamics. However, MPC controllers often involve "tunable" parameters, such as cost weights or terminal rewards, which are challenging to set manually. Automating this process via gradient-based learning—often referred to as Policy Optimization—requires the derivative of the controller's "solution map."
Standard nonlinear optimization problems are only differentiable under strict conditions: Strong Second-Order Sufficient Conditions (SSOSC), Linear Independence Constraint Qualification (LICQ), and Strict Complementarity Slackness (SCS). In practical nonlinear MPC applications, these conditions are frequently violated, leading to non-smooth or discontinuous solution maps. This causes standard sensitivity analysis tools to fail or provide inaccurate results.
Methodology
The authors propose a principled regularization strategy to bypass these restrictive assumptions:
- Reformulation: A general NLP with equality and inequality constraints is transformed into a purely equality-constrained problem using auxiliary variables.
- Proximal Regularization: "Proximal" terms are added to the objective function to penalize deviations from a nominal point, while also regularizing the constraints.
- Surrogate Differentiation: Instead of differentiating the original optimization landscape, the method differentiates the Karush-Kuhn-Tucker (KKT) conditions of the regularized surrogate problem.
- Implicit Function Theorem (IFT): The differentiability of the surrogate allows the application of the IFT to obtain a linear system of equations, yielding the "surrogate derivative."
Notably, the original problem can be solved using standard solvers like IPOPT, with the regularization math applied only during the "backward pass" to compute the gradient.
Experimental Benchmarks
The method was evaluated on three simulation benchmarks:
- Toy Quadratic Program (QP): A 3D problem designed to be non-differentiable at specific points.
- Free-Final-Time Trajectory Optimization: A car-like robot model minimizing travel time between points.
- Receding-Horizon Nonlinear MPC: A closed-loop tracking task for a nonlinear system over a 200-step horizon.
Key Insights
- Consistency with Warm-Starting: The method provides derivatives consistent with the local minimizer found by warm-started MPC solvers.
- Linear Convergence: The surrogate derivative converges linearly to the true derivative (where it exists) as the regularization factor ($\rho$) approaches zero.
- Bypassing Assumptions: The approach works for any NLP with twice-continuously differentiable functions, regardless of LICQ or SSOSC violations.
- Surrogate vs. Approximation: The surrogate problem is locally equivalent to the original at the solution point, ensuring the regularization does not shift the optimal solution.
Results
The proposed algorithm demonstrated significant improvements in accuracy, robustness, and efficiency. In car trajectory experiments, the surrogate gradient matched finite difference approximations with a relative error of only 5.8%, even in non-differentiable regions.
Furthermore, the method achieved a cosine similarity of 0.9995 compared to ground truth in high-dimensional tests, indicating near-perfect gradient direction. Computationally, the surrogate method was approximately 10x faster than finite difference calculations.
Limitations and Future Work
The primary limitation involves the selection of the regularization parameter $\rho$. As shown in Figure 4, the accuracy of the gradient is sensitive to this parameter.
If $\rho$ is too large, the gradient becomes inaccurate; if too small, the linear system may become numerically unstable. Future research could focus on automated tuning strategies for $\rho$ and optimizing the linear algebra overhead of the backward pass using specialized sparse solvers. Applying these gradients to large-scale reinforcement learning or real-world robotic hardware remains a promising future direction.
Summary updated