PPL  1.2
Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter Class Reference

Artificial parameters in PIP solution trees. More...

#include <PIP_Tree_defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter:
Collaboration diagram for Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter:

Public Member Functions

 Artificial_Parameter ()
 Default constructor: builds a zero artificial parameter. More...
 
 Artificial_Parameter (const Linear_Expression &expr, Coefficient_traits::const_reference d)
 Constructor. More...
 
 Artificial_Parameter (const Artificial_Parameter &y)
 Copy constructor. More...
 
Coefficient_traits::const_reference denominator () const
 Returns the normalized (i.e., positive) denominator. More...
 
void m_swap (Artificial_Parameter &y)
 Swaps *this with y. More...
 
bool operator== (const Artificial_Parameter &y) const
 Returns true if and only if *this and y are equal. More...
 
bool operator!= (const Artificial_Parameter &y) const
 Returns true if and only if *this and y are different. 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...
 
bool OK () const
 Returns true if and only if the parameter is well-formed. More...
 
- Public Member Functions inherited from Parma_Polyhedra_Library::Linear_Expression
 Linear_Expression (Representation r=default_representation)
 Default constructor: returns a copy of Linear_Expression::zero(). More...
 
 Linear_Expression (const Linear_Expression &e)
 Ordinary copy constructor. More...
 
 Linear_Expression (const Linear_Expression &e, Representation r)
 Copy constructor that takes also a Representation. More...
 
template<typename LE_Adapter >
 Linear_Expression (const LE_Adapter &e, typename Enable_If< Is_Same_Or_Derived< Expression_Adapter_Base, LE_Adapter >::value, void * >::type=0)
 Copy constructor from a linear expression adapter. More...
 
template<typename LE_Adapter >
 Linear_Expression (const LE_Adapter &e, Representation r, typename Enable_If< Is_Same_Or_Derived< Expression_Adapter_Base, LE_Adapter >::value, void * >::type=0)
 Copy constructor from a linear expression adapter that takes a Representation. More...
 
template<typename LE_Adapter >
 Linear_Expression (const LE_Adapter &e, dimension_type space_dim, typename Enable_If< Is_Same_Or_Derived< Expression_Adapter_Base, LE_Adapter >::value, void * >::type=0)
 Copy constructor from a linear expression adapter that takes a space dimension. More...
 
template<typename LE_Adapter >
 Linear_Expression (const LE_Adapter &e, dimension_type space_dim, Representation r, typename Enable_If< Is_Same_Or_Derived< Expression_Adapter_Base, LE_Adapter >::value, void * >::type=0)
 Copy constructor from a linear expression adapter that takes a space dimension and a Representation. More...
 
Linear_Expressionoperator= (const Linear_Expression &e)
 Assignment operator. More...
 
 ~Linear_Expression ()
 Destructor. More...
 
 Linear_Expression (Coefficient_traits::const_reference n, Representation r=default_representation)
 Builds the linear expression corresponding to the inhomogeneous term n. More...
 
 Linear_Expression (Variable v, Representation r=default_representation)
 Builds the linear expression corresponding to the variable v. More...
 
Representation representation () const
 Returns the current representation of *this. More...
 
void set_representation (Representation r)
 Converts *this to the specified representation. More...
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator lower_bound (Variable v) const
 
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this. More...
 
void set_space_dimension (dimension_type n)
 Sets the dimension of the vector space enclosing *this to n . More...
 
Coefficient_traits::const_reference coefficient (Variable v) const
 Returns the coefficient of v in *this. More...
 
void set_coefficient (Variable v, Coefficient_traits::const_reference n)
 Sets the coefficient of v in *this to n. More...
 
Coefficient_traits::const_reference inhomogeneous_term () const
 Returns the inhomogeneous term of *this. More...
 
void set_inhomogeneous_term (Coefficient_traits::const_reference n)
 Sets the inhomogeneous term of *this to n. More...
 
void linear_combine (const Linear_Expression &y, Variable v)
 
void linear_combine (const Linear_Expression &y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2)
 
void linear_combine_lax (const Linear_Expression &y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2)
 
void swap_space_dimensions (Variable v1, Variable v2)
 Swaps the coefficients of the variables v1 and v2 . More...
 
