arXiv(opens in a new tab)cs.ROSep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.01061

Accelerating Reinforcement Learning via MPC Solver-Gradient Guidance for Weights-varying MPC

Baha Zarrouki, Arslan Thobani, Jasper Hoffmann, Mattia Piccinini, Rudolf Reiter, Felix Jahncke, Sébastien Gros, Davide Scaramuzza, Johannes Betz

Baha Zarrouki, Arslan Thobani, Jasper Hoffmann, Mattia Piccinini, Rudolf Reiter, Felix Jahncke, Sébastien Gros, Davide Scaramuzza, and Johannes Betz

Abstract—In Model Predictive Control (MPC), cost-function weights shape closed-loop behavior, yet changing conditions often make fixed parametrizations suboptimal and motivate context-dependent online adaptation. Learning such policies is difficult because behavior depends implicitly on numerical MPC solutions, producing nonlinear, potentially nonsmooth, long-horizon dependencies on policy parameters. This creates a bias-variance tradeoff: Reinforcement Learning (RL) optimizes realized closed-loop return from environment samples but is sample-inefficient, whereas Gradient-Based Policy Learning (GB-PL) uses low-variance solver gradients from differentiable MPC to optimize surrogate losses on predicted trajectories but can be biased under model mismatch. We propose Solver-Gradient Guided Reinforcement Learning (SG-RL), a solver-sensitivity augmentation for RL-based online MPC cost-weight adaptation. SG-RL keeps sampled closed-loop return as the objective and uses bounded solver-derived gradients as auxiliary guidance to improve stability and sample efficiency. We instantiate SG-RL in Proximal Policy Optimization (PPO) with four modular algorithms that inject solver-gradient guidance into actor-update scaling, policy loss, advantage estimation, and value-function learning. On two full-scale autonomous racing platforms with intentional model mismatch, SG-RL reaches PPO's best closed-loop return with up to 70.6% fewer samples, outperforms GB-PL baselines by at least 54% in closed-loop return, and generalizes zero-shot to unseen environments.

Index Terms—Learning and Adaptive Systems; Robust/ Adaptive Control of Robotic Systems; Optimization and Optimal Control; Reinforcement Learning for MPC

I. INTRODUCTION

Model Predictive Control (MPC) is a powerful framework for constrained optimal control of complex dynamical systems [1]. Its closed-loop performance depends heavily on the formulation of the optimization problem, including the system model, constraints, and cost function. In many applications, the model and constraints are fixed to preserve safety guarantees. The cost function remains a primary mechanism for shaping controller closed-loop behavior and trading off competing objectives [2]. However, a single fixed set of cost-function weights is often insufficient when operating conditions change. Different scenarios may require different trade-offs between objectives, making the relationship between cost weights and closed-loop performance highly context dependent. This observation has motivated the development of Weights-varying MPC approaches [3], [4], [5], which adapt the cost-function weights online while keeping the underlying model and constraints unchanged. Such adaptation is particularly relevant in safety-critical and highly dynamic applications. A prominent example is the combined nonlinear longitudinal-lateral control problem in autonomous vehicle racing [6], where operating

Figure

Fig. 1: Solver-Gradient Guided Reinforcement Learning (SG-RL) learns an online MPC weight-adaptation policy πϕ\pi_{\phi} by combining environment-based policy-gradient learning ∇ϕJRL\nabla_{\phi} \mathcal{J}_{\mathrm{RL}} with model-based solver-gradient guidance ∇ϕJSG\nabla_{\phi} \mathcal{J}_{\mathrm{SG}}. The update preserves closed-loop return optimization while using solver sensitivities as bounded, model-informed guidance for improved sample efficiency and performance.

near the handling limits requires different performance trade-offs across racetrack segments.

Learning such policies is challenging because it induces a bilevel optimization structure [7]. Specifically, the return depends on the policy parameters only indirectly, through the numerical solution of a constrained MPC; decisions at one time step affect future states and therefore future MPC solutions, resulting in long-horizon credit-assignment problems; the MPC solver introduces implicit, nonlinear, and potentially non-smooth mappings that complicate gradient computation; and the policy must be learned in closed-loop interaction with the controlled system.

Existing approaches for MPC cost-weight optimization can broadly be divided into two categories. The first computes a single fixed parameter vector offline, whereas the second learns a state-dependent weight-adaptation policy online. Classical offline tuning methods, such as genetic algorithms and Bayesian optimization [8], [9], [10], [11], can identify useful fixed weights but do not address online adaptation to changing conditions. Since this work addresses online adaptation, we focus on the latter category. In the taxonomy of [12], this corresponds to a hierarchical Reinforcement Learning (RL)–MPC architecture in which the MPC is part of the actor and a neural policy supplies the MPC parameters. Within this setting, recent work distinguishes two complementary sources of learning signal: methods that build environment-based gradients from sampled closed-loop interactions (black-box learning), and methods that compute model-based solver gradients by differentiating through the MPC solver (white-box learning).

