Skip to content

Test ConstraintDual for bridges #2810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Test ConstraintDual for bridges #2810

wants to merge 8 commits into from

Conversation

blegat
Copy link
Member

@blegat blegat commented Aug 12, 2025

I always thought it a bit silly to only define the setter for ConstraintDualStart and not with ConstraintDual. I sometimes want to test things mixing a MockOptimizer and a bridge and I can't because bridges don't define the setters for ConstraintDual.

I suggest the following non-breaking change: We should now encourage bridges to supports ConstraintDual. When they do, a new test will be enabled that will do an important consistency check. So the new test will not be run for existing bridge which is nice since it could be breaking but after the transition, it will be run for all bridges that don't disable it by doing dual = nothing.

This would have caught the bug in #2809 as the CI should show

@blegat blegat force-pushed the bl/bridge_dual_test branch from 359a8e3 to cded928 Compare August 12, 2025 12:29
attr::Union{
MOI.ConstraintPrimalStart,
MOI.ConstraintDualStart,
MOI.ConstraintDual,
Copy link
Member

Choose a reason for hiding this comment

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

This is a big dislike from me. ConstraintDual is a result attribute. We shouldn't make bridges "support" it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since MockOptimizer supports ConstraintDual, then it's quite useful for testing. ConstraintDual and ConstraintDualStart have different semantics for solvers but for bridges that only care about how things are transformed, they are completely equivalent.

@odow
Copy link
Member

odow commented Aug 19, 2025

I'm still against this. Bridges could/should write better tests regardless. Testing the dual is tricky. And even our Start is a bad test because it checks only get/set doesn't error. It doesn't really have a way to test that the logic is correct.

@blegat
Copy link
Member Author

blegat commented Aug 22, 2025

Yes, we just check that get and set are inverse of each other and that's precisely what this PR is fixing. Now it also checks that it is the adjoint of the bridge transformation so it's starting to get difficult to get the test passing with an incorrect dual

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

Successfully merging this pull request may close these issues.

2 participants