Re: [eclipse-users] ECLiPSe-SWI Prolog relation

From: Marco Gavanelli <marco.gavanelli_at_...17...>
Date: Thu, 26 Apr 2007 15:54:04 +0200
Daniel Riera wrote:
> Hello,
> I am working in a model where there is a special value, ND (Not
> Determined) which
> should be considered for every single operation.
> I use finite domain constraints but it would be great if it was possible
> to redefine every operation
> to allow propagations like:
> Given:
> [X,Y,Z]::[0..100,ND],
> X + Y #= Z
> Thus, if X or Y is ND, then Z is ND
> The point is that several operations should be redefined. What is the
> best way to do this?

Hi Daniel!

If you have a general behaviour that constraints should have in presence 
of ND, you could use a variation of the following code:

:- lib(fd).
:- lib(propia).
     nd_constr(C,Vars) infers fd.

     foreach(X,Vars) do
         X #= nd.
     (foreach(X,Vars) do
         X #\= nd),

I.e., you define the behaviour in case of ND, and use the usual 
propagation of the constraint when there are no NDs.

[eclipse 30]: [X,Y,Z]::[0..100,nd], nd_constr(X+Y#=Z), nd_constr(X#>0).

Y = Y{[0..99, nd]}
Z = Z{[1..100, nd]}
X = X{[1..100, nd]}

But maybe this is not what you want, as from your description there 
seems to be a 'direction' in constraints. E.g.,

[eclipse 31]: [X,Y,Z]::[0..100,nd], nd_constr(X+Y#=Z), Z=nd.

X = nd
Y = nd
Z = nd

Is this what you need? Or do you want NDs to propagate only from X to Z 
and not vice-versa?


Marco Gavanelli, Ph.D.
Computer Science Division
Dipartimento di Ingegneria
University of Ferrara
Via Saragat 1 - 44100 Ferrara (Italy)
Tel  +39-0532-97-4833
Fax  +39-0532-97-4870
Received on Thu Apr 26 2007 - 14:54:11 CEST

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