The first family learns online cost-weight adaptation policies using environment-based gradients. The environment-based baselines considered here construct policy updates from sampled closed-loop returns, treating the MPC controller as part of the environment [3], [4], [13], [14]. RL has also been applied more broadly to learning fixed MPC parameters, such as terminal costs or prediction horizons [15], [14], while the concept of Weights-varying MPC introduced learning state-dependent cost-weight adaptation policies [3], [4]. More generally, MPC has been incorporated as a structured policy or value-function approximator within actor-critic architectures, deterministic and stochastic policy-gradient methods, economic MPC, learning-based MPC formulations, and joint system-identification and control frameworks [16], [17], [18], [19], [20], [21], [22], [23], [24]. These baselines benefit from long-horizon credit assignment and can use reward signals defined by broad classes of closed-loop objectives, including non-smooth or sparse terms. However, their updates still rely on sampled closed-loop interactions and inherit the usual approximation, finite-horizon, and estimator-bias issues of practical policy-gradient methods.

The second family learns MPC parameters using model-based solver gradients obtained from differentiable optimization. Building on task-based learning through optimization problems [25], differentiable optimization layers [26], [27], and differentiable MPC [28], recent advances enable efficient backpropagation through increasingly general MPC formulations, including constrained nonlinear MPC [29], [30]. Until recently, such approaches focused almost exclusively on optimizing fixed MPC parameters through solver sensitivities, including DiffTune-MPC [31], differentiable actor learning [32], cost-matching approaches [33], and ZipMPC [34]. Only very recently, gradient-based policy learning (Gradient-Based Policy Learning (GB-PL)) for nonlinear MPC [5] extended the differentiable nonlinear MPC to learn online cost-weight adaptation policies. Our GB-PL baseline is built upon [5] and uses a recent backpropagation software feature in acados [29] to efficiently compute solver gradients for nonlinear constrained MPC. In this view, GB-PL plays a cost-matching role: it aligns a differentiable MPC surrogate loss with task-level performance terms on trajectories generated by the predictive model. Unlike environment-based RL updates, these methods exploit local first-order gradients of the differentiable surrogate under solver-regularity assumptions, resulting in substantially higher sample efficiency when the surrogate is informative.

Despite their sample efficiency, differentiable-solver methods optimize model-based surrogate objectives whose gradients are only as accurate as the predictive model and therefore may become misleading under model mismatch. Furthermore, they generally lack the exploration mechanisms and long-horizon value estimation that make RL effective for optimizing the performance of the realized closed-loop. Conversely, our environment-based PPO baseline does not use the rich first-order information available from differentiable MPC solvers. The methods compared in this work therefore emphasize one of two complementary information sources: either sampled closed-loop returns or solver sensitivities. Environment-based gradients more directly reflect the realized closed-loop objective but can suffer from high variance, whereas solver gradients provide lower-variance local guidance but inherit bias from the predictive model. Their complementary properties motivate the combination of both within a single learning framework. This gap motivates the central question of this paper: how can environment-based and model-based solver gradients be combined effectively for learning online MPC cost-weight adaptation policies?

This question is related to a broader family of guided, structured, and hybrid reinforcement-learning methods that combine model-free policy updates with model-based gradients, planning modules, auxiliary losses, or teacher signals [35], [36], [37], [38], [39], [40], [41], [42], [43]. These methods demonstrate that combining complementary gradient estimators can substantially improve learning efficiency. However, these works do not use differentiable constrained nonlinear MPC solver sensitivities as structured auxiliary gradients for policy optimization over online MPC cost weights.

Within the differentiable MPC literature, solver sensitivities have also been used beyond direct parameter optimization. Adhau et al. [44] employ nonlinear-program sensitivities to approximate action-value quantities in a Q-learning framework, thereby reducing the number of MPC evaluations required during learning. This approach, however, neither learns an online cost-weight adaptation policy nor uses solver sensitivities to guide policy optimization itself. Romero et al. [32] propagate solver gradients through a differentiable linear MPC layer embedded in a PPO actor for quadrotor control, while related hybrid schemes study differentiable simulation gradients [45] or use RL to provide NMPC reference guidance [46]. In contrast, our differentiable nonlinear MPC-based work does not replace environment-based policy gradients with model-based solver gradients, nor does it guide the controller only through references. Instead of viewing solver gradients as an alternative optimization objective, we use them as auxiliary signals inside PPO. Consequently, the optimization objective remains the sampled closed-loop return, while solver sensitivities provide local model-informed search directions for online cost-weight adaptation with constrained nonlinear MPC.

