A system of constraints. More...
#include <Constraint_System.defs.hh>


Classes | |
| class | const_iterator |
| An iterator over a system of constraints. More... | |
Public Member Functions | |
| Constraint_System () | |
| Default constructor: builds an empty system of constraints. | |
| Constraint_System (const Constraint &c) | |
Builds the singleton system containing only constraint c. | |
| Constraint_System (const Congruence_System &cgs) | |
Builds a system containing copies of any equalities in cgs. | |
| Constraint_System (const Constraint_System &cs) | |
| Ordinary copy constructor. | |
| ~Constraint_System () | |
| Destructor. | |
| Constraint_System & | operator= (const Constraint_System &y) |
| Assignment operator. | |
| dimension_type | space_dimension () const |
Returns the dimension of the vector space enclosing *this. | |
| bool | has_equalities () const |
Returns true if and only if *this contains one or more equality constraints. | |
| bool | has_strict_inequalities () const |
Returns true if and only if *this contains one or more strict inequality constraints. | |
| void | clear () |
| Removes all the constraints from the constraint system and sets its space dimension to 0. | |
| void | insert (const Constraint &c) |
Inserts in *this a copy of the constraint c, increasing the number of space dimensions if needed. | |
| bool | empty () const |
Returns true if and only if *this has no constraints. | |
| 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. | |
| const_iterator | end () const |
| Returns the past-the-end const_iterator. | |
| bool | OK () const |
| Checks if all the invariants are satisfied. | |
| void | ascii_dump () const |
Writes to std::cerr an ASCII representation of *this. | |
| void | ascii_dump (std::ostream &s) const |
Writes to s an ASCII representation of *this. | |
| void | print () const |
Prints *this to std::cerr using operator<<. | |
| 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. | |
| memory_size_type | total_memory_in_bytes () const |
Returns the total size in bytes of the memory occupied by *this. | |
| memory_size_type | external_memory_in_bytes () const |
Returns the size in bytes of the memory managed by *this. | |
| void | swap (Constraint_System &y) |
Swaps *this with y. | |
Static Public Member Functions | |
| static dimension_type | max_space_dimension () |
| Returns the maximum space dimension a Constraint_System can handle. | |
| static void | initialize () |
| Initializes the class. | |
| static void | finalize () |
| Finalizes the class. | |
| static const Constraint_System & | zero_dim_empty () |
| Returns the singleton system containing only Constraint::zero_dim_false(). | |
Private Member Functions | |
| Constraint_System (Topology topol) | |
| Builds an empty system of constraints having the specified topology. | |
| Constraint_System (Topology topol, dimension_type n_rows, dimension_type n_columns) | |
Builds a system of n_rows constraints on a n_columns - 1 dimensional space (including the dimension, if topol is NOT_NECESSARILY_CLOSED). | |
| bool | adjust_topology_and_space_dimension (Topology topol, dimension_type num_dimensions) |
Adjusts *this so that it matches the topology and the number of space dimensions given as parameters (adding or removing columns if needed). Returns false if and only if topol is equal to NECESSARILY_CLOSED and *this contains strict inequalities. | |
| Constraint & | operator[] (dimension_type k) |
Returns the k- th constraint of the system. | |
| const Constraint & | operator[] (dimension_type k) const |
Returns a constant reference to the k- th constraint of the system. | |
| bool | satisfies_all_constraints (const Generator &g) const |
Returns true if g satisfies all the constraints. | |
| void | affine_preimage (dimension_type v, const Linear_Expression &expr, Coefficient_traits::const_reference denominator) |
| Substitutes a given column of coefficients by a given affine expression. | |
| dimension_type | num_equalities () const |
| Returns the number of equality constraints. | |
| dimension_type | num_inequalities () const |
| Returns the number of inequality constraints. | |
| void | simplify () |
| Applies Gaussian elimination and back-substitution so as to provide a partial simplification of the system of constraints. | |
| 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. | |
| void | add_low_level_constraints () |
| Adds low-level constraints to the constraint system. | |
Static Private Attributes | |
| static const Constraint_System * | zero_dim_empty_p = 0 |
| Holds (between class initialization and finalization) a pointer to the singleton system containing only Constraint::zero_dim_false(). | |
Friends | |
| class | const_iterator |
| class | Parma_Polyhedra_Library::Polyhedron |
| bool | operator== (const Polyhedron &x, const Polyhedron &y) |
Returns true if and only if x and y are the same polyhedron. | |
Related Functions | |
(Note that these are not member functions.) | |
| std::ostream & | operator<< (std::ostream &s, const Constraint_System &cs) |
| Output operator. | |
| void | swap (Parma_Polyhedra_Library::Constraint_System &x, Parma_Polyhedra_Library::Constraint_System &y) |
Specializes std::swap. | |
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.
x and y are defined as follows: Variable x(0); Variable y(1);
: Constraint_System cs; cs.insert(x >= 0); cs.insert(x <= 3); cs.insert(y >= 0); cs.insert(y <= 3);
and
, respectively.cs.insert(x + y > 0); cs.insert(x + y < 6); cs.insert(x - y < 3); cs.insert(y - x < 3);
: Constraint_System cs; cs.insert(x >= 0); cs.insert(x - y <= 0); cs.insert(x - y + 1 >= 0);
Definition at line 128 of file Constraint_System.defs.hh.
| Parma_Polyhedra_Library::Constraint_System::Constraint_System | ( | ) | [inline] |
Default constructor: builds an empty system of constraints.
Definition at line 32 of file Constraint_System.inlines.hh.
Referenced by initialize().
00033 : Linear_System(NECESSARILY_CLOSED) { 00034 }
| Parma_Polyhedra_Library::Constraint_System::Constraint_System | ( | const Constraint & | c | ) | [inline, explicit] |
Builds the singleton system containing only constraint c.
Definition at line 37 of file Constraint_System.inlines.hh.
References insert().
00038 : Linear_System(c.topology()) { 00039 Linear_System::insert(c); 00040 }
| Parma_Polyhedra_Library::Constraint_System::Constraint_System | ( | const Congruence_System & | cgs | ) | [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(), and insert().
00041 : Linear_System(NECESSARILY_CLOSED, 0, cgs.space_dimension() + 1) { 00042 for (Congruence_System::const_iterator i = cgs.begin(), 00043 cgs_end = cgs.end(); i != cgs_end; ++i) 00044 if (i->is_equality()) 00045 // TODO: Consider adding a recycling_insert to save the extra copy here. 00046 insert(Constraint(*i)); 00047 }
| Parma_Polyhedra_Library::Constraint_System::Constraint_System | ( | const Constraint_System & | cs | ) | [inline] |
Ordinary copy constructor.
Definition at line 43 of file Constraint_System.inlines.hh.
00044 : Linear_System(cs) { 00045 }
| Parma_Polyhedra_Library::Constraint_System::~Constraint_System | ( | ) | [inline] |
| Parma_Polyhedra_Library::Constraint_System::Constraint_System | ( | Topology | topol | ) | [inline, explicit, private] |
Builds an empty system of constraints having the specified topology.
Definition at line 48 of file Constraint_System.inlines.hh.
00049 : Linear_System(topol) { 00050 }
| Parma_Polyhedra_Library::Constraint_System::Constraint_System | ( | Topology | topol, | |
| dimension_type | n_rows, | |||
| dimension_type | n_columns | |||
| ) | [inline, private] |
Builds a system of n_rows constraints on a n_columns - 1 dimensional space (including the
dimension, if topol is NOT_NECESSARILY_CLOSED).
Definition at line 53 of file Constraint_System.inlines.hh.
00056 : Linear_System(topol, n_rows, n_columns) { 00057 }
| void Parma_Polyhedra_Library::Constraint_System::add_low_level_constraints | ( | ) | [inline, private] |
Adds low-level constraints to the constraint system.
Definition at line 181 of file Constraint_System.inlines.hh.
References Parma_Polyhedra_Library::Constraint::epsilon_geq_zero(), Parma_Polyhedra_Library::Constraint::epsilon_leq_one(), insert(), Parma_Polyhedra_Library::Linear_System::is_necessarily_closed(), and Parma_Polyhedra_Library::Constraint::zero_dim_positivity().
Referenced by Parma_Polyhedra_Library::Polyhedron::Polyhedron().
00181 { 00182 if (is_necessarily_closed()) 00183 // The positivity constraint. 00184 insert(Constraint::zero_dim_positivity()); 00185 else { 00186 // Add the epsilon constraints. 00187 insert(Constraint::epsilon_leq_one()); 00188 insert(Constraint::epsilon_geq_zero()); 00189 } 00190 }
| bool Parma_Polyhedra_Library::Constraint_System::adjust_topology_and_space_dimension | ( | Topology | topol, | |
| dimension_type | num_dimensions | |||
| ) | [private] |
Adjusts *this so that it matches the topology and the number of space dimensions given as parameters (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 51 of file Constraint_System.cc.
References Parma_Polyhedra_Library::Matrix::add_zero_columns(), Parma_Polyhedra_Library::Matrix::erase_to_end(), Parma_Polyhedra_Library::Linear_System::first_pending_row(), has_strict_inequalities(), Parma_Polyhedra_Library::Linear_System::is_sorted(), Parma_Polyhedra_Library::NECESSARILY_CLOSED, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, Parma_Polyhedra_Library::Matrix::num_columns(), Parma_Polyhedra_Library::Linear_System::num_pending_rows(), Parma_Polyhedra_Library::Matrix::num_rows(), OK(), Parma_Polyhedra_Library::Linear_System::remove_trailing_columns(), Parma_Polyhedra_Library::Linear_System::set_index_first_pending_row(), Parma_Polyhedra_Library::Linear_System::set_necessarily_closed(), Parma_Polyhedra_Library::Linear_System::set_not_necessarily_closed(), Parma_Polyhedra_Library::Linear_System::set_sorted(), Parma_Polyhedra_Library::Linear_System::sort_rows(), space_dimension(), Parma_Polyhedra_Library::swap(), swap(), Parma_Polyhedra_Library::Matrix::swap_columns(), Parma_Polyhedra_Library::Linear_System::topology(), and Parma_Polyhedra_Library::Linear_System::unset_pending_rows().
Referenced by Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::constraints(), and Parma_Polyhedra_Library::Polyhedron::Polyhedron().
00052 { 00053 PPL_ASSERT(space_dimension() <= new_space_dim); 00054 00055 const dimension_type old_space_dim = space_dimension(); 00056 const Topology old_topology = topology(); 00057 dimension_type cols_to_be_added = new_space_dim - old_space_dim; 00058 00059 // Dealing with empty constraint systems first. 00060 if (num_rows() == 0) { 00061 if (num_columns() == 0) 00062 if (new_topology == NECESSARILY_CLOSED) { 00063 add_zero_columns(++cols_to_be_added); 00064 set_necessarily_closed(); 00065 } 00066 else { 00067 cols_to_be_added += 2; 00068 add_zero_columns(cols_to_be_added); 00069 set_not_necessarily_closed(); 00070 } 00071 else 00072 // Here `num_columns() > 0'. 00073 if (old_topology != new_topology) 00074 if (new_topology == NECESSARILY_CLOSED) { 00075 switch (cols_to_be_added) { 00076 case 0: 00077 remove_trailing_columns(1); 00078 break; 00079 case 1: 00080 // Nothing to do. 00081 break; 00082 default: 00083 add_zero_columns(--cols_to_be_added); 00084 } 00085 set_necessarily_closed(); 00086 } 00087 else { 00088 // Here old_topology == NECESSARILY_CLOSED 00089 // and new_topology == NOT_NECESSARILY_CLOSED. 00090 add_zero_columns(++cols_to_be_added); 00091 set_not_necessarily_closed(); 00092 } 00093 else { 00094 // Here topologies agree. 00095 if (cols_to_be_added > 0) 00096 add_zero_columns(cols_to_be_added); 00097 } 00098 PPL_ASSERT(OK()); 00099 return true; 00100 } 00101 00102 // Here the constraint system is not empty. 00103 if (cols_to_be_added > 0) 00104 if (old_topology != new_topology) 00105 if (new_topology == NECESSARILY_CLOSED) { 00106 // A NOT_NECESSARILY_CLOSED constraint system 00107 // can be converted to a NECESSARILY_CLOSED one 00108 // only if it does not contain strict inequalities. 00109 if (has_strict_inequalities()) 00110 return false; 00111 // Since there were no strict inequalities, 00112 // the only constraints that may have a non-zero epsilon coefficient 00113 // are the eps-leq-one and the eps-geq-zero constraints. 00114 // If they are present, we erase these rows, so that the 00115 // epsilon column will only contain zeroes: as a consequence, 00116 // we just decrement the number of columns to be added. 00117 Constraint_System& cs = *this; 00118 const dimension_type eps_index = old_space_dim + 1; 00119 dimension_type cs_num_rows = cs.num_rows(); 00120 bool was_sorted = cs.is_sorted(); 00121 if (was_sorted) 00122 cs.set_sorted(false); 00123 00124 // If we have no pending rows, we only check if 00125 // we must erase some rows. 00126 if (cs.num_pending_rows() == 0) { 00127 for (dimension_type i = cs_num_rows; i-- > 0; ) 00128 if (cs[i][eps_index] != 0) { 00129 --cs_num_rows; 00130 std::swap(cs[i], cs[cs_num_rows]); 00131 } 00132 cs.erase_to_end(cs_num_rows); 00133 cs.unset_pending_rows(); 00134 } 00135 else { 00136 // There are pending rows, and we cannot swap them 00137 // into the non-pending part of the matrix. 00138 // Thus, we first work on the non-pending part as if it was 00139 // an independent matrix; then we work on the pending part. 00140 const dimension_type old_first_pending = cs.first_pending_row(); 00141 dimension_type new_first_pending = old_first_pending; 00142 for (dimension_type i = new_first_pending; i-- > 0; ) 00143 if (cs[i][eps_index] != 0) { 00144 --new_first_pending; 00145 std::swap(cs[i], cs[new_first_pending]); 00146 } 00147 const dimension_type num_swaps 00148 = old_first_pending - new_first_pending; 00149 cs.set_index_first_pending_row(new_first_pending); 00150 // Move the swapped rows to the real end of the matrix. 00151 for (dimension_type i = num_swaps; i-- > 0; ) 00152 std::swap(cs[old_first_pending - i], cs[cs_num_rows - i]); 00153 cs_num_rows -= num_swaps; 00154 // Now iterate through the pending rows. 00155 for (dimension_type i = cs_num_rows; i-- > new_first_pending; ) 00156 if (cs[i][eps_index] != 0) { 00157 --cs_num_rows; 00158 std::swap(cs[i], cs[cs_num_rows]); 00159 } 00160 cs.erase_to_end(cs_num_rows); 00161 } 00162 00163 // If `cs' was sorted we sort it again. 00164 if (was_sorted) 00165 cs.sort_rows(); 00166 if (--cols_to_be_added > 0) 00167 add_zero_columns(cols_to_be_added); 00168 set_necessarily_closed(); 00169 } 00170 else { 00171 // A NECESSARILY_CLOSED constraint system is converted to 00172 // a NOT_NECESSARILY_CLOSED one by adding a further column 00173 // of zeroes for the epsilon coefficients. 00174 add_zero_columns(++cols_to_be_added); 00175 set_not_necessarily_closed(); 00176 } 00177 else { 00178 // Topologies agree: first add the required zero columns ... 00179 add_zero_columns(cols_to_be_added); 00180 // ... and, if needed, move the epsilon coefficients 00181 // to the new last column. 00182 if (old_topology == NOT_NECESSARILY_CLOSED) 00183 swap_columns(old_space_dim + 1, new_space_dim + 1); 00184 } 00185 else 00186 // Here `cols_to_be_added == 0'. 00187 if (old_topology != new_topology) { 00188 if (new_topology == NECESSARILY_CLOSED) { 00189 // A NOT_NECESSARILY_CLOSED constraint system 00190 // can be converted to a NECESSARILY_CLOSED one 00191 // only if it does not contain strict inequalities. 00192 if (has_strict_inequalities()) 00193 return false; 00194 // We just remove the column of the epsilon coefficients. 00195 remove_trailing_columns(1); 00196 set_necessarily_closed(); 00197 } 00198 else { 00199 // We just add the column of the epsilon coefficients. 00200 add_zero_columns(1); 00201 set_not_necessarily_closed(); 00202 } 00203 } 00204 // We successfully adjusted space dimensions and topology. 00205 PPL_ASSERT(OK()); 00206 return true; 00207 }
| void Parma_Polyhedra_Library::Constraint_System::affine_preimage | ( | dimension_type | v, | |
| const Linear_Expression & | expr, | |||
| Coefficient_traits::const_reference | denominator | |||
| ) | [private] |
Substitutes a given column of coefficients by a given affine expression.
| v | Index of the column to which the affine transformation is substituted. | |
| expr | The numerator of the affine transformation: ; | |
| denominator | The 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
are built from the old one
as follows:
expr is a constant parameter and unaltered by this computation.
Definition at line 424 of file Constraint_System.cc.
References Parma_Polyhedra_Library::add_mul_assign(), Parma_Polyhedra_Library::Matrix::num_columns(), Parma_Polyhedra_Library::Matrix::num_rows(), Parma_Polyhedra_Library::Row::size(), Parma_Polyhedra_Library::Linear_Expression::space_dimension(), space_dimension(), and Parma_Polyhedra_Library::Linear_System::strong_normalize().
Referenced by Parma_Polyhedra_Library::Polyhedron::affine_image(), and Parma_Polyhedra_Library::Polyhedron::affine_preimage().
00426 { 00427 Constraint_System& x = *this; 00428 // `v' is the index of a column corresponding to 00429 // a "user" variable (i.e., it cannot be the inhomogeneous term, 00430 // nor the epsilon dimension of NNC polyhedra). 00431 PPL_ASSERT(v > 0 && v <= x.space_dimension()); 00432 PPL_ASSERT(expr.space_dimension() <= x.space_dimension()); 00433 PPL_ASSERT(denominator > 0); 00434 00435 const dimension_type n_columns = x.num_columns(); 00436 const dimension_type n_rows = x.num_rows(); 00437 const dimension_type expr_size = expr.size(); 00438 const bool not_invertible = (v >= expr_size || expr[v] == 0); 00439 00440 if (denominator != 1) 00441 for (dimension_type i = n_rows; i-- > 0; ) { 00442 Constraint& row = x[i]; 00443 Coefficient& row_v = row[v]; 00444 if (row_v != 0) { 00445 for (dimension_type j = n_columns; j-- > 0; ) 00446 if (j != v) { 00447 Coefficient& row_j = row[j]; 00448 row_j *= denominator; 00449 if (j < expr_size) 00450 add_mul_assign(row_j, row_v, expr[j]); 00451 } 00452 if (not_invertible) 00453 row_v = 0; 00454 else 00455 row_v *= expr[v]; 00456 } 00457 } 00458 else 00459 // Here `denominator' == 1: optimized computation 00460 // only considering columns having indexes < expr_size. 00461 for (dimension_type i = n_rows; i-- > 0; ) { 00462 Constraint& row = x[i]; 00463 Coefficient& row_v = row[v]; 00464 if (row_v != 0) { 00465 for (dimension_type j = expr_size; j-- > 0; ) 00466 if (j != v) 00467 add_mul_assign(row[j], row_v, expr[j]); 00468 if (not_invertible) 00469 row_v = 0; 00470 else 00471 row_v *= expr[v]; 00472 } 00473 } 00474 // Strong normalization also resets the sortedness flag. 00475 x.strong_normalize(); 00476 }
| void Parma_Polyhedra_Library::Constraint_System::ascii_dump | ( | std::ostream & | s | ) | const |
Writes to s an ASCII representation of *this.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Definition at line 479 of file Constraint_System.cc.
References Parma_Polyhedra_Library::Constraint::EQUALITY, Parma_Polyhedra_Library::Linear_System::first_pending_row(), Parma_Polyhedra_Library::Linear_System::is_necessarily_closed(), Parma_Polyhedra_Library::Linear_System::is_sorted(), Parma_Polyhedra_Library::Constraint::NONSTRICT_INEQUALITY, Parma_Polyhedra_Library::Matrix::num_columns(), Parma_Polyhedra_Library::Matrix::num_rows(), Parma_Polyhedra_Library::Constraint::STRICT_INEQUALITY, and Parma_Polyhedra_Library::Constraint::type().
00479 { 00480 const Constraint_System& x = *this; 00481 const dimension_type x_num_rows = x.num_rows(); 00482 const dimension_type x_num_columns = x.num_columns(); 00483 s << "topology " << (is_necessarily_closed() 00484 ? "NECESSARILY_CLOSED" 00485 : "NOT_NECESSARILY_CLOSED") 00486 << "\n" 00487 << x_num_rows << " x " << x_num_columns << ' ' 00488 << (x.is_sorted() ? "(sorted)" : "(not_sorted)") 00489 << "\n" 00490 << "index_first_pending " << x.first_pending_row() 00491 << "\n"; 00492 for (dimension_type i = 0; i < x_num_rows; ++i) { 00493 const Constraint& c = x[i]; 00494 for (dimension_type j = 0; j < x_num_columns; ++j) 00495 s << c[j] << ' '; 00496 switch (c.type()) { 00497 case Constraint::EQUALITY: 00498 s << "="; 00499 break; 00500 case Constraint::NONSTRICT_INEQUALITY: 00501 s << ">="; 00502 break; 00503 case Constraint::STRICT_INEQUALITY: 00504 s << ">"; 00505 break; 00506 } 00507 s << "\n"; 00508 } 00509 }
| void Parma_Polyhedra_Library::Constraint_System::ascii_dump | ( | ) | const |
Writes to std::cerr an ASCII representation of *this.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Referenced by Parma_Polyhedra_Library::Polyhedron::ascii_dump(), 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.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Definition at line 514 of file Constraint_System.cc.
References Parma_Polyhedra_Library::Constraint::EQUALITY, Parma_Polyhedra_Library::Constraint::NONSTRICT_INEQUALITY, Parma_Polyhedra_Library::Matrix::num_columns(), Parma_Polyhedra_Library::Matrix::num_rows(), and Parma_Polyhedra_Library::Constraint::STRICT_INEQUALITY.
Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::ascii_load().
00514 { 00515 std::string str; 00516 if (!(s >> str) || str != "topology") 00517 return false; 00518 if (!(s >> str)) 00519 return false; 00520 if (str == "NECESSARILY_CLOSED") 00521 set_necessarily_closed(); 00522 else { 00523 if (str != "NOT_NECESSARILY_CLOSED") 00524 return false; 00525 set_not_necessarily_closed(); 00526 } 00527 00528 dimension_type nrows; 00529 dimension_type ncols; 00530 if (!(s >> nrows)) 00531 return false; 00532 if (!(s >> str) || str != "x") 00533 return false; 00534 if (!(s >> ncols)) 00535 return false; 00536 resize_no_copy(nrows, ncols); 00537 00538 if (!(s >> str) || (str != "(sorted)" && str != "(not_sorted)")) 00539 return false; 00540 set_sorted(str == "(sorted)"); 00541 dimension_type index; 00542 if (!(s >> str) || str != "index_first_pending") 00543 return false; 00544 if (!(s >> index)) 00545 return false; 00546 set_index_first_pending_row(index); 00547 00548 Constraint_System& x = *this; 00549 for (dimension_type i = 0; i < x.num_rows(); ++i) { 00550 for (dimension_type j = 0; j < x.num_columns(); ++j) 00551 if (!(s >> x[i][j])) 00552 return false; 00553 00554 if (!(s >> str)) 00555 return false; 00556 if (str == "=") 00557 x[i].set_is_equality(); 00558 else if (str == ">=" || str == ">") 00559 x[i].set_is_inequality(); 00560 else 00561 return false; 00562 00563 // Checking for equality of actual and declared types. 00564 switch (x[i].type()) { 00565 case Constraint::EQUALITY: 00566 if (str == "=") 00567 continue; 00568 break; 00569 case Constraint::NONSTRICT_INEQUALITY: 00570 if (str == ">=") 00571 continue; 00572 break; 00573 case Constraint::STRICT_INEQUALITY: 00574 if (str == ">") 00575 continue; 00576 break; 00577 } 00578 // Reaching this point means that the input was illegal. 00579 return false; 00580 } 00581 // Check invariants. 00582 PPL_ASSERT(OK()); 00583 return true; 00584 }
| 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.
Reimplemented from Parma_Polyhedra_Library::Matrix.
Definition at line 163 of file Constraint_System.inlines.hh.
References Parma_Polyhedra_Library::Matrix::begin().
Referenced by Parma_Polyhedra_Library::PIP_Problem::add_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_constraints(), Parma_Polyhedra_Library::MIP_Problem::add_constraints(), Parma_Polyhedra_Library::Grid::add_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::add_constraints(), Parma_Polyhedra_Library::Box< ITV >::add_constraints_no_check(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::affine_dimension(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::affine_dimension(), Parma_Polyhedra_Library::Implementation::Termination::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::H79_Certificate::compare(), Parma_Polyhedra_Library::BHRZ03_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::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(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::PIP_Decision_Node::OK(), Parma_Polyhedra_Library::PIP_Tree_Node::OK(), 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::Octagonal_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::Grid::refine_with_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), Parma_Polyhedra_Library::PIP_Decision_Node::solve(), and Parma_Polyhedra_Library::Box< ITV >::wrap_assign().
00163 { 00164 const_iterator i(Linear_System::begin(), *this); 00165 i.skip_forward(); 00166 return i; 00167 }
| void Parma_Polyhedra_Library::Constraint_System::clear | ( | ) | [inline] |
Removes all the constraints from the constraint system and sets its space dimension to 0.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Definition at line 90 of file Constraint_System.inlines.hh.
Referenced by Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_project(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_combining_constraints(), Parma_Polyhedra_Library::Polyhedron::map_space_dimensions(), Parma_Polyhedra_Library::Shape_Preserving_Reduction< D1, D2 >::product_reduce(), Parma_Polyhedra_Library::Polyhedron::remove_higher_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::remove_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::set_empty(), and Parma_Polyhedra_Library::Polyhedron::set_zero_dim_univ().
00090 { 00091 Linear_System::clear(); 00092 }
| bool Parma_Polyhedra_Library::Constraint_System::empty | ( | ) | const [inline] |
Returns true if and only if *this has no constraints.
Definition at line 176 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_Solution_Node::print_tree(), Parma_Polyhedra_Library::PIP_Tree_Node::print_tree(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().
| Constraint_System::const_iterator Parma_Polyhedra_Library::Constraint_System::end | ( | ) | const [inline] |
Returns the past-the-end const_iterator.
Reimplemented from Parma_Polyhedra_Library::Matrix.
Definition at line 170 of file Constraint_System.inlines.hh.
References Parma_Polyhedra_Library::Matrix::end().
Referenced by Parma_Polyhedra_Library::PIP_Problem::add_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::add_constraints(), Parma_Polyhedra_Library::MIP_Problem::add_constraints(), Parma_Polyhedra_Library::Grid::add_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::add_constraints(), Parma_Polyhedra_Library::Box< ITV >::add_constraints_no_check(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), Parma_Polyhedra_Library::Polyhedron::affine_dimension(), Parma_Polyhedra_Library::Pointset_Powerset< PSET >::affine_dimension(), Parma_Polyhedra_Library::Implementation::Termination::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::H79_Certificate::compare(), Parma_Polyhedra_Library::BHRZ03_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::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(), Parma_Polyhedra_Library::Octagonal_Shape< T >::Octagonal_Shape(), Parma_Polyhedra_Library::PIP_Decision_Node::OK(), Parma_Polyhedra_Library::PIP_Tree_Node::OK(), 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::Octagonal_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::Grid::refine_with_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), Parma_Polyhedra_Library::PIP_Decision_Node::solve(), and Parma_Polyhedra_Library::Box< ITV >::wrap_assign().
00170 { 00171 const const_iterator i(Linear_System::end(), *this); 00172 return i; 00173 }
| 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.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Definition at line 198 of file Constraint_System.inlines.hh.
Referenced by Parma_Polyhedra_Library::Polyhedron::external_memory_in_bytes(), and Parma_Polyhedra_Library::PIP_Tree_Node::external_memory_in_bytes().
00198 { 00199 return Linear_System::external_memory_in_bytes(); 00200 }
| void Parma_Polyhedra_Library::Constraint_System::finalize | ( | ) | [static] |
Finalizes the class.
Definition at line 596 of file Constraint_System.cc.
References zero_dim_empty_p.
00596 { 00597 PPL_ASSERT(zero_dim_empty_p != 0); 00598 delete zero_dim_empty_p; 00599 zero_dim_empty_p = 0; 00600 }
| 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 210 of file Constraint_System.cc.
References Parma_Polyhedra_Library::Matrix::num_rows().
Referenced by Parma_Polyhedra_Library::Implementation::Termination::assign_all_inequalities_approximation().
00210 { 00211 const Constraint_System& cs = *this; 00212 // We verify if the system has equalities also in the pending part. 00213 for (dimension_type i = cs.num_rows(); i-- > 0; ) 00214 if (cs[i].is_equality()) 00215 return true; 00216 return false; 00217 }
| 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 220 of file Constraint_System.cc.
References Parma_Polyhedra_Library::Linear_System::is_necessarily_closed(), Parma_Polyhedra_Library::Constraint::is_tautological(), Parma_Polyhedra_Library::Matrix::num_columns(), and Parma_Polyhedra_Library::Matrix::num_rows().
Referenced by Parma_Polyhedra_Library::MIP_Problem::add_constraints(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), adjust_topology_and_space_dimension(), 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::Polyhedron::is_topologically_closed(), 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().
00220 { 00221 if (is_necessarily_closed()) 00222 return false; 00223 const Constraint_System& cs = *this; 00224 const dimension_type eps_index = cs.num_columns() - 1; 00225 // We verify if the system has strict inequalities 00226 // also in the pending part. 00227 for (dimension_type i = cs.num_rows(); i-- > 0; ) { 00228 const Constraint& c = cs[i]; 00229 // Optimized type checking: we already know the topology; 00230 // also, equalities have the epsilon coefficient equal to zero. 00231 // NOTE: the constraint eps_leq_one should not be considered 00232 // a strict inequality. 00233 if (c[eps_index] < 0 && !c.is_tautological()) 00234 return true; 00235 } 00236 return false; 00237 }
| void Parma_Polyhedra_Library::Constraint_System::initialize | ( | ) | [static] |
Initializes the class.
Definition at line 589 of file Constraint_System.cc.
References Constraint_System(), zero_dim_empty_p, and Parma_Polyhedra_Library::Constraint::zero_dim_false().
00589 { 00590 PPL_ASSERT(zero_dim_empty_p == 0); 00591 zero_dim_empty_p 00592 = new Constraint_System(Constraint::zero_dim_false()); 00593 }
| 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 240 of file Constraint_System.cc.
References Parma_Polyhedra_Library::Matrix::add_zero_columns(), Parma_Polyhedra_Library::Linear_System::insert(), Parma_Polyhedra_Library::Linear_System::is_necessarily_closed(), Parma_Polyhedra_Library::Linear_System::num_pending_rows(), OK(), Parma_Polyhedra_Library::Linear_System::set_not_necessarily_closed(), space_dimension(), Parma_Polyhedra_Library::Constraint::space_dimension(), Parma_Polyhedra_Library::Linear_Row::topology(), and Parma_Polyhedra_Library::Linear_System::topology().
Referenced by Parma_Polyhedra_Library::Polyhedron::add_congruences(), add_low_level_constraints(), Parma_Polyhedra_Library::Implementation::Termination::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::Partially_Reduced_Product< D1, D2, R >::constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::constraints(), Parma_Polyhedra_Library::Box< ITV >::constraints(), Parma_Polyhedra_Library::BD_Shape< T >::constraints(), Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points(), Parma_Polyhedra_Library::Polyhedron::expand_space_dimension(), Parma_Polyhedra_Library::Polyhedron::limited_BHRZ03_extrapolation_assign(), Parma_Polyhedra_Library::Polyhedron::limited_H79_extrapolation_assign(), Parma_Polyhedra_Library::Partially_Reduced_Product< D1, D2, R >::minimized_constraints(), Parma_Polyhedra_Library::Box< ITV >::minimized_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::minimized_constraints(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::Shape_Preserving_Reduction< D1, D2 >::product_reduce(), Parma_Polyhedra_Library::Polyhedron::refine_no_check(), Parma_Polyhedra_Library::Polyhedron::refine_with_congruences(), Parma_Polyhedra_Library::Polyhedron::refine_with_constraints(), 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(), and Parma_Polyhedra_Library::Polyhedron::topological_closure_assign().
00240 { 00241 // We are sure that the matrix has no pending rows 00242 // and that the new row is not a pending constraint. 00243 PPL_ASSERT(num_pending_rows() == 0); 00244 if (topology() == c.topology()) 00245 Linear_System::insert(c); 00246 else 00247 // `*this' and `c' have different topologies. 00248 if (is_necessarily_closed()) { 00249 // Padding the matrix with a columns of zeroes 00250 // corresponding to the epsilon coefficients. 00251 add_zero_columns(1); 00252 set_not_necessarily_closed(); 00253 Linear_System::insert(c); 00254 } 00255 else { 00256 // Here `*this' is NNC and `c' is necessarily closed. 00257 // Copying the constraint adding the epsilon coefficient 00258 // and the missing space dimensions, if any. 00259 // FIXME: provide a resizing copy constructor taking 00260 // topology and the space dimension. 00261 const dimension_type new_size = 2 + std::max(c.space_dimension(), 00262 space_dimension()); 00263 Constraint tmp_c(c, new_size); 00264 tmp_c.set_not_necessarily_closed(); 00265 Linear_System::insert(tmp_c); 00266 } 00267 PPL_ASSERT(OK()); 00268 }
| 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 271 of file Constraint_System.cc.
References Parma_Polyhedra_Library::Matrix::add_zero_columns(), Parma_Polyhedra_Library::Linear_System::insert_pending(), Parma_Polyhedra_Library::Linear_System::is_necessarily_closed(), OK(), Parma_Polyhedra_Library::Linear_System::set_not_necessarily_closed(), space_dimension(), Parma_Polyhedra_Library::Constraint::space_dimension(), Parma_Polyhedra_Library::Linear_Row::topology(), and Parma_Polyhedra_Library::Linear_System::topology().
Referenced by Parma_Polyhedra_Library::Polyhedron::refine_no_check(), and Parma_Polyhedra_Library::Polyhedron::refine_with_constraints().
00271 { 00272 if (topology() == c.topology()) 00273 Linear_System::insert_pending(c); 00274 else 00275 // `*this' and `c' have different topologies. 00276 if (is_necessarily_closed()) { 00277 // Padding the matrix with a columns of zeroes 00278 // corresponding to the epsilon coefficients. 00279 add_zero_columns(1); 00280 set_not_necessarily_closed(); 00281 Linear_System::insert_pending(c); 00282 } 00283 else { 00284 // Here `*this' is NNC and `c' is necessarily closed. 00285 // Copying the constraint adding the epsilon coefficient 00286 // and the missing space dimensions, if any. 00287 const dimension_type new_size = 2 + std::max(c.space_dimension(), 00288 space_dimension()); 00289 Constraint tmp_c(c, new_size); 00290 tmp_c.set_not_necessarily_closed(); 00291 Linear_System::insert_pending(tmp_c); 00292 } 00293 PPL_ASSERT(OK()); 00294 }
| dimension_type Parma_Polyhedra_Library::Constraint_System::max_space_dimension | ( | ) | [inline, static] |
Returns the maximum space dimension a Constraint_System can handle.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Definition at line 80 of file Constraint_System.inlines.hh.
Referenced by Parma_Polyhedra_Library::Polyhedron::max_space_dimension().
00080 { 00081 return Linear_System::max_space_dimension(); 00082 }
| PPL::dimension_type Parma_Polyhedra_Library::Constraint_System::num_equalities | ( | ) | const [private] |
Returns the number of equality constraints.
Definition at line 316 of file Constraint_System.cc.
References num_inequalities(), Parma_Polyhedra_Library::Linear_System::num_pending_rows(), and Parma_Polyhedra_Library::Matrix::num_rows().
Referenced by Parma_Polyhedra_Library::Polyhedron::H79_widening_assign(), Parma_Polyhedra_Library::Polyhedron::OK(), Parma_Polyhedra_Library::Polyhedron::quick_equivalence_test(), and Parma_Polyhedra_Library::Polyhedron::strongly_minimize_generators().
00316 { 00317 // We are sure that we call this method only when 00318 // the matrix has no pending rows. 00319 PPL_ASSERT(num_pending_rows() == 0); 00320 return num_rows() - num_inequalities(); 00321 }
| PPL::dimension_type Parma_Polyhedra_Library::Constraint_System::num_inequalities | ( | ) | const [private] |
Returns the number of inequality constraints.
Definition at line 297 of file Constraint_System.cc.
References Parma_Polyhedra_Library::Linear_System::is_sorted(), Parma_Polyhedra_Library::Linear_System::num_pending_rows(), and Parma_Polyhedra_Library::Matrix::num_rows().
Referenced by num_equalities().
00297 { 00298 // We are sure that we call this method only when 00299 // the matrix has no pending rows. 00300 PPL_ASSERT(num_pending_rows() == 0); 00301 const Constraint_System& cs = *this; 00302 dimension_type n = 0; 00303 // If the Linear_System happens to be sorted, take advantage of the fact 00304 // that inequalities are at the bottom of the system. 00305 if (is_sorted()) 00306 for (dimension_type i = num_rows(); i > 0 && cs[--i].is_inequality(); ) 00307 ++n; 00308 else 00309 for (dimension_type i = num_rows(); i-- > 0 ; ) 00310 if (cs[i].is_inequality()) 00311 ++n; 00312 return n; 00313 }
| bool Parma_Polyhedra_Library::Constraint_System::OK | ( | ) | const |
Checks if all the invariants are satisfied.
Returns true if and only if *this is a valid Linear_System and each row in the system is a valid Constraint.
Reimplemented from Parma_Polyhedra_Library::Matrix.
Definition at line 603 of file Constraint_System.cc.
References Parma_Polyhedra_Library::Matrix::num_rows(), and Parma_Polyhedra_Library::Matrix::OK().
Referenced by adjust_topology_and_space_dimension(), insert(), insert_pending(), and Parma_Polyhedra_Library::Polyhedron::OK().
00603 { 00604 // A Constraint_System must be a valid Linear_System; do not check for 00605 // strong normalization, since this will be done when 00606 // checking each individual constraint. 00607 if (!Linear_System::OK(false)) 00608 return false; 00609 00610 // Checking each constraint in the system. 00611 const Constraint_System& x = *this; 00612 for (dimension_type i = num_rows(); i-- > 0; ) 00613 if (!x[i].OK()) 00614 return false; 00615 00616 // All checks passed. 00617 return true; 00618 }
| Constraint_System & Parma_Polyhedra_Library::Constraint_System::operator= | ( | const Constraint_System & | y | ) | [inline] |
Assignment operator.
Definition at line 64 of file Constraint_System.inlines.hh.
00064 { 00065 Linear_System::operator=(y); 00066 return *this; 00067 }
| const Constraint & Parma_Polyhedra_Library::Constraint_System::operator[] | ( | dimension_type | k | ) | const [inline, private] |
Returns a constant reference to the k- th constraint of the system.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Definition at line 75 of file Constraint_System.inlines.hh.
References operator[]().
00075 { 00076 return static_cast<const Constraint&>(Linear_System::operator[](k)); 00077 }
| Constraint & Parma_Polyhedra_Library::Constraint_System::operator[] | ( | dimension_type | k | ) | [inline, private] |
Returns the k- th constraint of the system.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Definition at line 70 of file Constraint_System.inlines.hh.
Referenced by operator[]().
00070 { 00071 return static_cast<Constraint&>(Linear_System::operator[](k)); 00072 }
| void Parma_Polyhedra_Library::Constraint_System::print | ( | ) | const |
Prints *this to std::cerr using operator<<.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
| 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 331 of file Constraint_System.cc.
References 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::Linear_System::is_necessarily_closed(), Parma_Polyhedra_Library::Generator::LINE, Parma_Polyhedra_Library::Constraint::NONSTRICT_INEQUALITY, Parma_Polyhedra_Library::Matrix::num_rows(), Parma_Polyhedra_Library::Generator::POINT, Parma_Polyhedra_Library::Generator::RAY, space_dimension(), Parma_Polyhedra_Library::Generator::space_dimension(), Parma_Polyhedra_Library::Constraint::STRICT_INEQUALITY, Parma_Polyhedra_Library::Constraint::type(), and Parma_Polyhedra_Library::Generator::type().
Referenced by Parma_Polyhedra_Library::Polyhedron::relation_with().
00331 { 00332 PPL_ASSERT(g.space_dimension() <= space_dimension()); 00333 00334 // Setting `sps' to the appropriate scalar product sign operator. 00335 // This also avoids problems when having _legal_ topology mismatches 00336 // (which could also cause a mismatch in the number of columns). 00337 Topology_Adjusted_Scalar_Product_Sign sps(g); 00338 00339 const Constraint_System& cs = *this; 00340 if (cs.is_necessarily_closed()) { 00341 if (g.is_line()) { 00342 // Lines must saturate all constraints. 00343 for (dimension_type i = cs.num_rows(); i-- > 0; ) 00344 if (sps(g, cs[i]) != 0) 00345 return false; 00346 } 00347 else 00348 // `g' is either a ray, a point or a closure point. 00349 for (dimension_type i = cs.num_rows(); i-- > 0; ) { 00350 const Constraint& c = cs[i]; 00351 const int sp_sign = sps(g, c); 00352 if (c.is_inequality()) { 00353 // As `cs' is necessarily closed, 00354 // `c' is a non-strict inequality. 00355 if (sp_sign < 0) 00356 return false; 00357 } 00358 else 00359 // `c' is an equality. 00360 if (sp_sign != 0) 00361 return false; 00362 } 00363 } 00364 else 00365 // `cs' is not necessarily closed. 00366 switch (g.type()) { 00367 00368 case Generator::LINE: 00369 // Lines must saturate all constraints. 00370 for (dimension_type i = cs.num_rows(); i-- > 0; ) 00371 if (sps(g, cs[i]) != 0) 00372 return false; 00373 break; 00374 00375 case Generator::POINT: 00376 // Have to perform the special test 00377 // when dealing with a strict inequality. 00378 for (dimension_type i = cs.num_rows(); i-- > 0; ) { 00379 const Constraint& c = cs[i]; 00380 const int sp_sign = sps(g, c); 00381 switch (c.type()) { 00382 case Constraint::EQUALITY: 00383 if (sp_sign != 0) 00384 return false; 00385 break; 00386 case Constraint::NONSTRICT_INEQUALITY: 00387 if (sp_sign < 0) 00388 return false; 00389 break; 00390 case Constraint::STRICT_INEQUALITY: 00391 if (sp_sign <= 0) 00392 return false; 00393 break; 00394 } 00395 } 00396 break; 00397 00398 case Generator::RAY: 00399 // Intentionally fall through. 00400 case Generator::CLOSURE_POINT: 00401 for (dimension_type i = cs.num_rows(); i-- > 0; ) { 00402 const Constraint& c = cs[i]; 00403 const int sp_sign = sps(g, c); 00404 if (c.is_inequality()) { 00405 // Constraint `c' is either a strict or a non-strict inequality. 00406 if (sp_sign < 0) 00407 return false; 00408 } 00409 else 00410 // Constraint `c' is an equality. 00411 if (sp_sign != 0) 00412 return false; 00413 } 00414 break; 00415 } 00416 00417 // If we reach this point, `g' satisfies all constraints. 00418 return true; 00419 }
| void Parma_Polyhedra_Library::Constraint_System::simplify | ( | ) | [inline, private] |
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.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Definition at line 208 of file Constraint_System.inlines.hh.
Referenced by Parma_Polyhedra_Library::Polyhedron::OK(), and Parma_Polyhedra_Library::Polyhedron::simplified_constraints().
00208 { 00209 Linear_System::simplify(); 00210 }
| dimension_type Parma_Polyhedra_Library::Constraint_System::space_dimension | ( | ) | const [inline] |
Returns the dimension of the vector space enclosing *this.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Definition at line 85 of file Constraint_System.inlines.hh.
Referenced by Parma_Polyhedra_Library::MIP_Problem::add_constraints(), Parma_Polyhedra_Library::Grid::add_constraints(), Parma_Polyhedra_Library::Box< ITV >::add_constraints(), Parma_Polyhedra_Library::Box< ITV >::add_constraints_no_check(), Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), adjust_topology_and_space_dimension(), affine_preimage(), Parma_Polyhedra_Library::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_combining_constraints(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::Polyhedron::constraints(), 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(), insert(), insert_pending(), 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::Box< ITV >::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::Polyhedron::OK(), 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::Polyhedron::refine_with_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::refine_with_constraints(), Parma_Polyhedra_Library::Grid::refine_with_constraints(), Parma_Polyhedra_Library::Box< ITV >::refine_with_constraints(), Parma_Polyhedra_Library::BD_Shape< T >::refine_with_constraints(), satisfies_all_constraints(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), Parma_Polyhedra_Library::Polyhedron::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid::throw_dimension_incompatible(), Parma_Polyhedra_Library::Box< ITV >::throw_dimension_incompatible(), Parma_Polyhedra_Library::Grid::wrap_assign(), and Parma_Polyhedra_Library::Box< ITV >::wrap_assign().
00085 { 00086 return Linear_System::space_dimension(); 00087 }
| void Parma_Polyhedra_Library::Constraint_System::swap | ( | Constraint_System & | y | ) | [inline] |
Swaps *this with y.
Definition at line 193 of file Constraint_System.inlines.hh.
Referenced by adjust_topology_and_space_dimension(), Parma_Polyhedra_Library::Polyhedron::Polyhedron(), Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), Parma_Polyhedra_Library::PIP_Decision_Node::solve(), and swap().
00193 { 00194 Linear_System::swap(y); 00195 }
| 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.
Reimplemented from Parma_Polyhedra_Library::Linear_System.
Definition at line 203 of file Constraint_System.inlines.hh.
00203 { 00204 return Linear_System::total_memory_in_bytes(); 00205 }
| const Constraint_System & Parma_Polyhedra_Library::Constraint_System::zero_dim_empty | ( | ) | [inline, static] |
Returns the singleton system containing only Constraint::zero_dim_false().
Definition at line 95 of file Constraint_System.inlines.hh.
References zero_dim_empty_p.
Referenced by Parma_Polyhedra_Library::Polyhedron::constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::constraints(), Parma_Polyhedra_Library::Box< ITV >::constraints(), Parma_Polyhedra_Library::BD_Shape< T >::constraints(), Parma_Polyhedra_Library::Box< ITV >::minimized_constraints(), and Parma_Polyhedra_Library::BD_Shape< T >::minimized_constraints().
00095 { 00096 PPL_ASSERT(zero_dim_empty_p != 0); 00097 return *zero_dim_empty_p; 00098 }
friend class const_iterator [friend] |
Definition at line 311 of file Constraint_System.defs.hh.
| 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 ", ".
Definition at line 622 of file Constraint_System.cc.
References begin(), and end().
00622 { 00623 Constraint_System::const_iterator i = cs.begin(); 00624 const Constraint_System::const_iterator cs_end = cs.end(); 00625 if (i == cs_end) 00626 s << "true"; 00627 else { 00628 while (i != cs_end) { 00629 s << *i++; 00630 if (i != cs_end) 00631 s << ", "; 00632 } 00633 } 00634 return s; 00635 }
| bool operator== | ( | const Polyhedron & | x, | |
| const Polyhedron & | y | |||
| ) | [friend] |
Returns true if and only if x and y are the same polyhedron.
Note that x and y may be topology- and/or dimension-incompatible polyhedra: in those cases, the value false is returned.
Definition at line 3613 of file Polyhedron_public.cc.
03613 { 03614 // If the two polyhedra are topology-incompatible or dimension-incompatible, 03615 // then they cannot be the same polyhedron. 03616 if (x.topology() != y.topology() || x.space_dim != y.space_dim) 03617 return false; 03618 03619 if (x.marked_empty()) 03620 return y.is_empty(); 03621 else if (y.marked_empty()) 03622 return x.is_empty(); 03623 else if (x.space_dim == 0) 03624 return true; 03625 03626 switch (x.quick_equivalence_test(y)) { 03627 case Polyhedron::TVB_TRUE: 03628 return true; 03629 03630 case Polyhedron::TVB_FALSE: 03631 return false; 03632 03633 default: 03634 if (x.is_included_in(y)) 03635 if (x.marked_empty()) 03636 return y.is_empty(); 03637 else 03638 return y.is_included_in(x); 03639 else 03640 return false; 03641 } 03642 }
friend class Parma_Polyhedra_Library::Polyhedron [friend] |
Definition at line 312 of file Constraint_System.defs.hh.
| void swap | ( | Parma_Polyhedra_Library::Constraint_System & | x, | |
| Parma_Polyhedra_Library::Constraint_System & | y | |||
| ) | [related] |
Specializes std::swap.
Definition at line 219 of file Constraint_System.inlines.hh.
References swap().
00220 { 00221 x.swap(y); 00222 }
const PPL::Constraint_System * Parma_Polyhedra_Library::Constraint_System::zero_dim_empty_p = 0 [static, private] |
Holds (between class initialization and finalization) a pointer to the singleton system containing only Constraint::zero_dim_false().
Definition at line 309 of file Constraint_System.defs.hh.
Referenced by finalize(), initialize(), and zero_dim_empty().
1.6.3