PPL  1.2
Parma_Polyhedra_Library::Constraint_System Class Reference

A system of constraints. More...

#include <Constraint_System_defs.hh>

Collaboration diagram for Parma_Polyhedra_Library::Constraint_System:

Public Types

typedef Constraint row_type
 
typedef Constraint_System_const_iterator const_iterator
 

Public Member Functions

 Constraint_System (Representation r=default_representation)
 Default constructor: builds an empty system of constraints. More...
 
 Constraint_System (const Constraint &c, Representation r=default_representation)
 Builds the singleton system containing only constraint c. More...
 
 Constraint_System (const Congruence_System &cgs, Representation r=default_representation)
 Builds a system containing copies of any equalities in cgs. More...
 
 Constraint_System (const Constraint_System &cs)
 Ordinary copy constructor. More...
 
 Constraint_System (const Constraint_System &cs, Representation r)
 Copy constructor with specified representation. More...
 
 ~Constraint_System ()
 Destructor. More...
 
Constraint_Systemoperator= (const Constraint_System &y)
 Assignment operator. More...
 
Representation representation () const
 Returns the current representation of *this. More...
 
void set_representation (Representation r)
 Converts *this to the specified representation. More...
 
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this. More...
 
void set_space_dimension (dimension_type space_dim)
 Sets the space dimension of the rows in the system to space_dim . More...
 
bool has_equalities () const
 Returns true if and only if *this contains one or more equality constraints. More...
 
bool has_strict_inequalities () const
 Returns true if and only if *this contains one or more strict inequality constraints. More...
 
void insert (const Constraint &c)
 Inserts in *this a copy of the constraint c, increasing the number of space dimensions if needed. More...
 
bool empty () const
 Returns true if and only if *this has no constraints. More...
 
void clear ()
 Removes all the constraints from the constraint system and sets its space dimension to 0. More...
 
const_iterator begin () const
 Returns the const_iterator pointing to the first constraint, if *this is not empty; otherwise, returns the past-the-end const_iterator. More...
 
const_iterator end () const
 Returns the past-the-end const_iterator. 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...
 
memory_size_type total_memory_in_bytes () const
 Returns 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...
 
void m_swap (Constraint_System &y)
 Swaps *this with y. More...
 

Static Public Member Functions

static dimension_type max_space_dimension ()
 Returns the maximum space dimension a Constraint_System can handle. More...
 
static void initialize ()
 Initializes the class. More...
 
static void finalize ()
 Finalizes the class. More...
 
static const Constraint_Systemzero_dim_empty ()
 Returns the singleton system containing only Constraint::zero_dim_false(). More...
 

Static Public Attributes

static const Representation default_representation = SPARSE
 

Private Member Functions

 Constraint_System (Topology topol, Representation r=default_representation)
 Builds an empty system of constraints having the specified topology. More...
 
 Constraint_System (Topology topol, dimension_type space_dim, Representation r=default_representation)
 Builds a system of constraints on a space_dim dimensional space. If topol is NOT_NECESSARILY_CLOSED the $\epsilon$ dimension is added. More...
 
dimension_type num_equalities () const
 Returns the number of equality constraints. More...
 
dimension_type num_inequalities () const
 Returns the number of inequality constraints. More...
 
void simplify ()
 Applies Gaussian elimination and back-substitution so as to provide a partial simplification of the system of constraints. More...
 
bool adjust_topology_and_space_dimension (Topology new_topology, dimension_type new_space_dim)
 Adjusts *this so that it matches new_topology and new_space_dim (adding or removing columns if needed). Returns false if and only if topol is equal to NECESSARILY_CLOSED and *this contains strict inequalities. More...
 
const Constraintoperator[] (dimension_type k) const
 Returns a constant reference to the k- th constraint of the system. More...
 
bool satisfies_all_constraints (const Generator &g) const
 Returns true if g satisfies all the constraints. More...
 
void affine_preimage (Variable v, const Linear_Expression &expr, Coefficient_traits::const_reference denominator)
 Substitutes a given column of coefficients by a given affine expression. More...
 
void insert_pending (const Constraint &c)
 Inserts in *this a copy of the constraint c, increasing the number of space dimensions if needed. It is a pending constraint. More...
 
void add_low_level_constraints ()
 Adds low-level constraints to the constraint system. More...
 
Topology topology () const
 Returns the system topology. More...
 
dimension_type num_rows () const
 
bool is_necessarily_closed () const
 Returns true if and only if the system topology is NECESSARILY_CLOSED. More...
 
dimension_type num_pending_rows () const
 Returns the number of rows that are in the pending part of the system. More...
 
dimension_type first_pending_row () const
 Returns the index of the first pending row. More...
 
bool is_sorted () const
 Returns the value of the sortedness flag. More...
 
void unset_pending_rows ()
 Sets the index to indicate that the system has no pending rows. More...
 
void set_index_first_pending_row (dimension_type i)
 Sets the index of the first pending row to i. More...
 
void set_sorted (bool b)
 Sets the sortedness flag of the system to b. More...
 
void remove_row (dimension_type i, bool keep_sorted=false)
 Makes the system shrink by removing its i-th row. More...
 
void remove_rows (const std::vector< dimension_type > &indexes)
 
void remove_rows (dimension_type first, dimension_type last, bool keep_sorted=false)
 Makes the system shrink by removing the rows in [first,last). More...
 
void remove_trailing_rows (dimension_type n)
 Makes the system shrink by removing its n trailing rows. More...
 
void remove_space_dimensions (const Variables_Set &vars)
 Removes all the specified dimensions from the constraint system. More...
 
void shift_space_dimensions (Variable v, dimension_type n)
 
void permute_space_dimensions (const std::vector< Variable > &cycle)
 Permutes the space dimensions of the matrix. More...
 
void swap_space_dimensions (Variable v1, Variable v2)
 Swaps the coefficients of the variables v1 and v2 . More...
 
bool has_no_rows () const
 
void strong_normalize ()
 Strongly normalizes the system. More...
 
void sort_rows ()
 Sorts the non-pending rows (in growing order) and eliminates duplicated ones. More...
 
void insert_pending (Constraint &r, Recycle_Input)
 Adds the given row to the pending part of the system, stealing its contents and automatically resizing the system or the row, if needed. More...
 
void insert_pending (Constraint_System &r, Recycle_Input)
 
void insert (Constraint &r, Recycle_Input)
 Adds r to the system, stealing its contents and automatically resizing the system or the row, if needed. More...
 
void insert (Constraint_System &r, Recycle_Input)
 Adds to *this a the rows of `y', stealing them from `y'. More...
 
void insert_pending (const Constraint_System &r)
 Adds a copy of the rows of `y' to the pending part of `*this'. More...
 
void merge_rows_assign (const Constraint_System &y)
 Assigns to *this the result of merging its rows with those of y, obtaining a sorted system. More...
 
void insert (const Constraint_System &y)
 Adds to *this a copy of the rows of y. 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...
 
dimension_type gauss (dimension_type n_lines_or_equalities)
 Minimizes the subsystem of equations contained in *this. More...
 
void back_substitute (dimension_type n_lines_or_equalities)
 Back-substitutes the coefficients to reduce the complexity of the system. More...
 
void assign_with_pending (const Constraint_System &y)
 Full assignment operator: pending rows are copied as pending. More...
 
void sort_pending_and_remove_duplicates ()
 Sorts the pending rows and eliminates those that also occur in the non-pending part of the system. More...
 
void sort_and_remove_with_sat (Bit_Matrix &sat)
 Sorts the system, removing duplicates, keeping the saturation matrix consistent. More...
 
