Skip to content

Conversation

@Akash504-ai
Copy link
Contributor

This PR fixes a crash that occurs when computing the MAX_ELLIPSOID rounding
for low-dimensional (1D and 2D) polytopes.

Background

The MAX_ELLIPSOID rounding procedure computes the minimum and maximum
eigenvalues of the ellipsoid matrix in order to evaluate the roundness
condition. For performance reasons, this is done using
Spectra::SymEigsSolver, requesting the smallest and largest eigenvalues.

However, Spectra enforces the constraint:
1 <= nev <= d - 1
where d is the matrix dimension.

The previous implementation always requested nev = 2, which is valid for
d >= 3 but invalid for d <= 2. For 2D polytopes (d = 2), this results in
nev > d - 1 and causes Spectra to throw a std::invalid_argument exception,
terminating the program.

Fix

This PR updates the eigenvalue computation logic as follows:

  • For d > 2, the existing Spectra-based partial eigen decomposition is used
    unchanged.
  • For d <= 2, the code falls back to Eigen::SelfAdjointEigenSolver to compute
    the full spectrum safely.

This avoids invalid Spectra calls and ensures that MAX_ELLIPSOID works
correctly for low-dimensional polytopes, while preserving the original
behavior and performance characteristics for higher dimensions.

Notes

The crash is deterministic for d <= 2 and does not depend on input data.
Although the lp_solve-dependent example could not be run locally due to
environment constraints, the fix removes the exact failure path responsible
for the exception.

Fixes #325.

@Akash504-ai
Copy link
Contributor Author

Closing temporarily to reduce PR load as discussed. Will reopen sequentially once the current PRs are reviewed/merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Max inscribed ellipsoid segfault when given 2d polytope

1 participant