[PPL-devel] Use of non-integers in Java

Étienne André Etienne.Andre at lipn.univ-paris13.fr
Thu Mar 14 13:33:42 CET 2013


Dear Enea,

First, thank you for your reply, and sorry for my late reply.

I was a little surprised by what you said; but actually, after I could
take some time to have a look at the code, I realize I made a mistake,
due to the fact that my tool IMITATOR is based on an "interface to
PPL" designed by a colleague.
Where the rationals are allowed is actually in his interface; later
on, of course they are converted to integers using GCD techniques,
before getting fed into PPL.
So indeed, even in OCaml, I don't know a native way to deal with
rationals coefficients, although such an interface can help.

Best
--
Étienne André
LIPN, Université Paris 13, Sorbonne Paris Cité
http://www-lipn.univ-paris13.fr/~andre


2013/2/22 Enea Zaffanella <zaffanella at cs.unipr.it>:
> On 02/21/2013 03:21 PM, Étienne André wrote:
>>
>> Dear PPL developers,
>>
>> My intern would like to link PPL with a Java program.
>>
>> I have some experience of using PPL with OCaml, but not with Java.
>> And in particular I could not find how to use non-integers coefficients
>> (but rationals instead).
>> In OCaml, it was easy, e.g., using the "Gmp.Q.from_ints i j" function.
>>
>> But in the Java interface, I only see constructors from int, big int,
>> long and string.
>> How can we build some rational coefficients in the Java interface?
>>
>> Thank you very much,
>> --
>> Étienne André
>> LIPN, Université Paris 13, Sorbonne Paris Cité
>> http://www-lipn.univ-paris13.fr/~andre
>> <http://www-lipn.univ-paris13.fr/%7Eandre>
>
>
>
> Hello.
>
> The coefficient of constraints/generators in the Parma Polyhedra Library are
> *integral by design* (unbounded integers as provided by GMP, in the default
> configuration). Any constraint having non-integer rational coefficients can
> be "normalized" to become a constraint with integer coefficients before
> entering the library (same for generators, possibly using an integral
> divisor for points).
>
> This is the reason why Java class
>     parma_polyhedra_library.Coefficient
> only has constructors from int, long, BigInteger and String.
>
> As for the OCaml interface, things should be similar:
>
> type linear_expression =
> |       Variable of int
> |       Coefficient of Gmp.Z.t
> |       Unary_Plus of linear_expression
> |       Unary_Minus of linear_expression
> |       Plus of linear_expression * linear_expression
> |       Minus of linear_expression * linear_expression
> |       Times of Gmp.Z.t * linear_expression
>
> Again, only Gmp.Z.t coefficients are allowed.
>
> Can you clarify what you mean by:
>
>
>> In OCaml, it was easy, e.g., using the "Gmp.Q.from_ints i j" function.
>
> If you mean that you can use the mpq datatype outside of the Parma Polyhedra
> Library, that is perfectly fine. But the library does not support the
> specification of constraints having mpq coefficients ... so if you managed
> to directly fed these rationals to the PPL interface there might be
> something going wrong.
>
> As for Java ... I don't know if there is a "standard" rational class (have
> seen many different libraries with their own rational).
>
> Cheers,
> Enea.
>



More information about the PPL-devel mailing list