void remove_space_dimensions (const Variables_Set &vars)
 Removes all the specified dimensions from the expression. 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 expression. More...
 
bool is_zero () const
 Returns true if and only if *this is $0$. More...
 
bool all_homogeneous_terms_are_zero () const
 Returns true if and only if all the homogeneous terms of *this are $0$. More...
 
memory_size_type total_memory_in_bytes () const
 Returns a lower bound to the total size in bytes of the memory occupied by *this. More...
 
memory_size_type external_memory_in_bytes () const
 Returns the size in bytes of the memory managed by *this. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 
void ascii_dump () const
 Writes to std::cerr an ASCII representation of *this. More...
 
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of *this. More...
 
void print () const
 Prints *this to std::cerr using operator<<. More...
 
bool ascii_load (std::istream &s)
 Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise. More...
 
void m_swap (Linear_Expression &y)
 Swaps *this with y. More...
 
 Linear_Expression (const Linear_Expression &e, dimension_type space_dim)
 Copy constructor with a specified space dimension. More...
 
 Linear_Expression (const Linear_Expression &e, dimension_type space_dim, Representation r)
 Copy constructor with a specified space dimension and representation. More...
 
bool is_equal_to (const Linear_Expression &x) const
 
void normalize ()
 
void sign_normalize ()
 
bool all_zeroes (const Variables_Set &vars) const
 Returns true if the coefficient of each variable in vars[i] is $0$. More...
 

Private Attributes

Coefficient denom
 The normalized (i.e., positive) denominator. More...
 

Related Functions

(Note that these are not member functions.)

void swap (PIP_Tree_Node::Artificial_Parameter &x, PIP_Tree_Node::Artificial_Parameter &y)
 Swaps x with y. More...
 
std::ostream & operator<< (std::ostream &os, const PIP_Tree_Node::Artificial_Parameter &x)
 Output operator. More...
 
void swap (PIP_Tree_Node::Artificial_Parameter &x, PIP_Tree_Node::Artificial_Parameter &y)
 

Additional Inherited Members

- Public Types inherited from Parma_Polyhedra_Library::Linear_Expression
typedef const Linear_Expressionconst_reference
 
typedef Linear_Expression raw_type
 
- Static Public Member Functions inherited from Parma_Polyhedra_Library::Linear_Expression
static dimension_type max_space_dimension ()
 Returns the maximum space dimension a Linear_Expression can handle. More...
 
static void initialize ()
 Initializes the class. More...
 
static void finalize ()
 Finalizes the class. More...
 
static const Linear_Expressionzero ()
 Returns the (zero-dimension space) constant 0. More...
 
- Static Public Attributes inherited from Parma_Polyhedra_Library::Linear_Expression
static const Representation default_representation = SPARSE
 

Detailed Description

Artificial parameters in PIP solution trees.

These parameters are built from a linear expression combining other parameters (constant term included) divided by a positive integer denominator. Coefficients at variables indices corresponding to PIP problem variables are always zero.

Definition at line 285 of file PIP_Tree_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::Artificial_Parameter ( )
inline

Default constructor: builds a zero artificial parameter.

Definition at line 103 of file PIP_Tree_inlines.hh.

References OK().

104  : Linear_Expression(), denom(1) {
105  PPL_ASSERT(OK());
106 }
Coefficient denom
The normalized (i.e., positive) denominator.
bool OK() const
Returns true if and only if the parameter is well-formed.
Definition: PIP_Tree.cc:997
Linear_Expression(Representation r=default_representation)
Default constructor: returns a copy of Linear_Expression::zero().
Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::Artificial_Parameter ( const Linear_Expression expr,
Coefficient_traits::const_reference  d 
)

Constructor.

Builds artificial parameter $\frac{\mathtt{expr}}{\mathtt{d}}$.

Parameters
exprThe expression that, after normalization, will form the numerator of the artificial parameter.
dThe integer constant that, after normalization, will form the denominator of the artificial parameter.
Exceptions
std::invalid_argumentThrown if d is zero.

Normalization will ensure that the denominator is positive.

Definition at line 934 of file PIP_Tree.cc.