bool check_sorted () const
 Returns true if and only if *this is sorted, without checking for duplicates. More...
 
dimension_type num_lines_or_equalities () const
 Returns the number of rows in the system that represent either lines or equalities. More...
 
void add_universe_rows_and_space_dimensions (dimension_type n)
 Adds n rows and space dimensions to the system. More...
 

Private Attributes

Linear_System< Constraintsys
 

Static Private Attributes

static const Constraint_Systemzero_dim_empty_p = 0
 Holds (between class initialization and finalization) a pointer to the singleton system containing only Constraint::zero_dim_false(). More...
 

Friends

class Constraint_System_const_iterator
 
class Polyhedron
 
class Termination_Helpers
 
bool operator== (const Constraint_System &x, const Constraint_System &y)
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &s, const Constraint_System &cs)
 
std::ostream & operator<< (std::ostream &s, const Constraint_System &cs)
 Output operator. More...
 
bool operator== (const Constraint_System &x, const Constraint_System &y)
 Returns true if and only if x and y are identical. More...
 
bool operator!= (const Constraint_System &x, const Constraint_System &y)
 Returns true if and only if x and y are different. More...
 
void swap (Constraint_System &x, Constraint_System &y)
 
void swap (Constraint_System &x, Constraint_System &y)
 
dimension_type num_constraints (const Constraint_System &cs)
 

Detailed Description

A system of constraints.

An object of the class Constraint_System is a system of constraints, i.e., a multiset of objects of the class Constraint. When inserting constraints in a system, space dimensions are automatically adjusted so that all the constraints in the system are defined on the same vector space.

In all the examples it is assumed that variables x and y are defined as follows:
Variable x(0);
Variable y(1);
Example 1
The following code builds a system of constraints corresponding to a square in $\Rset^2$:
cs.insert(x >= 0);
cs.insert(x <= 3);
cs.insert(y >= 0);
cs.insert(y <= 3);
Note that: the constraint system is created with space dimension zero; the first and third constraint insertions increase the space dimension to $1$ and $2$, respectively.
Example 2
By adding four strict inequalities to the constraint system of the previous example, we can remove just the four vertices from the square defined above.
cs.insert(x + y > 0);
cs.insert(x + y < 6);
cs.insert(x - y < 3);
cs.insert(y - x < 3);
Example 3
The following code builds a system of constraints corresponding to a half-strip in $\Rset^2$:
cs.insert(x >= 0);
cs.insert(x - y <= 0);
cs.insert(x - y + 1 >= 0);
Note
After inserting a multiset of constraints in a constraint system, there are no guarantees that an exact copy of them can be retrieved: in general, only an equivalent constraint system will be available, where original constraints may have been reordered, removed (if they are trivial, duplicate or implied by other constraints), linearly combined, etc.

Definition at line 137 of file Constraint_System_defs.hh.

Member Typedef Documentation

Constructor & Destructor Documentation

Parma_Polyhedra_Library::Constraint_System::Constraint_System ( Representation  r = default_representation)
inlineexplicit

Default constructor: builds an empty system of constraints.

Definition at line 32 of file Constraint_System_inlines.hh.

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

Builds the singleton system containing only constraint c.

Definition at line 37 of file Constraint_System_inlines.hh.

References sys.

38  : sys(c.topology(), r) {
39  sys.insert(c);
40 }
Coefficient c
Definition: PIP_Tree.cc:64
Parma_Polyhedra_Library::Constraint_System::Constraint_System ( const Congruence_System cgs,
Representation  r = default_representation 
)
explicit

Builds a system containing copies of any equalities in cgs.

Definition at line 40 of file Constraint_System.cc.

References Parma_Polyhedra_Library::Congruence_System::begin(), Parma_Polyhedra_Library::Congruence_System::end(), insert(), and OK().

42  : sys(NECESSARILY_CLOSED, cgs.space_dimension(), r) {
43  for (Congruence_System::const_iterator i = cgs.begin(),
44  cgs_end = cgs.end(); i != cgs_end; ++i) {
45  if (i->is_equality()) {
46  Constraint tmp(*i);
47  insert(tmp, Recycle_Input());
48  }
49  }
50  PPL_ASSERT(OK());
51 }
void insert(const Constraint &c)
Inserts in *this a copy of the constraint c, increasing the number of space dimensions if needed...
bool OK() const
Checks if all the invariants are satisfied.
Parma_Polyhedra_Library::Constraint_System::Constraint_System ( const Constraint_System cs)
inline

Ordinary copy constructor.

Note
The copy will have the same representation as `cs', to make it indistinguishable from `cs'.

Definition at line 43 of file Constraint_System_inlines.hh.

44  : sys(cs.sys) {
45 }
Parma_Polyhedra_Library::Constraint_System::Constraint_System ( const Constraint_System cs,
Representation  r 
)
inline

Copy constructor with specified representation.

Definition at line 48 of file Constraint_System_inlines.hh.

50  : sys(cs.sys, r) {
51 }
Parma_Polyhedra_Library::Constraint_System::~Constraint_System ( )
inline

Destructor.

Definition at line 66 of file Constraint_System_inlines.hh.

66  {
67 }
Parma_Polyhedra_Library::Constraint_System::Constraint_System ( Topology  topol,
Representation  r = default_representation 
)
inlineexplicitprivate

Builds an empty system of constraints having the specified topology.

Definition at line 54 of file Constraint_System_inlines.hh.

55  : sys(topol, r) {
56 }
Parma_Polyhedra_Library::Constraint_System::Constraint_System ( Topology  topol,
dimension_type  space_dim,
Representation  r = default_representation 
)
inlineprivate

Builds a system of constraints on a space_dim dimensional space. If topol is NOT_NECESSARILY_CLOSED the $\epsilon$ dimension is added.

Definition at line 59 of file Constraint_System_inlines.hh.

62  : sys(topol, space_dim, r) {
63 }

Member Function Documentation

void Parma_Polyhedra_Library::Constraint_System::add_low_level_constraints ( )
inlineprivate

Adds low-level constraints to the constraint system.

Definition at line 198 of file Constraint_System_inlines.hh.

References Parma_Polyhedra_Library::Constraint::epsilon_geq_zero(), Parma_Polyhedra_Library::Constraint::epsilon_leq_one(), insert(), sys, and Parma_Polyhedra_Library::Constraint::zero_dim_positivity().

Referenced by Parma_Polyhedra_Library::Polyhedron::Polyhedron().

198  {
199  if (sys.is_necessarily_closed()) {
200  // The positivity constraint.
202  }
203  else {
204  // Add the epsilon constraints.
207  }
208 }
void insert(const Constraint &c)
Inserts in *this a copy of the constraint c, increasing the number of space dimensions if needed...
static const Constraint & epsilon_geq_zero()
Returns the zero-dimension space constraint .
static const Constraint & epsilon_leq_one()
The zero-dimension space constraint (used to implement NNC polyhedra).
static const Constraint & zero_dim_positivity()
The true (zero-dimension space) constraint , also known as positivity constraint. ...
void Parma_Polyhedra_Library::Constraint_System::add_universe_rows_and_space_dimensions ( dimension_type  n)
inlineprivate

Adds n rows and space dimensions to the system.

Parameters
nThe number of rows and space dimensions to be added: must be strictly positive.

Turns the system $M \in \Rset^r \times \Rset^c$ into the system $N \in \Rset^{r+n} \times \Rset^{c+n}$ such that $N = \bigl(\genfrac{}{}{0pt}{}{0}{M}\genfrac{}{}{0pt}{}{J}{o}\bigr)$, where $J$ is the specular image of the $n \times n$ identity matrix.

Definition at line 406 of file Constraint_System_inlines.hh.

References sys.

406  {
407  sys.add_universe_rows_and_space_dimensions(n);
408 }
bool Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension ( Topology  new_topology,
dimension_type  new_space_dim 
)
private

Adjusts *this so that it matches new_topology and new_space_dim (adding or removing columns if needed). Returns false if and only if topol is equal to NECESSARILY_CLOSED and *this contains strict inequalities.

Definition at line 55 of file Constraint_System.cc.

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

Referenced by Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::constraints(), and Parma_Polyhedra_Library::Polyhedron::Polyhedron().

56  {
57  PPL_ASSERT(space_dimension() <= new_space_dim);
58 
59  if (sys.topology() == NOT_NECESSARILY_CLOSED
60  && new_topology == NECESSARILY_CLOSED) {
61  // A NOT_NECESSARILY_CLOSED constraint system
62  // can be converted to a NECESSARILY_CLOSED one
63  // only if it does not contain strict inequalities.
65  return false;
66  }
67  // Since there were no strict inequalities,
68  // the only constraints that may have a non-zero epsilon coefficient
69  // are the eps-leq-one and the eps-geq-zero constraints.
70  // If they are present, we erase these rows, so that the
71  // epsilon column will only contain zeroes: as a consequence,
72  // we just decrement the number of columns to be added.
73  const bool was_sorted = sys.is_sorted();
74 
75  // Note that num_rows() is *not* constant, because it is decreased by
76  // remove_row().
77  for (dimension_type i = 0; i < num_rows(); ) {
78  if (sys[i].epsilon_coefficient() != 0) {
79  sys.remove_row(i, false);
80  }
81  else {
82  ++i;
83  }
84  }
85 
86  // If `cs' was sorted we sort it again.
87  if (was_sorted) {
88  sys.sort_rows();
89  }
90  }
91 
92  sys.set_topology(new_topology);
93  sys.set_space_dimension(new_space_dim);
94 
95  // We successfully adjusted space dimensions and topology.
96  PPL_ASSERT(OK());
97  return true;
98 }
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.
bool OK() const
Checks if all the invariants are satisfied.
bool has_strict_inequalities() const
Returns true if and only if *this contains one or more strict inequality constraints.
void Parma_Polyhedra_Library::Constraint_System::affine_preimage ( Variable  v,
const Linear_Expression expr,
Coefficient_traits::const_reference  denominator 
)
private

Substitutes a given column of coefficients by a given affine expression.

Parameters
vThe variable to which the affine transformation is substituted.
exprThe numerator of the affine transformation: $\sum_{i = 0}^{n - 1} a_i x_i + b$;
denominatorThe denominator of the affine transformation.

We want to allow affine transformations (see Section Images and Preimages of Affine Transfer Relations) having any rational coefficients. Since the coefficients of the constraints are integers we must also provide an integer denominator that will be used as denominator of the affine transformation. The denominator is required to be a positive integer.

