Skip to content

Push down negation before decompose#916

Open
IgnaceBleukx wants to merge 22 commits into
masterfrom
negation_before_decompose
Open

Push down negation before decompose#916
IgnaceBleukx wants to merge 22 commits into
masterfrom
negation_before_decompose

Conversation

@IgnaceBleukx
Copy link
Copy Markdown
Collaborator

Re-order the transformations such that negation is pushed down into the arguments of a "not" operator before we call decompose.

This allows to implement efficient implementations of negated global constraints (e.g., ~Table becomes Negtable).
We can also do this for some more (e.g., ~AllDiff(x) becomes NValue(x) < len(x)). We should probably do some small experiments to see what is more efficient? Also depends on the decomp of NValue of course if that one is not supported...

Downside is that no transformation can explicitly introduce negation, and needs to call recurse_negation themself. This turned out to be simpler to implement than I first thought.

Efficiency-wise, there might be some gains because we now have one transformation less to be called in each recursiveflatten_constraint call. I then also noticed we call simplify_boolean in each recursive flatten call, I've added a flag to disable it when we can. Not sure if this should remain in this PR

@IgnaceBleukx IgnaceBleukx requested a review from tias April 8, 2026 15:19
@tias
Copy link
Copy Markdown
Collaborator

tias commented Apr 21, 2026

you will have to rebase/merge master in I guess, now that push down negation rewrite is in (in a different form)

Copy link
Copy Markdown
Collaborator

@tias tias left a comment

Choose a reason for hiding this comment

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

almost there.

I guess you checked that no global cons/func introduces a negation, even on the latest master?

Also, we since have 'scip' as a solver, can you check that all solvers on master that need changing are changed?

Comment thread cpmpy/expressions/globalconstraints.py Outdated
Comment thread cpmpy/transformations/flatten_model.py
@IgnaceBleukx IgnaceBleukx requested a review from tias May 8, 2026 08:40
@IgnaceBleukx
Copy link
Copy Markdown
Collaborator Author

Processed the review, there were indeed a couple of cases where the decomposition/negation of a global might introduce negation.

Updated scip and docs

@IgnaceBleukx
Copy link
Copy Markdown
Collaborator Author

Also updated the newly added highs solver, should be ready to go in after tests complete?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants