Re: [eclipse-clp-users] number expected in set_up_ic_con

From: Marco Gavanelli <marco.gavanelli_at_...17...>
Date: Fri, 05 Dec 2014 12:27:12 +0100
Dear Philippe,

To find the problem, you can use the tracer:

[eclipse 6]: trace.
Debugger switched on - creep mode
[eclipse 7]: solve(A1).
   (1) 1 CALL  solve(A1)   %> creep
   (2) 2 CALL  ... = ...   %> creep
   (2) 2 EXIT  ... = ...   %> creep
   (3) 2 CALL  length(A1, 3)   %> creep
   (3) 2 EXIT  length([_501, _503, _505], 3)   %> creep
   (4) 2 CALL  '::_body'([_501, _503, _505], 0 .. 10, eclipse)   %> creep
   (4) 2 EXIT  '::_body'([_702{0 .. 10}, _716{0 .. 10}, _730{0 .. 10}], 
0 .. 10, eclipse)   %> creep
   (5) 2 CALL  -(10) + 2 * [_702{0 .. 10}, _716{0 .. 10}, _730{0 .. 10}] 
#= 0   %> creep
number expected in set_up_ic_con(7, 1, [0 * 1, -1 * 10, 2 * [_702{0 .. 
10}, _716{0 .. 10}, _730{0 .. 10}]])

As you can see, the constraint raising the error is A1 + A1 #= Total, 
which ECLiPSe rewrites as

    -(10) + 2 * [_702{0 .. 10}, _716{0 .. 10}, _730{0 .. 10}] #= 0

As you can see in the documentation:

http://eclipseclp.org/doc/bips/lib/ic/HE-2.html

the arguments of the #= should be two integer arithmetic expressions.

In the documentation you can also find how an arithmetic expression is 
built:

http://eclipseclp.org/doc/libman/libman017.html#sec34

and you can see that a list (or a sum of lists) is not an arithmetic 
expression. You can have sum(List) as an arithmetic expression, but I 
guess it is not what you need here.

I do not understand what you mean with "a list of values which when 
added two by two, are equal to 10"; do you mean that any pair of values 
taken from the list should sum to 10? Or do you mean that any two 
consecutive values in the list should sum up to 10?
In both cases, you should write a predicate for doing that.

Best,
Marco

On 04/12/14 21:03, Philippe de Rochambeau wrote:
> Hello,
>
> when I run the following program, whose purpose is to generate a list of values which when added two by two, are equal to 10,
>
> :- lib(ic).
> solve(A1) :-
>          Total = 10,
>          length(A1, 3),
>          A1 :: 0..10,
>          A1 + A1 #= Total,
>          labeling(A1).
>
> I get the following error message:
>
> "number expected in set_up_ic_con(7, 1, -1 * 10…"
>
> What am I doing wrong?
>
> Best regards,
>
> Philippe



-- 
Marco Gavanelli, Ph.D. in Computer Science
Dept of Engineering
University of Ferrara
Tel/Fax  +39-0532-97-4833
http://docente.unife.it/marco.gavanelli
Received on Fri Dec 05 2014 - 12:27:48 CET

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