# Re: [eclipse-clp-users] Managing lists of real variable

From: Oliver Scheickl <scheickl_at_...1...>
Date: Tue, 13 Oct 2009 16:39:24 +0200
```Hi Simone,

If you study my post to this mailing list of yesterday, you will see that I
solve a similar problem. I also don't know the concrete number of values in

As I am also new to constraint programming I know how difficult it is to get
startet. I would solve your problem as follows:

-----------snip--------------
sum_up_example(Amount, Variables) :-
Variables :: 0..10,

sum(Variables) #= Amount,
% arbitrary additional constraints for the variables
% e.g.

labeling(Variables).
-----------snip--------------

A query like "sum_up_example(10, [X1, X2, X3])" gives you a solution. Note
that in this example I am using integer values, not real.

Best regards,
Oliver.

2009/10/13 simone pascucci <cxjepa_at_...6...>

> Hi all,
>
> I'm trying to understand how constraint programming works, but I have to
> say that it's quite a difficult subject.
> I have a reasonable easy problem to solve, given a list of real variable
> {x_1,...,x_n}, a real constant that I'll call "amount" and a set of
> constraint on the values that the variables can take, I have to solve
>
> amount = sum_{i} x_i
>
> In all the example I could get from the tutorials, it seems to me that
> somehow all the programs are always bounded to a fixed, already known,
> number of variables. If someone could give a small code example about
> solving this simple problem that would help a lot.
>
> Thank you,
>
> simone
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay