Instantiation fault ECLiPSe CSP

895 views Asked by At

I have problems with my CSP under ECLiPSe. I wish to add a constraint to my cryptogram which requires that the number represented by TWO is divisible by 2.

[eclipse 11]: test(Xs).
instantiation fault in (_268{[1..4]}*100 + _200{[0..9]}*10 + _302{[0..9]}*1) mod 2#=0
Abort

Thanks for your help.

My code :

/*
          T W O                                           
   +  T H R E E      
   +  T H R E E                                       
      ---------                                      
      E I G H T                                     
*/

:- lib(fd).

myCsp(Xs):-
    Xs=[W,I,G,H,T,R,O,E],
    Xs::0..9,
    [C1,C2,C3,C4]::0..2,
    T #> 0,E #> 0,
    O + E + E #= C1*10 + T,
    W + E + E + C1 #= C2*10 + H,
    T + R + R + C2 #= C3*10 + G,
    H + H + C3 #= C4*10 + I,
    T + T + C4 #= E,
    (T*100 + W*10 + O*1) mod 2 #= 0,
    alldifferent([W,I,G,H,T,R,O,E]).

test(Xs):-
    myCsp(Xs),
    labeling(Xs).
1

There are 1 answers

0
jschimpf On BEST ANSWER

The mod/2 operation in

(T*100 + W*10 + O*1) mod 2 #= 0

isn't supported. You can rewrite the line as

T*100 + W*10 + O*1  #=  2*_

which says that the left hand side expression is equal to twice an anonymous integer variable, and thus a multiple of two.