Re: [eclipse-clp-users] Reified constraint without propia

From: Thorsten Winterer <>
Date: Wed, 28 Apr 2010 10:23:17 +0200
Am 28.04.2010 09:25, schrieb Philipp Marcus:
> is there a general pattern to combine the two to a reified constraint 
> without using propia? Especially I'd like to know how you would check 
> the entailment or disentailment when B is unknown. For the two cases, 
> where B is instantiated I'd implement the predicate something like this:
> mycon_constr(..,Y,B) :-
>      (ground(B)->    mycon(..,Y,B);    suspend( mycon_constr(..,Y,B), 3, 
> [B] -> inst)).
> But I need to include the entailment/disentailment check. I'd be really 
> happy if somebody could give me a suggestion.

You could write your own entailment check predicate (say, mycon_test(X,
Y, B)) which sets B to 1/0 if mycon is entailed/disentailed, and else
Then you can use:

mycon_constr(X, Y, B) :-
        mycon(X, Y, B)
        suspend(mycon(X, Y, B), 3, [B]->inst),       % use mycon/3
directly, not mycon_constr/3
        suspend(mycon_test(X, Y, B), 3, [Y]->constrained)

You can also make the entailment check a demon, which re-suspends
automatically. This is preferable if the test re-suspends often.

This would look something like this:

:- demon mycon_test/4.
mycon_test(X,Y,B,S) :-
        ...check entailment
        B #= 1
        ...check disentailment
        B #= 0
    ( ground(B) -> kill_suspension(S) ; true ).

The call would then be:

    suspend(mycon_test(X,Y,B,S), 3, [Y]->constrained, S)

Note that you shouldn't use constraints like in/3 for the entailment
check. Instead, use set_range/3 to get the upper/lower bounds on your
set variables and test membership on these.

Hope this helps.

Received on Wed Apr 28 2010 - 08:23:24 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET