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

From: simone pascucci <cxjepa_at_...6...>
Date: Wed, 14 Oct 2009 11:22:20 -0500
Hi,

after reading the examples I could finally write the following routine which
does exactly what I wanted

sum_to_Amount(Amount, MinAmount, MaxAmount, MantCorr, MantCorrMin,
MantCorrMax, MantPrev, Variables, MinValues, MaxValues) :-
        Variables $:: 0.0..inf,
        Amount $:: 0.0..inf,
        MantCorr $:: 0.0..inf,
        MantPrev $:: 0.0..inf,
        ( foreach(V, Variables), foreach(Min, MinValues), foreach(Max,
MaxValues) do
            V $>= Min,
            V $=< Max
        ),
        Amount $=< MaxAmount,
        Amount $>= MinAmount,
        MantCorr $=< MantCorrMax*Amount,
        MantCorr $>= MantCorrMin*Amount,
        MantPrev $= sum(Variables),
        Amount $= MantCorr + MantPrev,
        locate(Variables, 1e-5).

I tested it with some examples and I'm getting correct answers. Now,
abousing of your kindness, I have a related question, hope to not bother.
I'm using the java interface, after some debugging I could write the java
class which calls eclipse on a CompoundTerm which contains all the needed
parameter. Reading the embedding tutorial, I noticed that breal have not the
corrispondent java class and for that reason they are represented by a null
token. This explains why I had null printed on screen when printing the
result. In a previous post I can read that users should make some type
conversion if they want to pass the result to java (I suppose I should cast
the breals to float), but I'm experiencing a infinite loop (or at least
something like that). This happen for example if I add at the very end the
following

       locate(Variables, 1e-5),
       float(Amount).

I suppose this is due to a erroneus usage of the programming language
syntax. Hope someone can help.

bye

simone

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

> Dear Kish and Oliver,
>
> thank you very much for the help. I understand much more now with an
> example that reading tenth of pages.
>
> bye,
>
> simone
>
> 2009/10/13 Kish Shen <kisshen_at_...5...>
>
> simone pascucci wrote:
>>
>>>
>>> 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.
>>>
>>
>> Hi Simone,
>>
>> Some of the examples in
>>
>> http://www.eclipse-clp.org/examples/index.html
>>
>> solves problems with different sizes, for example, in the planning and
>> scheduling section. Examples are rostering, square tiling, and the generic
>> versions of transport (the non-generic version has a fixed number of
>> variables, so you can compare the two approaches).
>>
>> Cheers,
>>
>> Kish
>>
>> --
>> This e-mail may contain confidential and privileged material for the
>> sole use of the intended recipient. Any review, use, distribution or
>> disclosure by others is strictly prohibited. If you are not the intended
>> recipient (or authorized to receive for the recipient), please contact
>> the sender by reply e-mail and delete all copies of this message.
>> Cisco Systems Limited (Company Number: 02558939), is registered in
>> England and Wales with its registered office at 1 Callaghan Square,
>> Cardiff, South Glamorgan CF10 5BT.
>>
>
>
Received on Wed Oct 14 2009 - 16:22:28 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:20 CEST