-
Notifications
You must be signed in to change notification settings - Fork 25
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
adding QuickXplain #416
adding QuickXplain #416
Conversation
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.
Nice example, small improvements can be added for readibility and being closer to the original algorithm.
Added quickxplain also to the tools and implemented a naive version. |
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.
Some small improvements mostly for readability. Ready to be merged after changes.
from cpmpy.expressions.variables import NDVarArray | ||
from cpmpy.transformations.get_variables import get_variables | ||
from cpmpy.transformations.normalize import toplevel_list | ||
|
||
|
||
def mus(soft, hard=[], solver="ortools"): | ||
""" |
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.
If you are proposing improvements to MUS as well, then I would rename variable solver
to solvername
.
m = Model(hard+[assump.implies(candidates)]) # each assumption variable implies a candidate | ||
s = SolverLookup.get(solver, m) | ||
m = cp.Model(hard + [assump.implies(candidates)]) # each assumption variable implies a candidate | ||
s = cp.SolverLookup.get(solver, m) |
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.
Some thoughts for readability.
m -> model
s -> solver
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.
I'm only proposing changes for the quickXplain algo : )
But I do agree with your proposed improvements, so maybe we can put them in antoher PR?
return [dmap[a] for a in core] | ||
|
||
|
||
def recurse_explain(soft, hard, delta, solver): |
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.
Is there a reason why you recurse_explain (resp. do_recursion) in the tools is embedded and not here ?
Change the function name to be consistent across both files?
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.
Not really, I wanted to stay very close to the original pseudocode of the paper in the example, while the tools-version has some subtle optimizations, plus embedding the recursive call ensures users cannot call the helper function themselves by accident.
I implemented the original basic version of the QuickXplain algorithm of Junker: