-
Notifications
You must be signed in to change notification settings - Fork 15
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
Possible improvements to abs/1 #6
Comments
These are very good observations, thank you! Do these issues arise an actual use cases? The reason I ask is the following: Please tell me the (still reasonable) most general pattern of these types that you would like CLP(Z) to handle more efficiently. For example, I will start working on this issue by making And: Yes, for |
Please try the latest version: I have implemented this suggestion and would greatly appreciate your feedback. |
I'm not quite sure what you actually implemented; in anycase here's the following observation:
Seems that addition does not propagate as strongly as multiplication in that case. Though note that Another note:
Like (I am definitely not a fan of SICStus REPL...) |
So far, I have implemented specifically the cases you mentioned in your original post. For example, the following is now instantaneous: ?- X #= abs(X) + 1, X in 1..10000, indomain(X). This is because the specific form of the constraint is now handled via a dedicated propagator, which is applied if the posted constraint is subsumed by the symbolic pattern: Var #= abs(Var) + Expr where CLP(Z) has dedicated propagators for patterns of constraints that frequently occur in practice, and which can be handled more efficiently when they are taken into account in their entirety instead of decomposing them. Ongoing work on CLP(Z) also involves extending the recognizer with further patterns that users request. This is the usual way of constraint-based development: We extend and improve the solver so that it handles these patterns more efficiently. The challenge here is to generalize such patterns as far as possible, so that a small number of patterns suffice to recognize the cases that are important for you in practice. For example, to capture the constraints you originally reported, I added to m_c(var(X) #= abs(var(Y)) + any(V0), X == Y) => [d(V0,V),p(x_eq_abs_plus_v(X,V))], m_c(var(X) #= abs(var(Y)) - any(V0), X == Y) => [d(-V0,V),p(x_eq_abs_plus_v(X,V))], The syntax of these rules is explained in my thesis, please have a look. You have now reported an additional case for which you would like to have stronger propagation, which is not captured by the pattern above: abs(X) #= 1 + X It is easy to extend the recognizer accordingly, please try it out so that you see how to extend and adapt CLP(Z) for your use cases. The other new example, |
(Tested on SWI's CLP(FD), though I assume the same problem exists in CLP(Z))
Weak propagation
This could directly fail. As a result it takes a long time for this to fail, even though it is obvious that it will:
Redundant constraint
This correctly constrains
X
to0..sup
frominf..sup
, but then theX#=abs(X)
constraint is completely unnecessary.The text was updated successfully, but these errors were encountered: