[PPL-devel] PPL Constraints usage

Roberto Bagnara bagnara at cs.unipr.it
Thu Jun 12 13:56:42 CEST 2014


Hello Stefan.  Congratulations!  You found a bug in the PPL.
Additionally, your program has another problem.  See below.

On 12/06/2014 13:08, Stefan Schupp wrote:
> I created an example which reproduces my problem:
> 
> #include <ppl.hh>
> 
> int main(int argc, char** argv) {
> 
> using namespace Parma_Polyhedra_Library::IO_Operators;
> 
> Parma_Polyhedra_Library::C_Polyhedron mPolyhedron = Parma_Polyhedra_Library::C_Polyhedron(2, Parma_Polyhedra_Library::EMPTY);

This is the additional problem: an empty polyhedron is an
overconstrained polyhedron.  Adding constraints to an
overconstrained polyhedron is a no-op.

> Parma_Polyhedra_Library::Variable a(0); Parma_Polyhedra_Library::Variable b(1);
> 
> Parma_Polyhedra_Library::Linear_Expression polynom; polynom.set_coefficient(a, 1); polynom.set_coefficient(b, 3);

Here your program makes a mistake: the newly-created
linear expression `polynom' has space dimension 0,
so that attempting to set the coefficients of `a'
and `b' is a violation of the interface.  The bug in
the PPL is that, in this case, the PPL is not checking
its interface, so your program does not throw an exception
as it should.  Additionally, there is a bug in the documentation
as this is not explained.  We will fix everything asap.
Thanks for reporting.
Kind regards,

   Roberto

> polynom.set_inhomogeneous_term(-4);
> 
> std::cout << "Polynom: " << polynom << std::endl;
> 
> Parma_Polyhedra_Library::Constraint constraint; constraint = polynom <= 0;
> 
> std::cout << "Constraint: "; constraint.print(); std::cout << " Dimension: " << constraint.space_dimension()  << std::endl;
> 
> mPolyhedron.add_constraint(constraint);
> 
> std::cout << "Polyhedron: "; mPolyhedron.print(); std::cout << std::endl; }
> 
> Am 12/06/14 12:05, schrieb Roberto Bagnara:
>> On 11/06/2014 16:29, Stefan Schupp wrote:
>>> I am currently trying to create a Polytope from a matrix and a vector. Therefore I create linear expressions from the coefficients of the matrix in combination with the associated PPL-Variables. Afterwards I can add an inhomogenous term from the given vector.
>>> 
>>> As far as I read the documentation I can construct a Polytope naturally by adding constraints. These constraints are supposed to be constructed from a relation of either a linear expression and a constant (my inhomogenuous term, if you want to put it that way) or a relation from two linear expressions. I tried both ways, but the constraint created seems to be empty. How am I supposed to create and use the needed Constraints?
>>> 
>>> Short example:
>>> 
>>> Linear expression: A + 3*B - 5 (when printed) resulting constraint: 0 >= -5 (created by:
>>> 
>>> Parma_Polyhedra_Library::Constraint constraint = expr <= 0
>>> 
>>> , where expr is the linear expression)
> 
>> Hello Stefan,
> 
>> please send a piece of code that we can examine, compile and execute. Kind regards,
> 
>> Roberto
> 
> 
> The created output is: Polynom: A + 3*B - 4 Constraint: 0 >= -4 Dimension: 0 Polyhedron: false
> 
> I thought the constraint created should be something like A + 3*B - 4 <= 0.
> 
> Best regards, Stefan
> 
> _______________________________________________ PPL-devel mailing list PPL-devel at cs.unipr.it http://www.cs.unipr.it/mailman/listinfo/ppl-devel
> 

-- 
     Prof. Roberto Bagnara

Applied Formal Methods Laboratory - University of Parma, Italy
mailto:bagnara at cs.unipr.it
                              BUGSENG srl - http://bugseng.com
                              mailto:roberto.bagnara at bugseng.com



More information about the PPL-devel mailing list