[PPL-devel] PPL Library capabilities (fwd)

Enea Zaffanella zaffanella at cs.unipr.it
Fri May 15 00:36:16 CEST 2009


> ---------- Forwarded message ----------
> Date: Wed, 13 May 2009 12:52:33 +0100
> From: Vladimir Koshelev <vedun at ispras.ru>
> To: P M Hill <hill at comp.leeds.ac.uk>
> Subject: Re: [PPL-devel] PPL Library capabilities

[...snip...]

> Dear Pat,
> 
> We need to transform matrix returned by minimized_grid_generators() to
> another form. To do this we want to get matrix coefficients, but current
> version of Java interface doesn't give access to low level Linear
> Expression representaion. It's will be very useful to get direct access
> to Linear_Expression coefficients include setting and removing.
> Example :
> If we have Linear_Expression 4 * A + 5 * B - C - 6, we want to get {4,
> 5, -1, -6} ( As vector or getter method or another form.)
> 
> Method which can express one variable in constraint throw others will be
> useful too.
> Example :
> 4 * A + 6 * B - 7 * C = 0 => 4 * A = -6 * B + 7 * C

Hello Vladimir.

I have just committed in a few changes to the Java interface that should 
allow for accessing the type, linear expression and divisor of a 
Grid_Generator object (and, in case you need, similar accessor methods 
have been provided for the Generator and the Congruence classes). See 
commit 2fd333e0c585db16b3bf406fba0475e527ec0655 on the master branch.

You should now be able to write something like the following:

   Grid_Generator_System gs = gr.minimized_grid_generator_system();
   /* ... */
   Grid_Generator g = gs.get(0);
   Linear_Expression le = g.linear_expression();
   Grid_Generator_Type t = g.type();
   if (t != Grid_Generator_Type.LINE) {
       Coefficient d = g.divisor();
       /* ... */
   }

In order to inspect the structure of the Linear_Expression subobject, 
you will have to resort to Java RTTI support, writing something like the 
following:

   if (le instanceof Linear_Expression_Variable) {
     Variable var = ((Linear_Expression_Variable) le).argument();
     /* Use var ... */
   } else if (le instanceof Linear_Expression_Sum) {
     Linear_Expression lhs
       = ((Linear_Expression_Sum) le).left_hand_side();
     Linear_Expression rhs
       = ((Linear_Expression_Sum) le).right_hand_side();
     /* ... use lhs and rhs ... */
   }
   /* ... etc. ... */

Let us know if you find difficulties following the approach above, which 
should be enough to code in Java all of the utilities you need.

The usability of the Java language interface to PPL is something we will 
need to improve in the future ... if you have hints regarding the 
specification of a _good_ approach to interface PPL with Java, we are 
willing to listen.

Cheers,
Enea.



More information about the PPL-devel mailing list