References denom, Parma_Polyhedra_Library::Linear_Expression::exact_div_assign(), Parma_Polyhedra_Library::exact_div_assign(), Parma_Polyhedra_Library::Linear_Expression::gcd(), Parma_Polyhedra_Library::gcd_assign(), Parma_Polyhedra_Library::Linear_Expression::neg_assign, OK(), and Parma_Polyhedra_Library::Linear_Expression::space_dimension().

936  : Linear_Expression(expr), denom(d) {
937  if (denom == 0) {
938  throw std::invalid_argument("PIP_Tree_Node::Artificial_Parameter(e, d): "
939  "denominator d is zero.");
940  }
941 
942  // Normalize if needed.
943  // FIXME: Provide a proper normalization helper.
944  Linear_Expression& param_expr = *this;
945  if (denom < 0) {
946  neg_assign(denom);
947  neg_assign(param_expr);
948  }
949 
950  // Compute GCD of parameter expression and denominator.
951 
952  Coefficient gcd = param_expr.gcd(0, space_dimension() + 1);
953 
954  if (gcd == 1) {
955  return;
956  }
957 
958  if (gcd == 0) {
959  gcd = denom;
960  }
961  else {
962  gcd_assign(gcd, denom, gcd);
963  }
964 
965  if (gcd == 1) {
966  return;
967  }
968 
969  // Divide coefficients and denominator by their (non-trivial) GCD.
970  PPL_ASSERT(gcd > 1);
971  param_expr.exact_div_assign(gcd, 0, space_dimension() + 1);
973 
974  PPL_ASSERT(OK());
975 }
Coefficient denom
The normalized (i.e., positive) denominator.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void exact_div_assign(Checked_Number< T, Policy > &x, const Checked_Number< T, Policy > &y, const Checked_Number< T, Policy > &z)
Coefficient gcd(dimension_type start, dimension_type end) const
Returns the gcd of the nonzero coefficients in [start,end). If all the coefficients in this range are...
bool OK() const
Returns true if and only if the parameter is well-formed.
Definition: PIP_Tree.cc:997
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
friend void neg_assign(Linear_Expression &e)
void gcd_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
Linear_Expression(Representation r=default_representation)
Default constructor: returns a copy of Linear_Expression::zero().
Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::Artificial_Parameter ( const Artificial_Parameter y)
inline

Copy constructor.

Definition at line 110 of file PIP_Tree_inlines.hh.

References OK().

111  : Linear_Expression(y), denom(y.denom) {
112  PPL_ASSERT(OK());
113 }
Coefficient denom
The normalized (i.e., positive) denominator.
bool OK() const
Returns true if and only if the parameter is well-formed.
Definition: PIP_Tree.cc:997
Linear_Expression(Representation r=default_representation)
Default constructor: returns a copy of Linear_Expression::zero().

Member Function Documentation

void Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::ascii_dump ( ) const

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

void Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::ascii_dump ( std::ostream &  s) const

Writes to s an ASCII representation of *this.

Definition at line 1009 of file PIP_Tree.cc.

References Parma_Polyhedra_Library::Linear_Expression::ascii_dump().

1009  {
1010  s << "artificial_parameter ";
1012  s << " / " << denom << "\n";
1013 }
Coefficient denom
The normalized (i.e., positive) denominator.
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.
bool Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::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 1016 of file PIP_Tree.cc.

References Parma_Polyhedra_Library::Linear_Expression::ascii_load(), and Parma_Polyhedra_Library::PIP_Tree_Node::OK().

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

1016  {
1017  std::string str;
1018  if (!(s >> str) || str != "artificial_parameter") {
1019  return false;
1020  }
1022  return false;
1023  }
1024  if (!(s >> str) || str != "/") {
1025  return false;
1026  }
1027  if (!(s >> denom)) {
1028  return false;
1029  }
1030  PPL_ASSERT(OK());
1031  return true;
1032 }
Coefficient denom
The normalized (i.e., positive) denominator.
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
bool OK() const
Returns true if and only if the parameter is well-formed.
Definition: PIP_Tree.cc:997
Coefficient_traits::const_reference Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::denominator ( ) const
inline

