Parma_Polyhedra_Library::Constraint Class Reference
[C++ Language Interface]

A linear equality or inequality. More...

#include <Constraint.defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Constraint:
Inheritance graph
[legend]
Collaboration diagram for Parma_Polyhedra_Library::Constraint:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Type { EQUALITY, NONSTRICT_INEQUALITY, STRICT_INEQUALITY }
 

The constraint type.

More...

Public Member Functions

 Constraint (const Constraint &c)
 Ordinary copy constructor.
 Constraint (const Congruence &cg)
 Copy-constructs from equality congruence cg.
 ~Constraint ()
 Destructor.
Constraintoperator= (const Constraint &c)
 Assignment operator.
dimension_type space_dimension () const
 Returns the dimension of the vector space enclosing *this.
Type type () const
 Returns the constraint type of *this.
bool is_equality () const
 Returns true if and only if *this is an equality constraint.
bool is_inequality () const
 Returns true if and only if *this is an inequality constraint (either strict or non-strict).
bool is_nonstrict_inequality () const
 Returns true if and only if *this is a non-strict inequality constraint.
bool is_strict_inequality () const
 Returns true if and only if *this is a strict inequality constraint.
Coefficient_traits::const_reference coefficient (Variable v) const
 Returns the coefficient of v in *this.
Coefficient_traits::const_reference inhomogeneous_term () const
 Returns the inhomogeneous term of *this.
memory_size_type total_memory_in_bytes () const
 Returns a lower bound to 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.
bool is_tautological () const
 Returns true if and only if *this is a tautology (i.e., an always true constraint).
bool is_inconsistent () const
 Returns true if and only if *this is inconsistent (i.e., an always false constraint).
bool is_equivalent_to (const Constraint &y) const
 Returns true if and only if *this and y are equivalent constraints.
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.
bool OK () const
 Checks if all the invariants are satisfied.
void swap (Constraint &y)
 Swaps *this with y.

Static Public Member Functions

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

Private Member Functions

friend Parma_Polyhedra_Library::Linear_Expression::Linear_Expression (const Constraint &c)
 Constraint ()
 Default constructor: private and not implemented.
 Constraint (Linear_Expression &e, Type type, Topology topology)
 Builds a constraint of type type and topology topology, stealing the coefficients from e.
 Constraint (const Congruence &cg, dimension_type sz, dimension_type capacity)
 Constructs from a congruence, with specified size and capacity.
void throw_invalid_argument (const char *method, const char *message) const
 Throws a std::invalid_argument exception containing error message message.
void throw_dimension_incompatible (const char *method, const char *name_var, Variable v) const
 Throws a std::invalid_argument exception containing the appropriate error message.
 Constraint (const Constraint &c, dimension_type sz)
 Copy constructor with given size.
void set_is_equality ()
 Sets the constraint type to EQUALITY.
void set_is_inequality ()
 Sets the constraint to be an inequality.

Static Private Member Functions

static Constraint construct_epsilon_geq_zero ()
 Builds a new copy of the zero-dimension space constraint $\epsilon \geq 0$ (used to implement NNC polyhedra).
static const Constraintepsilon_geq_zero ()
 Returns the zero-dimension space constraint $\epsilon \geq 0$.
static const Constraintepsilon_leq_one ()
 The zero-dimension space constraint $\epsilon \leq 1$ (used to implement NNC polyhedra).

Static Private Attributes

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

Friends

