Skip to content

Make eigenvalue PSD/NSD tolerance configurable in hull exact quadratic reformulation#3

Merged
sergey-gusev94 merged 5 commits intoex_hullfrom
copilot/sub-pr-2
Mar 7, 2026
Merged

Make eigenvalue PSD/NSD tolerance configurable in hull exact quadratic reformulation#3
sergey-gusev94 merged 5 commits intoex_hullfrom
copilot/sub-pr-2

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 7, 2026

The numerical tolerance used for eigenvalue-based convexity checks in the exact hull quadratic reformulation (exact_hull_quadratic=True) was hardcoded at 1e-10, making it impossible to tune for ill-conditioned Q matrices without modifying source code.

Changes

  • New config parameter eigenvalue_tolerance (default 1e-10, PositiveFloat) added to Hull.CONFIG, following the same pattern as EPS
  • Replaces hardcoded value in the PSD/NSD eigenvalue check with self._config.eigenvalue_tolerance
  • Updated class docstring to document the new parameter

Usage

from pyomo.gdp import TransformationFactory

hull = TransformationFactory('gdp.hull')
hull.apply_to(
    model,
    exact_hull_quadratic=True,
    eigenvalue_tolerance=1e-8,  # looser tolerance for ill-conditioned Q
)

Larger values make the convexity check more conservative; smaller values more permissive.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Fix configurable parameter for exact hull reformulations Make eigenvalue PSD/NSD tolerance configurable in hull exact quadratic reformulation Mar 7, 2026
@sergey-gusev94 sergey-gusev94 marked this pull request as ready for review March 7, 2026 05:03
@sergey-gusev94 sergey-gusev94 requested a review from Copilot March 7, 2026 05:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a configurable numerical tolerance for eigenvalue-based PSD/NSD checks used by the GDP hull transformation’s exact quadratic hull reformulation, replacing a previously hardcoded constant so users can tune behavior for ill-conditioned quadratic forms.

Changes:

  • Document eigenvalue_tolerance in Hull_Reformulation docstring.
  • Declare eigenvalue_tolerance in Hull_Reformulation.CONFIG (default 1e-10).
  • Use self._config.eigenvalue_tolerance in the eigenvalue convexity check instead of a hardcoded 1e-10.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyomo/gdp/plugins/hull.py Outdated
Comment thread pyomo/gdp/plugins/hull.py
Comment on lines +1011 to 1014
numerical_tolerance = self._config.eigenvalue_tolerance
eigenvalues, _ = np.linalg.eigh(Q)
Q_is_psd = not np.any(eigenvalues < -numerical_tolerance)
Q_is_nsd = not np.any(eigenvalues > numerical_tolerance)
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces a new public config option (eigenvalue_tolerance) that affects whether the conic vs general exact-hull formulation is selected, but there do not appear to be any existing tests covering exact_hull_quadratic (and thus none validating that this tolerance is honored). Please add a focused unit test that sets exact_hull_quadratic=True and varies eigenvalue_tolerance to flip the PSD/NSD classification for a nearly-singular Q, asserting the chosen reformulation differs.

Copilot uses AI. Check for mistakes.
Comment thread pyomo/gdp/plugins/hull.py Outdated
Comment thread pyomo/gdp/plugins/hull.py Outdated
@sergey-gusev94 sergey-gusev94 merged commit 3b9ed7c into ex_hull Mar 7, 2026
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.

3 participants