Returns the normalized (i.e., positive) denominator.

Definition at line 116 of file PIP_Tree_inlines.hh.

Referenced by Parma_Polyhedra_Library::IO_Operators::operator<<().

116  {
117  return denom;
118 }
Coefficient denom
The normalized (i.e., positive) denominator.
memory_size_type Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::external_memory_in_bytes ( ) const

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

Definition at line 3730 of file PIP_Tree.cc.

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

3730  {
3733 }
Coefficient denom
The normalized (i.e., positive) denominator.
Enable_If< Is_Native< T >::value, memory_size_type >::type external_memory_in_bytes(const T &)
For native types, returns the size in bytes of the memory managed by the type of the (unused) paramet...
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::m_swap ( Artificial_Parameter y)
inline

Swaps *this with y.

Definition at line 121 of file PIP_Tree_inlines.hh.

References denom, Parma_Polyhedra_Library::Linear_Expression::m_swap(), and Parma_Polyhedra_Library::swap().

Referenced by swap().

121  {
123  using std::swap;
124  swap(denom, y.denom);
125 }
Coefficient denom
The normalized (i.e., positive) denominator.
void swap(CO_Tree &x, CO_Tree &y)
void swap(PIP_Tree_Node::Artificial_Parameter &x, PIP_Tree_Node::Artificial_Parameter &y)
Swaps x with y.
void m_swap(Linear_Expression &y)
Swaps *this with y.
bool Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::OK ( ) const

Returns true if and only if the parameter is well-formed.

Definition at line 997 of file PIP_Tree.cc.

Referenced by Artificial_Parameter().

997  {
998  if (denom <= 0) {
999 #ifndef NDEBUG
1000  std::cerr << "PIP_Tree_Node::Artificial_Parameter "
1001  << "has a non-positive denominator.\n";
1002 #endif
1003  return false;
1004  }
1005  return true;
1006 }
Coefficient denom
The normalized (i.e., positive) denominator.
bool Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::operator!= ( const Artificial_Parameter y) const

Returns true if and only if *this and y are different.

Definition at line 992 of file PIP_Tree.cc.

References Parma_Polyhedra_Library::operator==().

992  {
993  return !operator==(y);
994 }
bool operator==(const Artificial_Parameter &y) const
Returns true if and only if *this and y are equal.
Definition: PIP_Tree.cc:979
bool Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::operator== ( const Artificial_Parameter y) const

Returns true if and only if *this and y are equal.

Note that two artificial parameters having different space dimensions are considered to be different.

Definition at line 979 of file PIP_Tree.cc.

References denom, Parma_Polyhedra_Library::Linear_Expression::is_equal_to(), and Parma_Polyhedra_Library::Linear_Expression::space_dimension().

979  {
980  const Artificial_Parameter& x = *this;
981  if (x.space_dimension() != y.space_dimension()) {
982  return false;
983  }
984  if (x.denom != y.denom) {
985  return false;
986  }
987  return x.is_equal_to(y);
988 }
Artificial_Parameter()
Default constructor: builds a zero artificial parameter.
void Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::print ( ) const

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

memory_size_type Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::total_memory_in_bytes ( ) const

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

Definition at line 3736 of file PIP_Tree.cc.

References Parma_Polyhedra_Library::PIP_Solution_Node::external_memory_in_bytes().

3736  {
3737  return sizeof(*this) + external_memory_in_bytes();
3738 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Definition: PIP_Tree.cc:3730

Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  os,
const PIP_Tree_Node::Artificial_Parameter x 
)
related

Output operator.

Definition at line 908 of file PIP_Tree.cc.

908  {
909  const Linear_Expression& expr = static_cast<const Linear_Expression&>(x);
910  os << "(" << expr << ") div " << x.denominator();
911  return os;
912 }
Linear_Expression(Representation r=default_representation)
Default constructor: returns a copy of Linear_Expression::zero().

Definition at line 129 of file PIP_Tree_inlines.hh.

References m_swap().

130  {
131  x.m_swap(y);
132 }

Swaps x with y.

Member Data Documentation

Coefficient Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::denom
private

The normalized (i.e., positive) denominator.

Definition at line 348 of file PIP_Tree_defs.hh.

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


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