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

From: Ulrich Scholz <Ulrich.Scholz_at_...10...>
Date: Mon, 16 Nov 2009 11:12:02 +0100
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.

Below you find two tests that uses suspension and ic constraints.  The
condition is the standard waking condition "constrained".  I expect it to
wake any time a variable (including ic variables) is unified ("wake when a
variable gets [...] bound to another variable").

But it seems that condition "constrained" only wakes if domains are changed.

Thank you for your comments,

Ulrich


test1 yields:

[eclipse 26]: test1.
touched: _204 has bounds (1,10)
touched: _222 has bounds (1,10)
touched: _293 has bounds (2,10)
touched: _204 has bounds (2,10)



Delayed goals:
        touched(_222{1 .. 10})
        touched(_204{2 .. 10})
        touched(_204{2 .. 10})

The fourth "touched" shows that touched(_204) has been woken.


but then, test2 yields:

[eclipse 27]: test2.
touched: _204 has bounds (1,10)
touched: _222 has bounds (1,10)
touched: _293 has bounds (2,10)



Delayed goals:
        touched(_204{1 .. 10})
        touched(_204{1 .. 10})
        touched(_293{2 .. 10})


Here, nothing gets woken.  But it should, as _222 got bound to _204.



----
:- lib(ic).

init(A,B,C) :-
    [A,B] :: [1..10],
    [C] :: [2..10],
   
    touched(A),
    touched(B),
    touched(C),
    
    true.

touched(T) :-
    get_bounds(T, Low, High),
    sprintf(Message, "touched: %w has bounds (%d,%d)", [T, Low, High]),
    writeln(Message),
    
    (Low == High ->
        true
    ;
        suspend(touched(T), 0, [T->constrained])
%          suspend(touched(T), 0, [T->bound])
%          suspend(touched(T), 0, [T->ic:min, T->ic:max])
    ).

test1 :-
    init(A,_B,C),
    
    A #= C.

test2 :-
    init(A,B,_),
    
    A #= B.
----
Received on Mon Nov 16 2009 - 10:44:35 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST