The type for parametric simplex tableau. More...

Public Member Functions | |
| Tableau () | |
| Default constructor. | |
| Tableau (const Tableau &y) | |
| Copy constructor. | |
| ~Tableau () | |
| Destructor. | |
| bool | is_integer () const |
| Tests whether the matrix is integer, i.e., the denominator is 1. | |
| void | scale (Coefficient_traits::const_reference ratio) |
| Multiplies all coefficients and denominator with ratio. | |
| void | normalize () |
| Normalizes the modulo of coefficients so that they are mutually prime. | |
| bool | is_better_pivot (const std::vector< dimension_type > &mapping, const std::vector< bool > &basis, const dimension_type i, const dimension_type j, const dimension_type i_, const dimension_type j_) const |
| Compares two pivot row and column pairs before pivoting. | |
| Coefficient_traits::const_reference | denominator () const |
| Returns the value of the denominator. | |
| void | ascii_dump (std::ostream &s) const |
Dumps to s an ASCII representation of *this. | |
| 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 | external_memory_in_bytes () const |
Returns the size in bytes of the memory managed by *this. | |
| bool | OK () const |
Returns true if and only if *this is well formed. | |
Public Attributes | |
| Matrix | s |
| The matrix of simplex coefficients. | |
| Matrix | t |
| The matrix of parameter coefficients. | |
| Coefficient | denom |
| A common denominator for all matrix elements. | |
The type for parametric simplex tableau.
Definition at line 393 of file PIP_Tree.defs.hh.
| Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::Tableau | ( | ) | [inline] |
| Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::Tableau | ( | const Tableau & | y | ) | [inline] |
| Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::~Tableau | ( | ) | [inline] |
| void Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::ascii_dump | ( | std::ostream & | s | ) | const |
Dumps to s an ASCII representation of *this.
Definition at line 1232 of file PIP_Tree.cc.
References Parma_Polyhedra_Library::Matrix::ascii_dump(), denom, s, and t.
| bool Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::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 1241 of file PIP_Tree.cc.
References Parma_Polyhedra_Library::Matrix::ascii_load(), denom, OK(), s, and t.
01241 { 01242 std::string str; 01243 if (!(st >> str) || str != "denominator") 01244 return false; 01245 Coefficient den; 01246 if (!(st >> den)) 01247 return false; 01248 denom = den; 01249 if (!(st >> str) || str != "variables") 01250 return false; 01251 if (!s.ascii_load(st)) 01252 return false; 01253 if (!(st >> str) || str != "parameters") 01254 return false; 01255 if (!t.ascii_load(st)) 01256 return false; 01257 PPL_ASSERT(OK()); 01258 return true; 01259 }
| Coefficient_traits::const_reference Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::denominator | ( | ) | const [inline] |
Returns the value of the denominator.
Definition at line 51 of file PIP_Tree.inlines.hh.
References denom.
00051 { 00052 return denom; 00053 }
| memory_size_type Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::external_memory_in_bytes | ( | ) | const |
Returns the size in bytes of the memory managed by *this.
total_memory_in_bytes() method, since class Tableau is a private inner class of PIP_Solution_Node. Definition at line 2878 of file PIP_Tree.cc.
References denom, Parma_Polyhedra_Library::Matrix::external_memory_in_bytes(), s, and t.
02878 { 02879 return Parma_Polyhedra_Library::external_memory_in_bytes(denom) 02880 + s.external_memory_in_bytes() 02881 + t.external_memory_in_bytes(); 02882 }
| bool Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::is_better_pivot | ( | const std::vector< dimension_type > & | mapping, | |
| const std::vector< bool > & | basis, | |||
| const dimension_type | i, | |||
| const dimension_type | j, | |||
| const dimension_type | i_, | |||
| const dimension_type | j_ | |||
| ) | const |
Compares two pivot row and column pairs before pivoting.
The algorithm searches the first (ie, leftmost) column
in parameter matrix for which the
and
columns are different, where
denotes the
th column from the
matrix and
is the
th column of
.
is the computed column that would be subtracted to column
in parameter matrix if pivoting is done using the
row and column pair.
is the computed column that would be subtracted to column
in parameter matrix if pivoting is done using the
row and column pair.
The test is true if the computed
column is lexicographically bigger than the
column. Due to the column ordering in the parameter matrix of the tableau, leftmost search will enforce solution increase with respect to the following priority order:
true if pivot row and column pair
is more suitable for pivoting than the
pair| mapping | the PIP_Solution_Node::mapping vector for the tableau | |
| basis | the PIP_Solution_Node::basis vector for the tableau | |
| i | the row number for the first pivot row and column pair to be compared | |
| j | the column number for the first pivot row and column pair to be compared | |
| i_ | the row number for the second pivot row and column pair to be compared | |
| j_ | the column number for the second pivot row and column pair to be compared |
Definition at line 1140 of file PIP_Tree.cc.
References Parma_Polyhedra_Library::Matrix::num_columns(), Parma_Polyhedra_Library::Matrix::num_rows(), PPL_DIRTY_TEMP_COEFFICIENT, s, t, WEIGHT_ADD, and WEIGHT_BEGIN.
01145 { 01146 const dimension_type num_params = t.num_columns(); 01147 const dimension_type num_rows = s.num_rows(); 01148 const Row& s_0 = s[row_0]; 01149 const Row& s_1 = s[row_1]; 01150 const Coefficient& s_0_0 = s_0[col_0]; 01151 const Coefficient& s_1_1 = s_1[col_1]; 01152 const Row& t_0 = t[row_0]; 01153 const Row& t_1 = t[row_1]; 01154 PPL_DIRTY_TEMP_COEFFICIENT(coeff_0); 01155 PPL_DIRTY_TEMP_COEFFICIENT(coeff_1); 01156 PPL_DIRTY_TEMP_COEFFICIENT(product_0); 01157 PPL_DIRTY_TEMP_COEFFICIENT(product_1); 01158 WEIGHT_BEGIN(); 01159 // On exit from the loop, if j_mismatch == num_params then 01160 // no column mismatch was found. 01161 dimension_type j_mismatch = num_params; 01162 for (dimension_type j = 0; j < num_params; ++j) { 01163 coeff_0 = t_0[j] * s_1_1; 01164 coeff_1 = t_1[j] * s_0_0; 01165 WEIGHT_ADD(2); 01166 for (dimension_type i = 0; i < num_rows; ++i) { 01167 const Row& s_i = s[i]; 01168 product_0 = coeff_0 * s_i[col_0]; 01169 product_1 = coeff_1 * s_i[col_1]; 01170 WEIGHT_ADD(2); 01171 if (product_0 != product_1) { 01172 // Mismatch found: exit from both loops. 01173 j_mismatch = j; 01174 goto end_loop; 01175 } 01176 } 01177 } 01178 01179 end_loop: 01180 return (j_mismatch != num_params) 01181 && column_lower(s, mapping, basis, s_0, col_0, s_1, col_1, 01182 t_0[j_mismatch], t_1[j_mismatch]); 01183 }
| bool Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::is_integer | ( | ) | const [inline] |
Tests whether the matrix is integer, i.e., the denominator is 1.
Definition at line 46 of file PIP_Tree.inlines.hh.
References denom.
00046 { 00047 return denom == 1; 00048 }
| void Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::normalize | ( | ) |
Normalizes the modulo of coefficients so that they are mutually prime.
Computes the Greatest Common Divisor (GCD) among the elements of the matrices and normalizes them and the denominator by the GCD itself.
Definition at line 1064 of file PIP_Tree.cc.
References denom, Parma_Polyhedra_Library::exact_div_assign(), Parma_Polyhedra_Library::gcd_assign(), Parma_Polyhedra_Library::Matrix::num_columns(), Parma_Polyhedra_Library::Matrix::num_rows(), PPL_DIRTY_TEMP_COEFFICIENT, s, t, WEIGHT_ADD, WEIGHT_ADD_MUL, and WEIGHT_BEGIN.
01064 { 01065 if (denom == 1) 01066 return; 01067 01068 const dimension_type num_rows = s.num_rows(); 01069 const dimension_type s_cols = s.num_columns(); 01070 const dimension_type t_cols = t.num_columns(); 01071 01072 // Compute global gcd. 01073 PPL_DIRTY_TEMP_COEFFICIENT(gcd); 01074 gcd = denom; 01075 for (dimension_type i = num_rows; i-- > 0; ) { 01076 WEIGHT_BEGIN(); 01077 const Row& s_i = s[i]; 01078 for (dimension_type j = s_cols; j-- > 0; ) { 01079 const Coefficient& s_ij = s_i[j]; 01080 if (s_ij != 0) { 01081 WEIGHT_ADD(1); 01082 gcd_assign(gcd, s_ij, gcd); 01083 if (gcd == 1) 01084 return; 01085 } 01086 } 01087 WEIGHT_BEGIN(); 01088 const Row& t_i = t[i]; 01089 for (dimension_type j = t_cols; j-- > 0; ) { 01090 const Coefficient& t_ij = t_i[j]; 01091 if (t_ij != 0) { 01092 WEIGHT_ADD(1); 01093 gcd_assign(gcd, t_ij, gcd); 01094 if (gcd == 1) 01095 return; 01096 } 01097 } 01098 } 01099 01100 PPL_ASSERT(gcd > 1); 01101 // Normalize all coefficients. 01102 WEIGHT_BEGIN(); 01103 for (dimension_type i = num_rows; i-- > 0; ) { 01104 Row& s_i = s[i]; 01105 for (dimension_type j = s_cols; j-- > 0; ) { 01106 Coefficient& s_ij = s_i[j]; 01107 exact_div_assign(s_ij, s_ij, gcd); 01108 } 01109 Row& t_i = t[i]; 01110 for (dimension_type j = t_cols; j-- > 0; ) { 01111 Coefficient& t_ij = t_i[j]; 01112 exact_div_assign(t_ij, t_ij, gcd); 01113 } 01114 } 01115 WEIGHT_ADD_MUL(s_cols + t_cols, num_rows); 01116 // Normalize denominator. 01117 exact_div_assign(denom, denom, gcd); 01118 }
| bool Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::OK | ( | ) | const |
Returns true if and only if *this is well formed.
Definition at line 609 of file PIP_Tree.cc.
References denom, Parma_Polyhedra_Library::Matrix::num_rows(), Parma_Polyhedra_Library::Matrix::OK(), s, and t.
Referenced by ascii_load(), and Tableau().
00609 { 00610 if (s.num_rows() != t.num_rows()) { 00611 #ifndef NDEBUG 00612 std::cerr << "PIP_Solution_Node::Tableau matrices " 00613 << "have a different number of rows.\n"; 00614 #endif 00615 return false; 00616 } 00617 00618 if (!s.OK() || !t.OK()) { 00619 #ifndef NDEBUG 00620 std::cerr << "A PIP_Solution_Node::Tableau matrix is broken.\n"; 00621 #endif 00622 return false; 00623 } 00624 00625 if (denom <= 0) { 00626 #ifndef NDEBUG 00627 std::cerr << "PIP_Solution_Node::Tableau with non-positive denominator.\n"; 00628 #endif 00629 return false; 00630 } 00631 00632 // All tests passed. 00633 return true; 00634 }
| void Parma_Polyhedra_Library::PIP_Solution_Node::Tableau::scale | ( | Coefficient_traits::const_reference | ratio | ) |
Multiplies all coefficients and denominator with ratio.
Definition at line 1121 of file PIP_Tree.cc.
References denom, Parma_Polyhedra_Library::Matrix::num_columns(), Parma_Polyhedra_Library::Matrix::num_rows(), s, t, WEIGHT_ADD_MUL, and WEIGHT_BEGIN.
01121 { 01122 WEIGHT_BEGIN(); 01123 const dimension_type num_rows = s.num_rows(); 01124 const dimension_type s_cols = s.num_columns(); 01125 const dimension_type t_cols = t.num_columns(); 01126 for (dimension_type i = num_rows; i-- > 0; ) { 01127 Row& s_i = s[i]; 01128 for (dimension_type j = s_cols; j-- > 0; ) 01129 s_i[j] *= ratio; 01130 Row& t_i = t[i]; 01131 for (dimension_type j = t_cols; j-- > 0; ) 01132 t_i[j] *= ratio; 01133 } 01134 WEIGHT_ADD_MUL(s_cols + t_cols, num_rows); 01135 denom *= ratio; 01136 }
A common denominator for all matrix elements.
Definition at line 399 of file PIP_Tree.defs.hh.
Referenced by ascii_dump(), ascii_load(), denominator(), external_memory_in_bytes(), is_integer(), normalize(), OK(), and scale().
The matrix of simplex coefficients.
Definition at line 395 of file PIP_Tree.defs.hh.
Referenced by ascii_dump(), ascii_load(), external_memory_in_bytes(), is_better_pivot(), normalize(), OK(), and scale().
The matrix of parameter coefficients.
Definition at line 397 of file PIP_Tree.defs.hh.
Referenced by ascii_dump(), ascii_load(), external_memory_in_bytes(), is_better_pivot(), normalize(), OK(), and scale().
1.6.3