Re: [eclipse-clp-users] Suspension: "constrained" does not wake on unification of ic variables

From: Joachim Schimpf <joachim.schimpf_at_...44...>
Date: Mon, 16 Nov 2009 23:21:32 +1100
Ulrich Scholz wrote:
> Dear all,
> 
> Id like to wake a suspension on an ic variables if it becomes more
> constrained, in particular, if it gets unified with another ic variable
> (#=).  I thought, the "constrained" waking condition is the right way to
> achieve this effect.  But it does not seem to work in case no bound changes
> occur.  Maybe you can clarify.

IC-variables have the 3 generic waking conditions (inst,bound,constrained)
plus 4 specific ones (min,max,hole,type).  Some of them include others:

inst:	wake on instantiation
bound:	inst + wake on var-var binding (see below)
min:	wake on lower bound change
max:	wake on upper bound change
hole:	wake on domain reduction without bound change
type:	wake when real is restricted to integer
constrained: inst+bound+min+max+hole+type

The one you want is 'bound' (the name is unfortunate, it refers to binding,
not bounds!).  What you have overlooked is that it reacts only to var-var
bindings within the set of variables on which a particular goal delays.
Bindings to unrelated variables don't trigger anything, which is exactly
the behaviour you need:

% unifying any two of the three suspending variables causes waking
?- suspend(writeln(reduced(X, Y, Z)), 0, [X,Y,Z]->bound), X = Y.
reduced(X, X, Z)
X = X
Y = X
Z = Z
Yes (0.00s cpu)

% unifying X with an unrelated variable has no effect
?- suspend(writeln(reduced(X, Y, Z)), 0, [X,Y,Z]->bound), X = A.
X = A
Y = Y
Z = Z
A = A
There is 1 delayed goal.
Yes (0.00s cpu)


-- Joachim
Received on Mon Nov 16 2009 - 13:21:24 CET

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:20 CEST