The affine transformation substitutes the matrix of constraints by a new matrix whose elements ${a'}_{ij}$ are built from the old one $a_{ij}$ as follows:

\[ {a'}_{ij} = \begin{cases} a_{ij} * \mathrm{denominator} + a_{iv} * \mathrm{expr}[j] \quad \text{for } j \neq v; \\ \mathrm{expr}[v] * a_{iv} \quad \text{for } j = v. \end{cases} \]

expr is a constant parameter and unaltered by this computation.

Definition at line 327 of file Constraint_System.cc.

References c, Parma_Polyhedra_Library::Constraint::coefficient(), Parma_Polyhedra_Library::Linear_Expression::coefficient(), Parma_Polyhedra_Library::Coefficient_zero(), Parma_Polyhedra_Library::Constraint::expr, Parma_Polyhedra_Library::Linear_Expression::linear_combine(), Parma_Polyhedra_Library::Constraint::OK(), Parma_Polyhedra_Library::Linear_Expression::set_coefficient(), Parma_Polyhedra_Library::Variable::space_dimension(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), and Parma_Polyhedra_Library::Constraint::strong_normalize().

329  {
330  PPL_ASSERT(v.space_dimension() <= sys.space_dimension());
331  PPL_ASSERT(expr.space_dimension() <= sys.space_dimension());
332  PPL_ASSERT(denominator > 0);
333 
334  Coefficient_traits::const_reference expr_v = expr.coefficient(v);
335 
336  const dimension_type n_rows = sys.num_rows();
337  const bool not_invertible = (v.space_dimension() > expr.space_dimension()
338  || expr_v == 0);
339 
340  for (dimension_type i = n_rows; i-- > 0; ) {
341  Constraint& row = sys.rows[i];
342  Coefficient_traits::const_reference row_v = row.coefficient(v);
343  if (row_v != 0) {
344  const Coefficient c = row_v;
345  if (denominator != 1) {
346  row.expr *= denominator;
347  }
348  row.expr.linear_combine(expr, 1, c, 0, expr.space_dimension() + 1);
349  if (not_invertible) {
350  row.expr.set_coefficient(v, Coefficient_zero());
351  }
352  else {
353  row.expr.set_coefficient(v, c * expr_v);
354  }
355  row.strong_normalize();
356  PPL_ASSERT(row.OK());
357  }
358  }
359 
360  // Strong normalization also resets the sortedness flag.
361  sys.strong_normalize();
362 
363  PPL_ASSERT(sys.OK());
364 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
Coefficient c
Definition: PIP_Tree.cc:64
void Parma_Polyhedra_Library::Constraint_System::ascii_dump ( std::ostream &  s) const

Writes to s an ASCII representation of *this.

Definition at line 367 of file Constraint_System.cc.

367  {
368  sys.ascii_dump(s);
369 }
void Parma_Polyhedra_Library::Constraint_System::ascii_dump ( ) const

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

Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::ascii_dump(), and Parma_Polyhedra_Library::Polyhedron::OK().

bool Parma_Polyhedra_Library::Constraint_System::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 374 of file Constraint_System.cc.

Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::ascii_load().

374  {
375  if (!sys.ascii_load(s)) {
376  return false;
377  }
378 
379  PPL_ASSERT(OK());
380  return true;
381 }
bool OK() const
Checks if all the invariants are satisfied.
void Parma_Polyhedra_Library::Constraint_System::assign_with_pending ( const Constraint_System y)
inlineprivate

Full assignment operator: pending rows are copied as pending.

Definition at line 381 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::Polyhedron().

381  {
382  sys.assign_with_pending(y.sys);
383 }
void Parma_Polyhedra_Library::Constraint_System::back_substitute ( dimension_type  n_lines_or_equalities)
inlineprivate

Back-substitutes the coefficients to reduce the complexity of the system.

Takes an upper triangular system having n_lines_or_equalities rows. For each row, starting from the one having the minimum number of coefficients different from zero, computes the expression of an element as a function of the remaining ones and then substitutes this expression in all the other rows.

Definition at line 376 of file Constraint_System_inlines.hh.

References sys.

376  {
377  sys.back_substitute(n_lines_or_equalities);
378 }
Constraint_System_const_iterator Parma_Polyhedra_Library::Constraint_System::begin ( ) const
inline

Returns the const_iterator pointing to the first constraint, if *this is not empty; otherwise, returns the past-the-end const_iterator.

Definition at line 180 of file Constraint_System_inlines.hh.

References Parma_Polyhedra_Library::Constraint_System_const_iterator::skip_forward(), and sys.

Referenced by Parma_Polyhedra_Library::MIP_Problem::add_constraints(), Parma_Polyhedra_Library::PIP_Problem::add_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::add_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_constraints(), Parma_Polyhedra_Library::Grid::add_constraints(), Parma_Polyhedra_Library::Box< ITV >::add_constraints_no_check(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::affine_dimension(), Parma_Polyhedra_Library::Polyhedron::affine_dimension(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR_original(), Parma_Polyhedra_Library::Implementation::Termination::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::Termination_Helpers::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::BD_Shape< T >::BFT00_upper_bound_assign_if_exact(), Parma_Polyhedra_Library::BHRZ03_Certificate::BHRZ03_Certificate(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::C_Polyhedron::C_Polyhedron(), Parma_Polyhedra_Library::BHRZ03_Certificate::compare(), Parma_Polyhedra_Library::H79_Certificate::compare(), Parma_Polyhedra_Library::Congruence_System::Congruence_System(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::constraints(), Parma_Polyhedra_Library::Polyhedron::contains_integer_point(), Parma_Polyhedra_Library::Octagonal_Shape< T >::difference_assign(), Parma_Polyhedra_Library::BD_Shape< T >::difference_assign(), empty(), Parma_Polyhedra_Library::Polyhedron::expand_space_dimension(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR_original(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_systems_MS(), Parma_Polyhedra_Library::Box< ITV >::get_limiting_box(), Parma_Polyhedra_Library::Octagonal_Shape< T >::get_limiting_octagon(), Parma_Polyhedra_Library::BD_Shape< T >::get_limiting_shape(), Parma_Polyhedra_Library::Grid::Grid(), Parma_Polyhedra_Library::H79_Certificate::H79_Certificate(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::linear_partition(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::minimized_constraints(), Parma_Polyhedra_Library::MIP_Problem::MIP_Problem(), num_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::PIP_Tree_Node::OK(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR_original(), operator<<(), Parma_Polyhedra_Library::Polyhedron::poly_difference_assign(), Parma_Polyhedra_Library::PIP_Tree_Node::print_tree(), Parma_Polyhedra_Library::Shape_Preserving_Reduction< D1, D2 >::product_reduce(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraints_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_with_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::Grid::refine_with_constraints(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), Parma_Polyhedra_Library::PIP_Decision_Node::solve(), Parma_Polyhedra_Library::Implementation::wrap_assign(), Parma_Polyhedra_Library::Box< ITV >::wrap_assign(), and Parma_Polyhedra_Library::Implementation::wrap_assign_ind().

180  {
181  const_iterator i(sys.begin(), *this);
182  i.skip_forward();
183  return i;
184 }
void skip_forward()
*this skips to the next non-trivial constraint.
Constraint_System_const_iterator const_iterator
bool Parma_Polyhedra_Library::Constraint_System::check_sorted ( ) const
inlineprivate

Returns true if and only if *this is sorted, without checking for duplicates.

Definition at line 396 of file Constraint_System_inlines.hh.

References sys.

396  {
397  return sys.check_sorted();
398 }
void Parma_Polyhedra_Library::Constraint_System::clear ( )
inline
bool Parma_Polyhedra_Library::Constraint_System::empty ( ) const
inline

Returns true if and only if *this has no constraints.

Definition at line 193 of file Constraint_System_inlines.hh.

References begin(), and end().

Referenced by Parma_Polyhedra_Library::BD_Shape< T >::BFT00_upper_bound_assign_if_exact(), Parma_Polyhedra_Library::PIP_Tree_Node::print_tree(), Parma_Polyhedra_Library::PIP_Solution_Node::print_tree(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().

193  {
194  return begin() == end();
195 }
const_iterator begin() const
Returns the const_iterator pointing to the first constraint, if *this is not empty; otherwise...
const_iterator end() const
Returns the past-the-end const_iterator.
Constraint_System_const_iterator Parma_Polyhedra_Library::Constraint_System::end ( ) const
inline

Returns the past-the-end const_iterator.

Definition at line 187 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::MIP_Problem::add_constraints(), Parma_Polyhedra_Library::PIP_Problem::add_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::add_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_constraints(), Parma_Polyhedra_Library::Grid::add_constraints(), Parma_Polyhedra_Library::Box< ITV >::add_constraints_no_check(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::affine_dimension(), Parma_Polyhedra_Library::Polyhedron::affine_dimension(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR_original(), Parma_Polyhedra_Library::Implementation::Termination::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::Termination_Helpers::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::BD_Shape< T >::BFT00_upper_bound_assign_if_exact(), Parma_Polyhedra_Library::BHRZ03_Certificate::BHRZ03_Certificate(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::C_Polyhedron::C_Polyhedron(), Parma_Polyhedra_Library::BHRZ03_Certificate::compare(), Parma_Polyhedra_Library::H79_Certificate::compare(), Parma_Polyhedra_Library::Congruence_System::Congruence_System(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::constraints(), Parma_Polyhedra_Library::Polyhedron::contains_integer_point(), Parma_Polyhedra_Library::Octagonal_Shape< T >::difference_assign(), Parma_Polyhedra_Library::BD_Shape< T >::difference_assign(), empty(), Parma_Polyhedra_Library::Polyhedron::expand_space_dimension(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR_original(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_systems_MS(), Parma_Polyhedra_Library::Box< ITV >::get_limiting_box(), Parma_Polyhedra_Library::Octagonal_Shape< T >::get_limiting_octagon(), Parma_Polyhedra_Library::BD_Shape< T >::get_limiting_shape(), Parma_Polyhedra_Library::Grid::Grid(), Parma_Polyhedra_Library::H79_Certificate::H79_Certificate(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::linear_partition(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::minimized_constraints(), Parma_Polyhedra_Library::MIP_Problem::MIP_Problem(), num_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::PIP_Tree_Node::OK(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR_original(), operator<<(), Parma_Polyhedra_Library::Polyhedron::poly_difference_assign(), Parma_Polyhedra_Library::PIP_Tree_Node::print_tree(), Parma_Polyhedra_Library::Shape_Preserving_Reduction< D1, D2 >::product_reduce(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraints_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_with_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::Grid::refine_with_constraints(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), Parma_Polyhedra_Library::PIP_Decision_Node::solve(), Parma_Polyhedra_Library::Implementation::wrap_assign(), Parma_Polyhedra_Library::Box< ITV >::wrap_assign(), and Parma_Polyhedra_Library::Implementation::wrap_assign_ind().

187  {
188  const Constraint_System_const_iterator i(sys.end(), *this);
189  return i;
190 }
memory_size_type Parma_Polyhedra_Library::Constraint_System::external_memory_in_bytes ( ) const
inline

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

Definition at line 216 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::external_memory_in_bytes(), and total_memory_in_bytes().

216  {
217  return sys.external_memory_in_bytes();
218 }
void Parma_Polyhedra_Library::Constraint_System::finalize ( )
static

Finalizes the class.

Definition at line 393 of file Constraint_System.cc.

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

393  {
394  PPL_ASSERT(zero_dim_empty_p != 0);
395  delete zero_dim_empty_p;
396  zero_dim_empty_p = 0;
397 }
static const Constraint_System * zero_dim_empty_p
Holds (between class initialization and finalization) a pointer to the singleton system containing on...
dimension_type Parma_Polyhedra_Library::Constraint_System::first_pending_row ( ) const
inlineprivate

Returns the index of the first pending row.

Definition at line 251 of file Constraint_System_inlines.hh.

References sys.

251  {
252  return sys.first_pending_row();
253 }
dimension_type Parma_Polyhedra_Library::Constraint_System::gauss ( dimension_type  n_lines_or_equalities)
inlineprivate

Minimizes the subsystem of equations contained in *this.

This method works only on the equalities of the system: the system is required to be partially sorted, so that all the equalities are grouped at its top; it is assumed that the number of equalities is exactly n_lines_or_equalities. The method finds a minimal system for the equalities and returns its rank, i.e., the number of linearly independent equalities. The result is an upper triangular subsystem of equalities: for each equality, the pivot is chosen starting from the right-most columns.

Definition at line 371 of file Constraint_System_inlines.hh.

References sys.

371  {
372  return sys.gauss(n_lines_or_equalities);
373 }
bool Parma_Polyhedra_Library::Constraint_System::has_equalities ( ) const

Returns true if and only if *this contains one or more equality constraints.

Definition at line 101 of file Constraint_System.cc.

Referenced by Parma_Polyhedra_Library::Implementation::Termination::assign_all_inequalities_approximation().

101  {
102  // We verify if the system has equalities also in the pending part.
103  for (dimension_type i = sys.num_rows(); i-- > 0; ) {
104  if (sys[i].is_equality()) {
105  return true;
106  }
107  }
108  return false;
109 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool Parma_Polyhedra_Library::Constraint_System::has_no_rows ( ) const
inlineprivate
bool Parma_Polyhedra_Library::Constraint_System::has_strict_inequalities ( ) const

Returns true if and only if *this contains one or more strict inequality constraints.

Definition at line 112 of file Constraint_System.cc.

References c, Parma_Polyhedra_Library::Constraint::epsilon_coefficient(), and Parma_Polyhedra_Library::Constraint::is_tautological().

Referenced by Parma_Polyhedra_Library::MIP_Problem::add_constraints(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Implementation::Termination::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::Octagonal_Shape< T >::limited_BHMZ05_extrapolation_assign(), Parma_Polyhedra_Library::BD_Shape< T >::limited_BHMZ05_extrapolation_assign(), Parma_Polyhedra_Library::Polyhedron::limited_BHRZ03_extrapolation_assign(), Parma_Polyhedra_Library::Octagonal_Shape< T >::limited_CC76_extrapolation_assign(), Parma_Polyhedra_Library::BD_Shape< T >::limited_CC76_extrapolation_assign(), Parma_Polyhedra_Library::Polyhedron::limited_H79_extrapolation_assign(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::minimized_constraints(), Parma_Polyhedra_Library::MIP_Problem::MIP_Problem(), and Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape().

112  {
113  if (sys.is_necessarily_closed()) {
114  return false;
115  }
116  // We verify if the system has strict inequalities
117  // also in the pending part.
118  for (dimension_type i = sys.num_rows(); i-- > 0; ) {
119  const Constraint& c = sys[i];
120  // Optimized type checking: we already know the topology;
121  // also, equalities have the epsilon coefficient equal to zero.
122  // NOTE: the constraint eps_leq_one should not be considered
123  // a strict inequality.
124  if (c.epsilon_coefficient() < 0 && !c.is_tautological()) {
125  return true;
126  }
127  }
128  return false;
129 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
Coefficient c
Definition: PIP_Tree.cc:64
void Parma_Polyhedra_Library::Constraint_System::initialize ( )
static

Initializes the class.

Definition at line 386 of file Constraint_System.cc.

References Parma_Polyhedra_Library::Constraint::zero_dim_false().

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

386  {
387  PPL_ASSERT(zero_dim_empty_p == 0);
390 }
static const Constraint & zero_dim_false()
The unsatisfiable (zero-dimension space) constraint .
static const Constraint_System * zero_dim_empty_p
Holds (between class initialization and finalization) a pointer to the singleton system containing on...
Constraint_System(Representation r=default_representation)
Default constructor: builds an empty system of constraints.
void Parma_Polyhedra_Library::Constraint_System::insert ( const Constraint c)

Inserts in *this a copy of the constraint c, increasing the number of space dimensions if needed.

Definition at line 132 of file Constraint_System.cc.

Referenced by Parma_Polyhedra_Library::Polyhedron::add_congruences(), Parma_Polyhedra_Library::PIP_Tree_Node::add_constraint(), add_low_level_constraints(), Parma_Polyhedra_Library::Implementation::Termination::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::Termination_Helpers::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::BD_Shape< T >::BFT00_upper_bound_assign_if_exact(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_combining_constraints(), Constraint_System(), Parma_Polyhedra_Library::BD_Shape< T >::constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::constraints(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::constraints(), Parma_Polyhedra_Library::Box< ITV >::constraints(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR_original(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_systems_MS(), Parma_Polyhedra_Library::Polyhedron::intersection_assign(), Parma_Polyhedra_Library::Polyhedron::limited_BHRZ03_extrapolation_assign(), Parma_Polyhedra_Library::Polyhedron::limited_H79_extrapolation_assign(), Parma_Polyhedra_Library::BD_Shape< T >::minimized_constraints(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::minimized_constraints(), Parma_Polyhedra_Library::Box< ITV >::minimized_constraints(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR_original(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::Shape_Preserving_Reduction< D1, D2 >::product_reduce(), Parma_Polyhedra_Library::Polyhedron::refine_with_congruences(), Parma_Polyhedra_Library::Polyhedron::select_CH78_constraints(), Parma_Polyhedra_Library::Polyhedron::select_H79_constraints(), Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), Parma_Polyhedra_Library::PIP_Decision_Node::solve(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), Parma_Polyhedra_Library::Implementation::Termination::termination_test_PR(), and Parma_Polyhedra_Library::Implementation::wrap_assign().

132  {
133  Constraint tmp = r;
134  insert(tmp, Recycle_Input());
135 }
void insert(const Constraint &c)
Inserts in *this a copy of the constraint c, increasing the number of space dimensions if needed...
void Parma_Polyhedra_Library::Constraint_System::insert ( Constraint r,
Recycle_Input   
)
private

Adds r to the system, stealing its contents and automatically resizing the system or the row, if needed.

Definition at line 138 of file Constraint_System.cc.

References Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, Parma_Polyhedra_Library::Constraint::set_topology(), and Parma_Polyhedra_Library::Constraint::topology().

138  {
139  // We are sure that the matrix has no pending rows
140  // and that the new row is not a pending constraint.
141  PPL_ASSERT(sys.num_pending_rows() == 0);
142 
143  if (sys.topology() != c.topology()) {
144  if (sys.topology() == NECESSARILY_CLOSED) {
145  sys.set_topology(NOT_NECESSARILY_CLOSED);
146  }
147  else {
148  c.set_topology(NOT_NECESSARILY_CLOSED);
149  }
150  }
151 
152  sys.insert(c, Recycle_Input());
153 
154  PPL_ASSERT(OK());
155 }
bool OK() const
Checks if all the invariants are satisfied.
Coefficient c
Definition: PIP_Tree.cc:64
void Parma_Polyhedra_Library::Constraint_System::insert ( Constraint_System r,
Recycle_Input   
)
inlineprivate

Adds to *this a the rows of `y', stealing them from `y'.

It is assumed that *this has no pending rows.

Definition at line 341 of file Constraint_System_inlines.hh.

References sys.

341  {
342  sys.insert(r.sys, Recycle_Input());
343 }
void Parma_Polyhedra_Library::Constraint_System::insert ( const Constraint_System y)
inlineprivate

Adds to *this a copy of the rows of y.

It is assumed that *this has no pending rows.

Definition at line 356 of file Constraint_System_inlines.hh.

References sys.

356  {
357  sys.insert(y.sys);
358 }
void Parma_Polyhedra_Library::Constraint_System::insert_pending ( const Constraint c)
private

Inserts in *this a copy of the constraint c, increasing the number of space dimensions if needed. It is a pending constraint.

Definition at line 158 of file Constraint_System.cc.

Referenced by Parma_Polyhedra_Library::Polyhedron::intersection_assign(), and Parma_Polyhedra_Library::Polyhedron::refine_with_constraints().

158  {
159  Constraint tmp = r;
160  insert_pending(tmp, Recycle_Input());
161 }
void insert_pending(const Constraint &c)
Inserts in *this a copy of the constraint c, increasing the number of space dimensions if needed...
void Parma_Polyhedra_Library::Constraint_System::insert_pending ( Constraint r,
Recycle_Input   
)
private

Adds the given row to the pending part of the system, stealing its contents and automatically resizing the system or the row, if needed.

Definition at line 164 of file Constraint_System.cc.

References Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, Parma_Polyhedra_Library::Constraint::set_topology(), and Parma_Polyhedra_Library::Constraint::topology().

164  {
165  if (sys.topology() != c.topology()) {
166  if (sys.topology() == NECESSARILY_CLOSED) {
167  sys.set_topology(NOT_NECESSARILY_CLOSED);
168  }
169  else {
170  c.set_topology(NOT_NECESSARILY_CLOSED);
171  }
172  }
173 
174  sys.insert_pending(c, Recycle_Input());
175  PPL_ASSERT(OK());
176 }
bool OK() const
Checks if all the invariants are satisfied.
Coefficient c
Definition: PIP_Tree.cc:64
void Parma_Polyhedra_Library::Constraint_System::insert_pending ( Constraint_System r,
Recycle_Input   
)
inlineprivate

Adds the rows of `y' to the pending part of `*this', stealing them from `y'.

Definition at line 336 of file Constraint_System_inlines.hh.

References sys.

336  {
337  sys.insert_pending(r.sys, Recycle_Input());
338 }
void Parma_Polyhedra_Library::Constraint_System::insert_pending ( const Constraint_System r)
inlineprivate

Adds a copy of the rows of `y' to the pending part of `*this'.

Definition at line 346 of file Constraint_System_inlines.hh.

References sys.

346  {
347  sys.insert_pending(r.sys);
348 }
bool Parma_Polyhedra_Library::Constraint_System::is_necessarily_closed ( ) const
inlineprivate

Returns true if and only if the system topology is NECESSARILY_CLOSED.

Definition at line 241 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::is_necessarily_closed().

241  {
242  return sys.is_necessarily_closed();
243 }
bool Parma_Polyhedra_Library::Constraint_System::is_sorted ( ) const
inlineprivate
void Parma_Polyhedra_Library::Constraint_System::m_swap ( Constraint_System y)
inline

Swaps *this with y.

Definition at line 211 of file Constraint_System_inlines.hh.

References swap(), and sys.

Referenced by swap().

211  {
212  swap(sys, y.sys);
213 }
void swap(Constraint_System &x, Constraint_System &y)
void Parma_Polyhedra_Library::Constraint_System::mark_as_necessarily_closed ( )
inlineprivate

Marks the epsilon dimension as a standard dimension.

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

Definition at line 361 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints().

361  {
362  sys.mark_as_necessarily_closed();
363 }
void Parma_Polyhedra_Library::Constraint_System::mark_as_not_necessarily_closed ( )
inlineprivate

Marks the last dimension as the epsilon dimension.

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

Definition at line 366 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints().

366  {
367  sys.mark_as_not_necessarily_closed();
368 }
dimension_type Parma_Polyhedra_Library::Constraint_System::max_space_dimension ( )
inlinestatic

Returns the maximum space dimension a Constraint_System can handle.

Definition at line 92 of file Constraint_System_inlines.hh.

References Parma_Polyhedra_Library::Linear_System< Row >::max_space_dimension().

Referenced by Parma_Polyhedra_Library::Polyhedron::max_space_dimension().

92  {
94 }
static dimension_type max_space_dimension()
Returns the maximum space dimension a Linear_System can handle.
void Parma_Polyhedra_Library::Constraint_System::merge_rows_assign ( const Constraint_System y)
inlineprivate

Assigns to *this the result of merging its rows with those of y, obtaining a sorted system.

Duplicated rows will occur only once in the result. On entry, both systems are assumed to be sorted and have no pending rows.

Definition at line 351 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::intersection_assign().

351  {
352  sys.merge_rows_assign(y.sys);
353 }
PPL::dimension_type Parma_Polyhedra_Library::Constraint_System::num_equalities ( ) const
private

Returns the number of equality constraints.

Definition at line 204 of file Constraint_System.cc.

Referenced by Parma_Polyhedra_Library::Polyhedron::H79_widening_assign(), Parma_Polyhedra_Library::Polyhedron::OK(), and Parma_Polyhedra_Library::Polyhedron::quick_equivalence_test().

204  {
205  // We are sure that we call this method only when
206  // the matrix has no pending rows.
207  PPL_ASSERT(sys.num_pending_rows() == 0);
208  return sys.num_rows() - num_inequalities();
209 }
dimension_type num_inequalities() const
Returns the number of inequality constraints.
PPL::dimension_type Parma_Polyhedra_Library::Constraint_System::num_inequalities ( ) const
private

Returns the number of inequality constraints.

Definition at line 179 of file Constraint_System.cc.

179  {
180  // We are sure that we call this method only when
181  // the matrix has no pending rows.
182  PPL_ASSERT(sys.num_pending_rows() == 0);
183  const Constraint_System& cs = *this;
184  dimension_type n = 0;
185  // If the Base happens to be sorted, take advantage of the fact
186  // that inequalities are at the bottom of the system.
187  if (sys.is_sorted()) {
188  for (dimension_type i = sys.num_rows();
189  i > 0 && cs[--i].is_inequality(); ) {
190  ++n;
191  }
192  }
193  else {
194  for (dimension_type i = sys.num_rows(); i-- > 0 ; ) {
195  if (cs[i].is_inequality()) {
196  ++n;
197  }
198  }
199  }
200  return n;
201 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
Constraint_System(Representation r=default_representation)
Default constructor: builds an empty system of constraints.
dimension_type Parma_Polyhedra_Library::Constraint_System::num_lines_or_equalities ( ) const
inlineprivate

Returns the number of rows in the system that represent either lines or equalities.

Definition at line 401 of file Constraint_System_inlines.hh.

References sys.

401  {
402  return sys.num_lines_or_equalities();
403 }
dimension_type Parma_Polyhedra_Library::Constraint_System::num_pending_rows ( ) const
inlineprivate
bool Parma_Polyhedra_Library::Constraint_System::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 400 of file Constraint_System.cc.

Referenced by Constraint_System().

400  {
401  return sys.OK();
402 }
Constraint_System & Parma_Polyhedra_Library::Constraint_System::operator= ( const Constraint_System y)
inline

Assignment operator.

Definition at line 70 of file Constraint_System_inlines.hh.

References swap().

70  {
71  Constraint_System tmp = y;
72  swap(*this, tmp);
73  return *this;
74 }
Constraint_System(Representation r=default_representation)
Default constructor: builds an empty system of constraints.
void swap(Constraint_System &x, Constraint_System &y)
const Constraint & Parma_Polyhedra_Library::Constraint_System::operator[] ( dimension_type  k) const
inlineprivate

Returns a constant reference to the k- th constraint of the system.

Definition at line 77 of file Constraint_System_inlines.hh.

References sys.

77  {
78  return sys[k];
79 }
void Parma_Polyhedra_Library::Constraint_System::permute_space_dimensions ( const std::vector< Variable > &  cycle)
inlineprivate

Permutes the space dimensions of the matrix.

Definition at line 310 of file Constraint_System_inlines.hh.

Referenced by Parma_Polyhedra_Library::Polyhedron::map_space_dimensions().

310  {
311  sys.permute_space_dimensions(cycle);
312 }
void Parma_Polyhedra_Library::Constraint_System::print ( ) const

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

void Parma_Polyhedra_Library::Constraint_System::remove_row ( dimension_type  i,
bool  keep_sorted = false 
)
inlineprivate

Makes the system shrink by removing its i-th row.

When keep_sorted is true and the system is sorted, sortedness will be preserved, but this method costs O(n).

Otherwise, this method just swaps the i-th row with the last and then removes it, so it costs O(1).

Definition at line 276 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints().

276  {
277  sys.remove_row(i, keep_sorted);
278 }
void Parma_Polyhedra_Library::Constraint_System::remove_rows ( const std::vector< dimension_type > &  indexes)
inlineprivate

Removes the specified rows. The row ordering of remaining rows is preserved.

Parameters
indexesspecifies a list of row indexes. It must be sorted.

Definition at line 287 of file Constraint_System_inlines.hh.

References sys.

287  {
288  sys.remove_rows(indexes);
289 }
void Parma_Polyhedra_Library::Constraint_System::remove_rows ( dimension_type  first,
dimension_type  last,
bool  keep_sorted = false 
)
inlineprivate

Makes the system shrink by removing the rows in [first,last).

When keep_sorted is true and the system is sorted, sortedness will be preserved, but this method costs O(num_rows()).

Otherwise, this method just swaps the rows with the last ones and then removes them, so it costs O(last - first).

Definition at line 281 of file Constraint_System_inlines.hh.

References sys.

282  {
283  sys.remove_rows(first, last, keep_sorted);
284 }
void Parma_Polyhedra_Library::Constraint_System::remove_space_dimensions ( const Variables_Set vars)
inlineprivate

Removes all the specified dimensions from the constraint system.

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

Definition at line 298 of file Constraint_System_inlines.hh.

298  {
299  sys.remove_space_dimensions(vars);
300 }
void Parma_Polyhedra_Library::Constraint_System::remove_trailing_rows ( dimension_type  n)
inlineprivate

Makes the system shrink by removing its n trailing rows.

Definition at line 292 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::OK().

292  {
293  sys.remove_trailing_rows(n);
294 }
Representation Parma_Polyhedra_Library::Constraint_System::representation ( ) const
inline

Returns the current representation of *this.

Definition at line 82 of file Constraint_System_inlines.hh.

References sys.

82  {
83  return sys.representation();
84 }
bool Parma_Polyhedra_Library::Constraint_System::satisfies_all_constraints ( const Generator g) const
private

Returns true if g satisfies all the constraints.

Definition at line 220 of file Constraint_System.cc.

References c, Parma_Polyhedra_Library::Generator::CLOSURE_POINT, Parma_Polyhedra_Library::Constraint::EQUALITY, Parma_Polyhedra_Library::Constraint::is_inequality(), Parma_Polyhedra_Library::Generator::is_line(), Parma_Polyhedra_Library::Generator::LINE, Parma_Polyhedra_Library::Constraint::NONSTRICT_INEQUALITY, Parma_Polyhedra_Library::Generator::POINT, Parma_Polyhedra_Library::Generator::RAY, Parma_Polyhedra_Library::Generator::space_dimension(), Parma_Polyhedra_Library::Constraint::STRICT_INEQUALITY, Parma_Polyhedra_Library::Constraint::type(), and Parma_Polyhedra_Library::Generator::type().

220  {
221  PPL_ASSERT(g.space_dimension() <= space_dimension());
222 
223  // Setting `sps' to the appropriate scalar product sign operator.
224  // This also avoids problems when having _legal_ topology mismatches
225  // (which could also cause a mismatch in the number of columns).
226  const Topology_Adjusted_Scalar_Product_Sign sps(g);
227 
228  if (sys.is_necessarily_closed()) {
229  if (g.is_line()) {
230  // Lines must saturate all constraints.
231  for (dimension_type i = sys.num_rows(); i-- > 0; ) {
232  if (sps(g, sys[i]) != 0) {
233  return false;
234  }
235  }
236  }
237  else {
238  // `g' is either a ray, a point or a closure point.
239  for (dimension_type i = sys.num_rows(); i-- > 0; ) {
240  const Constraint& c = sys[i];
241  const int sp_sign = sps(g, c);
242  if (c.is_inequality()) {
243  // As `cs' is necessarily closed,
244  // `c' is a non-strict inequality.
245  if (sp_sign < 0) {
246  return false;
247  }
248  }
249  else {
250  // `c' is an equality.
251  if (sp_sign != 0) {
252  return false;
253  }
254  }
255  }
256  }
257  }
258  else {
259  // `cs' is not necessarily closed.
260  switch (g.type()) {
261 
262  case Generator::LINE:
263  // Lines must saturate all constraints.
264  for (dimension_type i = sys.num_rows(); i-- > 0; ) {
265  if (sps(g, sys[i]) != 0) {
266  return false;
267  }
268  }
269 
270  break;
271 
272  case Generator::POINT:
273  // Have to perform the special test
274  // when dealing with a strict inequality.
275  for (dimension_type i = sys.num_rows(); i-- > 0; ) {
276  const Constraint& c = sys[i];
277  const int sp_sign = sps(g, c);
278  switch (c.type()) {
280  if (sp_sign != 0) {
281  return false;
282  }
283  break;
285  if (sp_sign < 0) {
286  return false;
287  }
288  break;
290  if (sp_sign <= 0) {
291  return false;
292  }
293  break;
294  }
295  }
296  break;
297 
298  case Generator::RAY:
299  // Intentionally fall through.
301  for (dimension_type i = sys.num_rows(); i-- > 0; ) {
302  const Constraint& c = sys[i];
303  const int sp_sign = sps(g, c);
304  if (c.is_inequality()) {
305  // Constraint `c' is either a strict or a non-strict inequality.
306  if (sp_sign < 0) {
307  return false;
308  }
309  }
310  else
311  // Constraint `c' is an equality.
312  if (sp_sign != 0) {
313  return false;
314  }
315  }
316  break;
317  }
318  }
319 
320  // If we reach this point, `g' satisfies all constraints.
321  return true;
322 }
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.
Coefficient c
Definition: PIP_Tree.cc:64
void Parma_Polyhedra_Library::Constraint_System::set_index_first_pending_row ( dimension_type  i)
inlineprivate

Sets the index of the first pending row to i.

Definition at line 266 of file Constraint_System_inlines.hh.

References sys.

266  {
267  sys.set_index_first_pending_row(i);
268 }
void Parma_Polyhedra_Library::Constraint_System::set_representation ( Representation  r)
inline

Converts *this to the specified representation.

Definition at line 87 of file Constraint_System_inlines.hh.

References sys.

87  {
88  sys.set_representation(r);
89 }
void Parma_Polyhedra_Library::Constraint_System::set_sorted ( bool  b)
inlineprivate
void Parma_Polyhedra_Library::Constraint_System::shift_space_dimensions ( Variable  v,
dimension_type  n 
)
inlineprivate

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

Definition at line 304 of file Constraint_System_inlines.hh.

Referenced by Parma_Polyhedra_Library::Termination_Helpers::assign_all_inequalities_approximation().

304  {
305  sys.shift_space_dimensions(v, n);
306 }
void Parma_Polyhedra_Library::Constraint_System::simplify ( )
inlineprivate

Applies Gaussian elimination and back-substitution so as to provide a partial simplification of the system of constraints.

It is assumed that the system has no pending constraints.

Definition at line 226 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::OK(), and Parma_Polyhedra_Library::Polyhedron::simplified_constraints().

226  {
227  sys.simplify();
228 }
void Parma_Polyhedra_Library::Constraint_System::sort_and_remove_with_sat ( Bit_Matrix sat)
inlineprivate

Sorts the system, removing duplicates, keeping the saturation matrix consistent.

Parameters
satBit matrix with rows corresponding to the rows of *this.

Definition at line 391 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::obtain_sorted_constraints(), and Parma_Polyhedra_Library::Polyhedron::obtain_sorted_constraints_with_sat_c().

391  {
392  sys.sort_and_remove_with_sat(sat);
393 }
void Parma_Polyhedra_Library::Constraint_System::sort_pending_and_remove_duplicates ( )
inlineprivate

Sorts the pending rows and eliminates those that also occur in the non-pending part of the system.

Definition at line 386 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::process_pending_constraints().

386  {
387  sys.sort_pending_and_remove_duplicates();
388 }
void Parma_Polyhedra_Library::Constraint_System::sort_rows ( )
inlineprivate

Sorts the non-pending rows (in growing order) and eliminates duplicated ones.

Definition at line 331 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::obtain_sorted_constraints(), and Parma_Polyhedra_Library::Polyhedron::OK().

331  {
332  sys.sort_rows();
333 }
dimension_type Parma_Polyhedra_Library::Constraint_System::space_dimension ( ) const
inline

Returns the dimension of the vector space enclosing *this.

Definition at line 97 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::MIP_Problem::add_constraints(), Parma_Polyhedra_Library::Box< ITV >::add_constraints(), Parma_Polyhedra_Library::Grid::add_constraints(), Parma_Polyhedra_Library::Box< ITV >::add_constraints_no_check(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Implementation::Termination::all_affine_quasi_ranking_functions_MS(), Parma_Polyhedra_Library::Implementation::Termination::all_affine_ranking_functions_MS(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR(), Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR_original(), Parma_Polyhedra_Library::Termination_Helpers::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_combining_constraints(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR_original(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_systems_MS(), Parma_Polyhedra_Library::Box< ITV >::get_limiting_box(), Parma_Polyhedra_Library::Octagonal_Shape< T >::get_limiting_octagon(), Parma_Polyhedra_Library::BD_Shape< T >::get_limiting_shape(), Parma_Polyhedra_Library::Grid::Grid(), Parma_Polyhedra_Library::Octagonal_Shape< T >::limited_BHMZ05_extrapolation_assign(), Parma_Polyhedra_Library::BD_Shape< T >::limited_BHMZ05_extrapolation_assign(), Parma_Polyhedra_Library::Polyhedron::limited_BHRZ03_extrapolation_assign(), Parma_Polyhedra_Library::Box< ITV >::limited_CC76_extrapolation_assign(), Parma_Polyhedra_Library::Octagonal_Shape< T >::limited_CC76_extrapolation_assign(), Parma_Polyhedra_Library::BD_Shape< T >::limited_CC76_extrapolation_assign(), Parma_Polyhedra_Library::Polyhedron::limited_H79_extrapolation_assign(), Parma_Polyhedra_Library::MIP_Problem::MIP_Problem(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::Implementation::Termination::one_affine_ranking_function_MS(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR(), Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR_original(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraints(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraints_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_with_constraints(), Parma_Polyhedra_Library::Polyhedron::refine_with_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::Grid::refine_with_constraints(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), Parma_Polyhedra_Library::Implementation::Termination::termination_test_MS(), Parma_Polyhedra_Library::Implementation::Termination::termination_test_PR(), Parma_Polyhedra_Library::Implementation::Termination::termination_test_PR_original(), Parma_Polyhedra_Library::Box< ITV >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid::throw_dimension_incompatible(), Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible(), Parma_Polyhedra_Library::Implementation::wrap_assign(), Parma_Polyhedra_Library::Box< ITV >::wrap_assign(), and Parma_Polyhedra_Library::Grid::wrap_assign().

97  {
98  return sys.space_dimension();
99 }
void Parma_Polyhedra_Library::Constraint_System::strong_normalize ( )
inlineprivate

Strongly normalizes the system.

Definition at line 326 of file Constraint_System_inlines.hh.

References sys.

Referenced by Parma_Polyhedra_Library::Polyhedron::OK().

326  {
327  sys.strong_normalize();
328 }
void Parma_Polyhedra_Library::Constraint_System::swap_space_dimensions ( Variable  v1,
Variable  v2 
)
inlineprivate

Swaps the coefficients of the variables v1 and v2 .

Definition at line 316 of file Constraint_System_inlines.hh.

316  {
317  sys.swap_space_dimensions(v1, v2);
318 }
memory_size_type Parma_Polyhedra_Library::Constraint_System::total_memory_in_bytes ( ) const
inline

Returns the total size in bytes of the memory occupied by *this.

Definition at line 221 of file Constraint_System_inlines.hh.

References external_memory_in_bytes().

221  {
222  return external_memory_in_bytes() + sizeof(*this);
223 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void Parma_Polyhedra_Library::Constraint_System::unset_pending_rows ( )
inlineprivate
const Constraint_System & Parma_Polyhedra_Library::Constraint_System::zero_dim_empty ( )
inlinestatic

Friends And Related Function Documentation

friend class Constraint_System_const_iterator
friend

Definition at line 265 of file Constraint_System_defs.hh.

dimension_type num_constraints ( const Constraint_System cs)
related

Definition at line 432 of file Constraint_System_inlines.hh.

References begin(), and end().

432  {
433  return static_cast<dimension_type>(std::distance(cs.begin(), cs.end()));
434 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool operator!= ( const Constraint_System x,
const Constraint_System y 
)
related

Returns true if and only if x and y are different.

Definition at line 416 of file Constraint_System_inlines.hh.

416  {
417  return !(x == y);
418 }
std::ostream & operator<< ( std::ostream &  s,
const Constraint_System cs 
)
related

Output operator.

Writes true if cs is empty. Otherwise, writes on s the constraints of cs, all in one row and separated by ", ".

std::ostream & operator<< ( std::ostream &  s,
const Constraint_System cs 
)
related

Definition at line 406 of file Constraint_System.cc.

References begin(), and end().

406  {
407  Constraint_System_const_iterator i = cs.begin();
408  const Constraint_System_const_iterator cs_end = cs.end();
409  if (i == cs_end) {
410  s << "true";
411  }
412  else {
413  while (i != cs_end) {
414  s << *i;
415  ++i;
416  if (i != cs_end) {
417  s << ", ";
418  }
419  }
420  }
421  return s;
422 }
bool operator== ( const Constraint_System x,
const Constraint_System y 
)
related

Returns true if and only if x and y are identical.

Definition at line 411 of file Constraint_System_inlines.hh.

411  {
412  return x.sys == y.sys;
413 }
bool operator== ( const Constraint_System x,
const Constraint_System y 
)
friend

Definition at line 411 of file Constraint_System_inlines.hh.

411  {
412  return x.sys == y.sys;
413 }
friend class Polyhedron
friend

Definition at line 588 of file Constraint_System_defs.hh.

void swap ( Constraint_System x,
Constraint_System y 
)
related

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

void swap ( Constraint_System x,
Constraint_System y 
)
related

Definition at line 422 of file Constraint_System_inlines.hh.

References m_swap().

422  {
423  x.m_swap(y);
424 }
friend class Termination_Helpers
friend

Definition at line 589 of file Constraint_System_defs.hh.

Member Data Documentation

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

Definition at line 141 of file Constraint_System_defs.hh.

const PPL::Constraint_System * Parma_Polyhedra_Library::Constraint_System::zero_dim_empty_p = 0
staticprivate

Holds (between class initialization and finalization) a pointer to the singleton system containing only Constraint::zero_dim_false().

Definition at line 263 of file Constraint_System_defs.hh.

Referenced by zero_dim_empty().


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