Add encoding variables as expressions to CSE #781
+97
−52
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.
By adding encoding variables to CSE, e.g. for the direct encoding for
xwhich encodesb == ( x == 2 ), addingcse[x==2] = bensuresbis used whenever we see the expressionx==2.In the following test, we see how this improves the encoding of
(x == 0) | (x == 2)forx in 0..2:However, this does mean integer variables need to be collected and encoded before the other transformations. This may be an encoding inefficiency, plus it does mean we cannot inspect the constraint that holds the variable (an inequality constraint normally uses order encoding, an (dis)equality the direct encoding).
Another problem is that the
int2booltransformation requires boilerplate across solvers. This should be solved in a separate PR, I think. This optimization is now only added to pindakaas, but should also happen for the other solvers which useint2bool.