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

From: Oliver Scheickl <scheickl_at_googlemail.com>
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
advance. Here is my post:
http://sourceforge.net/mailarchive/forum.php?thread_name=a810a47b0910120652n71002f3fw3e6e4afff2b48f49%40mail.gmail.com&forum_name=eclipse-clp-users

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_gmail.com>

> 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
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>
>
Received on Tue Oct 13 2009 - 14:39:27 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET