Abstract
Model Predictive Control (MPC) is a cornerstone of modern control theory, yet its high computational demand often limits its application in real-time, high-speed systems. This paper introduces TransMPC, a novel explicit MPC framework that leverages an encoder-only Transformer architecture to generate entire optimal control sequences in a single forward pass. By utilizing direct policy optimization through automatic differentiation, TransMPC bypasses the need for slow classical solvers during training. Experimental results demonstrate that TransMPC achieves significant speedups—up to 516% over neural baselines—while maintaining superior tracking accuracy and handling variable prediction horizons effectively.
Introduction
Controlling complex systems like autonomous vehicles or drones requires handling nonlinearities and constraints, a task for which Model Predictive Control (MPC) is the industry standard. However, MPC typically requires solving a complex optimization problem at every time step, which is computationally prohibitive for resource-constrained hardware.
"Explicit MPC" aims to solve this by pre-computing the control policy offline. While traditional lookup-table methods suffer from the "curse of dimensionality," recent neural network approaches (MLPs, RNNs) have shown promise. Nevertheless, these models often struggle with long-range temporal dependencies and fixed prediction horizons. TransMPC addresses these limitations by reimagining the MPC policy as a sequence-to-sequence mapping handled by a Transformer.
Methodology
Encoder-Only Architecture
Unlike standard Transformers that generate tokens autoregressively, TransMPC employs an encoder-only structure with bidirectional self-attention. This design allows the model to process the entire future reference trajectory simultaneously, outputting the full control sequence $u_t, \dots, u_{t+N-1}$ in a single shot. This results in $O(1)$ inference latency relative to the horizon length.
Direct Policy Optimization
Rather than using imitation learning to copy a classical solver, TransMPC utilizes Direct Policy Optimization. The MPC cost function itself serves as the loss function. Through automatic differentiation, the network weights are updated to minimize this cost directly, ensuring the model learns the underlying control objective rather than just mimicking a labels-based ground truth.
Variable Horizon Training
To ensure robustness across different operational needs, TransMPC is trained using random horizon sampling. By varying the prediction horizon ($N$) during training within a replay buffer, the model learns to adapt to different look-ahead requirements at runtime without needing to be retrained for specific scenarios.
Experimental Evaluation
The framework was evaluated through both simulation and real-world robotics experiments:
- Simulation: A nonlinear bicycle model was used for sinusoidal and double-lane change maneuvers.
- Real-World: An Autolabor mobile robot equipped with LiDAR and IMU performed trajectory tracking and obstacle avoidance.
- Baselines: TransMPC was compared against classical MPC (IPOPT), MLPs (FHADP), bidirectional RNNs (biRMPC), and modern architectures like MPC-Mamba and MPC-TTT.
Key Results and Insights
Performance and Efficiency
TransMPC consistently outperformed neural baselines in both speed and accuracy. For a prediction horizon of 20, it achieved computational speeds 27% to 516% faster than other neural architectures. It maintained lower tracking errors and cumulative costs across all tested scenarios.
The "Implicit Look-Ahead" Advantage
A significant finding was that TransMPC outperformed "optimal" classical MPC at very short horizons (e.g., $N=5$). The Transformer appears to implicitly learn to leverage reference information beyond the immediate mathematical horizon, providing predictive capabilities that exceed the classical ground truth it was designed to approximate.
Conclusion
TransMPC represents a significant step forward for explicit MPC, combining the parallel processing power of Transformers with direct cost optimization. While currently limited by the requirement for differentiable system dynamics, its ability to provide high-speed, accurate control with variable horizons makes it a powerful tool for real-time robotics. Future work will focus on handling non-differentiable constraints and scaling to higher-dimensional state spaces.
Summary updated