Skip to content
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

227 false gets removed in transformations #229

Merged
merged 33 commits into from
Feb 27, 2023

Conversation

IgnaceBleukx
Copy link
Collaborator

Wasn't really sure about how to do it in pysdd...

@IgnaceBleukx IgnaceBleukx linked an issue Feb 16, 2023 that may be closed by this pull request
cpmpy/solvers/gurobi.py Outdated Show resolved Hide resolved
cpmpy/solvers/ortools.py Outdated Show resolved Hide resolved
@IgnaceBleukx
Copy link
Collaborator Author

After discussion offline: will implement a BoolVal wrapper so False can become a CPMpy expression. This will be part of a new transformation which also unravels all nested lists. Then every transformation will simply get a flat list of constraints and all transformations should work as is with the new BoolVal expression.
Will still have to add the cas of posting False to the solver in the _post_constraint of all solvers.

cpmpy/solvers/z3.py Show resolved Hide resolved
cpmpy/transformations/flatten_model.py Outdated Show resolved Hide resolved
tests/test_solvers.py Show resolved Hide resolved
@tias
Copy link
Collaborator

tias commented Feb 26, 2023

We have a bunch of research code that expects flatten_constraint() to continue working also on a single expression.

I hence propose to make flatten_constraint() a semi-meta function that calls make_expr internally. That means solvers dont need to add the transform themselvs. I'll play with this on the plane.

@tias
Copy link
Collaborator

tias commented Feb 27, 2023

I reworked it some more. I think its looking nice, would be good to see this land rather soon, so we can base other branches on this.

It tested good on bigtest (ortools) too (no noticable timing differences though, a bit to my surprise)

@Wout4 and @IgnaceBleukx can you have a final look and merge?

if isinstance(e, Expression):
if isinstance(e, NDVarArray): # sometimes does not have .name
unravel(e.flat, append)
elif e.name == "and":
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here check for merge_and, will add

@IgnaceBleukx
Copy link
Collaborator Author

Can confirm all tests run, for pysdd as well.
Ready to merge for me. @Wout4 waiting for your final thoughts before merging.

@Wout4
Copy link
Collaborator

Wout4 commented Feb 27, 2023

looks good to me!

@IgnaceBleukx IgnaceBleukx merged commit 4fca184 into master Feb 27, 2023
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.

'False' gets removed in transformations
5 participants