-
Notifications
You must be signed in to change notification settings - Fork 22
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
Extending automatic teststuite #464
Conversation
# Conflicts: # cpmpy/solvers/z3.py
# Conflicts: # tests/test_solvers.py
Is this a draft? |
Quite some errors in Choco too, regarding GCC. Choco accepts only ints for values, and not variables |
The inverse bug is just because it uses element probably? |
We could have argval return an 'undefined' value in stead of raising an error |
Fine to be merged by me, but some conflict to be resolved first |
…errors in argval() functions
I could not resist giving this another try :) Downside is that .value() is not safe anymore so you (and user) should always use argval() or .safe_value() in stead of .value() |
Hmm not sure if I like having two value functions... Using argval seems like a good solution tho! Take the following (convoluted) example: m = cp.Model()
arr = cp.intvar(0,10, shape=3, name="arr")
idx = cp.intvar(0,10, name="idx")
x = cp.boolvar(name="x")
y = cp.boolvar(name="y")
m += cp.AllEqual([cp.AllDifferent([arr[idx], 11, 12]),x,y])
m += idx == 7 Then, So basically what I'm saying is: the Boolean expression catching the undefinedness will never be at the top-level of the constraint model when the user is interested in the value of the decision variables. This is true as the model will be UNSAT when a constraint at toplevel is set to False because of the undefinedness so no values are assigned to the variables anyway. So, as long as the value of the arguments of any expression are calculated using |
yeah exactly, |
Yup indeed, but that can actually still happen... m = cp.Model()
arr = cp.intvar(0,10, shape=3, name="arr")
idx = cp.intvar(0,10, name="idx")
x = cp.boolvar(name="x")
y = cp.boolvar(name="y")
aldiff_expr = cp.AllDifferent([arr[idx], 11, 12])
m += cp.AllEqual([alldiff_expr,x,y])
m += idx == 7
m.solve()
alldiff_expr.value()
>> exception Ok, so lets indeed put in the exception one should use "argval" instead of value(), but still remove the safe_value(). You can still call the |
@Wout4 A lot of PRs depoend on this one now. I think it is ready to merge? |
Indeed, if it also looks good to you will merge it |
Strictly increasing test was failing for Minizinc but excluded it now and reported on their github. Will merge it so all other PRs can use the new testsuite too |
Extended the automatic
test_constraints
testsuite which uncovers several bugs (some of which are fixed in this PR)Main changes to test file:
solveAll
which tests wheter all solutions to the constraint are valid. Untested for now as it takes a long time for some consrtaints, but potentially usefull before doing a release?Bugs and fixes:
Inverse
consrtraint when nestedThe last is also why the automatic tests fail for now.