-
Notifications
You must be signed in to change notification settings - Fork 33
Expand CNF using encoding back-end #782
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
base: master
Are you sure you want to change the base?
Conversation
|
Ready to be reviewed. Outstanding issues and my reasons for not resolving them:
|
tias
left a comment
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.
yes, I think that this is the right way.
I see that you change the signature of to_cnf to also return ivarmap, which I would like to avoid.
I don't think the solver 'copies' the ivarmap when you give it to it; which would mean that the ivarmap given by the function caller might be updated when the function returns, hence not needing to return ivarmap. Can you check that?
|
ah, yeah, actually, of course we do not need to return it. If you need it, you should just also be in charge of creating the |
|
|
||
| cnf_txt = write_dimacs(m) | ||
| gt_cnf = "p cnf 3 3\n1 2 3 0\n-2 -3 0\n-1 0\n" | ||
| # TODO note the order is slightly unexpected, because of an optimization in `to_cnf` which puts simple clauses before encoded constraints (i.e.) sums |
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.
A solution to this would be to compare sets of lines, which is basically what we want for this tool anyway
E.g.
gt_clauses = set(gt_cnf.split("\n")[1:])
txt_clauses = set(cnf_txt.split("\n")[1:])
self.assertSetEqual(gt_clauses, txt_clauses)
This PR expands the
to_cnffunction to all CPMpy models (insofar supported by other Boolean solvers). It does so by passing all constraints throughpindakaastransform and encoding, and reading the Pindakaas encoding object back to CPMpy.TODO