The contributions of this work are threefold:

  1. Solver-gradient Guide for online MPC weight adaptation. We introduce Solver-Gradient Guided Reinforcement Learning (SG-RL), a framework for online cost-weight adaptation in constrained nonlinear MPC. Compared to RL, which learns from environment-based policy gradients estimated from sampled closed-loop returns, and differentiable-solver approaches that optimize model-based surrogate objectives using solver sensitivities, SG-RL uses solver-gradient guidance as an auxiliary signal for RL while still optimizing the realized closed-loop return (Sec. VI).

  2. Four methods for guiding Proximal Policy Optimization

(PPO) through solver sensitivities. We instantiate this mechanism through four modular SG-RL algorithms that integrate the same solver-gradient guidance into distinct PPO components: actor-update scaling, performance-gated auxiliary policy learning, solver-guided advantage estimation, and solver-aware critic learning. These methods provide four complementary instantiations of the SG-RL framework and are evaluated separately to understand which forms of solver guidance are most effective in practice (Sec. VI).

  1. Full-scale validation under model mismatch. We demonstrate our SG-RL on a closed-loop high-dimensional, highly nonlinear control task: nonlinear MPC for combined longitudinal and lateral vehicle control on two full-scale, high-fidelity autonomous racing simulation platforms, following racelines near the vehicle handling limits under intentional model mismatch. In this setting, all SG-RL variants outperform the PPO baseline in peak closed-loop performance, reach PPO's best return with up to 70.6% fewer training samples, and outperform the GB-PL baselines by at least 54% in return, while also demonstrating zero-shot generalization and interpretable weight-adaptation strategies (Sec. VIII-IX-B).

Notation and Background. We denote by πϕ(⋅∣ot)\pi_{\phi}(\cdot \mid o_t) a stochastic actor that maps the observation oto_t to a distribution over MPC weights, with mean μϕ(ot)\mu_{\phi}(o_t), while Vψ(ot)V_{\psi}(o_t) denotes the critic and provides the value function. We use the generalized-advantage estimate A^t\hat{A}_t [47] to quantify whether the sampled weight vector performed better or worse than expected. With TD residual δt:=rt+γVψ(ot+1)−Vψ(ot)\delta_t := r_t + \gamma V_{\psi}(o_{t+1}) - V_{\psi}(o_t), we write

A^t=δt+γλ(1−dt+1)A^t+1,(1)\hat{A}_{t}=\delta_{t}+\gamma\lambda(1-d_{t+1})\hat{A}_{t+1}, \tag{1}

where γ\gamma is the discount factor and λ\lambda is the GAE parameter [47]. PPO updates the actor through the clipped surrogate objective

JPPO(ϕ)=E^t[min⁡(ρt(ϕ)A^t,clip(ρt(ϕ),1−ϵ,1+ϵ)A^t)],\begin{align*}\mathcal{J}_{\mathrm{PPO}}(\phi)=\hat{\mathbb{E}}_{t}\Big[\min\big(\rho_{t}(\phi)\hat{A}_{t},\\ \mathrm{clip}\big(\rho_{t}(\phi),1-\epsilon,1+\epsilon\big)\hat{A}_{t}\big)\Big],\end{align*}

(2)

with sampled action at≡θt\boldsymbol{a}_t \equiv \boldsymbol{\theta}_t, ratio ρt(ϕ)=πϕ(at∣ot)/πϕold(at∣ot)\rho_t(\phi) = \pi_{\phi}(\boldsymbol{a}_t \mid \boldsymbol{o}_t)/\pi_{\phi_{\text{old}}}(\boldsymbol{a}_t \mid \boldsymbol{o}_t), and clipping range ϵ\epsilon. For the critic, we use the standard value-regression term based on the fixed target R^tλ:=A^t+Vψold(ot)\hat{R}_t^{\lambda} := \hat{A}_t + V_{\psi_{\text{old}}}(\boldsymbol{o}_t).

Actor and critic are then optimized through the standard combined PPO loss

LPPO(ϕ,ψ)=−JPPO(ϕ)+cVLV(ψ)−centE^t[H(πϕ(⋅∣ot))],(3)\begin{aligned}\mathcal{L}_{\mathrm{PPO}}(\phi,\psi)=&-\mathcal{J}_{\mathrm{PPO}}(\phi)+c_{V}\mathcal{L}_{V}(\psi)\\&-c_{\mathrm{ent}}\hat{\mathbb{E}}_{t}\big[\mathcal{H}(\pi_{\phi}(\cdot\mid\boldsymbol{o}_{t}))\big],\end{aligned} \tag{3}

