[PPL-devel] PPL Constraints usage

Enea Zaffanella zaffanella at cs.unipr.it
Thu Jun 12 13:30:50 CEST 2014


On 06/12/2014 01:08 PM, Stefan Schupp wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> Hello Roberto,
>
> 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);

The instruction above creates an empty polyhedron, i.e., a polyhedron 
whose constraint system is not consistent. Adding any constraint to an 
empty polyhedron is a no-op: you just obtain again the empty polyhedron 
and the added constraint is simplified away.
If you want to add constraints, then probably you want to start from the 
universe polyhedron, describing the 2 dimensional vector space:

Parma_Polyhedra_Library::C_Polyhedron(2, Parma_Polyhedra_Library::UNIVERSE);


Regards,
Enea Zaffanella.


>      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);
>      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
>
> - -- 
> Stefan Schupp M.Sc.
> RWTH Aachen University
> Computer Science Department, Informatik 2
> D-52056 Aachen, Germany
> http://www-i2.informatik.rwth-aachen.de/i2/schupp/
> Tel.: +49 241 80 21243
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
> Comment: GPGTools - https://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQEcBAEBCgAGBQJTmYozAAoJEFPSi5GyofDj0WUH+gI4uyUR0G3jVGZvyBgxqbAs
> ih4ZsWWItcz8smkR6aLIMUoqDg4NBIgy6dHaugS6Eoj4MBcZ5GlkWiQbjSHnI21P
> zNg7AOfEOJgm3LKn65hpKBtQ2duSjErh0xS8/uQQGHlB6OKcabpI/bmoHeCYjAZI
> 91aoDCc4PM0dopdMyW7tGtOER7fyAWqIiRZhbCbSp4l8U/211I7iXIuQZ5eE6jn1
> No8wXAnmFmvho0/1m59pDwX1HfCiLVjqPX/tK/OnaLzr3TJiXrZiEFJl2pWE4xfx
> aSTBGPwKNbE0i4bEC8vSS54NRRBNxLVRHW4gesnuZMljAro0Ubag8BmQawqukUo=
> =dTtc
> -----END PGP SIGNATURE-----
> _______________________________________________
> PPL-devel mailing list
> PPL-devel at cs.unipr.it
> http://www.cs.unipr.it/mailman/listinfo/ppl-devel
>




More information about the PPL-devel mailing list