Skip to content

Riemannian optimization ​

Module: sci_form::riemannian (core since 2026-10-14; beta::riemannian re-export) Feature flag: none (core); beta-riemannian kept as no-op alias


Validation and limits ​

QuestionAnswer
Compared withNumPy + SciPy L-BFGS-B
Measured separationprojection 8.2e-12; Frobenius distance 2.2e-16; objective/gradient 1.2e-16
Confidence regionsmall positive-semidefinite matrices and ETKDG objectives
Main limitationpsd_distance is a Frobenius proxy, not the affine-invariant geodesic; the retraction is first-order

The raw rows and the exact tolerances are in the full validation matrix.


Overview ​

Replaces the Euclidean BFGS optimizer in the embedding step with Riemannian L-BFGS over the manifold of fixed-rank positive semidefinite (PSD) matrices. Negative eigenvalues are eliminated by design, reducing the retry loop failure rate to zero.


Theory ​

PSD Manifold ​

The metric matrix G must be PSD for valid 3D coordinates. Instead of optimizing in RN×N and projecting, we optimize directly on:

M={X∈RN×N:X⪰0,rank(X)=r}

Retraction ​

The retraction maps a tangent vector back to the manifold:

RetrX(ξ)=P+(X+ξ+12ξX−1ξ)

where P+ projects onto the PSD cone by zeroing negative eigenvalues.

Riemannian Gradient ​

The Euclidean gradient is projected to the tangent space:

gradRf=PTX∇f

For the Stiefel manifold: PTX(ξ)=ξ−X⋅sym(XTξ)

L-BFGS on the Manifold ​

  • Store m=5 curvature pairs (sk,yk) in the tangent space
  • Two-loop recursion with vector transport along geodesics
  • Line search with Armijo condition along the manifold geodesic

API ​

rust
use sci_form::riemannian::*;

// PSD projection
let (projected, n_neg) = psd_projection(&matrix);

// Retraction (first-order): P₊(X + ξ)
let retracted = psd_retraction(&x, &xi);

// Full L-BFGS optimization under distance bounds
let config = RiemannianConfig {
    max_iter: 500,
    grad_tol: 1e-6,
    ..Default::default()
};
let opt = RiemannianLbfgs::new(config);
let result = opt.optimize(&x0, &constraints);
// result.metric_matrix, result.objective, result.converged

Convergence ​

  • Primary: ∥gradRf∥<10−6
  • Secondary: Maximum distance violation <0.01 Å
  • Fallback: Reverts to Euclidean BFGS + PSD projection if not converged in 500 iterations

Validation (F94, 2026-10-14) ​

External gate tests/beta_riemannian_validation.rs vs scripts/validation/oracle_riemannian.py (numpy + scipy L-BFGS-B): projection 8.2e-12, Frobenius distance 2.2e-16, objective/gradient 1.2e-16, optimizer reaches the feasible set like scipy. Documented gap: psd_distance is the Frobenius proxy, NOT the affine-invariant geodesic distance (geomstats cross-check unmet). Note: the implemented retraction is first-order P₊(X+ξ), not the second-order form once sketched in Theory.

Tests ​

bash
cargo test --features "beta-cpm beta-riemannian" --test experimental_gates -- test_riemannian

11 integration tests (tests/experimental/test_riemannian.rs) covering: PSD projection correctness, retraction stays on manifold, Riemannian gradient orthogonality, L-BFGS convergence on Rosenbrock and distance geometry objectives.

These tests live in the experimental_gates target — see Overview for the full command matrix.

Released under the MIT License.