Exact hull reformulation for quadratic constraints#3874
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: sergey-gusev94 <101810399+sergey-gusev94@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Make eigenvalue PSD/NSD tolerance configurable in hull exact quadratic reformulation
Co-authored-by: sergey-gusev94 <101810399+sergey-gusev94@users.noreply.github.com>
…ic feature Co-authored-by: sergey-gusev94 <101810399+sergey-gusev94@users.noreply.github.com>
doc: add `exact_hull_quadratic` to Hull class docstring
…unctions Co-authored-by: sergey-gusev94 <101810399+sergey-gusev94@users.noreply.github.com>
…envalue_tolerance in permissive test Co-authored-by: sergey-gusev94 <101810399+sergey-gusev94@users.noreply.github.com>
Add TestExactHullQuadratic tests and extract models into models.py
Co-authored-by: sergey-gusev94 <101810399+sergey-gusev94@users.noreply.github.com>
Co-authored-by: sergey-gusev94 <101810399+sergey-gusev94@users.noreply.github.com>
Co-authored-by: sergey-gusev94 <101810399+sergey-gusev94@users.noreply.github.com>
Co-authored-by: sergey-gusev94 <101810399+sergey-gusev94@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: sergey-gusev94 <101810399+sergey-gusev94@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Clean up stale "treated as linear" language and inline imports in test_hull.py
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3874 +/- ##
==========================================
+ Coverage 86.80% 89.78% +2.97%
==========================================
Files 903 903
Lines 106604 106780 +176
==========================================
+ Hits 92537 95871 +3334
+ Misses 14067 10909 -3158
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
emma58
left a comment
There was a problem hiding this comment.
This looks pretty good, but I'm submitting a partial review because there's one major revision: See my notes below, but can you please rewrite this to use the QuadraticRepnVisitor rather than generate_standard_repn? You'll be able to get all the same data, though it will come in a slightly different structure. But it is much more robust to edge cases--I think generate_standard_repn is not long for this world, actually.
| """Transform a single Constraint on a Disjunct. | ||
|
|
||
| Applies the appropriate hull reformulation to each | ||
| ``ConstraintData`` in ``obj``. When ``exact_hull_quadratic`` is | ||
| enabled and the constraint body has polynomial degree 2, an exact | ||
| hull formulation is used instead of the perspective function. | ||
|
|
…er minor comments
emma58
left a comment
There was a problem hiding this comment.
Thank you so much for making the change to the QuadraticRepnVisitor! This is looking quite good. Most of the changes suggested below are fairly minor, though if you can, it would be nice to abandon generate_standard_repn in the tests as well and to add public APIs where you are testing private components added by the transformation.
| t_var = relaxBlock.component('_conic_aux_t_c') | ||
| self.assertIsNotNone(t_var, "Expected auxiliary variable '_conic_aux_t_c'") |
There was a problem hiding this comment.
I would recommend against testing that depends on private names since any naming changes will break tests. It might be worth including an API (using the private_data Block) to retrieve the auxiliary variables, and then you can test them that way.
emma58
left a comment
There was a problem hiding this comment.
Thank you for the lightning-fast response! A couple more minor comments and then I really will be done complaining!
…t on a
transformed
Fixes # .
Summary/Motivation:
This PR adds support for the exact hull reformulation for quadratic constraints in Generalized Disjunctive Programming (GDP).
The current
gdp.hulltransformation applies perspective-function based relaxations for nonlinear constraints. While effective for many nonlinear expressions, this approach can produce weaker relaxations for quadratically constrained disjunctions.This PR implements the exact hull reformulation for quadratic constraints described in:
Gusev, S., & Bernal Neira, D. E. (2025).
Exact Hull Reformulation for Quadratically Constrained Generalized Disjunctive Programs.
https://arxiv.org/abs/2508.16093
The implementation extends the existing hull transformation with an optional configuration flag (which is
Falseby default) that detects quadratic constraints and applies the exact hull formulation when appropriate.For convex quadratic constraints, the reformulation is expressed as a rotated second-order cone (SOC) representable constraint. For nonconvex quadratics and equality constraints, the general exact hull formulation is used.
Convexity is determined automatically through eigenvalue analysis of the Hessian matrix.
This provides a tighter relaxation for quadratic GDP models and maintains the quadratic structure of constraints in hull reformulation.
Changes proposed in this PR:
Extend the
gdp.hulltransformation with a new configuration option:exact_hull_quadratic(default:False)When enabled, quadratic constraints inside disjuncts are reformulated using the exact hull formulation instead of the standard perspective function.
Implement automatic convexity detection via eigenvalue decomposition of the quadratic Hessian matrix.
Apply different reformulations depending on structure:
Convex quadratic inequalities
Reformulated using a rotated second-order cone representation.
Nonconvex quadratics or equalities
Reformulated using the general exact hull formulation.
Add a configuration parameter:
eigenvalue_toleranceControls numerical tolerance when checking positive or negative semidefiniteness of the Hessian.
Extend the implementation in
pyomo.gdp.plugins.hullto support these reformulations.Add unit tests verifying:
The default behavior of
gdp.hullis unchanged unless the new option is enabled.Example usage:
Legal Acknowledgement
By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution: