Re: uncaught exception: error(resource_error(too_big_fd_constraint), # /2)

Daniel Diaz <[email protected]> Fri, 17 Feb 2012 11:24:29 +0100
Newsgroups gmane.comp.gnu.prolog.bugs
Message-ID <[email protected]>
Hello,

There are some problems with your code. First you should write #<=>
instead of #= in your code.

Anyway the problem with the size of the constraints is not linked to
this. I have fixed it in my code and a version is available here:

http://gprolog.univ-paris1.fr/unstable/gprolog-20120217.tgz

However, there are 3 possible workarounds with the current version:

- note that an xor over n variables is true iff an odd number of
variables are true.

Thus you can obtain the same behavior with a linear equation
followed by a modulo.

E.g. X1 + X2 + ... + Xn #= S, S rem 2 #= 1.

- you can also split big constraints into smaller ones (max 10
variables is OK).

E.g. X1 ## X2 ## X3 ## ... X20 #<=> 1 becomes X1
## .. ## X10 #<=> S, S ## X11 ## ... X20 #<=> 1.

- You can define a predicate xor/2 that accepts a list and a
result and does the job. Use it as: xor([X1,...,X20],1).

Here is the definition of xor/2.

xor([X|L], R) :-

xor(L, X, R).

xor([], R, R).

xor([Y|L], X, R) :-

X ## Y #<=> Z,

xor(L, Z, R).

Daniel

Le 13/02/2012 18:00, Ujjwal Guin a écrit :

Hello,

My name is Ujjwal Guin, a doctoral student of University of
Connecticut. Currently, I am trying to run a prolog program on the
university server (Linux). The program is very small and quite simple.
If I run the same program in my Windows (BProlog), I am getting the
proper result. I am mentioning the program below.

solve(Vars):-
Vars=[A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,B0,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12],
fd_domain_bool(Vars),
B6##B3##B2##B1##B0##A5##A2##A1##A0#=1,
B4##B1##B0##A3##A0#=1,
B9##B6##B5##B3##B12##B10##A9##A7##A6##A5##A4##A3##A2##A11##A10#=1,
B9##B7##B6##B3##B2##B0##A8##A7##A6##A4##A3##A2##A1##A0#=0,
B7##B5##B4##B1##B0##A6##A5##A4##A2##A1##A0#=1,
B6##B4##B3##B0##A5##A4##A3##A1##A0#=1,
B8##B6##B2##B11##A9##A7##A6##A2##A12##A11##A0#=0,
B7##B5##B10##B1##A8##A6##A5##A11##A10##A1#=0,
B7##B4##B2##A8##A7##A5##A3##A2#=1,
B4##B1##A5##A4##A2##A0#=0,
fd_labeling(Vars).

I will really appreciate your help to execute the program..

Thank you very much.

Regards
Ujjwal Guin

_______________________________________________
Bug-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-prolog

--

Ce message a été vérifié par
MailScanner
pour des virus ou des polluriels et rien de
suspect n'a été trouvé.

_______________________________________________
Bug-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-prolog