ZipMPC: Context-Dependent Cost for MPC
- ZipMPC is a supervised imitation-learning framework that learns a compressed, context-dependent cost for short-horizon MPC, enabling the controller to mimic long-horizon expert behavior.
- It uses a neural network to adjust cost parameters online based on state and environmental context, ensuring decisions align with long-term objectives while remaining computationally efficient.
- Experimental results in autonomous racing show that ZipMPC achieves near long-horizon performance with significantly reduced computation time, validating its practical real-time deployment.
Searching arXiv for the ZipMPC paper and closely related differentiable MPC work. Searching arXiv for "ZipMPC" and "Differentiable MPC". ZipMPC is a supervised imitation-learning framework for learning a context-dependent cost function for short-horizon model predictive control (MPC). It is designed for settings in which long-horizon MPC yields desirable behavior but is computationally too expensive for real-time deployment. The method trains a neural network to map the current state and long-horizon environmental context into cost parameters for a short-horizon constrained MPC, so that the resulting controller imitates a well-tuned long-horizon expert while retaining online runtime close to that of the short-horizon problem (Rickenbach et al., 17 Jul 2025).
1. Problem setting and conceptual scope
ZipMPC addresses a standard tradeoff in model predictive control. Long-horizon MPC can optimize behavior with respect to long-term objectives because it reasons farther into the future, but its optimization problem grows with horizon length and can become impractical for real-time systems. Short-horizon MPC is computationally cheaper and therefore real-time feasible, but it often behaves myopically because it lacks future information. The paper emphasizes that this tradeoff is not only computational: short horizons also make cost design substantially harder, because a stage cost that works well under a long horizon may fail to align local decisions with the desired long-term task objective when the controller cannot anticipate distant consequences (Rickenbach et al., 17 Jul 2025).
ZipMPC is proposed precisely for the question of how to design a short-horizon MPC cost that preserves the behavior and long-term objective of a well-performing long-horizon MPC. Its core idea is to learn a compressed, context-dependent short-horizon cost rather than a direct policy . In this formulation, the system dynamics, the constraint structure, and the online optimization layer remain explicit. What changes online is the objective of the short-horizon MPC, conditioned on the current situation and on information lying beyond the short horizon (Rickenbach et al., 17 Jul 2025).
The term “compressed context-dependent MPC cost” has two specific meanings in the paper. “Compressed” means that the effect of long-horizon future information is not represented by explicitly optimizing over the full long horizon; instead, it is summarized into a lower-dimensional set of cost parameters for the short-horizon problem. “Context-dependent” means that the cost is not globally fixed, but changes with state and environment. In the racing experiments, the context is a long-horizon sequence of track curvatures ahead of the vehicle, which provides exactly the kind of future geometric information a short-horizon controller would otherwise miss (Rickenbach et al., 17 Jul 2025).
A common ambiguity in the literature concerns the acronym “MPC.” In ZipMPC it denotes model predictive control, not secure multi-party computation; the latter usage appears in unrelated systems-oriented work such as "SMT-Boosted Security Types for Low-Level MPC" (Skalka et al., 29 Jan 2025).
2. Mathematical formulation and learned cost structure
The paper formulates a context-dependent discrete-time system as
where is the state, is the control input, and is environmental context. For prediction horizon , the MPC problem is written as
Here are stage-cost parameters and . Only the first control is applied before the problem is re-solved at the next step. The formulation deliberately omits terminal ingredients, motivated by the observation that sufficiently long horizons may already produce good performance and that terminal cost or constraint design can itself be difficult (Rickenbach et al., 17 Jul 2025).
The expert controller is a long-horizon MPC with horizon 0,
1
where 2 is manually tuned. The learned controller is a short-horizon MPC with 3,
4
Learning is posed as trajectory imitation:
5
Because the horizons differ, the comparison uses only the first part of the trajectories; conceptually this is the first 6 steps, while the implementation uses only the first 7 steps (Rickenbach et al., 17 Jul 2025).
The central parameterization is
8
where 9 is a neural network and 0 is the contextual sequence carrying long-horizon information. In implementation, ZipMPC learns a residual correction on top of a manual warm start:
1
Accordingly, the method does not predict the entire cost from scratch; it learns how to modify a standard short-horizon cost so that the resulting short-horizon optimizer behaves like the long-horizon expert (Rickenbach et al., 17 Jul 2025).
For autonomous racing, the short-horizon controller is a model predictive contouring controller (MPCC) in Frenet coordinates with quadratic stage cost. The per-stage parameter is
2
and the stage objective takes the quadratic-plus-linear form
3
The network predicts both 4 and 5, denoted in the paper by mappings 6 and 7 (Rickenbach et al., 17 Jul 2025).
3. Differentiable training pipeline
Training requires gradient propagation through the short-horizon MPC solution map. The paper writes the loss gradient as
8
The difficult term is the derivative of the MPC solution with respect to the cost parameters. For this, ZipMPC uses the differentiable MPC method of Amos et al. (2018), based on iLQR-style approximations and KKT-based differentiation (Rickenbach et al., 17 Jul 2025, Amos et al., 2018).
The data generation and optimization pipeline is explicit. A feasible initial state 9 is sampled, the long-horizon expert 0 is solved, and its optimal predicted trajectory is used as supervision. The neural network receives the current state and context sequence, predicts the cost correction 1, forms the learned cost 2, solves the short-horizon MPC, compares the resulting trajectory with the expert trajectory, and updates 3 by backpropagation using Adam. Algorithm 1 is executed in mini-batches (Rickenbach et al., 17 Jul 2025).
The imitation objective is mean squared error over trajectories:
4
The appendix clarifies that the loss is the sum of MSE on state variables and MSE on control variables, that only the first 5 steps are used, and that variables are manually weighted because their scales differ. The training target is therefore trajectory and action imitation rather than direct matching of cost parameters (Rickenbach et al., 17 Jul 2025).
Several stabilization measures are reported. The residual formulation provides a warm start via the manual short-horizon cost. Infeasible initial states are excluded. Because the differentiable MPC approximation uses soft state constraints, samples for which the differentiable solver mismatches a standard solver beyond a tolerance are also excluded from gradient computation. Validation and model selection are based on lap performance on a fixed initial state; this is described as especially important for the Pacejka model because of nonconvexity (Rickenbach et al., 17 Jul 2025).
4. Architecture, context encoding, and deployment behavior
The input to the neural network consists of three state-derived global variables, 6, 7, and 8, together with the context time series 9, which is a sequence of upcoming track curvatures. This sequence is formed starting from the current progress 0 and collecting curvature values up to the maximum possible progress 1 achievable over the long horizon; the appendix gives the example
2
In the racing setting, this context representation is intended to supply the information gap between 3 and 4, such as upcoming curvature that would matter for preparatory positioning and speed adaptation (Rickenbach et al., 17 Jul 2025).
The network architecture combines a convolutional feature extractor for the curvature time series with batch normalization and dropout, followed by four fully connected layers, each with 512 hidden units and LeakyReLU activation. The final shared representation branches into two outputs: a global representation layer producing a fixed component of the MPC cost, and a modulation layer producing time-varying components. The modulation layer has output dimension
5
because it predicts both 6 and 7. The final output is scaled to keep predicted parameters within a certain range, although the exact range is specified in code rather than in the paper text (Rickenbach et al., 17 Jul 2025).
At deployment time, the controller measures the current state 8, extracts the context sequence 9 from environment geometry, runs the neural network to obtain 0, forms 1, solves the short-horizon MPC using the known dynamics and constraints, and applies the first control action. The online computational budget is therefore described as the cost of neural-network inference plus the solve time of the short-horizon MPC (Rickenbach et al., 17 Jul 2025).
The paper emphasizes that ZipMPC learns the cost rather than the control action directly. What remains fixed is the dynamics model 2, the MPC constraint structure, the short horizon 3, the long-horizon expert formulation, and the manual base cost 4. What is learned is the mapping 5, equivalently the cost correction 6, or the short-horizon cost parameters 7 and 8. This distinction is central to the method’s claim of preserving structured constraint-aware control (Rickenbach et al., 17 Jul 2025).
5. Autonomous racing instantiation and experimental evidence
The main application domain is autonomous racing in Frenet coordinates, evaluated in simulation with a kinematic bicycle model and a more complex Pacejka vehicle model, and in real-world experiments with a 1/28-scaled miniature race car. For the kinematic model, the state is
9
with inputs acceleration 0 and steering angle 1. For the Pacejka model, the state is
2
with inputs motor torque 3 and steering angle 4. The racing MPCC uses the track boundary constraint
5
together with polyhedral constraints
6
Tracks have constant width 7, and context is based on track curvature 8 (Rickenbach et al., 17 Jul 2025).
The experimental baselines are the long-horizon expert 9, the short-horizon controller 0, a Bayesian-optimization baseline that tunes a constant 1-cost to minimize imitation loss between short and long MPC, and an eMPC baseline consisting of a neural network policy that clones the long-horizon MPC directly. The paper also situates ZipMPC conceptually against approximate explicit MPC and automatic cost parameter tuning, though not all such methods are direct empirical baselines (Rickenbach et al., 17 Jul 2025).
On the kinematic model, ZipMPC achieves the lowest trajectory imitation RMSE in all tested horizon settings. For 2, the reported trajectory RMSE is 3 for short MPC, 4 for the BO baseline, 5 for eMPC, and 6 for ZipMPC. For 7, the corresponding values are 8, 9, 0, and 1, respectively (Rickenbach et al., 17 Jul 2025).
Lap-time results show the same pattern. For the kinematic model with 2, long-horizon MPC achieves 3 s, short-horizon MPC 4 s, BO 5 s, eMPC does not complete the lap, and ZipMPC achieves 6 s. For 7, long-horizon MPC remains at 8 s, short-horizon MPC achieves 9 s, BO 0 s, and ZipMPC 1 s. These results place ZipMPC close to the long-horizon reference while maintaining short-horizon computational characteristics (Rickenbach et al., 17 Jul 2025).
The Pacejka results are more severe because short horizons can fail to complete the lap. For 2, long-horizon MPC achieves 3 s, short-horizon MPC does not complete, and ZipMPC achieves 4 s, successful in at least 80% of attempts, with execution time reduction 5. For 6, long-horizon MPC achieves 7 s, short-horizon MPC does not complete, and ZipMPC achieves 8 s, with execution time reduction 9. For 00, short-horizon MPC achieves 01 s, whereas ZipMPC achieves 02 s, with execution time reduction 03 (Rickenbach et al., 17 Jul 2025).
The runtime appendix supports the claim that ZipMPC remains near the computational cost of short-horizon MPC. For the kinematic model with 04, 05 runs at 06 ms, 07 at 08 ms, and ZipMPC at 09 ms. For the Pacejka model with 10, the corresponding values are 11 ms, 12 ms, and 13 ms (Rickenbach et al., 17 Jul 2025).
6. Generalization, interpretation, and limitations
A central empirical claim is generalization to unseen environments. The training procedure uses a single track containing diverse curvature sequences, while evaluation is performed both on that track and on two unseen tracks of different lengths and curvature patterns. For the kinematic model with 14, lap times are 15 for long MPC, 16 for short MPC, and 17 for ZipMPC on the training track; 18, 19, and 20 on Test 1; and 21, 22, and 23 on Test 2. For the Pacejka model with 24, the train-track times are 25, 26, and 27; Test 1 gives 28, 29, and 30; Test 2 gives 31, 32, and 33. The paper stresses that the unseen tracks are chosen so that curvature steepness does not extrapolate beyond training support (Rickenbach et al., 17 Jul 2025).
The ablation study isolates the importance of context dependence by comparing 34 and 35 against context-free variants depending only on 36. The reported result is that context provides substantial improvement, especially when 37 is much smaller than 38, while the benefit diminishes as 39 approaches 40. The paper also analyzes a learned linear cost component 41 associated with lateral deviation, reporting that right-hand curves lead to positive learned 42, left-hand curves lead to negative learned 43, and that 44 strongly correlates with average upcoming curvature. This supports an interpretable reading of the learned cost shaping (Rickenbach et al., 17 Jul 2025).
The real-world setup uses the Chronos and CRS test bench, with a 1/28-scaled miniature car, pose measurement by a motion capture system, a server running the control algorithm, WiFi communication, and racing on a predefined track. ZipMPC is trained in simulation and deployed on hardware without retraining. The hardware results are mostly qualitative in the main text, but they include the observation that ZipMPC improves trajectories over short-horizon MPC and, in one additional setting with 45, that short-horizon MPC gets stuck at the third corner after 4 seconds while ZipMPC completes the lap (Rickenbach et al., 17 Jul 2025).
The method’s strengths, assumptions, and limitations are stated explicitly. The claimed strengths are near long-horizon performance with short-horizon runtime, preservation of model-based structured constraint handling, improved alignment with long-term objectives, better generalization than direct policy cloning baselines, and interpretable adaptation of learned cost parameters. The assumptions are access to a good long-horizon expert MPC, a sufficiently accurate known dynamics model, a differentiable MPC implementation providing useful gradients, runtime access to contextual variables such as future curvature, and a representative feasible training set. The limitations include dependence on the differentiable MPC approximation, sensitivity to infeasible training samples, nonconvexity of the learning problem, imperfect handling of hard state constraints during differentiable training, lack of automatic inheritance of theoretical guarantees from the expert MPC, and the absence of a detailed study of noisy or partial context (Rickenbach et al., 17 Jul 2025).
In that sense, ZipMPC occupies a specific point in the design space. It does not learn dynamics, and it does not replace constrained optimization by an unconstrained policy network. Instead, it learns how to shape the objective of a constrained short-horizon MPC so that future information, compressed into context-conditioned cost parameters, can substitute for explicit long-horizon optimization at deployment time (Rickenbach et al., 17 Jul 2025).