Skip to content

simplify_boolean in the new pattern (9s -> 6s flatten)#959

Open
tias wants to merge 13 commits into
masterfrom
simpl_bool
Open

simplify_boolean in the new pattern (9s -> 6s flatten)#959
tias wants to merge 13 commits into
masterfrom
simpl_bool

Conversation

@tias
Copy link
Copy Markdown
Collaborator

@tias tias commented Apr 26, 2026

No description provided.

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

@IgnaceBleukx IgnaceBleukx left a comment

Choose a reason for hiding this comment

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

Primarily doc-related comments

else: # variables/constants/direct constraints
changed, newexpr = _simplify_boolean_expr(expr, num_context=num_context)
if changed:
assert not isinstance(newexpr, int)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can also assert this by using an overload on the _simplify_boolean_expr header?
If num_context is False, then return type is bool/Expression.

I would expect the num_context on the main transformation to be deprecated? Users should only call this one at the toplevel, where everything is bool

Comment thread cpmpy/transformations/normalize.py
return False, expr

elif expr.name == "not":
if isinstance(args[0], _BoolVarImpl):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This case should not happen anymore, right? We should have already pushed down negation. Only case left here should be not(GlobalConstraint)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm according to the coverage tool, it still fires -- not sure from where

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah yes of course... #916 is not yet merged.

Comment thread cpmpy/transformations/normalize.py
Comment thread cpmpy/transformations/normalize.py
Comment thread cpmpy/transformations/normalize.py Outdated
Comment thread cpmpy/transformations/normalize.py
Comment thread cpmpy/transformations/normalize.py
Comment thread cpmpy/transformations/normalize.py
Comment thread cpmpy/transformations/normalize.py
@IgnaceBleukx
Copy link
Copy Markdown
Collaborator

This PR merges to solver_vars, is that on purpose? Or should it be rebased on master?

@IgnaceBleukx IgnaceBleukx changed the base branch from solver_vars to master May 7, 2026 11:29
@IgnaceBleukx IgnaceBleukx self-requested a review May 11, 2026 13:04
Copy link
Copy Markdown
Collaborator

@IgnaceBleukx IgnaceBleukx left a comment

Choose a reason for hiding this comment

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

Fixed my comments and cleaned up the PR by removing solver-var-1d-related stuff.

Can you also have a look at the final result @tias ?

@tias
Copy link
Copy Markdown
Collaborator Author

tias commented May 11, 2026

Pumpkin triggers a floating point error (we currently have a test that feeds a 0.5, even though we don't intend to support it).

So maybe we should merge #957 first, which removes that case and does foresee the only way we do intend to accept floats in the objective

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