Linearly constrained Gaussian processes

Carl Jidling, Niklas Wahlström, Adrian Wills, Thomas B. Schön

Gaussian Processes (GPs) are a powerhouse in Bayesian non-parametric modeling, prized for their principled uncertainty estimates. However, standard GPs are inherently "physics-blind." When modeling physical phenomena like magnetic fields or fluid flows, a standard GP has no built-in understanding that the field must obey fundamental laws, such as being curl-free or divergence-free.

In their NIPS 2017 paper, Jidling et al. present an elegant method to bake physical laws—specifically linear operator constraints—directly into GP models. By transforming the covariance function itself, they ensure that every sample drawn and every prediction made perfectly satisfies these constraints, without the computational bloat of previous methods.

The Problem with Pointwise Constraints

Previously, researchers forced GPs to respect physical laws by adding "artificial observations." Essentially, they would tell the model, "at these 100 specific points, the divergence must be zero." This approach suffers from two major flaws:

  1. Computational Cost: Every artificial point increases the size of the Gram matrix, exacerbating the standard $O(N^3)$ scaling issues of GPs.
  2. "Leaky" Constraints: The physical law is only enforced at those specific, discrete points. The model might still violate physics in the spaces between them.

A Method for Continuous Constraint Enforcement

The authors propose a fundamentally different approach: defining the target function $\mathbf{f}(\mathbf{x})$ as the result of a linear operator $\mathcal{G}_{\mathbf{x}}$ acting on an underlying, unconstrained GP $\mathbf{g}(\mathbf{x})$.

Mathematically, if we want $\mathbf{f}$ to satisfy a physical constraint $\mathcal{F}_{\mathbf{x}}[\mathbf{f}] = 0$, we look for a transformation such that $\mathbf{f} = \mathcal{G}_{\mathbf{x}}[\mathbf{g}]$. If the composition of these operators is zero ($\mathcal{F}_{\mathbf{x}}\mathcal{G}_{\mathbf{x}} = 0$), then $\mathbf{f}$ is guaranteed to satisfy the constraint everywhere by construction.

Because GPs are closed under linear operators, if the underlying function $\mathbf{g}$ has a covariance $K_g$, then the constrained function $\mathbf{f}$ has a transformed covariance $K_f = \mathcal{G}_{\mathbf{x}} K_g \mathcal{G}_{\mathbf{x}'}^T$. The authors provide a constructive "recipe" to find this operator $\mathcal{G}_{\mathbf{x}}$ using a parametric ansatz, turning the functional constraint into a solvable system of linear equations.

Experimental Validation

The paper evaluates this method on two primary setups: a simulated 2D divergence-free field and a real-world 3D magnetic field.

Simulated Divergence-Free Field

The authors tested their approach on a synthetic 2D vector field designed to satisfy $\nabla \cdot \mathbf{f} = 0$.

Comparison of vector field predictions showing the proposed approach achieves the lowest RMSE.

As shown in the comparison above, the proposed method achieved a significantly lower Root Mean Squared Error ($e_{\text{rms}} = 0.37$) than both standard diagonal GPs ($e_{\text{rms}} = 0.78$) and GPs relying on artificial observations ($e_{\text{rms}} = 0.46$). Furthermore, the qualitative plots demonstrate that the proposed method produces field lines that perfectly respect the physical boundaries, whereas unconstrained models produce physically impossible "swirls."

Real-World Magnetic Field Data

The second experiment involved 3D magnetic field measurements collected in an indoor environment. By physical law, this field must be curl-free ($\nabla \times \mathbf{f} = 0$).

3D visualization of the predicted magnetic field strength and sensor trajectories.

In this real-world scenario, the "artificial observations" method initially improved as more constraints were added, but eventually, its accuracy plummeted due to numerical instability (ill-conditioned matrices). The proposed method, however, maintained peak accuracy without this numerical overhead, proving its stability at scale.

Key Insights and Limitations

By moving the constraint into the covariance function, the "rules" of the system become part of the model's DNA. This approach offers a clean separation of concerns: practitioners can choose the "smoothness" of the model via the base kernel independently from the structural physical constraints. It also provides much-needed numerical robustness, avoiding the ill-conditioned matrices that plague pointwise constraint methods.

However, the method does have limitations:

  • The Ansatz Requirement: The algorithm relies on the user providing a structured guess (an ansatz) to build the transformation. A more automated way to determine these requirements would be beneficial.
  • Existence of Potentials: The method assumes the target function can always be expressed as a transformation of an underlying function. While often true, whether this is mathematically guaranteed for all linear constraints remains an open theoretical question.
  • Linearity: This approach is strictly for linear operators. Extending it to non-linear constraints (like those in complex fluid dynamics or General Relativity) remains an open challenge.

Summary updated

BibTeX
@inproceedings{jidling2017linearly,
  author = {Carl Jidling and Niklas Wahlström and Adrian Wills and Thomas B. Schön},
  title = {{Linearly constrained Gaussian processes}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2017},
  url = {https://openreview.net/forum?id=HybF_O-OWH},
}
Figure