Inherited by Parma_Polyhedra_Library::C_Polyhedron, and Parma_Polyhedra_Library::NNC_Polyhedron.
Public Types | |
enum | Degenerate_Kind { UNIVERSE, EMPTY } |
Kinds of degenerate polyhedra. More... | |
Public Member Functions | |
Member Functions that Do Not Modify the Polyhedron | |
dimension_type | space_dimension () const |
Returns the dimension of the vector space enclosing *this . | |
const ConSys & | constraints () const |
Returns the system of constraints. | |
const ConSys & | minimized_constraints () const |
Returns the system of constraints, with no redundant constraint. | |
const GenSys & | generators () const |
Returns the system of generators. | |
const GenSys & | minimized_generators () const |
Returns the system of generators, with no redundant generator. | |
Poly_Con_Relation | relation_with (const Constraint &c) const |
Returns the relations holding between the polyhedron *this and the constraint c . | |
Poly_Gen_Relation | relation_with (const Generator &g) const |
Returns the relations holding between the polyhedron *this and the generator g . | |
bool | is_empty () const |
Returns true if and only if *this is an empty polyhedron. | |
bool | is_universe () const |
Returns true if and only if *this is a universe polyhedron. | |
bool | is_topologically_closed () const |
Returns true if and only if *this is a topologically closed subset of the vector space. | |
bool | is_disjoint_from (const Polyhedron &y) const |
Returns true if and only if *this and y are disjoint. | |
bool | is_bounded () const |
Returns true if and only if *this is a bounded polyhedron. | |
bool | bounds_from_above (const LinExpression &expr) const |
Returns true if and only if expr is bounded from above in *this . | |
bool | bounds_from_below (const LinExpression &expr) const |
Returns true if and only if expr is bounded from below in *this . | |
bool | maximize (const LinExpression &expr, Integer &sup_n, Integer &sup_d, bool &maximum) const |
Returns true if and only if *this is not empty and expr is bounded from above in *this , in which case the supremum value is computed. | |
bool | maximize (const LinExpression &expr, Integer &sup_n, Integer &sup_d, bool &maximum, const Generator **const pppoint) const |
Returns true if and only if *this is not empty and expr is bounded from above in *this , in which case the supremum value and a point where expr reaches it are computed. | |
bool | minimize (const LinExpression &expr, Integer &inf_n, Integer &inf_d, bool &minimum) const |
Returns true if and only if *this is not empty and expr is bounded from below in *this , in which case the infimum value is computed. | |
bool | minimize (const LinExpression &expr, Integer &inf_n, Integer &inf_d, bool &minimum, const Generator **const pppoint) const |
Returns true if and only if *this is not empty and expr is bounded from below in *this , in which case the infimum value and a point where expr reaches it are computed. | |
bool | contains (const Polyhedron &y) const |
Returns true if and only if *this contains y . | |
bool | strictly_contains (const Polyhedron &y) const |
Returns true if and only if *this strictly contains y . | |
template<typename Box> void | shrink_bounding_box (Box &box, Complexity_Class complexity=ANY) const |
Uses *this to shrink a generic, interval-based bounding box. | |
bool | OK (bool check_not_empty=false) const |
Checks if all the invariants are satisfied. | |
Space-Dimension Preserving Member Functions that May Modify the Polyhedron | |
void | add_constraint (const Constraint &c) |
Adds a copy of constraint c to the system of constraints of *this (without minimizing the result). | |
bool | add_constraint_and_minimize (const Constraint &c) |
Adds a copy of constraint c to the system of constraints of *this , minimizing the result. | |
void | add_generator (const Generator &g) |
Adds a copy of generator g to the system of generators of *this (without minimizing the result). | |
bool | add_generator_and_minimize (const Generator &g) |
Adds a copy of generator g to the system of generators of *this , minimizing the result. | |
void | add_constraints (const ConSys &cs) |
Adds a copy of the constraints in cs to the system of constraints of *this (without minimizing the result). | |
void | add_recycled_constraints (ConSys &cs) |
Adds the constraints in cs to the system of constraints of *this (without minimizing the result). | |
bool | add_constraints_and_minimize (const ConSys &cs) |
Adds a copy of the constraints in cs to the system of constraints of *this , minimizing the result. | |
bool | add_recycled_constraints_and_minimize (ConSys &cs) |
Adds the constraints in cs to the system of constraints of *this , minimizing the result. | |
void | add_generators (const GenSys &gs) |
Adds a copy of the generators in gs to the system of generators of *this (without minimizing the result). | |
void | add_recycled_generators (GenSys &gs) |
Adds the generators in gs to the system of generators of *this (without minimizing the result). | |
bool | add_generators_and_minimize (const GenSys &gs) |
Adds a copy of the generators in gs to the system of generators of *this , minimizing the result. | |
bool | add_recycled_generators_and_minimize (GenSys &gs) |
Adds the generators in gs to the system of generators of *this , minimizing the result. | |
void | intersection_assign (const Polyhedron &y) |
Assigns to *this the intersection of *this and y . The result is not guaranteed to be minimized. | |
bool | intersection_assign_and_minimize (const Polyhedron &y) |
Assigns to *this the intersection of *this and y , minimizing the result. | |
void | poly_hull_assign (const Polyhedron &y) |
Assigns to *this the poly-hull of *this and y . The result is not guaranteed to be minimized. | |
bool | poly_hull_assign_and_minimize (const Polyhedron &y) |
Assigns to *this the poly-hull of *this and y , minimizing the result. | |
void | poly_difference_assign (const Polyhedron &y) |
Assigns to *this the poly-difference of *this and y . The result is not guaranteed to be minimized. | |
void | affine_image (Variable var, const LinExpression &expr, const Integer &denominator=Integer_one()) |
Assigns to *this the affine image of *this under the function mapping variable var to the affine expression specified by expr and denominator . | |
void | affine_preimage (Variable var, const LinExpression &expr, const Integer &denominator=Integer_one()) |
Assigns to *this the affine preimage of *this under the function mapping variable var to the affine expression specified by expr and denominator . | |
void | generalized_affine_image (Variable var, const Relation_Symbol relsym, const LinExpression &expr, const Integer &denominator=Integer_one()) |
Assigns to *this the image of *this with respect to the generalized affine transfer function ![]() ![]() relsym . | |
void | generalized_affine_image (const LinExpression &lhs, const Relation_Symbol relsym, const LinExpression &rhs) |
Assigns to *this the image of *this with respect to the generalized affine transfer function ![]() ![]() relsym . | |
void | time_elapse_assign (const Polyhedron &y) |
Assigns to *this the result of computing the time-elapse between *this and y . | |
void | topological_closure_assign () |
Assigns to *this its topological closure. | |
void | BHRZ03_widening_assign (const Polyhedron &y, unsigned *tp=0) |
Assigns to *this the result of computing the BHRZ03-widening between *this and y . | |
void | limited_BHRZ03_extrapolation_assign (const Polyhedron &y, const ConSys &cs, unsigned *tp=0) |
Improves the result of the BHRZ03-widening computation by also enforcing those constraints in cs that are satisfied by all the points of *this . | |
void | bounded_BHRZ03_extrapolation_assign (const Polyhedron &y, const ConSys &cs, unsigned *tp=0) |
Improves the result of the BHRZ03-widening computation by also enforcing those constraints in cs that are satisfied by all the points of *this , plus all the constraints of the form ![]() ![]() ![]() *this . | |
void | H79_widening_assign (const Polyhedron &y, unsigned *tp=0) |
Assigns to *this the result of computing the H79-widening between *this and y . | |
void | limited_H79_extrapolation_assign (const Polyhedron &y, const ConSys &cs, unsigned *tp=0) |
Improves the result of the H79-widening computation by also enforcing those constraints in cs that are satisfied by all the points of *this . | |
void | bounded_H79_extrapolation_assign (const Polyhedron &y, const ConSys &cs, unsigned *tp=0) |
Improves the result of the H79-widening computation by also enforcing those constraints in cs that are satisfied by all the points of *this , plus all the constraints of the form ![]() ![]() ![]() *this . | |
Member Functions that May Modify the Dimension of the Vector Space | |
void | add_dimensions_and_embed (dimension_type m) |
Adds m new dimensions and embeds the old polyhedron in the new space. | |
void | add_dimensions_and_project (dimension_type m) |
Adds m new dimensions to the polyhedron and does not embed it in the new space. | |
void | concatenate_assign (const Polyhedron &y) |
Assigns to *this the concatenation of *this and y , taken in this order. | |
void | remove_dimensions (const Variables_Set &to_be_removed) |
Removes all the specified dimensions. | |
void | remove_higher_dimensions (dimension_type new_dimension) |
Removes the higher dimensions so that the resulting space will have dimension new_dimension . | |
template<typename PartialFunction> void | map_dimensions (const PartialFunction &pfunc) |
Remaps the dimensions of the vector space according to a partial function. | |
void | expand_dimension (Variable var, dimension_type m) |
Creates m copies of the dimension corresponding to var . | |
void | fold_dimensions (const Variables_Set &to_be_folded, Variable var) |
Folds the dimensions in to_be_folded into var . | |
Miscellaneous Member Functions | |
~Polyhedron () | |
Destructor. | |
void | swap (Polyhedron &y) |
Swaps *this with polyhedron y . (*this and y can be dimension-incompatible.). | |
Static Public Member Functions | |
dimension_type | max_space_dimension () |
Returns the maximum space dimension all kinds of Polyhedron can handle. | |
Protected Member Functions | |
Polyhedron (Topology topol, dimension_type num_dimensions, Degenerate_Kind kind) | |
Builds a polyhedron having the specified properties. | |
Polyhedron (const Polyhedron &y) | |
Ordinary copy-constructor. | |
Polyhedron (Topology topol, const ConSys &cs) | |
Builds a polyhedron from a system of constraints. | |
Polyhedron (Topology topol, ConSys &cs) | |
Builds a polyhedron recycling a system of constraints. | |
Polyhedron (Topology topol, const GenSys &gs) | |
Builds a polyhedron from a system of generators. | |
Polyhedron (Topology topol, GenSys &gs) | |
Builds a polyhedron recycling a system of generators. | |
template<typename Box> | Polyhedron (Topology topol, const Box &box) |
Builds a polyhedron out of a generic, interval-based bounding box. | |
Polyhedron & | operator= (const Polyhedron &y) |
The assignment operator. (*this and y can be dimension-incompatible.). | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &s, const Polyhedron &ph) |
Output operator. | |
bool | operator== (const Polyhedron &x, const Polyhedron &y) |
Returns true if and only if x and y are the same polyhedron. | |
bool | operator!= (const Polyhedron &x, const Polyhedron &y) |
Returns true if and only if x and y are different polyhedra. | |
void | swap (Parma_Polyhedra_Library::Polyhedron &x, Parma_Polyhedra_Library::Polyhedron &y) |
Specializes std::swap . | |
template<typename PH> bool | poly_hull_assign_if_exact (PH &p, const PH &q) |
If the poly-hull between p and q is exact it is assigned to p . |
An object of the class Polyhedron represents a convex polyhedron in the vector space .
A polyhedron can be specified as either a finite system of constraints or a finite system of generators (see Section Representations of Convex Polyhedra) and it is always possible to obtain either representation. That is, if we know the system of constraints, we can obtain from this the system of generators that define the same polyhedron and vice versa. These systems can contain redundant members: in this case we say that they are not in the minimal form. Most operators on polyhedra are provided with two implementations: one of these, denoted <operator-name>_and_minimize
, also enforces the minimization of the representations, and returns the Boolean value false
whenever the resulting polyhedron turns out to be empty.
Two key attributes of any polyhedron are its topological kind (recording whether it is a C_Polyhedron or an NNC_Polyhedron object) and its space dimension (the dimension of the enclosing vector space):
Note that four different polyhedra can be defined on the zero-dimension space: the empty polyhedron, either closed or NNC, and the universe polyhedron , again either closed or NNC.
x
and y
are defined (where they are used) as follows: Variable x(0); Variable y(1);
ConSys cs; cs.insert(x >= 0); cs.insert(x <= 3); cs.insert(y >= 0); cs.insert(y <= 3); C_Polyhedron ph(cs);
GenSys gs; gs.insert(point(0*x + 0*y)); gs.insert(point(0*x + 3*y)); gs.insert(point(3*x + 0*y)); gs.insert(point(3*x + 3*y)); C_Polyhedron ph(gs);
ConSys cs; cs.insert(x >= 0); cs.insert(x - y <= 0); cs.insert(x - y + 1 >= 0); C_Polyhedron ph(cs);
GenSys gs; gs.insert(point(0*x + 0*y)); gs.insert(point(0*x + y)); gs.insert(ray(x - y)); C_Polyhedron ph(gs);
C_Polyhedron ph(2); ph.add_constraint(y >= 0);
C_Polyhedron ph(2, Polyhedron::EMPTY); ph.add_generator(point(0*x + 0*y)); ph.add_generator(ray(y)); ph.add_generator(line(x));
add_dimensions_and_embed
: C_Polyhedron ph(1); ph.add_constraint(x == 2); ph.add_dimensions_and_embed(1);
add_dimensions_and_project
: C_Polyhedron ph(1); ph.add_constraint(x == 2); ph.add_dimensions_and_project(1);
add_dimensions_and_embed
. After the last line of code, the resulting polyhedron is the singleton set affine_image
: C_Polyhedron ph(2, Polyhedron::EMPTY); ph.add_generator(point(0*x + 0*y)); ph.add_generator(point(0*x + 3*y)); ph.add_generator(point(3*x + 0*y)); ph.add_generator(point(3*x + 3*y)); LinExpression coeff = x + 4; ph.affine_image(x, coeff);
x
is LinExpression coeff = x + y;
LinExpression coeff = y;
affine_preimage
: C_Polyhedron ph(2); ph.add_constraint(x >= 0); ph.add_constraint(x <= 3); ph.add_constraint(y >= 0); ph.add_constraint(y <= 3); LinExpression coeff = x + 4; ph.affine_preimage(x, coeff);
var
and the affine expression and the denominator are the same as in Example 6, while the resulting polyhedron is again the same square, but translated to the left. Moreover, if the affine transformation for x
is LinExpression coeff = x + y;
x
, for example, the affine expression LinExpression coeff = y;
Variable z(2); Variable w(3);
remove_dimensions
: GenSys gs; gs.insert(point(3*x + y +0*z + 2*w)); C_Polyhedron ph(gs); set<Variable> to_be_removed; to_be_removed.insert(y); to_be_removed.insert(z); ph.remove_dimensions(to_be_removed);
remove_dimensions
operator, unexpected results can be obtained. For instance, by using the following code we would obtain a different result: set<Variable> to_be_removed1; to_be_removed1.insert(y); ph.remove_dimensions(to_be_removed1); set<Variable> to_be_removed2; to_be_removed2.insert(z); ph.remove_dimensions(to_be_removed2);
to_be_removed2
we are actually removing variable remove_dimensions
is not idempotent: removing twice the same set of dimensions is never a no-op.
|
Kinds of degenerate polyhedra.
|
|
Builds a polyhedron having the specified properties.
|
|
Builds a polyhedron from a system of constraints. The polyhedron inherits the space dimension of the constraint system.
|
|
Builds a polyhedron recycling a system of constraints. The polyhedron inherits the space dimension of the constraint system.
|
|
Builds a polyhedron from a system of generators. The polyhedron inherits the space dimension of the generator system.
|
|
Builds a polyhedron recycling a system of generators. The polyhedron inherits the space dimension of the generator system.
|
|
Builds a polyhedron out of a generic, interval-based bounding box.
dimension_type space_dimension() const bool is_empty() const true if and only if the bounding box describes the empty set. The is_empty() method will always be called before the methods below. However, if is_empty() returns true , none of the functions below will be called. bool get_lower_bound(dimension_type k, bool closed, Integer& n, Integer& d) const ![]() k -th dimension. If ![]() false . Otherwise, set closed , n and d as follows: closed is set to true if the the lower boundary of ![]() false otherwise; n and d are assigned the integers ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() bool get_upper_bound(dimension_type k, bool closed, Integer& n, Integer& d) const ![]() k -th dimension. If ![]() false . Otherwise, set closed , n and d as follows: closed is set to true if the the upper boundary of ![]() false otherwise; n and d are assigned the integers ![]() ![]() ![]() ![]() |
|
Returns the relations holding between the polyhedron
|
|
Returns the relations holding between the polyhedron
|
|
Returns
|
|
Returns
|
|
Returns
|
|
Returns
*this is empty or expr is not bounded from above, false is returned and sup_n , sup_d and maximum are left untouched. |
|
Returns
*this is empty or expr is not bounded from above, false is returned and sup_n , sup_d , maximum and pppoint are left untouched. |
|
Returns
*this is empty or expr is not bounded from below, false is returned and inf_n , inf_d and minimum are left untouched. |
|
Returns
*this is empty or expr is not bounded from below, false is returned and inf_n , inf_d , minimum and pppoint are left untouched. |
|
Returns
|
|
Returns
|
|
Uses
set_empty() raise_lower_bound(dimension_type k, bool closed, const Integer& n, const Integer& d) k -th dimension with ![]() closed is true , with ![]() closed is false . lower_upper_bound(dimension_type k, bool closed, const Integer& n, const Integer& d) k -th dimension with ![]() closed is true , with ![]() closed is false .
The function |
|
Checks if all the invariants are satisfied.
std::cerr in case invariants are violated. This is useful for the purpose of debugging the library. |
|
Adds a copy of constraint
|
|
Adds a copy of constraint
|
|
Adds a copy of generator
|
|
Adds a copy of generator
|
|
Adds a copy of the constraints in
|
|
Adds the constraints in
|
|
Adds a copy of the constraints in
|
|
Adds the constraints in
|
|
Adds a copy of the generators in
|
|
Adds the generators in
|
|
Adds a copy of the generators in
|
|
Adds the generators in
|
|
Assigns to
|
|
Assigns to
|
|
Assigns to
|
|
Assigns to
|
|
Assigns to
|
|
Assigns to
|
|
Assigns to
|
|
Assigns to
|
|
Assigns to
|
|
Assigns to
|
|
Assigns to
|
|
Improves the result of the BHRZ03-widening computation by also enforcing those constraints in
|
|
Improves the result of the BHRZ03-widening computation by also enforcing those constraints in
|
|
Assigns to
|
|
Improves the result of the H79-widening computation by also enforcing those constraints in
|
|
Improves the result of the H79-widening computation by also enforcing those constraints in
|
|
Adds
![]()
|
|
Adds
![]()
|
|
Assigns to
|
|
Removes all the specified dimensions.
|
|
Removes the higher dimensions so that the resulting space will have dimension
|
|
Remaps the dimensions of the vector space according to a partial function.
bool has_empty_codomain() const
true if and only if the represented partial function has an empty codomain (i.e., it is always undefined). The has_empty_codomain() method will always be called before the methods below. However, if has_empty_codomain() returns true , none of the functions below will be called. dimension_type max_in_codomain() const max_in_codomain() method is called at most once. bool maps(dimension_type i, dimension_type& j) const ![]() ![]() i . If ![]() ![]() ![]() j and true is returned. If ![]() ![]() false is returned. This method is called at most ![]() ![]()
The result is undefined if |
|
Creates
*this is ![]() ![]() ![]() var.id() , then the ![]() m new dimensions ![]() ![]() ![]() ![]() |
|
Folds the dimensions in
*this is ![]() ![]() ![]() var.id() , to_be_folded is a set of variables whose id() is also less than ![]() var is not a member of to_be_folded , then the dimensions corresponding to variables in to_be_folded are folded into dimension ![]() |
|
Swaps
|
|
Output operator.
Writes a textual representation of |
|
Returns
Note that |
|
Returns
Note that |