Reinforcement Learning of the Prediction Horizon in Model Predictive Control

Eivind Bøhn, Sebastien Gros, Signe Moe, Tor Arne Johansen

Abstract

Model Predictive Control (MPC) is a cornerstone of industrial control, yet it suffers from a fundamental trade-off regarding its prediction horizon. A short horizon can lead to myopic, unstable behavior, while an excessively long horizon incurs high computational costs and may rely on unreliable long-term predictions in uncertain environments. This paper presents an Adaptive Horizon MPC (AHMPC) framework that leverages Reinforcement Learning (RL) to dynamically select the optimal prediction horizon in real-time. By training a Soft Actor-Critic (SAC) agent, the controller learns to balance control performance, constraint satisfaction, and computational overhead. Our results on classic control benchmarks show that this adaptive approach outperforms the best-tuned fixed-horizon controllers by up to 8%.

Introduction

Model Predictive Control (MPC) is highly effective for managing complex systems with explicit constraints. However, the selection of the prediction horizon ($N$) remains a challenging hyperparameter tuning problem. Traditionally, $N$ is fixed, which often results in a "Goldilocks" dilemma: horizons that are too short fail to anticipate future constraints, while horizons that are too long waste computational resources and may overfit to noisy predictions.

This research addresses the need for Adaptive Horizon MPC (AHMPC), where the prediction horizon is treated as a dynamic variable adjusted based on the system's current state and environmental context.

Methodology

The proposed framework frames horizon selection as a Reinforcement Learning problem.

The RL Policy

The authors utilize the Soft Actor-Critic (SAC) algorithm to learn the horizon selection policy. Since SAC typically operates in continuous action spaces, the policy's output is scaled to the range $[1, N_{max}]$ and rounded to the nearest integer to provide a discrete horizon $N$ for the MPC solver.

Reward Function and Joint Learning

The RL agent is optimized against a multi-objective reward function that penalizes:

  1. Tracking Error: Standard MPC stage costs.
  2. Constraint Violations: Penalties for boundary or obstacle collisions.
  3. Computational Cost: A penalty proportional to the chosen horizon length $N$.

Furthermore, the framework incorporates Joint Learning of the MPC terminal cost (the Value Function). By using RL to estimate the long-term "cost-to-go," the MPC can achieve high performance even with relatively short local horizons, as the terminal cost provides a global guidance signal.

Experimental Evaluation

The AHMPC approach was evaluated on two primary benchmarks: an Inverted Pendulum on a Cart and a Collision Avoidance task.

Visualization of the collision avoidance task, where a vehicle navigates through obstacles with increasing uncertainty.

In the collision avoidance scenario, a unicycle-model vehicle must navigate a field of obstacles. A key feature of this environment is that obstacle position uncertainty increases with distance, making long-range predictions potentially detrimental if the controller over-relies on noisy data.

Key Results and Discussion

The RL-based adaptive horizon policy demonstrated significant improvements over traditional fixed-horizon (FH) methods. Specifically, it achieved a 4% improvement in the inverted pendulum task and an 8% improvement in the collision avoidance task compared to the best-tuned fixed-horizon baselines.

Comparison of total and component costs for the RL-based adaptive horizon versus various fixed-horizon (FH) policies in the collision avoidance task.

As shown in the cost breakdown, the RL agent (labeled 'RL') achieves the lowest total cost. It successfully minimizes performance costs while keeping computational overhead low. In contrast, very short horizons (e.g., FH5) suffer from extreme performance and constraint costs due to their myopic nature, while longer horizons (e.g., FH50) incur unnecessary computational penalties without proportional gains in performance.

Robustness and Efficiency

A key insight is that the RL agent learns state-dependent horizons. In the collision avoidance task, the agent reduces the horizon when uncertainty is high, avoiding reliance on unreliable distant data. Conversely, it extends the horizon when complex maneuvering is required. Additionally, the system exhibits rapid convergence, typically reaching optimal performance within 10–25 minutes of simulated interaction.

Conclusion and Future Work

This work demonstrates that RL can effectively automate the tuning of MPC horizons, providing a principled way to navigate the performance-computation trade-off. While the empirical results are promising, future work should address formal stability guarantees for varying-horizon MPC and explore more sophisticated methods for handling the discrete nature of the horizon action space. Scaling these methods to high-dimensional systems remains a critical next step for real-world deployment.

Summary updated

BibTeX
@inproceedings{bhn2021reinforcement,
  author = {Eivind Bøhn and Sebastien Gros and Signe Moe and Tor Arne Johansen},
  title = {{Reinforcement Learning of the Prediction Horizon in Model Predictive Control}},
  booktitle = {IFAC-PapersOnLine},
  year = {2021},
  doi = {10.1016/j.ifacol.2021.08.563},
}
Figure