Exact Worst-Case Execution-Time Analysis for Implicit Model Predictive Control

Daniel Arnström, David Broman, Daniel Axehill · DOI

TL;DR

Researchers have developed the first method to determine the exact worst-case execution time (WCET) for implicit linear Model Predictive Control (MPC). By leveraging complexity certification to identify a finite set of "archetypal" optimization problems, they can guarantee real-time performance on embedded hardware without the extreme conservatism of traditional static analysis.

What Problem Does This Paper Address?

Model Predictive Control (MPC) is a powerful strategy that solves an optimization problem at every time step to find the best control action. While highly effective, using "implicit" MPC—where the solver runs online on embedded hardware—poses a major challenge for safety-critical systems like self-driving cars or drones.

In these systems, you must guarantee that the controller will finish its calculations before the next clock tick. This is known as the Worst-Case Execution Time (WCET). Traditionally, engineers have two choices:

  1. Static Analysis: Use abstract models of hardware to find an upper bound. This is "safe" but often yields results that are 10x to 100x higher than reality, leading to massive over-provisioning of hardware.
  2. Measurement-Based Analysis: Run the controller with many random inputs and record the times. This is "realistic" but provides no formal guarantee that you actually hit the absolute worst-case scenario.

The gap lies in the fact that an optimization solver's execution path depends entirely on the input data (the system's current state), which exists on a continuum. You can't test every possible state.

Methods

The authors bridge this gap by combining optimization theory with real-time systems analysis. Their approach relies on three key pillars:

  • Complexity Certification: They leverage a framework that partitions the entire space of possible system states into a finite number of regions. Within each region, an active-set solver is guaranteed to follow the exact same "path" (the same sequence of iterations and operations).
  • Archetypal Problems: From each region, they select one "archetypal" problem. Because every problem in a region is "execution-time equivalent," solving just one archetypal problem on the target hardware tells you the execution time for every possible state in that region.
  • Execution-Time Equivalent Covers: They prove that this finite set of archetypal problems forms a "cover" that captures the execution time of any possible problem the controller might encounter online.

By running these specific problems on the actual deployment hardware (e.g., an ARM Cortex-M4) and recording the cycles, they find the true, exact WCET.

Datasets

The method was validated using a standard benchmark in control theory: an inverted pendulum on a cart.

  • The MPC problem involved 10 decision variables and 20 constraints.
  • The authors generated over 10^6 random samples to validate their theoretical "exact" bound.
  • They tested the system across different MPC horizons ($N=6$ to $N=14$), resulting in up to 1.5 million archetypal problems for the most complex case.

Key Insights and Ideas

  • The "Aha!" Moment: The realization that while there are infinite possible inputs, there are only a finite number of unique execution paths for active-set solvers. This turns an intractable continuous problem into a finite, measurable one.
  • Hardware-Awareness without Models: Unlike static analysis, this method doesn't need a complex mathematical model of the CPU's pipeline or cache. It uses the hardware itself as the "model" by measuring the archetypal problems directly.
  • Pruning for Efficiency: The authors introduced a pruning technique based on "subsequences." If one solver path is a subset of another, you only need to measure the longer one, significantly reducing the number of tests needed on the hardware.
  • Compiler Sensitivity: The paper demonstrates that the method perfectly accounts for implementation-specific details, such as compiler optimization flags (-O0 vs -O3), which drastically change execution paths and timing.

Key Results

  • Exactness: The method successfully identified the exact WCET. Random sampling (1 million points) never exceeded the bound found by the archetypal problems, confirming the method's soundness.
  • Superiority over Static Analysis: When compared to aiT, a state-of-the-art commercial static WCET analyzer, the authors' method provided a bound that was 40 times tighter. The static analyzer estimated 5.7 million cycles, while the actual worst case was only 136,809 cycles.
  • Efficiency: For a horizon of $N=10$, the certification took only 14 seconds, and measuring the resulting ~89,000 archetypal problems on the hardware took about 10 minutes.

Limitations and Future Work

  • Solver Specificity: The current framework is tailored for active-set solvers (like DAQP or qpOASES). It does not yet apply to interior-point methods or first-order methods (like ADMM), where execution paths are less discrete.
  • Linear Constraints: The analysis is currently restricted to linear MPC (quadratic programs with affine constraints). Nonlinear MPC would introduce significantly more complexity in partitioning the parameter space.
  • Hardware Assumptions: The method assumes a deterministic starting state and non-preemptive tasks. While common in simple microcontrollers, complex CPUs with deep out-of-order execution or complex OS scheduling might introduce timing jitter that requires further relaxation of these assumptions.

Summary updated

BibTeX
@article{arnstrom2024exact,
  author = {Daniel Arnström and David Broman and Daniel Axehill},
  title = {{Exact Worst-Case Execution-Time Analysis for Implicit Model Predictive Control}},
  journal = {IEEE Trans. Automatic Control},
  year = {2024},
  doi = {10.1109/tac.2024.3395521},
}
Figure