class Parma_Polyhedra_Library::Congruence
class Parma_Polyhedra_Library::Scalar_Products
class Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Sign
class Parma_Polyhedra_Library::Constraint_System
class Parma_Polyhedra_Library::Constraint_System::const_iterator
class Parma_Polyhedra_Library::Polyhedron
Constraint operator== (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the constraint e1 = e2.
Constraint operator== (Variable v1, Variable v2)
 Returns the constraint v1 = v2.
Constraint operator== (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the constraint e = n.
Constraint operator== (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the constraint n = e.
Constraint operator>= (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the constraint e1 >= e2.
Constraint operator>= (Variable v1, Variable v2)
 Returns the constraint v1 >= v2.
Constraint operator>= (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the constraint e >= n.
Constraint operator>= (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the constraint n >= e.
Constraint operator<= (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the constraint e1 <= e2.
Constraint operator<= (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the constraint e <= n.
Constraint operator<= (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the constraint n <= e.
Constraint operator> (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the constraint e1 > e2.
Constraint operator> (Variable v1, Variable v2)
 Returns the constraint v1 > v2.
Constraint operator> (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the constraint e > n.
Constraint operator> (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the constraint n > e.
Constraint operator< (const Linear_Expression &e1, const Linear_Expression &e2)
 Returns the constraint e1 < e2.
Constraint operator< (const Linear_Expression &e, Coefficient_traits::const_reference n)
 Returns the constraint e < n.
Constraint operator< (Coefficient_traits::const_reference n, const Linear_Expression &e)
 Returns the constraint n < e.

Related Functions

(Note that these are not member functions.)



bool operator== (const Constraint &x, const Constraint &y)
 Returns true if and only if x is equivalent to y.
bool operator!= (const Constraint &x, const Constraint &y)
 Returns true if and only if x is not equivalent to y.
Constraint operator<= (Variable v1, Variable v2)
 Returns the constraint v1 <= v2.
Constraint operator< (Variable v1, Variable v2)
 Returns the constraint v1 < v2.
void swap (Parma_Polyhedra_Library::Constraint &x, Parma_Polyhedra_Library::Constraint &y)
 Specializes std::swap.
std::ostream & operator<< (std::ostream &s, const Constraint &c)
 Output operator.
std::ostream & operator<< (std::ostream &s, const Constraint::Type &t)
 Output operator.

Detailed Description

A linear equality or inequality.

An object of the class Constraint is either:

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

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

Definition at line 261 of file Constraint.defs.hh.


Member Enumeration Documentation

The constraint type.

Enumerator:
EQUALITY 

The constraint is an equality.

NONSTRICT_INEQUALITY 

The constraint is a non-strict inequality.

STRICT_INEQUALITY 

The constraint is a strict inequality.

Definition at line 286 of file Constraint.defs.hh.

00286             {
00288     EQUALITY,
00290     NONSTRICT_INEQUALITY,
00292     STRICT_INEQUALITY
00293   };


Constructor & Destructor Documentation

Parma_Polyhedra_Library::Constraint::Constraint ( const Constraint c  )  [inline]

Ordinary copy constructor.

Definition at line 41 of file Constraint.inlines.hh.

00042   : Linear_Row(c) {
00043 }

Parma_Polyhedra_Library::Constraint::Constraint ( const Congruence cg  )  [explicit]

Copy-constructs from equality congruence cg.

Exceptions:
std::invalid_argument Thrown if cg is a proper congruence.

Definition at line 62 of file Constraint.cc.

References Parma_Polyhedra_Library::Congruence::space_dimension(), and Parma_Polyhedra_Library::Linear_Row::strong_normalize().

00063   : Linear_Row(cg.is_equality()
00064                // Size includes extra column for the inhomogeneous term.
00065                ? cg.space_dimension() + 1
00066                : (throw_invalid_argument("Constraint(cg)",
00067                                          "congruence cg must be an equality."),
00068                   0),
00069                // Capacity also includes a column for the epsilon coefficient.
00070                compute_capacity(cg.space_dimension() + 2, Row::max_size()),
00071                Flags(NECESSARILY_CLOSED, LINE_OR_EQUALITY)) {
00072   Constraint& c = *this;
00073   // Copy coefficients and inhomogeneous term.
00074   for (dimension_type i = cg.space_dimension() + 1; i-- > 0; )
00075     c[i] = cg[i];
00076   // Enforce normalization.
00077   strong_normalize();
00078 }

Parma_Polyhedra_Library::Constraint::~Constraint (  )  [inline]

Destructor.

Definition at line 51 of file Constraint.inlines.hh.

00051                         {
00052 }

Parma_Polyhedra_Library::Constraint::Constraint (  )  [private]

Default constructor: private and not implemented.

Referenced by initialize().

Parma_Polyhedra_Library::Constraint::Constraint ( Linear_Expression e,
Type  type,
Topology  topology 
) [inline, private]
Parma_Polyhedra_Library::Constraint::Constraint ( const Congruence cg,
dimension_type  sz,
dimension_type  capacity 
) [private]

Constructs from a congruence, with specified size and capacity.

Definition at line 80 of file Constraint.cc.

00083   : Linear_Row(cg.is_equality()
00084                ? sz
00085                : (throw_invalid_argument("Constraint(cg, sz, c)",
00086                                          "congruence cg must be an equality."),
00087                   0),
00088                capacity,
00089                Flags(NECESSARILY_CLOSED, LINE_OR_EQUALITY)) {
00090   Constraint& c = *this;
00091   // Copy coefficients.
00092   PPL_ASSERT(sz > 0);
00093   while (sz-- > 0)
00094     c[sz] = cg[sz];
00095 }

Parma_Polyhedra_Library::Constraint::Constraint ( const Constraint c,
dimension_type  sz 
) [inline, private]

Copy constructor with given size.

Definition at line 46 of file Constraint.inlines.hh.

00047   : Linear_Row(c, sz, sz) {
00048 }


Member Function Documentation

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

Writes to s an ASCII representation of *this.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Definition at line 353 of file Constraint.inlines.hh.

References ascii_dump().

00353                                           {
00354   Linear_Row::ascii_dump(s);
00355 }

void Parma_Polyhedra_Library::Constraint::ascii_dump (  )  const

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

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Referenced by ascii_dump().

bool Parma_Polyhedra_Library::Constraint::ascii_load ( std::istream &  s  )  [inline]

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_Row.

Definition at line 358 of file Constraint.inlines.hh.

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

00358                                     {
00359   return Linear_Row::ascii_load(s);
00360 }

Coefficient_traits::const_reference Parma_Polyhedra_Library::Constraint::coefficient ( Variable  v  )  const [inline]

Returns the coefficient of v in *this.

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

Definition at line 113 of file Constraint.inlines.hh.

References Parma_Polyhedra_Library::Variable::id(), space_dimension(), Parma_Polyhedra_Library::Variable::space_dimension(), and throw_dimension_incompatible().

Referenced by Parma_Polyhedra_Library::Box< ITV >::add_constraint_no_check(), Parma_Polyhedra_Library::Polyhedron::contains_integer_point(), Parma_Polyhedra_Library::Polyhedron::expand_space_dimension(), Parma_Polyhedra_Library::BD_Shape< T >::extract_bounded_difference(), Parma_Polyhedra_Library::Box< ITV >::extract_interval_constraint(), Parma_Polyhedra_Library::Octagonal_Shape< T >::extract_octagonal_difference(), Parma_Polyhedra_Library::Box< ITV >::get_limiting_box(), operator<<(), Parma_Polyhedra_Library::MIP_Problem::parse_constraints(), Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints(), Parma_Polyhedra_Library::Box< ITV >::propagate_constraint_no_check(), Parma_Polyhedra_Library::Box< ITV >::refine_no_check(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::Grid::relation_with(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::PIP_Problem::solve(), Parma_Polyhedra_Library::PIP_Solution_Node::update_tableau(), and Parma_Polyhedra_Library::Box< ITV >::wrap_assign().

00113                                               {
00114   if (v.space_dimension() > space_dimension())
00115     throw_dimension_incompatible("coefficient(v)", "v", v);
00116   return Linear_Row::coefficient(v.id());
00117 }

PPL::Constraint Parma_Polyhedra_Library::Constraint::construct_epsilon_geq_zero (  )  [static, private]

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

Definition at line 56 of file Constraint.cc.

References NONSTRICT_INEQUALITY, and Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED.

Referenced by initialize().

00056                                           {
00057   Linear_Expression e = Variable(0);
00058   Constraint c(e, NONSTRICT_INEQUALITY, NOT_NECESSARILY_CLOSED);
00059   return c;
00060 }

const Constraint & Parma_Polyhedra_Library::Constraint::epsilon_geq_zero (  )  [inline, static, private]

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

Definition at line 341 of file Constraint.inlines.hh.

References epsilon_geq_zero_p.

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

00341                              {
00342   PPL_ASSERT(epsilon_geq_zero_p != 0);
00343   return *epsilon_geq_zero_p;
00344 }

const Constraint & Parma_Polyhedra_Library::Constraint::epsilon_leq_one (  )  [inline, static, private]
memory_size_type Parma_Polyhedra_Library::Constraint::external_memory_in_bytes (  )  const [inline]

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

Reimplemented from Parma_Polyhedra_Library::Row.

Definition at line 125 of file Constraint.inlines.hh.

00125                                            {
00126   return Linear_Row::external_memory_in_bytes();
00127 }

void Parma_Polyhedra_Library::Constraint::finalize (  )  [static]

Finalizes the class.

Definition at line 245 of file Constraint.cc.

References epsilon_geq_zero_p, epsilon_leq_one_p, zero_dim_false_p, and zero_dim_positivity_p.

00245                         {
00246   PPL_ASSERT(zero_dim_false_p != 0);
00247   delete zero_dim_false_p;
00248   zero_dim_false_p = 0;
00249 
00250   PPL_ASSERT(zero_dim_positivity_p != 0);
00251   delete zero_dim_positivity_p;
00252   zero_dim_positivity_p = 0;
00253 
00254   PPL_ASSERT(epsilon_geq_zero_p != 0);
00255   delete epsilon_geq_zero_p;
00256   epsilon_geq_zero_p = 0;
00257 
00258   PPL_ASSERT(epsilon_leq_one_p != 0);
00259   delete epsilon_leq_one_p;
00260   epsilon_leq_one_p = 0;
00261 }

Coefficient_traits::const_reference Parma_Polyhedra_Library::Constraint::inhomogeneous_term (  )  const [inline]

Returns the inhomogeneous term of *this.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Definition at line 120 of file Constraint.inlines.hh.

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

00120                                      {
00121   return Linear_Row::inhomogeneous_term();
00122 }

void Parma_Polyhedra_Library::Constraint::initialize (  )  [static]
bool Parma_Polyhedra_Library::Constraint::is_equality (  )  const [inline]

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

Definition at line 71 of file Constraint.inlines.hh.

References Parma_Polyhedra_Library::Linear_Row::is_line_or_equality().

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

00071                               {
00072   return is_line_or_equality();
00073 }

bool Parma_Polyhedra_Library::Constraint::is_equivalent_to ( const Constraint y  )  const

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

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

Definition at line 179 of file Constraint.cc.

References is_inconsistent(), is_tautological(), Parma_Polyhedra_Library::Row::normalize(), space_dimension(), STRICT_INEQUALITY, and type().

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

00179                                                          {
00180   const Constraint& x = *this;
00181   const dimension_type x_space_dim = x.space_dimension();
00182   if (x_space_dim != y.space_dimension())
00183     return false;
00184 
00185   const Type x_type = x.type();
00186   if (x_type != y.type()) {
00187     // Check for special cases.
00188     if (x.is_tautological())
00189       return y.is_tautological();
00190     else
00191       return x.is_inconsistent() && y.is_inconsistent();
00192   }
00193 
00194   if (x_type == STRICT_INEQUALITY) {
00195     // Due to the presence of epsilon-coefficients, syntactically
00196     // different strict inequalities may actually encode the same
00197     // topologically open half-space.
00198     // First, drop the epsilon-coefficient ...
00199     Linear_Expression x_expr(x);
00200     Linear_Expression y_expr(y);
00201     // ... then, re-normalize ...
00202     x_expr.normalize();
00203     y_expr.normalize();
00204     // ... and finally check for syntactic equality.
00205     for (dimension_type i = x_space_dim + 1; i-- > 0; )
00206       if (x_expr[i] != y_expr[i])
00207         return false;
00208     return true;
00209   }
00210 
00211   // `x' and 'y' are of the same type and they are not strict inequalities;
00212   // thus, the epsilon-coefficient, if present, is zero.
00213   // It is sufficient to check for syntactic equality.
00214   for (dimension_type i = x_space_dim + 1; i-- > 0; )
00215     if (x[i] != y[i])
00216       return false;
00217   return true;
00218 }

bool Parma_Polyhedra_Library::Constraint::is_inconsistent (  )  const

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

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

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

Definition at line 139 of file Constraint.cc.

References Parma_Polyhedra_Library::Linear_Row::all_homogeneous_terms_are_zero(), is_equality(), Parma_Polyhedra_Library::Linear_Row::is_necessarily_closed(), and Parma_Polyhedra_Library::Row::size().

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

00139                                      {
00140   PPL_ASSERT(size() > 0);
00141   const Constraint& x = *this;
00142   if (x.all_homogeneous_terms_are_zero())
00143     // The inhomogeneous term is the only non-zero coefficient.
00144     if (is_equality())
00145       return x[0] != 0;
00146     else
00147       // Non-strict inequality constraint.
00148       return x[0] < 0;
00149   else
00150     // There is a non-zero homogeneous coefficient.
00151     if (is_necessarily_closed())
00152       return false;
00153     else {
00154       // The constraint is NOT necessarily closed.
00155       const dimension_type eps_index = size() - 1;
00156       if (x[eps_index] >= 0)
00157         // If positive, we have found the constraint epsilon >= 0.
00158         // If zero, one of the `true' dimensions has a non-zero coefficient.
00159         // In both cases, it is not trivially false.
00160         return false;
00161       else {
00162         // Here the epsilon coefficient is negative: strict inequality.
00163         if (x[0] > 0)
00164           // A strict inequality such as `lhs + k > 0',
00165           // where k is a positive integer, cannot be trivially false.
00166           return false;
00167         // Checking for another non-zero coefficient.
00168         for (dimension_type i = eps_index; --i > 0; )
00169           if (x[i] != 0)
00170             return false;
00171         // We have the inequality `k > 0',
00172         // where k is zero or a negative integer.
00173         return true;
00174       }
00175     }
00176 }

bool Parma_Polyhedra_Library::Constraint::is_inequality (  )  const [inline]
bool Parma_Polyhedra_Library::Constraint::is_nonstrict_inequality (  )  const [inline]

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

Definition at line 93 of file Constraint.inlines.hh.

References NONSTRICT_INEQUALITY, and type().

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

00093                                           {
00094   return type() == NONSTRICT_INEQUALITY;
00095 }

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

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

Definition at line 98 of file Constraint.inlines.hh.

References STRICT_INEQUALITY, and type().

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

00098                                        {
00099   return type() == STRICT_INEQUALITY;
00100 }

bool Parma_Polyhedra_Library::Constraint::is_tautological (  )  const

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

A tautology can have either one of the following forms:

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

Definition at line 98 of file Constraint.cc.

References Parma_Polyhedra_Library::Linear_Row::all_homogeneous_terms_are_zero(), is_equality(), Parma_Polyhedra_Library::Linear_Row::is_necessarily_closed(), and Parma_Polyhedra_Library::Row::size().

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

00098                                      {
00099   PPL_ASSERT(size() > 0);
00100   const Constraint& x = *this;
00101   if (x.all_homogeneous_terms_are_zero())
00102     if (is_equality())
00103       return x[0] == 0;
00104     else
00105       // Non-strict inequality constraint.
00106       return x[0] >= 0;
00107   else
00108     // There is a non-zero homogeneous coefficient.
00109     if (is_necessarily_closed())
00110       return false;
00111     else {
00112       // The constraint is NOT necessarily closed.
00113       const dimension_type eps_index = size() - 1;
00114       const int eps_sign = sgn(x[eps_index]);
00115       if (eps_sign > 0)
00116         // We have found the constraint epsilon >= 0.
00117         return true;
00118       if (eps_sign == 0)
00119         // One of the `true' dimensions has a non-zero coefficient.
00120         return false;
00121       else {
00122         // Here the epsilon coefficient is negative: strict inequality.
00123         if (x[0] <= 0)
00124           // A strict inequality such as `lhs - k > 0',
00125           // where k is a non negative integer, cannot be trivially true.
00126           return false;
00127         // Checking for another non-zero coefficient.
00128         for (dimension_type i = eps_index; --i > 0; )
00129           if (x[i] != 0)
00130             return false;
00131         // We have the inequality `k > 0',
00132         // where k is a positive integer.
00133         return true;
00134       }
00135     }
00136 }

dimension_type Parma_Polyhedra_Library::Constraint::max_space_dimension (  )  [inline, static]

Returns the maximum space dimension a Constraint can handle.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Definition at line 61 of file Constraint.inlines.hh.

00061                                 {
00062   return Linear_Row::max_space_dimension();
00063 }

bool Parma_Polyhedra_Library::Constraint::OK (  )  const

Checks if all the invariants are satisfied.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Definition at line 329 of file Constraint.cc.

References Parma_Polyhedra_Library::Linear_Row::OK(), and Parma_Polyhedra_Library::Linear_Row::strong_normalize().

00329                         {
00330   // Check the underlying Linear_Row object.
00331   if (!Linear_Row::OK())
00332     return false;
00333 
00334   // Topology consistency checks.
00335   const dimension_type min_size = is_necessarily_closed() ? 1 : 2;
00336   if (size() < min_size) {
00337 #ifndef NDEBUG
00338     std::cerr << "Constraint has fewer coefficients than the minimum "
00339               << "allowed by its topology:"
00340               << std::endl
00341               << "size is " << size()
00342               << ", minimum is " << min_size << "."
00343               << std::endl;
00344 #endif
00345     return false;
00346   }
00347 
00348   if (is_equality() && !is_necessarily_closed() && (*this)[size() - 1] != 0) {
00349 #ifndef NDEBUG
00350     std::cerr << "Illegal constraint: an equality cannot be strict."
00351               << std::endl;
00352 #endif
00353     return false;
00354   }
00355 
00356   // Normalization check.
00357   Constraint tmp = *this;
00358   tmp.strong_normalize();
00359   if (tmp != *this) {
00360 #ifndef NDEBUG
00361     std::cerr << "Constraint is not strongly normalized as it should be."
00362               << std::endl;
00363 #endif
00364     return false;
00365   }
00366 
00367   // All tests passed.
00368   return true;
00369 }

Constraint & Parma_Polyhedra_Library::Constraint::operator= ( const Constraint c  )  [inline]

Assignment operator.

Definition at line 55 of file Constraint.inlines.hh.

00055                                          {
00056   Linear_Row::operator=(c);
00057   return *this;
00058 }

Parma_Polyhedra_Library::Constraint::Parma_Polyhedra_Library::Linear_Expression::Linear_Expression ( const Constraint c  )  [private]
void Parma_Polyhedra_Library::Constraint::print (  )  const

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

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

void Parma_Polyhedra_Library::Constraint::set_is_equality (  )  [inline, private]
void Parma_Polyhedra_Library::Constraint::set_is_inequality (  )  [inline, private]

Sets the constraint to be an inequality.

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

Definition at line 108 of file Constraint.inlines.hh.

References Parma_Polyhedra_Library::Linear_Row::set_is_ray_or_point_or_inequality().

00108                               {
00109   set_is_ray_or_point_or_inequality();
00110 }

dimension_type Parma_Polyhedra_Library::Constraint::space_dimension (  )  const [inline]

Returns the dimension of the vector space enclosing *this.

Reimplemented from Parma_Polyhedra_Library::Linear_Row.

Definition at line 66 of file Constraint.inlines.hh.

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

00066                                   {
00067   return Linear_Row::space_dimension();
00068 }

void Parma_Polyhedra_Library::Constraint::swap ( Constraint y  )  [inline]

Swaps *this with y.

Definition at line 363 of file Constraint.inlines.hh.

Referenced by Constraint(), and swap().

00363                               {
00364   Linear_Row::swap(y);
00365 }

void Parma_Polyhedra_Library::Constraint::throw_dimension_incompatible ( const char *  method,
const char *  name_var,
Variable  v 
) const [private]

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

Definition at line 45 of file Constraint.cc.

References Parma_Polyhedra_Library::Variable::space_dimension(), and space_dimension().

Referenced by coefficient().

00047                                                                       {
00048   std::ostringstream s;
00049   s << "PPL::Constraint::" << method << ":" << std::endl
00050     << "this->space_dimension() == " << space_dimension() << ", "
00051     << name_var << ".space_dimension() == " << v.space_dimension() << ".";
00052   throw std::invalid_argument(s.str());
00053 }

void Parma_Polyhedra_Library::Constraint::throw_invalid_argument ( const char *  method,
const char *  message 
) const [private]

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

Definition at line 36 of file Constraint.cc.

00037                                                                    {
00038   std::ostringstream s;
00039   s << "PPL::Constraint::" << method << ":" << std::endl
00040     << message;
00041   throw std::invalid_argument(s.str());
00042 }

memory_size_type Parma_Polyhedra_Library::Constraint::total_memory_in_bytes (  )  const [inline]

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

Reimplemented from Parma_Polyhedra_Library::Row.

Definition at line 130 of file Constraint.inlines.hh.

00130                                         {
00131   return Linear_Row::total_memory_in_bytes();
00132 }

Constraint::Type Parma_Polyhedra_Library::Constraint::type (  )  const [inline]

Returns the constraint type of *this.

Definition at line 81 of file Constraint.inlines.hh.

References EQUALITY, is_equality(), Parma_Polyhedra_Library::Linear_Row::is_necessarily_closed(), NONSTRICT_INEQUALITY, Parma_Polyhedra_Library::Row::size(), and STRICT_INEQUALITY.

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

00081                        {
00082   if (is_equality())
00083     return EQUALITY;
00084   if (is_necessarily_closed())
00085     return NONSTRICT_INEQUALITY;
00086   else
00087     return ((*this)[size() - 1] < 0)
00088       ? STRICT_INEQUALITY
00089       : NONSTRICT_INEQUALITY;
00090 }

const Constraint & Parma_Polyhedra_Library::Constraint::zero_dim_false (  )  [inline, static]

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

Definition at line 329 of file Constraint.inlines.hh.

References zero_dim_false_p.

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

00329                            {
00330   PPL_ASSERT(zero_dim_false_p != 0);
00331   return *zero_dim_false_p;
00332 }

const Constraint & Parma_Polyhedra_Library::Constraint::zero_dim_positivity (  )  [inline, static]

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

Definition at line 335 of file Constraint.inlines.hh.

References zero_dim_positivity_p.

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

00335                                 {
00336   PPL_ASSERT(zero_dim_positivity_p != 0);
00337   return *zero_dim_positivity_p;
00338 }


Friends And Related Function Documentation

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

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

Definition at line 142 of file Constraint.inlines.hh.

References is_equivalent_to().

00142                                                      {
00143   return !x.is_equivalent_to(y);
00144 }

Constraint operator< ( Variable  v1,
Variable  v2 
) [related]

Returns the constraint v1 < v2.

Definition at line 312 of file Constraint.inlines.hh.

00312                                                 {
00313   return v2 > v1;
00314 }

Constraint operator< ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
) [friend]

Returns the constraint n < e.

Definition at line 318 of file Constraint.inlines.hh.

00318                                                                            {
00319   return e > n;
00320 }

Constraint operator< ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
) [friend]

Returns the constraint e < n.

Definition at line 324 of file Constraint.inlines.hh.

00324                                                                            {
00325   return n > e;
00326 }

Constraint operator< ( const Linear_Expression e1,
const Linear_Expression e2 
) [friend]

Returns the constraint e1 < e2.

Definition at line 306 of file Constraint.inlines.hh.

00306                                                                     {
00307   return e2 > e1;
00308 }

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

Output operator.

Definition at line 309 of file Constraint.cc.

References EQUALITY, NONSTRICT_INEQUALITY, and STRICT_INEQUALITY.

00309                                                                   {
00310   const char* n = 0;
00311   switch (t) {
00312   case Constraint::EQUALITY:
00313     n = "EQUALITY";
00314     break;
00315   case Constraint::NONSTRICT_INEQUALITY:
00316     n = "NONSTRICT_INEQUALITY";
00317     break;
00318   case Constraint::STRICT_INEQUALITY:
00319     n = "STRICT_INEQUALITY";
00320     break;
00321   }
00322   s << n;
00323   return s;
00324 }

std::ostream & operator<< ( std::ostream &  s,
const Constraint c 
) [related]

Output operator.

Definition at line 265 of file Constraint.cc.

References coefficient(), Parma_Polyhedra_Library::Coefficient_zero(), EQUALITY, inhomogeneous_term(), Parma_Polyhedra_Library::neg_assign(), NONSTRICT_INEQUALITY, PPL_DIRTY_TEMP_COEFFICIENT, space_dimension(), STRICT_INEQUALITY, and type().

00265                                                               {
00266   const dimension_type num_variables = c.space_dimension();
00267   PPL_DIRTY_TEMP_COEFFICIENT(cv);
00268   bool first = true;
00269   for (dimension_type v = 0; v < num_variables; ++v) {
00270     cv = c.coefficient(Variable(v));
00271     if (cv != 0) {
00272       if (!first) {
00273         if (cv > 0)
00274           s << " + ";
00275         else {
00276           s << " - ";
00277           neg_assign(cv);
00278         }
00279       }
00280       else
00281         first = false;
00282       if (cv == -1)
00283         s << "-";
00284       else if (cv != 1)
00285         s << cv << "*";
00286       s << PPL::Variable(v);
00287     }
00288   }
00289   if (first)
00290     s << Coefficient_zero();
00291   const char* relation_symbol = 0;
00292   switch (c.type()) {
00293   case Constraint::EQUALITY:
00294     relation_symbol = " = ";
00295     break;
00296   case Constraint::NONSTRICT_INEQUALITY:
00297     relation_symbol = " >= ";
00298     break;
00299   case Constraint::STRICT_INEQUALITY:
00300     relation_symbol = " > ";
00301     break;
00302   }
00303   s << relation_symbol << -c.inhomogeneous_term();
00304   return s;
00305 }

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

Returns the constraint v1 <= v2.

Definition at line 288 of file Constraint.inlines.hh.

00288                                                  {
00289   return v2 >= v1;
00290 }

Constraint operator<= ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
) [friend]

Returns the constraint n <= e.

Definition at line 294 of file Constraint.inlines.hh.

00294                                                                             {
00295   return e >= n;
00296 }

Constraint operator<= ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
) [friend]

Returns the constraint e <= n.

Definition at line 300 of file Constraint.inlines.hh.

00300                                                                             {
00301   return n >= e;
00302 }

Constraint operator<= ( const Linear_Expression e1,
const Linear_Expression e2 
) [friend]

Returns the constraint e1 <= e2.

Definition at line 282 of file Constraint.inlines.hh.

00282                                                                      {
00283   return e2 >= e1;
00284 }

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

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

Definition at line 136 of file Constraint.inlines.hh.

References is_equivalent_to().

00136                                                      {
00137   return x.is_equivalent_to(y);
00138 }

Constraint operator== ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
) [friend]

Returns the constraint n = e.

Definition at line 212 of file Constraint.inlines.hh.

00212                                                                             {
00213   Linear_Expression diff = n - e;
00214   Constraint c(diff, Constraint::EQUALITY, NECESSARILY_CLOSED);
00215   // Enforce normalization.
00216   c.strong_normalize();
00217   return c;
00218 }

Constraint operator== ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
) [friend]

Returns the constraint e = n.

Definition at line 246 of file Constraint.inlines.hh.

00246                                                                             {
00247   Linear_Expression diff = e - n;
00248   Constraint c(diff, Constraint::EQUALITY, NECESSARILY_CLOSED);
00249   // Enforce normalization.
00250   c.strong_normalize();
00251   return c;
00252 }

Constraint operator== ( Variable  v1,
Variable  v2 
) [friend]

Returns the constraint v1 = v2.

Definition at line 158 of file Constraint.inlines.hh.

00158                                                  {
00159   Linear_Expression diff
00160     = (v1.space_dimension() < v2.space_dimension()) ? v1-v2 : v2-v1;
00161   return Constraint(diff, Constraint::EQUALITY, NECESSARILY_CLOSED);
00162 }

Constraint operator== ( const Linear_Expression e1,
const Linear_Expression e2 
) [friend]

Returns the constraint e1 = e2.

Definition at line 148 of file Constraint.inlines.hh.

00148                                                                      {
00149   Linear_Expression diff = e1 - e2;
00150   Constraint c(diff, Constraint::EQUALITY, NECESSARILY_CLOSED);
00151   // Enforce normalization.
00152   c.strong_normalize();
00153   return c;
00154 }

Constraint operator> ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
) [friend]

Returns the constraint n > e.

Definition at line 232 of file Constraint.inlines.hh.

00232                                                                            {
00233   Linear_Expression diff;
00234   // Setting the epsilon coefficient to -1.
00235   // NOTE: this also enforces normalization.
00236   diff -= Variable(e.space_dimension());
00237   diff += n;
00238   diff -= e;
00239 
00240   Constraint c(diff, Constraint::STRICT_INEQUALITY, NOT_NECESSARILY_CLOSED);
00241   return c;
00242 }

Constraint operator> ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
) [friend]

Returns the constraint e > n.

Definition at line 266 of file Constraint.inlines.hh.

00266                                                                            {
00267   Linear_Expression diff;
00268   // Setting the epsilon coefficient to -1.
00269   // NOTE: this also enforces normalization.
00270   diff -= Variable(e.space_dimension());
00271   diff += e;
00272   diff -= n;
00273 
00274   Constraint c(diff, Constraint::STRICT_INEQUALITY, NOT_NECESSARILY_CLOSED);
00275   c.set_not_necessarily_closed();
00276   c.set_is_inequality();
00277   return c;
00278 }

Constraint operator> ( Variable  v1,
Variable  v2 
) [friend]

Returns the constraint v1 > v2.

Definition at line 202 of file Constraint.inlines.hh.

00202                                                 {
00203   Linear_Expression diff = v1-v2;
00204   diff -= Variable(std::max(v1.space_dimension(), v2.space_dimension()));
00205   return Constraint(diff,
00206                     Constraint::STRICT_INEQUALITY,
00207                     NOT_NECESSARILY_CLOSED);
00208 }

Constraint operator> ( const Linear_Expression e1,
const Linear_Expression e2 
) [friend]

Returns the constraint e1 > e2.

Definition at line 183 of file Constraint.inlines.hh.

00183                                                                     {
00184   Linear_Expression diff;
00185   // Setting the epsilon coefficient to -1.
00186   // NOTE: this also enforces normalization.
00187   const dimension_type e1_dim = e1.space_dimension();
00188   const dimension_type e2_dim = e2.space_dimension();
00189   if (e1_dim > e2_dim)
00190     diff -= Variable(e1_dim);
00191   else
00192     diff -= Variable(e2_dim);
00193   diff += e1;
00194   diff -= e2;
00195 
00196   Constraint c(diff, Constraint::STRICT_INEQUALITY, NOT_NECESSARILY_CLOSED);
00197   return c;
00198 }

Constraint operator>= ( Coefficient_traits::const_reference  n,
const Linear_Expression e 
) [friend]

Returns the constraint n >= e.

Definition at line 222 of file Constraint.inlines.hh.

00222                                                                             {
00223   Linear_Expression diff = n - e;
00224   Constraint c(diff, Constraint::NONSTRICT_INEQUALITY, NECESSARILY_CLOSED);
00225   // Enforce normalization.
00226   c.normalize();
00227   return c;
00228 }

Constraint operator>= ( const Linear_Expression e,
Coefficient_traits::const_reference  n 
) [friend]

Returns the constraint e >= n.

Definition at line 256 of file Constraint.inlines.hh.

00256                                                                             {
00257   Linear_Expression diff = e - n;
00258   Constraint c(diff, Constraint::NONSTRICT_INEQUALITY, NECESSARILY_CLOSED);
00259   // Enforce normalization.
00260   c.normalize();
00261   return c;
00262 }

Constraint operator>= ( Variable  v1,
Variable  v2 
) [friend]

Returns the constraint v1 >= v2.

Definition at line 176 of file Constraint.inlines.hh.

00176                                                  {
00177   Linear_Expression diff = v1-v2;
00178   return Constraint(diff, Constraint::NONSTRICT_INEQUALITY, NECESSARILY_CLOSED);
00179 }

Constraint operator>= ( const Linear_Expression e1,
const Linear_Expression e2 
) [friend]

Returns the constraint e1 >= e2.

Definition at line 166 of file Constraint.inlines.hh.

00166                                                                      {
00167   Linear_Expression diff = e1 - e2;
00168   Constraint c(diff, Constraint::NONSTRICT_INEQUALITY, NECESSARILY_CLOSED);
00169   // Enforce normalization.
00170   c.normalize();
00171   return c;
00172 }

friend class Parma_Polyhedra_Library::Congruence [friend]

Definition at line 435 of file Constraint.defs.hh.

Definition at line 438 of file Constraint.defs.hh.

Definition at line 439 of file Constraint.defs.hh.

friend class Parma_Polyhedra_Library::Polyhedron [friend]

Definition at line 441 of file Constraint.defs.hh.

Definition at line 436 of file Constraint.defs.hh.

Definition at line 437 of file Constraint.defs.hh.

Specializes std::swap.

Definition at line 373 of file Constraint.inlines.hh.

References swap().

00374                                            {
00375   x.swap(y);
00376 }


Member Data Documentation

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

Definition at line 426 of file Constraint.defs.hh.

Referenced by epsilon_geq_zero(), finalize(), and initialize().

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

Definition at line 433 of file Constraint.defs.hh.

Referenced by epsilon_leq_one(), finalize(), and initialize().

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

Definition at line 413 of file Constraint.defs.hh.

Referenced by finalize(), initialize(), and zero_dim_false().

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

Definition at line 420 of file Constraint.defs.hh.

Referenced by finalize(), initialize(), and zero_dim_positivity().


The documentation for this class was generated from the following files:
Generated on Sun Feb 27 16:20:24 2011 for PPL by  doxygen 1.6.3