-
Notifications
You must be signed in to change notification settings - Fork 269
Require binary variables in logical constraints #1005
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #1004 by enforcing that logical constraints only accept binary variables.
- Added a failing test for non-variable inputs to logical constraints
- Inserted runtime type checks in Cython methods handling logical constraints
- Documented the fix in the changelog
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
tests/test_cons.py | Added test_cons_logical_fail marked xfail to catch non-Variable inputs in OR cons |
src/pyscipopt/scip.pxi | Added isinstance checks for vars in logical-constraint methods; tweaked branchVarVal signature |
CHANGELOG.md | Logged the segmentation-fault fix when expressions were used in logical constraints |
Comments suppressed due to low confidence (2)
tests/test_cons.py:90
- Instead of
xfail
, usewith pytest.raises(TypeError)
to explicitly assert the exception; this ensures the test only passes when the correct error is raised.
m.addConsOr([x1*x3, x2*x4], result1)
src/pyscipopt/scip.pxi:8775
- [nitpick] The signature indentation and mixed annotation style differ from surrounding methods. Align the indentation and consider adding a type for
value
or reverting to the original untyped signature for consistency.
def branchVarVal(self, Variable variable, value):
The suppressed suggestions seem to make more sense than the unsuppressed suggestions. |
Co-authored-by: DominikKamp <[email protected]>
Co-authored-by: DominikKamp <[email protected]>
Co-authored-by: DominikKamp <[email protected]>
Could you explain when test functions also need to be called? |
Ah, I didn't understand what you were saying at first, but if you're talking about the So the answer is never, actually :) |
There are also other test files where this landed in the source, could you check? |
Yeah, had one in the numerical tests, thank you! Okay, so everything is done now, right? |
Well, now that the logic seems fixed, the code review can begin... |
You know, Dominik, I have a draft for a song titled "Every Commit you Make (Every Breath You Take - Dominik Edition)". It's times like these that I think I should pick up my guitar again 😆 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After resolving the remaining threads, this is fine.
Co-authored-by: DominikKamp <[email protected]>
That should be it, then. Thank you for the awesome review, Dominik! |
Fix #1004