where cVc_{V} and centc_{ent} weight the value and entropy terms, respectively. The standard RL update used as baseline later with learning rate η\eta is

URL:(ϕk+1,ψk+1)=(ϕk,ψk)−η∇ϕ,ψLPPO(ϕ,ψ)(4)\mathcal{U}_{\mathrm{R L}}:\left(\phi_{k+1},\psi_{k+1}\right)=\left(\phi_{k},\psi_{k}\right)-\eta\nabla_{\phi,\psi}\mathcal{L}_{\mathrm{P P O}}(\phi,\psi) \tag{4}

References (56)

  • theory, computation, and design, 2nd ed. Madison, Wisconsin: Nob Hill Publishing, 2017
  • Actor-Critic Model Predictive Control
  • Weights-varying mpc for autonomous vehicle guidance: a deep reinforcement learning approach
  • A safe reinforcement learning driven weights-varying model predictive control for autonomous vehicle motion control
  • Differentiable weights-varying nonlinear mpc via gradient-based policy learning: An autonomous vehicle guidance example
  • Autonomous vehicles on the edge: A survey on autonomous vehicle racing
  • Bilevel programming for hyperparameter optimization and meta-learning
  • Optimal tuning of model predictive controller weights using genetic algorithm with interactive decision tree for industrial cement kiln process
  • Tuning a model predictive controller for doubly fed induction generator employing a constrained genetic algorithm
  • A data-driven automatic tuning method for mpc under uncertainty using constrained bayesian optimization
  • Performance-based trajectory optimization for path following control using bayesian optimization
  • Synthesis of model predictive control and reinforcement learning: Survey and classification
  • A hierarchical approach for strategic motion planning in autonomous racing
  • Optimization of the model predictive control meta-parameters through reinforcement learning
  • Reinforcement learning of the prediction horizon in model predictive control
  • Practical reinforcement learning of stabilizing economic mpc
  • Data-driven economic nmpc using reinforcement learning
  • Reinforcement learning for mixed-integer problems based on mpc
  • Reinforcement learning based on mpc and the stochastic policy gradient method
  • Mpc-based reinforcement learning for economic problems with application to battery storage
  • Combining q-learning and deterministic policy gradient for learning-based mpc
  • Combining system identification with reinforcement learning-based mpc
  • Adaptive Stochastic Nonlinear Model Predictive Control with Look-ahead Deep Reinforcement Learning for Autonomous Vehicle Motion Control
  • Learning-based mpc from big data using reinforcement learning
  • Task-based end-to-end model learning in stochastic optimization
  • Optnet: Differentiable optimization as a layer in neural networks
  • Differentiable convex optimization layers
  • Differentiable mpc for end-to-end planning and control
  • Differentiable Nonlinear Model Predictive Control
  • leap-c/leap-c: v0.1.0-alpha
  • DiffTune-MPC: Closed-Loop Learning for Model Predictive Control
  • Actor-critic model predictive control: Differentiable optimization meets reinforcement learning for agile flight
  • Cost-matching model predictive control for efficient reinforcement learning in humanoid locomotion (opens arXiv in a new tab)
  • ZipMPC: Compressed Context-Dependent MPC Cost via Imitation Learning
  • Learning neural network policies with guided policy search under unknown dynamics
  • Learning continuous control policies by stochastic value gradients
  • Value iteration networks
  • PIPPS: Flexible model-based policy search robust to the curse of chaos
  • Model-augmented actor-critic: Back-propagation through paths
  • Accelerated policy learning with parallel differentiable simulation
  • Temporal difference learning for model predictive control
  • TD-MPC2: Scalable, robust world models for continuous control (opens arXiv in a new tab)
  • Kickstarting deep reinforcement learning
  • Fast reinforcement learning based mpc based on nlp sensitivities
  • Do differentiable simulators give better policy gradients?
  • Ac4mpc: Actor-critic reinforcement learning for guiding model predictive control
  • High-dimensional continuous control using generalized advantage estimation (opens arXiv in a new tab)
  • acados—a modular open-source framework for fast embedded optimal control
  • A stochastic nonlinear model predictive control with an uncertainty propagation horizon for autonomous vehicle motion control
  • RNMPC: A Real-Time Reduced Robustified Nonlinear Model Predictive Control with Ellipsoidal Uncertainty Sets for Autonomous Vehicle Motion Control
  • Magic formula tyre model with transient properties
  • Online time-optimal trajectory planning on three-dimensional race tracks
  • Impacts of g-g-v constraints formulations on online minimum-time vehicle trajectory planning
  • Analyzing the impact of simulation fidelity on the evaluation of autonomous driving motion control
  • A comprehensive benchmark of vehicle dynamics models for autonomous racing: a deep dive into mpc
  • Stable-baselines3: Reliable reinforcement learning implementations