Automated Custom Code Generation for Embedded, Real-time Second Order Cone Programming

Daniel Dueri, Jing Zhang, Behçet AçıkmeşeIFAC 2014

TL;DR

This paper introduces a novel method for automatically generating highly optimized, custom C code for solving Second Order Cone Programming (SOCP) problems on embedded systems. This approach significantly speeds up real-time optimization for critical applications, as demonstrated by its successful deployment on a NASA rocket for autonomous landing.

What Problem Does This Paper Address?

Traditionally, complex optimization problems were confined to powerful ground-based computers due to their computational demands and the perceived unreliability of numerical optimization for real-time, safety-critical tasks. While convex optimization (CO) offers guarantees of global optimality, applying it to embedded systems with limited resources (processing power, memory) and strict real-time constraints has been a significant challenge. Existing generic SOCP solvers, while capable, often lack the efficiency needed for these environments. The authors aim to bridge this gap by creating specialized, highly efficient solvers tailored to specific problem structures, enabling real-time convex optimization for autonomous systems.

Methods

The core of the paper lies in developing an Interior Point Method (IPM) solver that can generate customized ANSI-C code. Key methodological contributions include:

  • Homogenous Self-Embedding: A technique to reformulate the primal-dual SOCP problem into a self-dual form, which simplifies initialization and feasibility checks for the IPM.
  • Mehrotra Predictor-Corrector IPM: A standard, robust IPM algorithm that uses Newton search directions to iteratively refine solutions.
  • Nesterov-Todd (NT) Scalings: Symmetric scalings applied to the problem to improve numerical conditioning and efficiency without altering the solution or central path.
  • Approximate Minimum Degree (AMD) Heuristic: Used to optimize the sparsity of Cholesky factorizations, a computationally intensive step in solving the linear systems arising from the IPM. This minimizes "fill-in" (new non-zero entries) during factorization.
  • Explicit Coding and Customization: The most significant innovation. Instead of using generic sparse linear algebra libraries, the authors generate explicit C code tailored to the specific sparsity pattern of the problem. This eliminates dynamic memory allocation, minimizes branching (if-statements), and removes unnecessary computations, leading to highly efficient, embedded-friendly code. The customization is based on defining a "problem class" where the sparsity structure of the problem remains constant.

Datasets

The paper does not introduce new datasets. Instead, it uses two well-established benchmark problems for evaluation:

  • Mars Landing Optimal Control Problem: A trajectory optimization problem requiring fuel-efficient landing.
  • Reaction Wheel Allocation Problem: An optimization problem to determine reaction wheel speeds for attitude control while minimizing power usage.

Key Insights and Ideas

  • Customization is King for Embedded Real-Time: The paper strongly argues that for embedded systems, tailoring the optimization solver to the specific problem structure (its sparsity pattern) yields dramatic performance gains, far exceeding generic solvers.
  • Eliminating Dynamic Memory and Branching is Crucial: For embedded systems, avoiding dynamic memory allocation and minimizing conditional logic (branches) is paramount for reliability and predictable performance. The "explicit coding" approach directly addresses this.
  • SOCP is Ready for Real-Time Deployment: The successful real-time application of their customized SOCP solver on a NASA rocket demonstrates that complex convex optimization can be reliably used in safety-critical, high-performance autonomous systems.
  • Sparsity Exploitation Beyond Libraries: The paper shows that manually generating code for sparse linear algebra operations, rather than relying on general-purpose libraries, can be significantly more efficient for fixed problem structures.

Key Results

  • Significant Speedups: For small to medium-sized problems, the customized solver achieved speedups of approximately two times compared to the general Bsocp solver and was competitive with or outperformed other established solvers like ECOS, SDPT3, and SeDuMi.
  • Real-World Validation: The customized IPM code was successfully deployed and validated in three flights onboard a NASA test rocket for autonomous landing, guiding the vehicle in real-time. This was a pioneering application of real-time embedded convex optimization for controlling a large vehicle.
  • Reaction Wheel Allocation: For a small problem (40 solution variables), the customized solver offered a 2.5 times improvement in runtime efficiency compared to CVXGEN.
  • Scalability Trade-offs: For very large problems (around 2,000 solution variables), the benefits of customization diminish due to increased compilation times and instruction cache misses caused by the generated code's length.

Limitations and Future Work

  • Compilation Time and Code Length: The authors acknowledge that for very large problems, the generated code can become excessively long, leading to increased compilation times and potential instruction cache misses, which can negate the algorithmic speedups.
  • Future Work: The authors plan to focus on making the linear algebra libraries used by their general solver more scalable and exploring methods to reduce the compilation time of customized code. They are also investigating ways to further optimize the implementation of IPM algorithms.

Summary updated

BibTeX
@inproceedings{dueri2014automated,
  author = {Daniel Dueri and Jing Zhang and Behçet Açıkmeşe},
  title = {{Automated Custom Code Generation for Embedded, Real-time Second Order Cone Programming}},
  booktitle = {IFAC},
  year = {2014},
  doi = {10.3182/20140824-6-za-1003.02736},
}
Figure