PPL Constraints usage

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
Hi,
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)
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

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

-----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); 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

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@cs.unipr.it http://www.cs.unipr.it/mailman/listinfo/ppl-devel

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@cs.unipr.it http://www.cs.unipr.it/mailman/listinfo/ppl-devel
participants (3)
-
Enea Zaffanella
-
Roberto Bagnara
-
Stefan Schupp