-
Notifications
You must be signed in to change notification settings - Fork 25
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
Decompose globals #246
Decompose globals #246
Conversation
Significantly cleaned up the code of the new transformation. |
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.
Looks good, but the decompose algorithm has many edge cases that are not covered, probably correctly so. So I'd like some more comment and explanation why these do not need to be covered.
# Conflicts: # cpmpy/solvers/ortools.py
Added some documentation and covered + tested more edge cases. |
# Conflicts: # cpmpy/expressions/globalconstraints.py
Merged master with bound calculations into this branch, now |
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.
Allright, I'm pretty sure this is not the final word on decomposing globals, but it is a good step in the right direction. I've got two open comments left that should be easy to resolve, so the PR gets an approve.
Broader concerns:
- what about
abs
? This one should simply be a global constraint. - this decomposition code assumes a lot about the form of the constraints (e.g., flattened). Based on these assumptions, we get a lot of if-then cases that are handled, and now we hope that we handled all possibilities. A different way of decomposing would be to traverse the expression trees, keeping track of whether we are in a reified or non-reified (top-level) expression. We return the appropriate decomposition to the parent, who then replaces its child. This is a generic way of decomposing, which to me looks less hard to maintain. But it is out of the scope of this MR.
I agree we should make Regarding decomposing globals in the expression tree, I thought about it as well but there are many edges cases which are unclear how to handle. So it is to prevent these cases I opted for decomposing the globals after flattening |
New transformation to decompose any unsupported global constraints in flat expressions.
Code is functional but can be somewhat compacted I think...
Transformation should be run after flatten() for every solver so we do not have to decompose globals at a later stage.
Work in progress still