PPL  1.2
Parma_Polyhedra_Library::Constraint Class Reference

A linear equality or inequality. More...

#include <Constraint_defs.hh>

Collaboration diagram for Parma_Polyhedra_Library::Constraint:

Public Types

enum  Type { EQUALITY, NONSTRICT_INEQUALITY, STRICT_INEQUALITY }
 The constraint type. More...
 
typedef Expression_Hide_Last< Linear_Expressionexpr_type
 The type of the (adapted) internal expression. More...
 

Public Member Functions

 Constraint (Representation r=default_representation)
 Constructs the $0<=0$ constraint. More...
 
 Constraint (const Constraint &c)
 Ordinary copy constructor. More...
 
 Constraint (const Constraint &c, dimension_type space_dim)
 Copy constructor with given size. More...
 
 Constraint (const Constraint &c, Representation r)
 Copy constructor with given representation. More...
 
 Constraint (const Constraint &c, dimension_type space_dim, Representation r)
 Copy constructor with given size and representation. More...
 
 Constraint (const Congruence &cg, Representation r=default_representation)
 Copy-constructs from equality congruence cg. More...
 
 ~Constraint ()
 Destructor. More...
 
Representation representation () const
 Returns the current representation of *this. More...
 
void set_representation (Representation r)
 Converts *this to the specified representation. More...
 
Constraintoperator= (const Constraint &c)
 Assignment operator. More...
 
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this. More...
 
void set_space_dimension (dimension_type space_dim)
 
void swap_space_dimensions (Variable v1, Variable v2)
 Swaps the coefficients of the variables v1 and v2 . More...
 
bool remove_space_dimensions (const Variables_Set &vars)
 Removes all the specified dimensions from the constraint. More...
 
void permute_space_dimensions (const std::vector< Variable > &cycle)
 Permutes the space dimensions of the constraint. More...
 
void shift_space_dimensions (Variable v, dimension_type n)
 
Type type () const
 Returns the constraint type of *this. More...
 
bool is_equality () const
 Returns true if and only if *this is an equality constraint. More...
 
bool is_inequality () const
 Returns true if and only if *this is an inequality constraint (either strict or non-strict). More...
 
bool is_nonstrict_inequality () const
 Returns true if and only if *this is a non-strict inequality constraint. More...
 
bool is_strict_inequality () const
 Returns true if and only if *this is a strict inequality constraint. More...
 
Coefficient_traits::const_reference coefficient (Variable v) const
 Returns the coefficient of v in *this. More...
 
Coefficient_traits::const_reference inhomogeneous_term () const
 Returns the inhomogeneous term of *this. More...
 
memory_size_type total_memory_in_bytes () const
 Returns a lower bound to the total size in bytes of the memory occupied by *this. More...
 
memory_size_type external_memory_in_bytes () const
 Returns the size in bytes of the memory managed by *this. More...
 
bool is_tautological () const
 Returns true if and only if *this is a tautology (i.e., an always true constraint). More...
 
bool is_inconsistent () const
 Returns true if and only if *this is inconsistent (i.e., an always false constraint). More...
 
bool is_equivalent_to (const Constraint &y) const
 Returns true if and only if *this and y are equivalent constraints. More...
 
bool is_equal_to (const Constraint &y) const
 Returns true if *this is identical to y. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 
void ascii_dump () const
 Writes to std::cerr an ASCII representation of *this. More...
 
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of *this. More...
 
void print () const
 Prints *this to std::cerr using operator<<. More...
 
bool ascii_load (std::istream &s)
 Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise. More...
 
void m_swap (Constraint &y)
 Swaps *this with y. More...
 
expr_type expression () const
 Partial read access to the (adapted) internal expression. More...
 

Static Public Member Functions

static dimension_type max_space_dimension ()
 Returns the maximum space dimension a Constraint can handle. More...
 
static void initialize ()
 Initializes the class. More...
 
static void finalize ()
 Finalizes the class. More...
 
static const Constraintzero_dim_false ()
 The unsatisfiable (zero-dimension space) constraint $0 = 1$. More...
 
static const Constraintzero_dim_positivity ()
 The true (zero-dimension space) constraint $0 \leq 1$, also known as positivity constraint. More...
 
static const Constraintepsilon_geq_zero ()
 Returns the zero-dimension space constraint $\epsilon \geq 0$. More...
 
static const Constraintepsilon_leq_one ()
 The zero-dimension space constraint $\epsilon \leq 1$ (used to implement NNC polyhedra). More...
 

Static Public Attributes

static const Representation default_representation = SPARSE
 The representation used for new Constraints. More...
 

Private Types

enum  Kind { LINE_OR_EQUALITY = 0, RAY_OR_POINT_OR_INEQUALITY = 1 }
 The possible kinds of Constraint objects. More...
 

Private Member Functions

 Constraint (dimension_type space_dim, Kind kind, Topology topology, Representation r=default_representation)
 Constructs the $0<0$ constraint. More...
 
 Constraint (Linear_Expression &e, Kind kind, Topology topology)
 Builds a constraint of kind kind and topology topology, stealing the coefficients from e. More...
 
 Constraint (Linear_Expression &e, Type type, Topology topology)
 Builds a constraint of type type and topology topology, stealing the coefficients from e. More...
 
bool is_line_or_equality () const
 Returns true if and only if *this row represents a line or an equality. More...
 
bool is_ray_or_point_or_inequality () const
 Returns true if and only if *this row represents a ray, a point or an inequality. More...
 
void set_is_line_or_equality ()
 Sets to LINE_OR_EQUALITY the kind of *this row. More...
 
void set_is_ray_or_point_or_inequality ()
 Sets to RAY_OR_POINT_OR_INEQUALITY the kind of *this row. More...
 
void set_space_dimension_no_ok (dimension_type space_dim)
 
void throw_invalid_argument (const char *method, const char *message) const
 Throws a std::invalid_argument exception containing error message message. More...
 
void throw_dimension_incompatible (const char *method, const char *name_var, Variable v) const
 Throws a std::invalid_argument exception containing the appropriate error message. More...
 
Coefficient_traits::const_reference epsilon_coefficient () const
 Returns the epsilon coefficient. The constraint must be NNC. More...
 
void set_epsilon_coefficient (Coefficient_traits::const_reference n)
 Sets the epsilon coefficient to n. The constraint must be NNC. More...
 
void mark_as_necessarily_closed ()
 Marks the epsilon dimension as a standard dimension. More...
 
void mark_as_not_necessarily_closed ()
 Marks the last dimension as the epsilon dimension. More...
 
void set_is_equality ()
 Sets the constraint type to EQUALITY. More...
 
void set_is_inequality ()
 Sets the constraint to be an inequality. More...
 
void linear_combine (const Constraint &y, dimension_type i)
 Linearly combines *this with y so that i-th coefficient is 0. More...
 
void sign_normalize ()
 Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a line-or-equality is positive. More...
 
void strong_normalize ()
 Strong normalization: ensures that different Constraint objects represent different hyperplanes or hyperspaces. More...
 
bool check_strong_normalized () const
 Returns true if and only if the coefficients are strongly normalized. More...
 
Flags inspection methods
Topology topology () const
 Returns the topological kind of *this. More...
 
bool is_not_necessarily_closed () const
 Returns true if and only if the topology of *this row is not necessarily closed. More...
 
bool is_necessarily_closed () const
 Returns true if and only if the topology of *this row is necessarily closed. More...
 
Flags coercion methods
void set_topology (Topology x)
 Sets to x the topological kind of *this row. More...
 
void set_necessarily_closed ()
 Sets to NECESSARILY_CLOSED the topological kind of *this row. More...
 
void set_not_necessarily_closed ()
 Sets to NOT_NECESSARILY_CLOSED the topological kind of *this row. More...
 

Static Private Member Functions

static Constraint construct_epsilon_geq_zero ()
 Builds a new copy of the zero-dimension space constraint $\epsilon \geq 0$ (used to implement NNC polyhedra). More...
 

Private Attributes

Linear_Expression expr
 
Kind kind_
 
Topology topology_
 

Static Private Attributes

static const Constraintzero_dim_false_p = 0
 Holds (between class initialization and finalization) a pointer to the unsatisfiable (zero-dimension space) constraint $0 = 1$. More...
 
static const Constraintzero_dim_positivity_p = 0
 Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) constraint $0 \leq 1$, also known as positivity constraint. More...
 
static const Constraintepsilon_geq_zero_p = 0
 Holds (between class initialization and finalization) a pointer to the zero-dimension space constraint $\epsilon \geq 0$. More...
 
static const Constraintepsilon_leq_one_p = 0
 Holds (between class initialization and finalization) a pointer to the zero-dimension space constraint $\epsilon \leq 1$ (used to implement NNC polyhedra). More...
 

Friends

class Linear_System< Constraint >
 
class Constraint_System
 
class Polyhedron
 
class Scalar_Products
 
class Topology_Adjusted_Scalar_Product_Sign
 
class Termination_Helpers
 
class Grid
 
template<typename T >
class Octagonal_Shape
 
int compare (const Constraint &x, const Constraint &y)
 
Constraint operator< (const Linear_Expression &e1, const Linear_Expression &e2)
 
Constraint operator< (Variable v1, Variable v2)
 
