GAPS: Generator for Automatic Polynomial Solvers

Bo Li, Viktor LarssonarXiv 2020

TL;DR

GAPS (Generator for Automatic Polynomial Solvers) is a powerful tool designed to automatically generate highly efficient C++/Matlab solvers for complex systems of polynomial equations. By analyzing the problem's structure in a finite field offline, GAPS produces optimized "action matrix" solvers that can handle real-time computer vision tasks, such as camera pose estimation, with state-of-the-art speed and stability.

What Problem Does This Paper Address?

In computer vision, many "minimal problems"—such as estimating a camera’s position from just five points—boil down to solving systems of non-linear polynomial equations. These systems must be solved thousands of times per second (e.g., inside a RANSAC loop).

Standard symbolic math packages (like Mathematica) are too slow for real-time use, and general-purpose numerical solvers are often too heavy or unstable. Researchers typically rely on "Gröbner basis" methods, which transform the equations into an eigenvalue problem. However, manually deriving these solvers is incredibly difficult. GAPS automates this process, improving upon previous tools like autogen by making the resulting solvers smaller, faster, and easier to implement.

Methods

GAPS follows a two-phase approach:

  1. Offline Phase (Analysis): The software analyzes the polynomial system using a finite prime field ($\mathbb{Z}_p$). By working with integers modulo $p$, GAPS avoids numerical round-off errors while identifying the consistent "inner structure" of the equations. It determines which polynomial combinations are needed to reach a solution and constructs a "template matrix."
  2. Online Phase (Solving): The generated solver takes real-world coefficients, fills them into the pre-defined template matrix, performs a linear elimination (RREF), and extracts an "action matrix." The roots of the original polynomials are then found by computing the eigenvalues of this action matrix.

Key Technical Innovations in GAPS: * Syzygy Reduction: It uses "syzygies" (relations between equations) to reduce the degree of polynomials, leading to significantly smaller template matrices. * Upper Triangular Reduction: It reorders the template matrix to find an upper-triangular sub-structure, speeding up the linear algebra steps. * Symmetry Detection: It automatically identifies $p$-fold symmetries (like sign changes in quaternions), allowing the solver to find only unique solutions and ignore redundant symmetric ones. * Coefficient Simplification: It optimizes the generated code to avoid redundant calculations of the input coefficients.

Datasets

As a software tool paper, GAPS does not use traditional training datasets. Instead, it is evaluated and demonstrated using classic "minimal problems" from computer vision:

  • The 5-point Relative Pose Problem: The gold standard for testing polynomial solvers in CV.
  • The 4-point Relative Pose Problem with known rotation angle: Used as a "full example" to demonstrate how users can define complex geometric constraints within the GAPS framework.

Key Insights and Ideas

  • Structure is Constant: The core "aha!" moment is that while the coefficients of a problem change (different points in an image), the algebraic steps required to solve it remain identical. GAPS "bakes" these steps into the solver.
  • Finite Fields for Robustness: Using $\mathbb{Z}_p$ during the design phase is a brilliant way to handle the "messiness" of algebraic geometry without worrying about floating-point precision until the very last step.
  • Automation of Expertise: Building these solvers used to require a PhD in algebraic geometry. GAPS wraps this complexity into a Matlab class-based interface, making high-performance solver generation accessible to general CV researchers.

Key Results

While the paper focuses on the software's features rather than a benchmark table, the primary results are:

  • Efficiency: By utilizing syzygy and upper-triangular reduction, GAPS produces solvers with smaller template matrices than previous versions of autogen.
  • Usability: The introduction of a structured "Short Tutorial" and a class-based inheritance model in Matlab simplifies the workflow for defining new problems.
  • Functionality: GAPS can generate solvers based on either the Action Matrix (more stable) or the Characteristic Polynomial (faster but potentially less stable), giving researchers a choice based on their specific needs.

Limitations and Future Work

  • Numerical Stability: The authors acknowledge that solvers based on characteristic polynomials, while fast, are widely known to be less numerically stable than action matrix-based ones.
  • Symmetry Constraints: Currently, the tool only automatically detects "variable-aligned" symmetries (like simple sign flips). More complex, non-aligned symmetries still require manual handling.
  • Manual Setup: Users still need to provide a generative script for $\mathbb{Z}_p$ instances, which requires some understanding of how to represent geometric problems (like rotations or unit vectors) in a finite field.

Summary updated

BibTeX
@misc{li2020gaps,
  author = {Bo Li and Viktor Larsson},
  title = {{GAPS: Generator for Automatic Polynomial Solvers}},
  year = {2020},
  eprint = {2004.11765},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2004.11765},
}
Figure