Re: [eclipse-users] Why expression in constraint breaks at run-time

From: Kish Shen <kisshen_at_...5...>
Date: Tue, 31 Jul 2007 23:13:35 +0100
Hi Bill,

Bill Wood wrote:
> This is driving me nuts.  I am fairly comfortable with Prolog but I'm a
> newbie with eclipse.
>
> I used tkeclipse+emacs to, first, build, compile and run a file with
> SEND_MORE_MONEY example; it went flawlessly.  I then started modifying
> the file to solve a different constraint problem, involving a collection
> of digits with constraints on various subsets of them.  Here's the
> modified file:
>
>   foo( Digits ) :-
>       Digits = [D01,D02,D03,D04,D05,D06,D07,D08,D09,D10],
>       Digits :: [0 .. 9],
>       alldifferent( Digits ),
>       D01 #\= 0,
>
>       (D02 * 100 + D03 * 10 + D04) mod 2 #= 0,
>       (D03 * 100 + D04 * 10 + D05) mod 3 #= 0,
>       (D04 * 100 + D05 * 10 + D06) mod 5 #= 0,
>       (D05 * 100 + D06 * 10 + D07) mod 7 #= 0,
>       (D06 * 100 + D07 * 10 + D08) mod 11 #= 0,
>       (D07 * 100 + D08 * 10 + D09) mod 13 #= 0,
>       (D08 * 100 + D09 * 10 + D10) mod 17 #= 0,
>       labeling( Digits ).
>
> Doing make in tkeclipse seems to go OK -- I only get the following in
> the Message window:
>
>      fubb.ecl   compiled traceable 2952 bytes in 0.00 seconds
>
> But when I place the query "foo(Digits)." in the Query window and hit
> return I get the following message:
>
>     number expected in mod(D02{0 .. 9} * 100 + D03{0 .. 9} * 10 +
>     D04{0 .. 9}, 2, _894{-1.0Inf .. 1.0Inf})
>
> It looks like a complaint about unbound variables in the expression, but
> I can't figure out why the constraints in the SEND_MORE_MONEY can have
> variables and the constrainbys can't.  The tutorial explicitly says that
> "IC supports a range of mathematical operators beyond +/2, -/2, */2,
> etc.  See the IC chapter in the Constraint Library Manual for full
> details." (pg. 78).  Page 70 of the User Manual describes the mod
> operator.  I haven't seen anything about some operators being
> unavailable in constraint expressions.
>
>   
IC supports a subset of the mathematical operators, and mod/2 is *not* 
supported, so if it appears in an expression posted as a constraint, it 
is evaluated at that point, and you get an error because of the 
uninstantiated variables. .

The operators supported by IC are described in the IC chapter of the 
Constraint Library Manual,  as quoted by you:

http://eclipse.crosscoreop.com/doc/tutorial/tutorial057.html

This is not the same as the User Manual.

You can also get help information while you are running ECLiPSe,  using 
the help/1 query, which works in both tkeclipse and eclipse, e.g.

help lib(ic).

In tkeclipse, you can also get the same information via the "ECLiPSe 
Library Browser and Help" tool from the "Tools" menu.

You can also access the manual online as html pages -- these are 
included in the documentation package
(eclipse_doc.tgz).

The information for help lib(ic) includes which operators are supported 
by IC as well.

Cheers,

Kish Shen

>  -- Bill Wood
>
>
>
> _______________________________________________
> ECLiPSe-Users mailing list
> ECLiPSe-Users_at_...2...
> http://www.crosscoreop.com/mailman/options/eclipse-users
>   
Received on Tue Jul 31 2007 - 23:14:04 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST