Quote:

> Can sb tell me what the equivalent of the line below in Eclipse?

> Sicstus:

> X in 1..10, Y #= X mod 3, labeling([],[X]).

> The line below doesn't work in eclipse:

> X :: [1..10], Y#=X mod 3,labeling([X]).

As noted, there is no `mod' constraint in ECLiPSe. However, it is

fairly straightforward to transform such a constraint into a normal

linear constraint.

E.g.

Y #= X mod 3 -> Y #= X + 3 * K

... with appropriate constraints on X and Y (and maybe K) depending upon

how you want the mod to behave (e.g. you probably want Y to be

restricted to 0..2 in this case).

Note that if your constraint is not `#=' but instead `#\=' or `#>=' or

whatever, then you need a little more care, but in general whenever you

have `X mod A' you can do a similar transformation to get what you want.

Here's an example implementation of a predicate you can use to provide a

mod constraint even when A is a variable. Note however that it does not

do full arc-consistency: if you want something which propagates more

strongly, you will have to implement it yourself.

% Y #= X mod A

% (Assumes A is positive, and Y should be in the range 0..(A-1))

fd_mod(X, A, Y) :-

Y #>= 0,

Y #< A,

Y #= X + A * _K.

Cheers,

Warwick