[Bridges] fix SquareBridge with differing constants in off-diagonal - #3068
Merged
Conversation
odow
commented
Sep 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SquareBridgeConstraintFunctiongetter has a sign error when a symmetrization constraint has a nonzero constantsrc/Bridges/Constraint/bridges/SquareBridge.jl,MOI.get(::MOI.ModelLike, ::MOI.ConstraintFunction, ::SquareBridge), line 270.When entries
(i, j)and(j, i)of the square matrix differ by a nonzeroconstant
c(e.g.f_ij = 3 + x,f_ji = 2 + x),bridge_constraintadds aconstraint
(f_ij - f_ji) - c == -c(the constant is moved into the set bynormalize_and_add_constraint). When reconstructingf_jiin theConstraintFunctiongetter, the code subtractsrhsa second time instead ofadding it back, so the recovered
f_jiis off by2c.Repro (
c = 1):This only shows up when the off-diagonal expressions differ by a nonzero
constant (e.g.
1 + xvs2 + x); the common case of numerically-identicalor purely-linear-difference-with-zero-constant entries doesn't trigger it,
which is presumably why the existing test suite (
test/Bridges/Constraint/test_SquareBridge.jl)didn't catch it.
Fix
Add
rhsinstead of subtracting it:See
issue-001.patch. Verified: the repro above returns the originalfunction exactly after the fix, and
test/Bridges/Constraint/test_SquareBridge.jlstill passes in full (all testsets, 367
@tests total).Note:
issue-003.patchtouches a different hunk of the same file(
SquareBridge.jl, theConstraintPrimal/ConstraintPrimalStartgetter andsetter rather than the
ConstraintFunctiongetter); they're independentfixes and both apply cleanly together.