Constraint operator< (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
Constraint operator< (Coefficient_traits::const_reference n, const Linear_Expression &e)
 
Constraint operator> (const Linear_Expression &e1, const Linear_Expression &e2)
 
Constraint operator> (Variable v1, Variable v2)
 
Constraint operator> (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
Constraint operator> (Coefficient_traits::const_reference n, const Linear_Expression &e)
 
Constraint operator== (const Linear_Expression &e1, const Linear_Expression &e2)
 
Constraint operator== (Variable v1, Variable v2)
 
Constraint operator== (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
Constraint operator== (Coefficient_traits::const_reference n, const Linear_Expression &e)
 
Constraint operator<= (const Linear_Expression &e1, const Linear_Expression &e2)
 
Constraint operator<= (Variable v1, Variable v2)
 
Constraint operator<= (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
Constraint operator<= (Coefficient_traits::const_reference n, const Linear_Expression &e)
 
Constraint operator>= (const Linear_Expression &e1, const Linear_Expression &e2)
 
Constraint operator>= (Variable v1, Variable v2)
 
Constraint operator>= (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
Constraint operator>= (Coefficient_traits::const_reference n, const Linear_Expression &e)
 

Related Functions

(Note that these are not member functions.)

int compare (const Constraint &x, const Constraint &y)
 
std::ostream & operator<< (std::ostream &s, const Constraint &c)
 
std::ostream & operator<< (std::ostream &s, const Constraint::Type &t)
 
Constraint operator< (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the constraint e1 < e2. More...
 
Constraint operator< (Variable v1, Variable v2)
 Returns the constraint v1 < v2. More...
 
Constraint operator< (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the constraint e < n. More...
 
Constraint operator< (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the constraint n < e. More...
 
Constraint operator> (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the constraint e1 > e2. More...
 
Constraint operator> (Variable v1, Variable v2)
 Returns the constraint v1 > v2. More...
 
Constraint operator> (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the constraint e > n. More...
 
Constraint operator> (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the constraint n > e. More...
 
Constraint operator== (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the constraint e1 = e2. More...
 
Constraint operator== (Variable v1, Variable v2)
 Returns the constraint v1 = v2. More...
 
Constraint operator== (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the constraint e = n. More...
 
Constraint operator== (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the constraint n = e. More...
 
Constraint operator<= (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the constraint e1 <= e2. More...
 
Constraint operator<= (Variable v1, Variable v2)
 Returns the constraint v1 <= v2. More...
 
Constraint operator<= (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the constraint e <= n. More...
 
Constraint operator<= (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the constraint n <= e. More...
 
Constraint operator>= (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the constraint e1 >= e2. More...
 
Constraint operator>= (Variable v1, Variable v2)
 Returns the constraint v1 >= v2. More...
 
Constraint operator>= (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the constraint e >= n. More...
 
Constraint operator>= (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the constraint n >= e. More...
 
int compare (const Constraint &x, const Constraint &y)
 The basic comparison function. More...
 
std::ostream & operator<< (std::ostream &s, const Constraint &c)
 Output operator. More...
 
std::ostream & operator<< (std::ostream &s, const Constraint::Type &t)
 Output operator. More...
 
bool operator== (const Constraint &x, const Constraint &y)
 Returns true if and only if x is equivalent to y. More...
 
bool operator!= (const Constraint &x, const Constraint &y)
 Returns true if and only if x is not equivalent to y. More...
 
void swap (Constraint &x, Constraint &y)
 
bool operator== (const Constraint &x, const Constraint &y)
 
bool operator!= (const Constraint &x, const Constraint &y)
 
Constraint operator== (const Linear_Expression &e1, const Linear_Expression &e2)
 
Constraint operator== (Variable v1, Variable v2)
 
Constraint operator>= (const Linear_Expression &e1, const Linear_Expression &e2)
 
Constraint operator>= (const Variable v1, const Variable v2)
 
Constraint operator> (const Linear_Expression &e1, const Linear_Expression &e2)
 
Constraint operator> (const Variable v1, const Variable v2)
 
Constraint operator== (Coefficient_traits::const_reference n, const Linear_Expression &e)
 
Constraint operator>= (Coefficient_traits::const_reference n, const Linear_Expression &e)
 
Constraint operator> (Coefficient_traits::const_reference n, const Linear_Expression &e)
 
Constraint operator== (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
Constraint operator>= (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
Constraint operator> (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
Constraint operator<= (const Linear_Expression &e1, const Linear_Expression &e2)
 
Constraint operator<= (const Variable v1, const Variable v2)
 
Constraint operator<= (Coefficient_traits::const_reference n, const Linear_Expression &e)
 
Constraint operator<= (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
Constraint operator< (const Linear_Expression &e1, const Linear_Expression &e2)
 
Constraint operator< (const Variable v1, const Variable v2)
 
Constraint operator< (Coefficient_traits::const_reference n, const Linear_Expression &e)
 
Constraint operator< (const Linear_Expression &e, Coefficient_traits::const_reference n)
 
void swap (Constraint &x, Constraint &y)
 

Detailed Description

A linear equality or inequality.

An object of the class Constraint is either:

  • an equality: $\sum_{i=0}^{n-1} a_i x_i + b = 0$;
  • a non-strict inequality: $\sum_{i=0}^{n-1} a_i x_i + b \geq 0$; or
  • a strict inequality: $\sum_{i=0}^{n-1} a_i x_i + b > 0$;

where $n$ is the dimension of the space, $a_i$ is the integer coefficient of variable $x_i$ and $b$ is the integer inhomogeneous term.

How to build a constraint
Constraints are typically built by applying a relation symbol to a pair of linear expressions. Available relation symbols are equality (==), non-strict inequalities (>= and <=) and strict inequalities (< and >). The space dimension of a constraint is defined as the maximum space dimension of the arguments of its constructor.
In the following examples it is assumed that variables x, y and z are defined as follows:
Variable x(0);
Variable y(1);
Variable z(2);
Example 1
The following code builds the equality constraint $3x + 5y - z = 0$, having space dimension $3$:
Constraint eq_c(3*x + 5*y - z == 0);
The following code builds the (non-strict) inequality constraint $4x \geq 2y - 13$, having space dimension $2$:
Constraint ineq_c(4*x >= 2*y - 13);
The corresponding strict inequality constraint $4x > 2y - 13$ is obtained as follows:
Constraint strict_ineq_c(4*x > 2*y - 13);
An unsatisfiable constraint on the zero-dimension space $\Rset^0$ can be specified as follows: Equivalent, but more involved ways are the following: In contrast, the following code defines an unsatisfiable constraint having space dimension $3$:
Constraint false_c(0*z == 1);
How to inspect a constraint
Several methods are provided to examine a constraint and extract all the encoded information: its space dimension, its type (equality, non-strict inequality, strict inequality) and the value of its integer coefficients.
Example 2
The following code shows how it is possible to access each single coefficient of a constraint. Given an inequality constraint (in this case $x - 5y + 3z \leq 4$), we construct a new constraint corresponding to its complement (thus, in this case we want to obtain the strict inequality constraint $x - 5y + 3z > 4$).
Constraint c1(x - 5*y + 3*z <= 4);
cout << "Constraint c1: " << c1 << endl;
if (c1.is_equality())
cout << "Constraint c1 is not an inequality." << endl;
else {
Linear_Expression e;
for (dimension_type i = c1.space_dimension(); i-- > 0; )
e += c1.coefficient(Variable(i)) * Variable(i);
e += c1.inhomogeneous_term();
Constraint c2 = c1.is_strict_inequality() ? (e <= 0) : (e < 0);
cout << "Complement c2: " << c2 << endl;
}
The actual output is the following:
Constraint c1: -A + 5*B - 3*C >= -4
Complement c2: A - 5*B + 3*C > 4
Note that, in general, the particular output obtained can be syntactically different from the (semantically equivalent) constraint considered.

Definition at line 284 of file Constraint_defs.hh.

Member Typedef Documentation

The type of the (adapted) internal expression.

Definition at line 521 of file Constraint_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::Constraint::Constraint ( Representation  r = default_representation)
inlineexplicit
Parma_Polyhedra_Library::Constraint::Constraint ( const Constraint c)
inline

Ordinary copy constructor.

Note
The new Constraint will have the same representation as `c', not default_representation, so that they are indistinguishable.

Definition at line 171 of file Constraint_inlines.hh.

172  : expr(c.expr),
173  kind_(c.kind_),
174  topology_(c.topology_) {
175  // NOTE: This does not call PPL_ASSERT(OK()) because this is called by OK().
176 }
Coefficient c
Definition: PIP_Tree.cc:64
Parma_Polyhedra_Library::Constraint::Constraint ( const Constraint c,
dimension_type  space_dim 
)
inline

Copy constructor with given size.

Note
The new Constraint will have the same representation as `c', not default_representation, so that they are indistinguishable.

Definition at line 187 of file Constraint_inlines.hh.

References OK(), and space_dimension().

188  : expr(c.expr, c.is_necessarily_closed() ? space_dim : (space_dim + 1)),
189  kind_(c.kind_), topology_(c.topology_) {
190  PPL_ASSERT(space_dimension() == space_dim);
191  PPL_ASSERT(OK());
192 }
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Constraint.cc:467
Coefficient c
Definition: PIP_Tree.cc:64
Parma_Polyhedra_Library::Constraint::Constraint ( const Constraint c,
Representation  r 
)
inline

Copy constructor with given representation.

Definition at line 179 of file Constraint_inlines.hh.

References OK().

180  : expr(c.expr, r),
181  kind_(c.kind_),
182  topology_(c.topology_) {
183  PPL_ASSERT(OK());
184 }
bool OK() const
Checks if all the invariants are satisfied.
Definition: Constraint.cc:467
Coefficient c
Definition: PIP_Tree.cc:64
Parma_Polyhedra_Library::Constraint::Constraint ( const Constraint c,
dimension_type  space_dim,
Representation  r 
)
inline

Copy constructor with given size and representation.

Definition at line 195 of file Constraint_inlines.hh.

References OK(), and space_dimension().

197  : expr(c.expr, c.is_necessarily_closed() ? space_dim : (space_dim + 1), r),
198  kind_(c.kind_), topology_(c.topology_) {
199  PPL_ASSERT(space_dimension() == space_dim);
200  PPL_ASSERT(OK());
201 }
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Constraint.cc:467
Coefficient c
Definition: PIP_Tree.cc:64
Parma_Polyhedra_Library::Constraint::Constraint ( const Congruence cg,
Representation  r = default_representation 
)
explicit

Copy-constructs from equality congruence cg.

Exceptions
std::invalid_argumentThrown if cg is a proper congruence.

Definition at line 66 of file Constraint.cc.

References Parma_Polyhedra_Library::Congruence::is_equality(), OK(), strong_normalize(), and throw_invalid_argument().

67  : expr(cg.expression(), r),
70  if (!cg.is_equality()) {
71  throw_invalid_argument("Constraint(cg)",
72  "congruence cg must be an equality.");
73  }
74  // Enforce normalization.
76  PPL_ASSERT(OK());
77 }
void strong_normalize()
Strong normalization: ensures that different Constraint objects represent different hyperplanes or hy...
void throw_invalid_argument(const char *method, const char *message) const
Throws a std::invalid_argument exception containing error message message.
Definition: Constraint.cc:38
bool OK() const
Checks if all the invariants are satisfied.
Definition: Constraint.cc:467
Parma_Polyhedra_Library::Constraint::~Constraint ( )
inline

Destructor.

Definition at line 204 of file Constraint_inlines.hh.

204  {
205 }
Parma_Polyhedra_Library::Constraint::Constraint ( dimension_type  space_dim,
Kind  kind,
Topology  topology,
Representation  r = default_representation 
)
inlineprivate

Constructs the $0<0$ constraint.

Definition at line 128 of file Constraint_inlines.hh.

References expr, OK(), Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), and space_dimension().

130  : expr(r),
131  kind_(kind),
133  expr.set_space_dimension(space_dim + 1);
134  PPL_ASSERT(space_dimension() == space_dim);
135  PPL_ASSERT(OK());
136 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Constraint.cc:467
Topology topology() const
Returns the topological kind of *this.
Parma_Polyhedra_Library::Constraint::Constraint ( Linear_Expression e,
Kind  kind,
Topology  topology 
)
inlineprivate

Builds a constraint of kind kind and topology topology, stealing the coefficients from e.

Note
The new Constraint will have the same representation as `e'.

Definition at line 139 of file Constraint_inlines.hh.

References expr, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, OK(), RAY_OR_POINT_OR_INEQUALITY, Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), strong_normalize(), and swap().

140  : kind_(kind),
143  swap(expr, e);
145  // Add the epsilon dimension.
147  }
149  PPL_ASSERT(OK());
150 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void strong_normalize()
Strong normalization: ensures that different Constraint objects represent different hyperplanes or hy...
bool OK() const
Checks if all the invariants are satisfied.
Definition: Constraint.cc:467
Topology topology() const
Returns the topological kind of *this.
void swap(Constraint &x, Constraint &y)
Parma_Polyhedra_Library::Constraint::Constraint ( Linear_Expression e,
Type  type,
Topology  topology 
)
inlineprivate

Builds a constraint of type type and topology topology, stealing the coefficients from e.

Note
The new Constraint will have the same representation as `e'.

Definition at line 153 of file Constraint_inlines.hh.

References EQUALITY, expr, kind_, LINE_OR_EQUALITY, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, OK(), RAY_OR_POINT_OR_INEQUALITY, Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), STRICT_INEQUALITY, strong_normalize(), and swap().

154  : topology_(topology) {
156  swap(expr, e);
159  }
160  if (type == EQUALITY) {
162  }
163  else {
165  }
167  PPL_ASSERT(OK());
168 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
Type type() const
Returns the constraint type of *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void strong_normalize()
Strong normalization: ensures that different Constraint objects represent different hyperplanes or hy...
bool OK() const
Checks if all the invariants are satisfied.
Definition: Constraint.cc:467
Topology topology() const
Returns the topological kind of *this.
void swap(Constraint &x, Constraint &y)

Member Function Documentation

void Parma_Polyhedra_Library::Constraint::ascii_dump ( ) const

Writes to std::cerr an ASCII representation of *this.

void Parma_Polyhedra_Library::Constraint::ascii_dump ( std::ostream &  s) const

Writes to s an ASCII representation of *this.

Definition at line 309 of file Constraint.cc.

References EQUALITY, Parma_Polyhedra_Library::NECESSARILY_CLOSED, NONSTRICT_INEQUALITY, and STRICT_INEQUALITY.

309  {
310  expr.ascii_dump(s);
311 
312  s << " ";
313 
314  switch (type()) {
316  s << "=";
317  break;
319  s << ">=";
320  break;
322  s << ">";
323  break;
324  }
325  s << " ";
326  if (topology() == NECESSARILY_CLOSED) {
327  s << "(C)";
328  }
329  else {
330  s << "(NNC)";
331  }
332  s << "\n";
333 }
Type type() const
Returns the constraint type of *this.
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.
Topology topology() const
Returns the topological kind of *this.
bool Parma_Polyhedra_Library::Constraint::ascii_load ( std::istream &  s)

Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise.

Definition at line 336 of file Constraint.cc.

References Parma_Polyhedra_Library::NECESSARILY_CLOSED, and Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED.

Referenced by Parma_Polyhedra_Library::MIP_Problem::ascii_load(), and Parma_Polyhedra_Library::PIP_Problem::ascii_load().

336  {
337  std::string str;
338  std::string str2;
339 
340  expr.ascii_load(s);
341 
342  if (!(s >> str)) {
343  return false;
344  }
345  if (str == "=") {
346  set_is_equality();
347  }
348  else if (str == ">=" || str == ">") {
350  }
351  else {
352  return false;
353  }
354 
355  if (!(s >> str2)) {
356  return false;
357  }
358  if (str2 == "(NNC)") {
359  // TODO: Avoid the mark_as_*() methods if possible.
360  if (topology() == NECESSARILY_CLOSED) {
362  }
363  }
364  else {
365  if (str2 == "(C)") {
366  // TODO: Avoid the mark_as_*() methods if possible.
367  if (topology() == NOT_NECESSARILY_CLOSED) {
369  }
370  }
371  else {
372  return false;
373  }
374  }
375 
376  // Checking for equality of actual and declared types.
377  switch (type()) {
378  case EQUALITY:
379  if (str != "=") {
380  return false;
381  }
382  break;
384  if (str != ">=") {
385  return false;
386  }
387  break;
388  case STRICT_INEQUALITY:
389  if (str != ">") {
390  return false;
391  }
392  break;
393  }
394 
395  return true;
396 }
Type type() const
Returns the constraint type of *this.
void mark_as_necessarily_closed()
Marks the epsilon dimension as a standard dimension.
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
void set_is_equality()
Sets the constraint type to EQUALITY.
void set_is_inequality()
Sets the constraint to be an inequality.
Topology topology() const
Returns the topological kind of *this.
void mark_as_not_necessarily_closed()
Marks the last dimension as the epsilon dimension.
bool Parma_Polyhedra_Library::Constraint::check_strong_normalized ( ) const
private

Returns true if and only if the coefficients are strongly normalized.

Definition at line 259 of file Constraint.cc.

References Parma_Polyhedra_Library::compare(), and strong_normalize().

259  {
260  Constraint tmp = *this;
261  tmp.strong_normalize();
262  return compare(*this, tmp) == 0;
263 }
Constraint(Representation r=default_representation)
Constructs the constraint.
friend int compare(const Constraint &x, const Constraint &y)
Coefficient_traits::const_reference Parma_Polyhedra_Library::Constraint::coefficient ( Variable  v) const
inline

Returns the coefficient of v in *this.

Exceptions
std::invalid_argumentthrown if the index of v is greater than or equal to the space dimension of *this.

Definition at line 312 of file Constraint_inlines.hh.

References Parma_Polyhedra_Library::Linear_Expression::coefficient(), expr, Parma_Polyhedra_Library::Variable::space_dimension(), space_dimension(), and throw_dimension_incompatible().

Referenced by Parma_Polyhedra_Library::Box< ITV >::add_constraint_no_check(), Parma_Polyhedra_Library::Constraint_System::affine_preimage(), Parma_Polyhedra_Library::Polyhedron::expand_space_dimension(), Parma_Polyhedra_Library::Octagonal_Shape< T >::extract_octagonal_difference(), Parma_Polyhedra_Library::Box< ITV >::get_limiting_box(), Parma_Polyhedra_Library::MIP_Problem::parse_constraints(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::PIP_Problem::solve(), Parma_Polyhedra_Library::Implementation::wrap_assign(), and Parma_Polyhedra_Library::Box< ITV >::wrap_assign().

312  {
313  if (v.space_dimension() > space_dimension()) {
314  throw_dimension_incompatible("coefficient(v)", "v", v);
315  }
316  return expr.coefficient(v);
317 }
void throw_dimension_incompatible(const char *method, const char *name_var, Variable v) const
Throws a std::invalid_argument exception containing the appropriate error message.
Definition: Constraint.cc:47
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
PPL::Constraint Parma_Polyhedra_Library::Constraint::construct_epsilon_geq_zero ( )
staticprivate

Builds a new copy of the zero-dimension space constraint $\epsilon \geq 0$ (used to implement NNC polyhedra).

Definition at line 58 of file Constraint.cc.

References c, Parma_Polyhedra_Library::Coefficient_one(), Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, OK(), and set_epsilon_coefficient().

58  {
59  Linear_Expression e;
61  c.set_epsilon_coefficient(Coefficient_one());
62  PPL_ASSERT(c.OK());
63  return c;
64 }
Constraint(Representation r=default_representation)
Constructs the constraint.
Coefficient c
Definition: PIP_Tree.cc:64
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
Coefficient_traits::const_reference Parma_Polyhedra_Library::Constraint::epsilon_coefficient ( ) const
inlineprivate

Returns the epsilon coefficient. The constraint must be NNC.

Definition at line 570 of file Constraint_inlines.hh.

References Parma_Polyhedra_Library::Linear_Expression::coefficient(), expr, is_not_necessarily_closed(), and Parma_Polyhedra_Library::Linear_Expression::space_dimension().

Referenced by Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points(), Parma_Polyhedra_Library::Constraint_System::has_strict_inequalities(), Parma_Polyhedra_Library::Polyhedron::is_universe(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), Parma_Polyhedra_Library::Polyhedron::topological_closure_assign(), and type().

570  {
571  PPL_ASSERT(is_not_necessarily_closed());
572  return expr.coefficient(Variable(expr.space_dimension() - 1));
573 }
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
const Constraint & Parma_Polyhedra_Library::Constraint::epsilon_geq_zero ( )
inlinestatic

Returns the zero-dimension space constraint $\epsilon \geq 0$.

Definition at line 550 of file Constraint_inlines.hh.

References epsilon_geq_zero_p.

Referenced by Parma_Polyhedra_Library::Constraint_System::add_low_level_constraints().

550  {
551  PPL_ASSERT(epsilon_geq_zero_p != 0);
552  return *epsilon_geq_zero_p;
553 }
static const Constraint * epsilon_geq_zero_p
Holds (between class initialization and finalization) a pointer to the zero-dimension space constrain...
const Constraint & Parma_Polyhedra_Library::Constraint::epsilon_leq_one ( )
inlinestatic

The zero-dimension space constraint $\epsilon \leq 1$ (used to implement NNC polyhedra).

Definition at line 556 of file Constraint_inlines.hh.

References epsilon_leq_one_p.

Referenced by Parma_Polyhedra_Library::Constraint_System::add_low_level_constraints(), Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), and Parma_Polyhedra_Library::Polyhedron::topological_closure_assign().

556  {
557  PPL_ASSERT(epsilon_leq_one_p != 0);
558  return *epsilon_leq_one_p;
559 }
static const Constraint * epsilon_leq_one_p
Holds (between class initialization and finalization) a pointer to the zero-dimension space constrain...
Constraint::expr_type Parma_Polyhedra_Library::Constraint::expression ( ) const
inline

Partial read access to the (adapted) internal expression.

Definition at line 42 of file Constraint_inlines.hh.

References expr, and is_not_necessarily_closed().

Referenced by Parma_Polyhedra_Library::Implementation::Termination::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::C_Polyhedron::C_Polyhedron(), Parma_Polyhedra_Library::Polyhedron::contains_integer_point(), Parma_Polyhedra_Library::Octagonal_Shape< T >::difference_assign(), Parma_Polyhedra_Library::BD_Shape< T >::difference_assign(), Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points(), Parma_Polyhedra_Library::BD_Shape< T >::extract_bounded_difference(), Parma_Polyhedra_Library::Box_Helpers::extract_interval_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::extract_octagonal_difference(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_systems_MS(), is_equivalent_to(), Parma_Polyhedra_Library::Polyhedron::is_universe(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::linear_partition(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::linear_partition_aux(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), operator<<(), Parma_Polyhedra_Library::MIP_Problem::parse_constraints(), Parma_Polyhedra_Library::Polyhedron::poly_difference_assign(), Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints(), Parma_Polyhedra_Library::Shape_Preserving_Reduction< D1, D2 >::product_reduce(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraint_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_with_constraints(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign(), Parma_Polyhedra_Library::PIP_Problem::solve(), space_dimension(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), and Parma_Polyhedra_Library::PIP_Solution_Node::update_tableau().

42  {
44 }
Expression_Hide_Last< Linear_Expression > expr_type
The type of the (adapted) internal expression.
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
memory_size_type Parma_Polyhedra_Library::Constraint::external_memory_in_bytes ( ) const
inline

Returns the size in bytes of the memory managed by *this.

Definition at line 325 of file Constraint_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::external_memory_in_bytes().

Referenced by total_memory_in_bytes().

325  {
327 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void Parma_Polyhedra_Library::Constraint::finalize ( )
static

Finalizes the class.

Definition at line 290 of file Constraint.cc.

Referenced by Parma_Polyhedra_Library::Init::~Init().

290  {
291  PPL_ASSERT(zero_dim_false_p != 0);
292  delete zero_dim_false_p;
293  zero_dim_false_p = 0;
294 
295  PPL_ASSERT(zero_dim_positivity_p != 0);
296  delete zero_dim_positivity_p;
298 
299  PPL_ASSERT(epsilon_geq_zero_p != 0);
300  delete epsilon_geq_zero_p;
301  epsilon_geq_zero_p = 0;
302 
303  PPL_ASSERT(epsilon_leq_one_p != 0);
304  delete epsilon_leq_one_p;
305  epsilon_leq_one_p = 0;
306 }
static const Constraint * zero_dim_false_p
Holds (between class initialization and finalization) a pointer to the unsatisfiable (zero-dimension ...
static const Constraint * epsilon_geq_zero_p
Holds (between class initialization and finalization) a pointer to the zero-dimension space constrain...
static const Constraint * zero_dim_positivity_p
Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) co...
static const Constraint * epsilon_leq_one_p
Holds (between class initialization and finalization) a pointer to the zero-dimension space constrain...
Coefficient_traits::const_reference Parma_Polyhedra_Library::Constraint::inhomogeneous_term ( ) const
inline

Returns the inhomogeneous term of *this.

Definition at line 320 of file Constraint_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::inhomogeneous_term().

Referenced by Parma_Polyhedra_Library::BD_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Box< ITV >::add_constraint_no_check(), Parma_Polyhedra_Library::Polyhedron::contains_integer_point(), Parma_Polyhedra_Library::Octagonal_Shape< T >::extract_octagonal_difference(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_systems_MS(), Parma_Polyhedra_Library::Box< ITV >::get_limiting_box(), Parma_Polyhedra_Library::BD_Shape< T >::get_limiting_shape(), Parma_Polyhedra_Library::Polyhedron::is_universe(), operator<<(), Parma_Polyhedra_Library::MIP_Problem::parse_constraints(), Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraint_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::BD_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Polyhedron::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::PIP_Problem::solve(), Parma_Polyhedra_Library::PIP_Solution_Node::update_tableau(), and Parma_Polyhedra_Library::Box< ITV >::wrap_assign().

320  {
321  return expr.inhomogeneous_term();
322 }
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
void Parma_Polyhedra_Library::Constraint::initialize ( )
static

Initializes the class.

Definition at line 271 of file Constraint.cc.

References Parma_Polyhedra_Library::Coefficient_one(), and Parma_Polyhedra_Library::Linear_Expression::zero().

Referenced by Parma_Polyhedra_Library::Init::Init().

271  {
272  PPL_ASSERT(zero_dim_false_p == 0);
275 
276  PPL_ASSERT(zero_dim_positivity_p == 0);
279 
280  PPL_ASSERT(epsilon_geq_zero_p == 0);
283 
284  PPL_ASSERT(epsilon_leq_one_p == 0);
287 }
static const Constraint * zero_dim_false_p
Holds (between class initialization and finalization) a pointer to the unsatisfiable (zero-dimension ...
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Constraint * epsilon_geq_zero_p
Holds (between class initialization and finalization) a pointer to the zero-dimension space constrain...
static Constraint construct_epsilon_geq_zero()
Builds a new copy of the zero-dimension space constraint (used to implement NNC polyhedra).
Definition: Constraint.cc:58
static const Constraint * zero_dim_positivity_p
Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) co...
static const Constraint * epsilon_leq_one_p
Holds (between class initialization and finalization) a pointer to the zero-dimension space constrain...
static const Linear_Expression & zero()
Returns the (zero-dimension space) constant 0.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
bool Parma_Polyhedra_Library::Constraint::is_equal_to ( const Constraint y) const

Returns true if *this is identical to y.

This is faster than is_equivalent_to(), but it may return `false' even for equivalent constraints.

Definition at line 247 of file Constraint.cc.

References expr, kind_, and topology().

247  {
248  return expr.is_equal_to(y.expr) && kind_ == y.kind_ && topology() == y.topology();
249 }
bool is_equal_to(const Linear_Expression &x) const
Topology topology() const
Returns the topological kind of *this.
bool Parma_Polyhedra_Library::Constraint::is_equality ( ) const
inline

Returns true if and only if *this is an equality constraint.

Definition at line 266 of file Constraint_inlines.hh.

References is_line_or_equality().

Referenced by Parma_Polyhedra_Library::BD_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Box< ITV >::add_constraint_no_check(), Parma_Polyhedra_Library::Grid::add_constraint_no_check(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::affine_dimension(), Parma_Polyhedra_Library::Implementation::Termination::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::Polyhedron::BFT00_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Congruence::Congruence(), Parma_Polyhedra_Library::Octagonal_Shape< T >::difference_assign(), Parma_Polyhedra_Library::BD_Shape< T >::difference_assign(), Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::linear_partition(), Parma_Polyhedra_Library::MIP_Problem::parse_constraints(), Parma_Polyhedra_Library::Shape_Preserving_Reduction< D1, D2 >::product_reduce(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_no_check(), Parma_Polyhedra_Library::BD_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::Grid::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_with_constraints(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Polyhedron::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::PIP_Problem::solve(), type(), and Parma_Polyhedra_Library::PIP_Solution_Node::update_tableau().

266  {
267  return is_line_or_equality();
268 }
bool is_line_or_equality() const
Returns true if and only if *this row represents a line or an equality.
bool Parma_Polyhedra_Library::Constraint::is_equivalent_to ( const Constraint y) const

Returns true if and only if *this and y are equivalent constraints.

Constraints having different space dimensions are not equivalent. Note that constraints having different types may nonetheless be equivalent, if they both are tautologies or inconsistent.

Definition at line 208 of file Constraint.cc.

References expr, expression(), Parma_Polyhedra_Library::Linear_Expression::is_equal_to(), is_inconsistent(), is_tautological(), Parma_Polyhedra_Library::Linear_Expression::normalize(), space_dimension(), and type().

Referenced by operator!=(), and operator==().

208  {
209  const Constraint& x = *this;
210  const dimension_type x_space_dim = x.space_dimension();
211  if (x_space_dim != y.space_dimension()) {
212  return false;
213  }
214 
215  const Type x_type = x.type();
216  if (x_type != y.type()) {
217  // Check for special cases.
218  if (x.is_tautological()) {
219  return y.is_tautological();
220  }
221  else {
222  return x.is_inconsistent() && y.is_inconsistent();
223  }
224  }
225 
226  if (x_type == STRICT_INEQUALITY) {
227  // Due to the presence of epsilon-coefficients, syntactically
228  // different strict inequalities may actually encode the same
229  // topologically open half-space.
230  // First, drop the epsilon-coefficient ...
231  Linear_Expression x_expr(x.expression());
232  Linear_Expression y_expr(y.expression());
233  // ... then, re-normalize ...
234  x_expr.normalize();
235  y_expr.normalize();
236  // ... and finally check for syntactic equality.
237  return x_expr.is_equal_to(y_expr);
238  }
239 
240  // `x' and 'y' are of the same type and they are not strict inequalities;
241  // thus, the epsilon-coefficient, if present, is zero.
242  // It is sufficient to check for syntactic equality.
243  return x.expr.is_equal_to(y.expr);
244 }
Constraint(Representation r=default_representation)
Constructs the constraint.
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool Parma_Polyhedra_Library::Constraint::is_inconsistent ( ) const

Returns true if and only if *this is inconsistent (i.e., an always false constraint).

An inconsistent constraint can have either one of the following forms:

  • an equality: $\sum_{i=0}^{n-1} 0 x_i + b = 0$, where $b \neq 0$; or
  • a non-strict inequality: $\sum_{i=0}^{n-1} 0 x_i + b \geq 0$, where $b < 0$; or
  • a strict inequality: $\sum_{i=0}^{n-1} 0 x_i + b > 0$, where $b \leq 0$.

Definition at line 148 of file Constraint.cc.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_constraint(), Parma_Polyhedra_Library::BD_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Grid::add_constraint_no_check(), Parma_Polyhedra_Library::Polyhedron::contains_integer_point(), is_equivalent_to(), Parma_Polyhedra_Library::Polyhedron::poly_difference_assign(), Parma_Polyhedra_Library::Polyhedron::refine_no_check(), Parma_Polyhedra_Library::Grid::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), and Parma_Polyhedra_Library::Box< ITV >::wrap_assign().

148  {
150  // The inhomogeneous term is the only non-zero coefficient.
151  if (is_equality()) {
152  return expr.inhomogeneous_term() != 0;
153  }
154  else {
155  // Non-strict inequality constraint.
156  return expr.inhomogeneous_term() < 0;
157  }
158  }
159  else {
160  // There is a non-zero homogeneous coefficient.
161  if (is_necessarily_closed()) {
162  return false;
163  }
164  else {
165  // The constraint is NOT necessarily closed.
166  if (epsilon_coefficient() >= 0) {
167  // If positive, we have found the constraint epsilon >= 0.
168  // If zero, one of the `true' dimensions has a non-zero coefficient.
169  // In both cases, it is not trivially false.
170  return false;
171  }
172  else {
173  // Here the epsilon coefficient is negative: strict inequality.
174  if (expr.inhomogeneous_term() > 0) {
175  // A strict inequality such as `lhs + k > 0',
176  // where k is a positive integer, cannot be trivially false.
177  return false;
178  }
179  // Checking for another non-zero coefficient.
180  // If the check succeeds, we have the inequality `k > 0',
181  // where k is a positive integer.
183  }
184  }
185  }
186 }
bool is_equality() const
Returns true if and only if *this is an equality constraint.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are zero.
Coefficient_traits::const_reference epsilon_coefficient() const
Returns the epsilon coefficient. The constraint must be NNC.
expr_type expression() const
Partial read access to the (adapted) internal expression.
bool Parma_Polyhedra_Library::Constraint::is_line_or_equality ( ) const
inlineprivate

Returns true if and only if *this row represents a line or an equality.

Definition at line 57 of file Constraint_inlines.hh.

References kind_, and LINE_OR_EQUALITY.

Referenced by compare(), and is_equality().

bool Parma_Polyhedra_Library::Constraint::is_nonstrict_inequality ( ) const
inline

Returns true if and only if *this is a non-strict inequality constraint.

Definition at line 292 of file Constraint_inlines.hh.

References NONSTRICT_INEQUALITY, and type().

Referenced by Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), and Parma_Polyhedra_Library::BD_Shape< T >::relation_with().

292  {
293  return type() == NONSTRICT_INEQUALITY;
294 }
Type type() const
Returns the constraint type of *this.
bool Parma_Polyhedra_Library::Constraint::is_not_necessarily_closed ( ) const
inlineprivate

Returns true if and only if the topology of *this row is not necessarily closed.

Definition at line 37 of file Constraint_inlines.hh.

References is_necessarily_closed().

Referenced by epsilon_coefficient(), expression(), mark_as_necessarily_closed(), and set_epsilon_coefficient().

37  {
38  return !is_necessarily_closed();
39 }
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
bool Parma_Polyhedra_Library::Constraint::is_ray_or_point_or_inequality ( ) const
inlineprivate

Returns true if and only if *this row represents a ray, a point or an inequality.

Definition at line 62 of file Constraint_inlines.hh.

References kind_, and RAY_OR_POINT_OR_INEQUALITY.

Referenced by is_inequality().

bool Parma_Polyhedra_Library::Constraint::is_strict_inequality ( ) const
inline

Returns true if and only if *this is a strict inequality constraint.

Definition at line 297 of file Constraint_inlines.hh.

References STRICT_INEQUALITY, and type().

Referenced by Parma_Polyhedra_Library::MIP_Problem::add_constraint(), Parma_Polyhedra_Library::Polyhedron::add_constraint(), Parma_Polyhedra_Library::BD_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Box< ITV >::add_constraint_no_check(), Parma_Polyhedra_Library::Implementation::Termination::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::Polyhedron::BHZ09_NNC_poly_hull_assign_if_exact(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::C_Polyhedron::C_Polyhedron(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::linear_partition_aux(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::BD_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Polyhedron::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::Polyhedron::select_H79_constraints(), Parma_Polyhedra_Library::PIP_Problem::solve(), and Parma_Polyhedra_Library::PIP_Solution_Node::update_tableau().

297  {
298  return type() == STRICT_INEQUALITY;
299 }
Type type() const
Returns the constraint type of *this.
bool Parma_Polyhedra_Library::Constraint::is_tautological ( ) const

Returns true if and only if *this is a tautology (i.e., an always true constraint).

A tautology can have either one of the following forms:

  • an equality: $\sum_{i=0}^{n-1} 0 x_i + 0 = 0$; or
  • a non-strict inequality: $\sum_{i=0}^{n-1} 0 x_i + b \geq 0$, where $b \geq 0$; or
  • a strict inequality: $\sum_{i=0}^{n-1} 0 x_i + b > 0$, where $b > 0$.

Definition at line 105 of file Constraint.cc.

References Parma_Polyhedra_Library::Boundary_NS::sgn().

Referenced by Parma_Polyhedra_Library::Polyhedron::add_constraint(), Parma_Polyhedra_Library::BD_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Grid::add_constraint_no_check(), Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points(), Parma_Polyhedra_Library::Constraint_System::has_strict_inequalities(), is_equivalent_to(), Parma_Polyhedra_Library::Polyhedron::poly_difference_assign(), Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign(), and Parma_Polyhedra_Library::Polyhedron::topological_closure_assign().

105  {
107  if (is_equality()) {
108  return expr.inhomogeneous_term() == 0;
109  }
110  else {
111  // Non-strict inequality constraint.
112  return expr.inhomogeneous_term() >= 0;
113  }
114  }
115  else {
116  // There is a non-zero homogeneous coefficient.
117  if (is_necessarily_closed()) {
118  return false;
119  }
120  else {
121  // The constraint is NOT necessarily closed.
122  const int eps_sign = sgn(epsilon_coefficient());
123  if (eps_sign > 0) {
124  // We have found the constraint epsilon >= 0.
125  return true;
126  }
127  if (eps_sign == 0) {
128  // One of the `true' dimensions has a non-zero coefficient.
129  return false;
130  }
131  else {
132  // Here the epsilon coefficient is negative: strict inequality.
133  if (expr.inhomogeneous_term() <= 0) {
134  // A strict inequality such as `lhs - k > 0',
135  // where k is a non negative integer, cannot be trivially true.
136  return false;
137  }
138  // Checking for another non-zero coefficient.
139  // If the check succeeds, we have the inequality `k > 0',
140  // where k is a positive integer.
142  }
143  }
144  }
145 }
bool is_equality() const
Returns true if and only if *this is an equality constraint.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are zero.
Coefficient_traits::const_reference epsilon_coefficient() const
Returns the epsilon coefficient. The constraint must be NNC.
int sgn(Boundary_Type type, const T &x, const Info &info)
expr_type expression() const
Partial read access to the (adapted) internal expression.
void Parma_Polyhedra_Library::Constraint::linear_combine ( const Constraint y,
dimension_type  i 
)
private

Linearly combines *this with y so that i-th coefficient is 0.

Parameters
yThe Constraint that will be combined with *this object;
iThe index of the coefficient that has to become $0$.

Computes a linear combination of *this and y having the i-th coefficient equal to $0$. Then it assigns the resulting Constraint to *this and normalizes it.

Definition at line 189 of file Constraint.cc.

References expr.

189  {
190  expr.linear_combine(y.expr, i);
192 }
void strong_normalize()
Strong normalization: ensures that different Constraint objects represent different hyperplanes or hy...
void linear_combine(const Linear_Expression &y, Variable v)
void Parma_Polyhedra_Library::Constraint::m_swap ( Constraint y)
inline

Swaps *this with y.

Definition at line 562 of file Constraint_inlines.hh.

References expr, kind_, swap(), Parma_Polyhedra_Library::swap(), and topology_.

Referenced by swap().

562  {
563  using std::swap;
564  swap(expr, y.expr);
565  swap(kind_, y.kind_);
566  swap(topology_, y.topology_);
567 }
void swap(CO_Tree &x, CO_Tree &y)
void swap(Constraint &x, Constraint &y)
void Parma_Polyhedra_Library::Constraint::mark_as_necessarily_closed ( )
inlineprivate

Marks the epsilon dimension as a standard dimension.

The row topology is changed to NOT_NECESSARILY_CLOSED, and the number of space dimensions is increased by 1.

Definition at line 98 of file Constraint_inlines.hh.

References is_not_necessarily_closed(), Parma_Polyhedra_Library::NECESSARILY_CLOSED, and topology_.

98  {
99  PPL_ASSERT(is_not_necessarily_closed());
101 }
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
void Parma_Polyhedra_Library::Constraint::mark_as_not_necessarily_closed ( )
inlineprivate

Marks the last dimension as the epsilon dimension.

The row topology is changed to NECESSARILY_CLOSED, and the number of space dimensions is decreased by 1.

Definition at line 104 of file Constraint_inlines.hh.

References is_necessarily_closed(), Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, and topology_.

104  {
105  PPL_ASSERT(is_necessarily_closed());
107 }
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
dimension_type Parma_Polyhedra_Library::Constraint::max_space_dimension ( )
inlinestatic

Returns the maximum space dimension a Constraint can handle.

Definition at line 226 of file Constraint_inlines.hh.

References Parma_Polyhedra_Library::Linear_Expression::max_space_dimension().

Referenced by Parma_Polyhedra_Library::MIP_Problem::max_space_dimension(), and Parma_Polyhedra_Library::PIP_Problem::max_space_dimension().

226  {
228 }
static dimension_type max_space_dimension()
Returns the maximum space dimension a Linear_Expression can handle.
bool Parma_Polyhedra_Library::Constraint::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 467 of file Constraint.cc.

References strong_normalize().

Referenced by Parma_Polyhedra_Library::Constraint_System::affine_preimage(), Constraint(), construct_epsilon_geq_zero(), Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points(), Parma_Polyhedra_Library::Polyhedron::expand_space_dimension(), operator>(), set_space_dimension(), and Parma_Polyhedra_Library::Polyhedron::topological_closure_assign().

467  {
468  // Topology consistency checks.
470 #ifndef NDEBUG
471  std::cerr << "Constraint has fewer coefficients than the minimum "
472  << "allowed by its topology."
473  << std::endl;
474 #endif
475  return false;
476  }
477 
479  && epsilon_coefficient() != 0) {
480 #ifndef NDEBUG
481  std::cerr << "Illegal constraint: an equality cannot be strict."
482  << std::endl;
483 #endif
484  return false;
485  }
486 
487  // Normalization check.
488  Constraint tmp = *this;
489  tmp.strong_normalize();
490  if (tmp != *this) {
491 #ifndef NDEBUG
492  std::cerr << "Constraint is not strongly normalized as it should be."
493  << std::endl;
494 #endif
495  return false;
496  }
497 
498  // All tests passed.
499  return true;
500 }
bool is_equality() const
Returns true if and only if *this is an equality constraint.
Constraint(Representation r=default_representation)
Constructs the constraint.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
Coefficient_traits::const_reference epsilon_coefficient() const
Returns the epsilon coefficient. The constraint must be NNC.
Constraint & Parma_Polyhedra_Library::Constraint::operator= ( const Constraint c)
inline

Assignment operator.

Definition at line 208 of file Constraint_inlines.hh.

References c, and swap().

208  {
209  Constraint tmp = c;
210  swap(*this, tmp);
211 
212  return *this;
213 }
Constraint(Representation r=default_representation)
Constructs the constraint.
Coefficient c
Definition: PIP_Tree.cc:64
void swap(Constraint &x, Constraint &y)
void Parma_Polyhedra_Library::Constraint::permute_space_dimensions ( const std::vector< Variable > &  cycle)

Permutes the space dimensions of the constraint.

Definition at line 91 of file Constraint.cc.

91  {
92  if (cycle.size() < 2) {
93  // No-op. No need to call sign_normalize().
94  return;
95  }
96 
98  // *this is still normalized but may be not strongly normalized:
99  // sign normalization is necessary.
100  sign_normalize();
101  PPL_ASSERT(OK());
102 }
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the expression.
bool OK() const
Checks if all the invariants are satisfied.
Definition: Constraint.cc:467
void sign_normalize()
Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a lin...
Definition: Constraint.cc:252
void Parma_Polyhedra_Library::Constraint::print ( ) const

Prints *this to std::cerr using operator<<.

bool Parma_Polyhedra_Library::Constraint::remove_space_dimensions ( const Variables_Set vars)
inline

Removes all the specified dimensions from the constraint.

The space dimension of the variable with the highest space dimension in vars must be at most the space dimension of this.

Always returns true. The return value is needed for compatibility with the Generator class.

Definition at line 260 of file Constraint_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::remove_space_dimensions().

260  {
262  return true;
263 }
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the expression.
Representation Parma_Polyhedra_Library::Constraint::representation ( ) const
inline

Returns the current representation of *this.

Definition at line 216 of file Constraint_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::representation().

216  {
217  return expr.representation();
218 }
Representation representation() const
Returns the current representation of *this.
void Parma_Polyhedra_Library::Constraint::set_epsilon_coefficient ( Coefficient_traits::const_reference  n)
inlineprivate

Sets the epsilon coefficient to n. The constraint must be NNC.

Definition at line 576 of file Constraint_inlines.hh.

References expr, is_not_necessarily_closed(), Parma_Polyhedra_Library::Linear_Expression::set_coefficient(), and Parma_Polyhedra_Library::Linear_Expression::space_dimension().

Referenced by construct_epsilon_geq_zero(), Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points(), operator>(), and Parma_Polyhedra_Library::Polyhedron::topological_closure_assign().

576  {
577  PPL_ASSERT(is_not_necessarily_closed());
578  expr.set_coefficient(Variable(expr.space_dimension() - 1), n);
579 }
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void set_coefficient(Variable v, Coefficient_traits::const_reference n)
Sets the coefficient of v in *this to n.
bool is_not_necessarily_closed() const
Returns true if and only if the topology of *this row is not necessarily closed.
void Parma_Polyhedra_Library::Constraint::set_is_equality ( )
inlineprivate

Sets the constraint type to EQUALITY.

Definition at line 302 of file Constraint_inlines.hh.

References set_is_line_or_equality().

302  {
304 }
void set_is_line_or_equality()
Sets to LINE_OR_EQUALITY the kind of *this row.
void Parma_Polyhedra_Library::Constraint::set_is_inequality ( )
inlineprivate

Sets the constraint to be an inequality.

Whether the constraint type will become NONSTRICT_INEQUALITY or STRICT_INEQUALITY depends on the topology and the value of the low-level coefficients of the constraint.

Definition at line 307 of file Constraint_inlines.hh.

References set_is_ray_or_point_or_inequality().

307  {
309 }
void set_is_ray_or_point_or_inequality()
Sets to RAY_OR_POINT_OR_INEQUALITY the kind of *this row.
void Parma_Polyhedra_Library::Constraint::set_is_line_or_equality ( )
inlineprivate
void Parma_Polyhedra_Library::Constraint::set_is_ray_or_point_or_inequality ( )
inlineprivate

Sets to RAY_OR_POINT_OR_INEQUALITY the kind of *this row.

Definition at line 77 of file Constraint_inlines.hh.

References kind_, and RAY_OR_POINT_OR_INEQUALITY.

Referenced by set_is_inequality().

void Parma_Polyhedra_Library::Constraint::set_necessarily_closed ( )
inlineprivate

Sets to NECESSARILY_CLOSED the topological kind of *this row.

Definition at line 110 of file Constraint_inlines.hh.

References Parma_Polyhedra_Library::NECESSARILY_CLOSED, and set_topology().

110  {
112 }
void set_topology(Topology x)
Sets to x the topological kind of *this row.
void Parma_Polyhedra_Library::Constraint::set_not_necessarily_closed ( )
inlineprivate

Sets to NOT_NECESSARILY_CLOSED the topological kind of *this row.

Definition at line 115 of file Constraint_inlines.hh.

References Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, and set_topology().

115  {
117 }
void set_topology(Topology x)
Sets to x the topological kind of *this row.
void Parma_Polyhedra_Library::Constraint::set_representation ( Representation  r)
inline

Converts *this to the specified representation.

Definition at line 221 of file Constraint_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::set_representation().

221  {
223 }
void set_representation(Representation r)
Converts *this to the specified representation.
void Parma_Polyhedra_Library::Constraint::set_space_dimension ( dimension_type  space_dim)
inline

Sets the dimension of the vector space enclosing *this to space_dim .

Definition at line 254 of file Constraint_inlines.hh.

References OK(), and set_space_dimension_no_ok().

254  {
255  set_space_dimension_no_ok(space_dim);
256  PPL_ASSERT(OK());
257 }
bool OK() const
Checks if all the invariants are satisfied.
Definition: Constraint.cc:467
void set_space_dimension_no_ok(dimension_type space_dim)
void Parma_Polyhedra_Library::Constraint::set_space_dimension_no_ok ( dimension_type  space_dim)
inlineprivate

Sets the dimension of the vector space enclosing *this to space_dim . Sets the space dimension of the rows in the system to space_dim .

This method is for internal use, it does *not* assert OK() at the end, so it can be used for invalid objects.

Definition at line 231 of file Constraint_inlines.hh.

References expr, Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), strong_normalize(), Parma_Polyhedra_Library::Linear_Expression::swap_space_dimensions(), and topology().

Referenced by set_space_dimension().

231  {
232  const dimension_type old_expr_space_dim = expr.space_dimension();
233  if (topology() == NECESSARILY_CLOSED) {
234  expr.set_space_dimension(space_dim);
235  }
236  else {
237  const dimension_type old_space_dim = space_dimension();
238  if (space_dim > old_space_dim) {
239  expr.set_space_dimension(space_dim + 1);
240  expr.swap_space_dimensions(Variable(space_dim), Variable(old_space_dim));
241  }
242  else {
243  expr.swap_space_dimensions(Variable(space_dim), Variable(old_space_dim));
244  expr.set_space_dimension(space_dim + 1);
245  }
246  }
247  PPL_ASSERT(space_dimension() == space_dim);
248  if (expr.space_dimension() < old_expr_space_dim) {
250  }
251 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
void strong_normalize()
Strong normalization: ensures that different Constraint objects represent different hyperplanes or hy...
Topology topology() const
Returns the topological kind of *this.
void Parma_Polyhedra_Library::Constraint::set_topology ( Topology  x)
inlineprivate

Sets to x the topological kind of *this row.

Definition at line 82 of file Constraint_inlines.hh.

References expr, Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), topology(), and topology_.

Referenced by Parma_Polyhedra_Library::Constraint_System::insert(), Parma_Polyhedra_Library::Constraint_System::insert_pending(), set_necessarily_closed(), and set_not_necessarily_closed().

82  {
83  if (topology() == x) {
84  return;
85  }
86  if (topology() == NECESSARILY_CLOSED) {
87  // Add a column for the epsilon dimension.
89  }
90  else {
91  PPL_ASSERT(expr.space_dimension() != 0);
93  }
94  topology_ = x;
95 }
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
Topology topology() const
Returns the topological kind of *this.
void Parma_Polyhedra_Library::Constraint::shift_space_dimensions ( Variable  v,
dimension_type  n 
)
inline

Shift by n positions the coefficients of variables, starting from the coefficient of v. This increases the space dimension by n.

Definition at line 52 of file Constraint_inlines.hh.

References expr, and Parma_Polyhedra_Library::Linear_Expression::shift_space_dimensions().

52  {
54 }
void shift_space_dimensions(Variable v, dimension_type n)
void Parma_Polyhedra_Library::Constraint::sign_normalize ( )
private

Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a line-or-equality is positive.

Definition at line 252 of file Constraint.cc.

Referenced by Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign(), and strong_normalize().

252  {
253  if (is_line_or_equality()) {
255  }
256 }
bool is_line_or_equality() const
Returns true if and only if *this row represents a line or an equality.
dimension_type Parma_Polyhedra_Library::Constraint::space_dimension ( ) const
inline

Returns the dimension of the vector space enclosing *this.

Definition at line 47 of file Constraint_inlines.hh.

References expression(), and Parma_Polyhedra_Library::Expression_Hide_Last< T >::space_dimension().

Referenced by Parma_Polyhedra_Library::MIP_Problem::add_constraint(), Parma_Polyhedra_Library::PIP_Problem::add_constraint(), Parma_Polyhedra_Library::Box< ITV >::add_constraint(), Parma_Polyhedra_Library::Polyhedron::add_constraint(), Parma_Polyhedra_Library::BD_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_constraint(), Parma_Polyhedra_Library::Grid::add_constraint(), Parma_Polyhedra_Library::Box< ITV >::add_constraint_no_check(), Parma_Polyhedra_Library::Grid::add_constraint_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::bounds(), coefficient(), Constraint(), Parma_Polyhedra_Library::BD_Shape< T >::extract_bounded_difference(), Parma_Polyhedra_Library::Box_Helpers::extract_interval_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::extract_octagonal_difference(), Parma_Polyhedra_Library::Scalar_Products::homogeneous_assign(), Parma_Polyhedra_Library::Congruence_System::insert(), is_equivalent_to(), Parma_Polyhedra_Library::MIP_Problem::is_satisfied(), Parma_Polyhedra_Library::MIP_Problem::is_saturated(), Parma_Polyhedra_Library::Octagonal_Shape< T >::max_min(), Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Sign::operator()(), Parma_Polyhedra_Library::MIP_Problem::parse_constraints(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraint(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraint_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_no_check(), Parma_Polyhedra_Library::BD_Shape< T >::refine_no_check(), Parma_Polyhedra_Library::Grid::refine_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_with_constraint(), Parma_Polyhedra_Library::Polyhedron::refine_with_constraint(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_with_constraint(), Parma_Polyhedra_Library::Grid::refine_with_constraint(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Polyhedron::relation_with(), Parma_Polyhedra_Library::Generator_System::relation_with(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::Generator_System::satisfied_by_all_generators(), set_space_dimension_no_ok(), Parma_Polyhedra_Library::PIP_Problem::solve(), Parma_Polyhedra_Library::Box< ITV >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Octagonal_Shape< T >::throw_dimension_incompatible(), Parma_Polyhedra_Library::BD_Shape< T >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid::throw_dimension_incompatible(), and Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible().

47  {
48  return expression().space_dimension();
49 }
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
expr_type expression() const
Partial read access to the (adapted) internal expression.
void Parma_Polyhedra_Library::Constraint::strong_normalize ( )
inlineprivate

Strong normalization: ensures that different Constraint objects represent different hyperplanes or hyperspaces.

Applies both Constraint::normalize() and Constraint::sign_normalize().

Definition at line 335 of file Constraint_inlines.hh.

References expr, Parma_Polyhedra_Library::Linear_Expression::normalize(), and sign_normalize().

Referenced by Parma_Polyhedra_Library::Constraint_System::affine_preimage(), check_strong_normalized(), Constraint(), OK(), and set_space_dimension_no_ok().

335  {
336  expr.normalize();
337  sign_normalize();
338 }
void sign_normalize()
Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a lin...
Definition: Constraint.cc:252
void Parma_Polyhedra_Library::Constraint::swap_space_dimensions ( Variable  v1,
Variable  v2 
)

Swaps the coefficients of the variables v1 and v2 .

Definition at line 80 of file Constraint.cc.

References Parma_Polyhedra_Library::Variable::space_dimension().

80  {
81  PPL_ASSERT(v1.space_dimension() <= space_dimension());
82  PPL_ASSERT(v2.space_dimension() <= space_dimension());
84  // *this is still normalized but it may not be strongly normalized.
86  PPL_ASSERT(OK());
87 }
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
bool OK() const
Checks if all the invariants are satisfied.
Definition: Constraint.cc:467
void sign_normalize()
Normalizes the sign of the coefficients so that the first non-zero (homogeneous) coefficient of a lin...
Definition: Constraint.cc:252
void Parma_Polyhedra_Library::Constraint::throw_dimension_incompatible ( const char *  method,
const char *  name_var,
Variable  v 
) const
private

Throws a std::invalid_argument exception containing the appropriate error message.

Definition at line 47 of file Constraint.cc.

References Parma_Polyhedra_Library::Variable::space_dimension().

Referenced by coefficient().

49  {
50  std::ostringstream s;
51  s << "PPL::Constraint::" << method << ":" << std::endl
52  << "this->space_dimension() == " << space_dimension() << ", "
53  << name_var << ".space_dimension() == " << v.space_dimension() << ".";
54  throw std::invalid_argument(s.str());
55 }
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void Parma_Polyhedra_Library::Constraint::throw_invalid_argument ( const char *  method,
const char *  message 
) const
private

Throws a std::invalid_argument exception containing error message message.

Definition at line 38 of file Constraint.cc.

Referenced by Constraint().

39  {
40  std::ostringstream s;
41  s << "PPL::Constraint::" << method << ":" << std::endl
42  << message;
43  throw std::invalid_argument(s.str());
44 }
Topology Parma_Polyhedra_Library::Constraint::topology ( ) const
inlineprivate
memory_size_type Parma_Polyhedra_Library::Constraint::total_memory_in_bytes ( ) const
inline

Returns a lower bound to the total size in bytes of the memory occupied by *this.

Definition at line 330 of file Constraint_inlines.hh.

References external_memory_in_bytes().

330  {
331  return sizeof(*this) + external_memory_in_bytes();
332 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Constraint::Type Parma_Polyhedra_Library::Constraint::type ( ) const
inline

Returns the constraint type of *this.

Definition at line 276 of file Constraint_inlines.hh.

References epsilon_coefficient(), EQUALITY, is_equality(), is_necessarily_closed(), NONSTRICT_INEQUALITY, and STRICT_INEQUALITY.

Referenced by Parma_Polyhedra_Library::Box< ITV >::add_constraint_no_check(), Parma_Polyhedra_Library::Polyhedron::contains_integer_point(), Parma_Polyhedra_Library::Box< ITV >::get_limiting_box(), is_equivalent_to(), Parma_Polyhedra_Library::Polyhedron::is_included_in(), is_nonstrict_inequality(), is_strict_inequality(), operator<<(), Parma_Polyhedra_Library::Polyhedron::poly_difference_assign(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraint_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::Generator_System::relation_with(), Parma_Polyhedra_Library::Generator_System::satisfied_by_all_generators(), Parma_Polyhedra_Library::Constraint_System::satisfies_all_constraints(), Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign(), and Parma_Polyhedra_Library::Box< ITV >::wrap_assign().

276  {
277  if (is_equality()) {
278  return EQUALITY;
279  }
280  if (is_necessarily_closed()) {
281  return NONSTRICT_INEQUALITY;
282  }
283  if (epsilon_coefficient() < 0) {
284  return STRICT_INEQUALITY;
285  }
286  else {
287  return NONSTRICT_INEQUALITY;
288  }
289 }
bool is_equality() const
Returns true if and only if *this is an equality constraint.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
Coefficient_traits::const_reference epsilon_coefficient() const
Returns the epsilon coefficient. The constraint must be NNC.
const Constraint & Parma_Polyhedra_Library::Constraint::zero_dim_false ( )
inlinestatic

The unsatisfiable (zero-dimension space) constraint $0 = 1$.

Definition at line 538 of file Constraint_inlines.hh.

References zero_dim_false_p.

Referenced by Parma_Polyhedra_Library::BD_Shape< T >::constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::constraints(), Parma_Polyhedra_Library::Box< ITV >::constraints(), Parma_Polyhedra_Library::Constraint_System::initialize(), Parma_Polyhedra_Library::BD_Shape< T >::minimized_constraints(), and Parma_Polyhedra_Library::Box< ITV >::minimized_constraints().

538  {
539  PPL_ASSERT(zero_dim_false_p != 0);
540  return *zero_dim_false_p;
541 }
static const Constraint * zero_dim_false_p
Holds (between class initialization and finalization) a pointer to the unsatisfiable (zero-dimension ...
const Constraint & Parma_Polyhedra_Library::Constraint::zero_dim_positivity ( )
inlinestatic

The true (zero-dimension space) constraint $0 \leq 1$, also known as positivity constraint.

Definition at line 544 of file Constraint_inlines.hh.

References zero_dim_positivity_p.

Referenced by Parma_Polyhedra_Library::Constraint_System::add_low_level_constraints(), Parma_Polyhedra_Library::MIP_Problem::ascii_load(), Parma_Polyhedra_Library::PIP_Problem::ascii_load(), and Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points().

544  {
545  PPL_ASSERT(zero_dim_positivity_p != 0);
546  return *zero_dim_positivity_p;
547 }
static const Constraint * zero_dim_positivity_p
Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) co...

Friends And Related Function Documentation

int compare ( const Constraint x,
const Constraint y 
)
related

The basic comparison function.

Returns
The returned absolute value can be $0$, $1$ or $2$.
Parameters
xA row of coefficients;
yAnother row.

Compares x and y, where x and y may be of different size, in which case the "missing" coefficients are assumed to be zero. The comparison is such that:

  1. equalities are smaller than inequalities;
  2. lines are smaller than points and rays;
  3. the ordering is lexicographic;
  4. the positions compared are, in decreasing order of significance, 1, 2, ..., size(), 0;
  5. the result is negative, zero, or positive if x is smaller than, equal to, or greater than y, respectively;
  6. when x and y are different, the absolute value of the result is 1 if the difference is due to the coefficient in position 0; it is 2 otherwise.

When x and y represent the hyper-planes associated to two equality or inequality constraints, the coefficient at 0 is the known term. In this case, the return value can be characterized as follows:

  • -2, if x is smaller than y and they are not parallel;
  • -1, if x is smaller than y and they are parallel;
  • 0, if x and y are equal;
  • +1, if y is smaller than x and they are parallel;
  • +2, if y is smaller than x and they are not parallel.
int compare ( const Constraint x,
const Constraint y 
)
related

Definition at line 196 of file Constraint.cc.

References Parma_Polyhedra_Library::compare(), expr, and is_line_or_equality().

196  {
197  const bool x_is_line_or_equality = x.is_line_or_equality();
198  const bool y_is_line_or_equality = y.is_line_or_equality();
199  if (x_is_line_or_equality != y_is_line_or_equality) {
200  // Equalities (lines) precede inequalities (ray/point).
201  return y_is_line_or_equality ? 2 : -2;
202  }
203 
204  return compare(x.expr, y.expr);
205 }
friend int compare(const Constraint &x, const Constraint &y)
int compare ( const Constraint x,
const Constraint y 
)
friend
friend class Constraint_System
friend

Definition at line 735 of file Constraint_defs.hh.

friend class Grid
friend

Definition at line 740 of file Constraint_defs.hh.

friend class Linear_System< Constraint >
friend

Definition at line 734 of file Constraint_defs.hh.

template<typename T >
friend class Octagonal_Shape
friend

Definition at line 742 of file Constraint_defs.hh.

bool operator!= ( const Constraint x,
const Constraint y 
)
related

Definition at line 348 of file Constraint_inlines.hh.

References is_equivalent_to().

348  {
349  return !x.is_equivalent_to(y);
350 }
bool operator!= ( const Constraint x,
const Constraint y 
)
related

Returns true if and only if x is not equivalent to y.

Constraint operator< ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Returns the constraint e1 < e2.

Constraint operator< ( Variable  v1,
Variable  v2 
)
related

Returns the constraint v1 < v2.

Constraint operator< ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the constraint e < n.

Constraint operator< ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Returns the constraint n < e.

Constraint operator< ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Definition at line 515 of file Constraint_inlines.hh.

515  {
516  return e2 > e1;
517 }
Constraint operator< ( const Variable  v1,
const Variable  v2 
)
related

Definition at line 521 of file Constraint_inlines.hh.

521  {
522  return v2 > v1;
523 }
Constraint operator< ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Definition at line 527 of file Constraint_inlines.hh.

527  {
528  return e > n;
529 }
Constraint operator< ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 533 of file Constraint_inlines.hh.

533  {
534  return n > e;
535 }
Constraint operator< ( const Linear_Expression e1,
const Linear_Expression e2 
)
friend
Constraint operator< ( Variable  v1,
Variable  v2 
)
friend
Constraint operator< ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
Constraint operator< ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
friend
std::ostream & operator<< ( std::ostream &  s,
const Constraint c 
)
related

Definition at line 400 of file Constraint.cc.

References Parma_Polyhedra_Library::Expression_Adapter< T >::begin(), Parma_Polyhedra_Library::Coefficient_zero(), Parma_Polyhedra_Library::Expression_Hide_Last< T >::end(), EQUALITY, expression(), inhomogeneous_term(), Parma_Polyhedra_Library::neg_assign(), NONSTRICT_INEQUALITY, PPL_DIRTY_TEMP_COEFFICIENT, STRICT_INEQUALITY, and type().

400  {
402  bool first = true;
403  for (Constraint::expr_type::const_iterator i = c.expression().begin(),
404  i_end = c.expression().end(); i != i_end; ++i) {
405  cv = *i;
406  if (!first) {
407  if (cv > 0) {
408  s << " + ";
409  }
410  else {
411  s << " - ";
412  neg_assign(cv);
413  }
414  }
415  else {
416  first = false;
417  }
418  if (cv == -1) {
419  s << "-";
420  }
421  else if (cv != 1) {
422  s << cv << "*";
423  }
424  s << i.variable();
425  }
426  if (first) {
427  s << Coefficient_zero();
428  }
429  const char* relation_symbol = 0;
430  switch (c.type()) {
432  relation_symbol = " = ";
433  break;
435  relation_symbol = " >= ";
436  break;
438  relation_symbol = " > ";
439  break;
440  }
441  s << relation_symbol << -c.inhomogeneous_term();
442  return s;
443 }
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
void neg_assign(GMP_Integer &x)
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
base_type::const_iterator const_iterator
The type of const iterators on coefficients.
Coefficient c
Definition: PIP_Tree.cc:64
std::ostream & operator<< ( std::ostream &  s,
const Constraint::Type t 
)
related

Definition at line 447 of file Constraint.cc.

References EQUALITY, NONSTRICT_INEQUALITY, and STRICT_INEQUALITY.

447  {
448  const char* n = 0;
449  switch (t) {
451  n = "EQUALITY";
452  break;
454  n = "NONSTRICT_INEQUALITY";
455  break;
457  n = "STRICT_INEQUALITY";
458  break;
459  }
460  s << n;
461  return s;
462 }
std::ostream & operator<< ( std::ostream &  s,
const Constraint c 
)
related

Output operator.

std::ostream & operator<< ( std::ostream &  s,
const Constraint::Type t 
)
related

Output operator.

Constraint operator<= ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Returns the constraint e1 <= e2.

Constraint operator<= ( Variable  v1,
Variable  v2 
)
related

Returns the constraint v1 <= v2.

Constraint operator<= ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the constraint e <= n.

Constraint operator<= ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Returns the constraint n <= e.

Constraint operator<= ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Definition at line 491 of file Constraint_inlines.hh.

491  {
492  return e2 >= e1;
493 }
Constraint operator<= ( const Variable  v1,
const Variable  v2 
)
related

Definition at line 497 of file Constraint_inlines.hh.

497  {
498  return v2 >= v1;
499 }
Constraint operator<= ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Definition at line 503 of file Constraint_inlines.hh.

503  {
504  return e >= n;
505 }
Constraint operator<= ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 509 of file Constraint_inlines.hh.

509  {
510  return n >= e;
511 }
Constraint operator<= ( const Linear_Expression e1,
const Linear_Expression e2 
)
friend
Constraint operator<= ( Variable  v1,
Variable  v2 
)
friend
Constraint operator<= ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
Constraint operator<= ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
friend
Constraint operator== ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Returns the constraint e1 = e2.

Constraint operator== ( Variable  v1,
Variable  v2 
)
related

Returns the constraint v1 = v2.

Constraint operator== ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the constraint e = n.

Constraint operator== ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Returns the constraint n = e.

bool operator== ( const Constraint x,
const Constraint y 
)
related

Definition at line 342 of file Constraint_inlines.hh.

References is_equivalent_to().

342  {
343  return x.is_equivalent_to(y);
344 }
Constraint operator== ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Definition at line 354 of file Constraint_inlines.hh.

References default_representation, EQUALITY, Parma_Polyhedra_Library::NECESSARILY_CLOSED, and Parma_Polyhedra_Library::Linear_Expression::space_dimension().

354  {
355  Linear_Expression diff(e1,
356  std::max(e1.space_dimension(), e2.space_dimension()),
358  diff -= e2;
360 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
Constraint operator== ( Variable  v1,
Variable  v2 
)
related

Definition at line 364 of file Constraint_inlines.hh.

References default_representation, EQUALITY, Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::Variable::space_dimension(), and Parma_Polyhedra_Library::swap().

364  {
365  if (v1.space_dimension() > v2.space_dimension()) {
366  swap(v1, v2);
367  }
368  PPL_ASSERT(v1.space_dimension() <= v2.space_dimension());
369 
370  Linear_Expression diff(v1, Constraint::default_representation);
371  diff -= v2;
373 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
void swap(Constraint &x, Constraint &y)
Constraint operator== ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Definition at line 428 of file Constraint_inlines.hh.

References default_representation, EQUALITY, Parma_Polyhedra_Library::NECESSARILY_CLOSED, and Parma_Polyhedra_Library::neg_assign().

428  {
429  Linear_Expression diff(e, Constraint::default_representation);
430  neg_assign(diff);
431  diff += n;
433 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
void neg_assign(GMP_Integer &x)
Constraint operator== ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 461 of file Constraint_inlines.hh.

References default_representation, EQUALITY, and Parma_Polyhedra_Library::NECESSARILY_CLOSED.

461  {
462  Linear_Expression diff(e, Constraint::default_representation);
463  diff -= n;
465 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
Constraint operator== ( const Linear_Expression e1,
const Linear_Expression e2 
)
friend
Constraint operator== ( Variable  v1,
Variable  v2 
)
friend
Constraint operator== ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
Constraint operator== ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
friend
bool operator== ( const Constraint x,
const Constraint y 
)
related

Returns true if and only if x is equivalent to y.

Constraint operator> ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Returns the constraint e1 > e2.

Constraint operator> ( Variable  v1,
Variable  v2 
)
related

Returns the constraint v1 > v2.

Constraint operator> ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the constraint e > n.

Constraint operator> ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Returns the constraint n > e.

Constraint operator> ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Definition at line 398 of file Constraint_inlines.hh.

References c, default_representation, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, OK(), set_epsilon_coefficient(), and STRICT_INEQUALITY.

398  {
399  Linear_Expression diff(e1, Constraint::default_representation);
400  diff -= e2;
402 
403  // NOTE: this also enforces normalization.
404  c.set_epsilon_coefficient(-1);
405  PPL_ASSERT(c.OK());
406 
407  return c;
408 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
Coefficient c
Definition: PIP_Tree.cc:64
Constraint operator> ( const Variable  v1,
const Variable  v2 
)
related

Definition at line 412 of file Constraint_inlines.hh.

References c, default_representation, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, OK(), set_epsilon_coefficient(), Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), Parma_Polyhedra_Library::Variable::space_dimension(), and STRICT_INEQUALITY.

412  {
413  Linear_Expression diff(Constraint::default_representation);
414  diff.set_space_dimension(std::max(v1.space_dimension(),
415  v2.space_dimension()));
416  diff += v1;
417  diff -= v2;
419 
420  c.set_epsilon_coefficient(-1);
421  PPL_ASSERT(c.OK());
422 
423  return c;
424 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
Coefficient c
Definition: PIP_Tree.cc:64
Constraint operator> ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Definition at line 446 of file Constraint_inlines.hh.

References c, default_representation, Parma_Polyhedra_Library::neg_assign(), Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, OK(), set_epsilon_coefficient(), and STRICT_INEQUALITY.

446  {
447  Linear_Expression diff(e, Constraint::default_representation);
448  neg_assign(diff);
449  diff += n;
451 
452  // NOTE: this also enforces normalization.
453  c.set_epsilon_coefficient(-1);
454  PPL_ASSERT(c.OK());
455 
456  return c;
457 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
void neg_assign(GMP_Integer &x)
Coefficient c
Definition: PIP_Tree.cc:64
Constraint operator> ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 477 of file Constraint_inlines.hh.

References c, default_representation, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, OK(), set_epsilon_coefficient(), and STRICT_INEQUALITY.

477  {
478  Linear_Expression diff(e, Constraint::default_representation);
479  diff -= n;
481 
482  // NOTE: this also enforces normalization.
483  c.set_epsilon_coefficient(-1);
484  PPL_ASSERT(c.OK());
485 
486  return c;
487 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
Coefficient c
Definition: PIP_Tree.cc:64
Constraint operator> ( const Linear_Expression e1,
const Linear_Expression e2 
)
friend
Constraint operator> ( Variable  v1,
Variable  v2 
)
friend
Constraint operator> ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
Constraint operator> ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
friend
Constraint operator>= ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Returns the constraint e1 >= e2.

Constraint operator>= ( Variable  v1,
Variable  v2 
)
related

Returns the constraint v1 >= v2.

Constraint operator>= ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Returns the constraint e >= n.

Constraint operator>= ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Returns the constraint n >= e.

Constraint operator>= ( const Linear_Expression e1,
const Linear_Expression e2 
)
related

Definition at line 377 of file Constraint_inlines.hh.

References default_representation, Parma_Polyhedra_Library::NECESSARILY_CLOSED, NONSTRICT_INEQUALITY, and Parma_Polyhedra_Library::Linear_Expression::space_dimension().

377  {
378  Linear_Expression diff(e1,
379  std::max(e1.space_dimension(), e2.space_dimension()),
381  diff -= e2;
383 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
Constraint operator>= ( const Variable  v1,
const Variable  v2 
)
related

Definition at line 387 of file Constraint_inlines.hh.

References default_representation, Parma_Polyhedra_Library::NECESSARILY_CLOSED, NONSTRICT_INEQUALITY, Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), and Parma_Polyhedra_Library::Variable::space_dimension().

387  {
388  Linear_Expression diff(Constraint::default_representation);
389  diff.set_space_dimension(std::max(v1.space_dimension(),
390  v2.space_dimension()));
391  diff += v1;
392  diff -= v2;
394 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
Constraint operator>= ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
related

Definition at line 437 of file Constraint_inlines.hh.

References default_representation, Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::neg_assign(), and NONSTRICT_INEQUALITY.

437  {
438  Linear_Expression diff(e, Constraint::default_representation);
439  neg_assign(diff);
440  diff += n;
442 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
void neg_assign(GMP_Integer &x)
Constraint operator>= ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
related

Definition at line 469 of file Constraint_inlines.hh.

References default_representation, Parma_Polyhedra_Library::NECESSARILY_CLOSED, and NONSTRICT_INEQUALITY.

469  {
470  Linear_Expression diff(e, Constraint::default_representation);
471  diff -= n;
473 }
Constraint(Representation r=default_representation)
Constructs the constraint.
static const Representation default_representation
The representation used for new Constraints.
Constraint operator>= ( const Linear_Expression e1,
const Linear_Expression e2 
)
friend
Constraint operator>= ( Variable  v1,
Variable  v2 
)
friend
Constraint operator>= ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
)
friend
Constraint operator>= ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
)
friend
friend class Polyhedron
friend

Definition at line 736 of file Constraint_defs.hh.

friend class Scalar_Products
friend

Definition at line 737 of file Constraint_defs.hh.

void swap ( Constraint x,
Constraint y 
)
related

Definition at line 583 of file Constraint_inlines.hh.

References m_swap().

583  {
584  x.m_swap(y);
585 }
void swap ( Constraint x,
Constraint y 
)
related

Referenced by Constraint(), m_swap(), and operator=().

friend class Termination_Helpers
friend

Definition at line 739 of file Constraint_defs.hh.

Definition at line 738 of file Constraint_defs.hh.

Member Data Documentation

const Representation Parma_Polyhedra_Library::Constraint::default_representation = SPARSE
static

The representation used for new Constraints.

Note
The copy constructor and the copy constructor with specified size use the representation of the original object, so that it is indistinguishable from the original object.

Definition at line 303 of file Constraint_defs.hh.

Referenced by operator==(), operator>(), and operator>=().

const PPL::Constraint * Parma_Polyhedra_Library::Constraint::epsilon_geq_zero_p = 0
staticprivate

Holds (between class initialization and finalization) a pointer to the zero-dimension space constraint $\epsilon \geq 0$.

Definition at line 556 of file Constraint_defs.hh.

Referenced by epsilon_geq_zero().

const PPL::Constraint * Parma_Polyhedra_Library::Constraint::epsilon_leq_one_p = 0
staticprivate

Holds (between class initialization and finalization) a pointer to the zero-dimension space constraint $\epsilon \leq 1$ (used to implement NNC polyhedra).

Definition at line 563 of file Constraint_defs.hh.

Referenced by epsilon_leq_one().

Kind Parma_Polyhedra_Library::Constraint::kind_
private
Topology Parma_Polyhedra_Library::Constraint::topology_
private
const PPL::Constraint * Parma_Polyhedra_Library::Constraint::zero_dim_false_p = 0
staticprivate

Holds (between class initialization and finalization) a pointer to the unsatisfiable (zero-dimension space) constraint $0 = 1$.

Definition at line 543 of file Constraint_defs.hh.

Referenced by zero_dim_false().

const PPL::Constraint * Parma_Polyhedra_Library::Constraint::zero_dim_positivity_p = 0
staticprivate

Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) constraint $0 \leq 1$, also known as positivity constraint.

Definition at line 550 of file Constraint_defs.hh.

Referenced by zero_dim_positivity().


The documentation for this class was generated from the following files: