From: Warwick Harvey <wh_at_icparc.ic.ac.uk>

Date: Thu 01 May 2003 12:50:01 PM GMT

Message-ID: <20030501135000.I11209@tempest.icparc.ic.ac.uk>

Date: Thu 01 May 2003 12:50:01 PM GMT

Message-ID: <20030501135000.I11209@tempest.icparc.ic.ac.uk>

On Thu, May 01, 2003 at 11:58:37AM +0100, Tom Kelsey wrote: > Another approach is one constraint for each variable pair: Tom's idea is fine, but unfortunately his implementation is wrong in a number of ways. > ( > Y #< 4 -> Z #= 3 > ; > true > ), Unless you really know what you're doing, don't put a constraint in the condition of an if-then-else; it almost certainly does not do what you want. Probably what Tom meant was: Y #< 4 #=> Z #= 3 The difference is that the latter sets up the implication as a constraint, whereas the former does not. The former immediately imposes the constraint Y #< 4, and then decides whether or not to impose Z #= 3 right away; it also can never impose Y #>= 4 (if Z #\= 3, for instance). The latter will only impose Z #= 3 if at some point Y's domain is sufficiently reduced that Y is guaranteed to be less than 4; and if Z is assigned a value other than 3 it will impose the constraint Y #>= 4. The point is that the former commits to the choice immediately (which may be premature) while the latter does not. In any event, what was really wanted was Y #=< 3, Z #= 3 since Y cannot be more than 3, regardless of the value of Z, and Z is 3 regardless of the value of Y. > ( > Z ## 3 -> X #= Z > ; > X #= 1 > ), This is less convenient to write correctly, and there are a number of ways of doing it. One way might be: #=(Z, 3, B), % B = 1 iff Z = 3 B #=> X #= 1, % if B = 1 (i.e. Z = 3) then X = 1 B #\/ X #= Z % if B = 0 (i.e. Z =\= 3) then X = Z But since the relation is actually a function from Z to X, an easier (and more effective in terms of propagation strength) way of implementing it would be to use the element/3 constraint: element(Z, [1, 2, 1, 4, 5], X) Cheers, WarwickReceived on Thu May 01 13:50:12 2003

*
This archive was generated by hypermail 2.1.8
: Wed 16 Nov 2005 06:07:23 PM GMT GMT
*