#include <Constraint.defs.hh>
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. | |
Constraint & | operator= (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 Constraint & | zero_dim_false () |
The unsatisfiable (zero-dimension space) constraint ![]() | |
static const Constraint & | zero_dim_positivity () |
The true (zero-dimension space) 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 ![]() | |
static const Constraint & | epsilon_geq_zero () |
Returns the zero-dimension space constraint ![]() | |
static const Constraint & | epsilon_leq_one () |
The zero-dimension space constraint ![]() | |
Static Private Attributes | |
static const Constraint * | zero_dim_false_p = 0 |
Holds (between class initialization and finalization) a pointer to the unsatisfiable (zero-dimension space) constraint ![]() | |
static const Constraint * | zero_dim_positivity_p = 0 |
Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) constraint ![]() | |
static const Constraint * | epsilon_geq_zero_p = 0 |
Holds (between class initialization and finalization) a pointer to the zero-dimension space constraint ![]() | |
static const Constraint * | epsilon_leq_one_p = 0 |
Holds (between class initialization and finalization) a pointer to the zero-dimension space constraint ![]() | |
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. |
An object of the class Constraint is either:
where is the dimension of the space,
is the integer coefficient of variable
and
is the integer inhomogeneous term.
==
), 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.x
, y
and z
are defined as follows: Variable x(0); Variable y(1); Variable z(2);
Constraint eq_c(3*x + 5*y - z == 0);
Constraint ineq_c(4*x >= 2*y - 13);
Constraint strict_ineq_c(4*x > 2*y - 13);
Constraint false_c = Constraint::zero_dim_false();
Constraint false_c1(Linear_Expression::zero() == 1); Constraint false_c2(Linear_Expression::zero() >= 1); Constraint false_c3(Linear_Expression::zero() > 0);
Constraint false_c(0*z == 1);
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; }
Constraint c1: -A + 5*B - 3*C >= -4 Complement c2: A - 5*B + 3*C > 4
Definition at line 260 of file Constraint.defs.hh.
The constraint type.
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 285 of file Constraint.defs.hh.
00285 { 00287 EQUALITY, 00289 NONSTRICT_INEQUALITY, 00291 STRICT_INEQUALITY 00292 };
Parma_Polyhedra_Library::Constraint::Constraint | ( | const Constraint & | c | ) | [inline] |
Ordinary copy-constructor.
Definition at line 40 of file Constraint.inlines.hh.
00041 : Linear_Row(c) { 00042 }
Parma_Polyhedra_Library::Constraint::Constraint | ( | const Congruence & | cg | ) | [explicit] |
Copy-constructs from equality congruence cg
.
std::invalid_argument | Thrown if cg is a proper congruence. |
Definition at line 61 of file Constraint.cc.
References Parma_Polyhedra_Library::Congruence::space_dimension(), and Parma_Polyhedra_Library::Linear_Row::strong_normalize().
00062 : Linear_Row(cg.is_equality() 00063 // Size includes extra column for the inhomogeneous term. 00064 ? cg.space_dimension() + 1 00065 : (throw_invalid_argument("Constraint(cg)", 00066 "congruence cg must be an equality."), 00067 0), 00068 // Capacity also includes a column for the epsilon coefficient. 00069 compute_capacity(cg.space_dimension() + 2, Row::max_size()), 00070 Flags(NECESSARILY_CLOSED, LINE_OR_EQUALITY)) { 00071 Constraint& c = *this; 00072 // Copy coefficients and inhomogeneous term. 00073 for (dimension_type i = cg.space_dimension() + 1; i-- > 0; ) 00074 c[i] = cg[i]; 00075 // Enforce normalization. 00076 strong_normalize(); 00077 }
Parma_Polyhedra_Library::Constraint::~Constraint | ( | ) | [inline] |
Parma_Polyhedra_Library::Constraint::Constraint | ( | ) | [private] |
Parma_Polyhedra_Library::Constraint::Constraint | ( | Linear_Expression & | e, | |
Type | type, | |||
Topology | topology | |||
) | [inline, private] |
Builds a constraint of type type
and topology topology
, stealing the coefficients from e
.
Definition at line 31 of file Constraint.inlines.hh.
References EQUALITY, Parma_Polyhedra_Library::Linear_Row::flags(), Parma_Polyhedra_Library::Linear_Row::LINE_OR_EQUALITY, Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, Parma_Polyhedra_Library::Linear_Row::RAY_OR_POINT_OR_INEQUALITY, STRICT_INEQUALITY, and Parma_Polyhedra_Library::swap().
00031 { 00032 assert(type != STRICT_INEQUALITY || topology == NOT_NECESSARILY_CLOSED); 00033 Linear_Row::swap(e); 00034 flags() = Flags(topology, (type == EQUALITY 00035 ? LINE_OR_EQUALITY 00036 : RAY_OR_POINT_OR_INEQUALITY)); 00037 }
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 79 of file Constraint.cc.
00082 : Linear_Row(cg.is_equality() 00083 ? sz 00084 : (throw_invalid_argument("Constraint(cg, sz, c)", 00085 "congruence cg must be an equality."), 00086 0), 00087 capacity, 00088 Flags(NECESSARILY_CLOSED, LINE_OR_EQUALITY)) { 00089 Constraint& c = *this; 00090 // Copy coefficients. 00091 assert(sz > 0); 00092 while (sz-- > 0) 00093 c[sz] = cg[sz]; 00094 }
Parma_Polyhedra_Library::Constraint::Constraint | ( | const Constraint & | c, | |
dimension_type | sz | |||
) | [inline, private] |
Copy-constructor with given size.
Definition at line 45 of file Constraint.inlines.hh.
00046 : Linear_Row(c, sz, sz) { 00047 }
Constraint & Parma_Polyhedra_Library::Constraint::operator= | ( | const Constraint & | c | ) | [inline] |
Assignment operator.
Definition at line 54 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::Row::operator=().
00054 { 00055 Linear_Row::operator=(c); 00056 return *this; 00057 }
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 60 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::max_space_dimension().
Referenced by Parma_Polyhedra_Library::MIP_Problem::max_space_dimension().
00060 { 00061 return Linear_Row::max_space_dimension(); 00062 }
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 65 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::space_dimension().
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::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::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(), and Parma_Polyhedra_Library::BD_Shape< T >::throw_dimension_incompatible().
00065 { 00066 return Linear_Row::space_dimension(); 00067 }
Constraint::Type Parma_Polyhedra_Library::Constraint::type | ( | ) | const [inline] |
Returns the constraint type of *this
.
Definition at line 80 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(), 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(), and Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign().
00080 { 00081 if (is_equality()) 00082 return EQUALITY; 00083 if (is_necessarily_closed()) 00084 return NONSTRICT_INEQUALITY; 00085 else 00086 return ((*this)[size() - 1] < 0) 00087 ? STRICT_INEQUALITY 00088 : NONSTRICT_INEQUALITY; 00089 }
bool Parma_Polyhedra_Library::Constraint::is_equality | ( | ) | const [inline] |
Returns true
if and only if *this
is an equality constraint.
Definition at line 70 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< PS >::affine_dimension(), 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::expand_space_dimension(), is_inconsistent(), is_tautological(), Parma_Polyhedra_Library::Pointset_Powerset< PS >::linear_partition(), OK(), Parma_Polyhedra_Library::MIP_Problem::parse_constraints(), 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(), and type().
00070 { 00071 return is_line_or_equality(); 00072 }
bool Parma_Polyhedra_Library::Constraint::is_inequality | ( | ) | const [inline] |
Returns true
if and only if *this
is an inequality constraint (either strict or non-strict).
Definition at line 75 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::is_ray_or_point_or_inequality().
Referenced by Parma_Polyhedra_Library::Grid::add_constraint_no_check(), Parma_Polyhedra_Library::Polyhedron::BHRZ03_combining_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::get_limiting_octagon(), Parma_Polyhedra_Library::BD_Shape< T >::get_limiting_shape(), Parma_Polyhedra_Library::Polyhedron::is_included_in(), Parma_Polyhedra_Library::MIP_Problem::is_satisfied(), Parma_Polyhedra_Library::MIP_Problem::parse_constraints(), Parma_Polyhedra_Library::MIP_Problem::process_pending_constraints(), Parma_Polyhedra_Library::Octagonal_Shape< T >::relation_with(), Parma_Polyhedra_Library::Box< ITV >::relation_with(), Parma_Polyhedra_Library::BD_Shape< T >::relation_with(), Parma_Polyhedra_Library::Constraint_System::satisfies_all_constraints(), and Parma_Polyhedra_Library::Polyhedron::simplify_using_context_assign().
00075 { 00076 return is_ray_or_point_or_inequality(); 00077 }
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 92 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().
00092 { 00093 return type() == NONSTRICT_INEQUALITY; 00094 }
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 97 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::BD_Shape< T >::BD_Shape(), Parma_Polyhedra_Library::Box< ITV >::Box(), Parma_Polyhedra_Library::C_Polyhedron::C_Polyhedron(), Parma_Polyhedra_Library::Pointset_Powerset< PS >::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(), and Parma_Polyhedra_Library::Polyhedron::select_H79_constraints().
00097 { 00098 return type() == STRICT_INEQUALITY; 00099 }
Coefficient_traits::const_reference Parma_Polyhedra_Library::Constraint::coefficient | ( | Variable | v | ) | const [inline] |
Returns the coefficient of v
in *this
.
std::invalid_argument | thrown if the index of v is greater than or equal to the space dimension of *this . |
Definition at line 112 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::coefficient(), 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(), 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(), and Parma_Polyhedra_Library::BD_Shape< T >::relation_with().
00112 { 00113 if (v.space_dimension() > space_dimension()) 00114 throw_dimension_incompatible("coefficient(v)", "v", v); 00115 return Linear_Row::coefficient(v.id()); 00116 }
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 119 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::inhomogeneous_term().
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::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(), and Parma_Polyhedra_Library::BD_Shape< T >::relation_with().
00119 { 00120 return Linear_Row::inhomogeneous_term(); 00121 }
void Parma_Polyhedra_Library::Constraint::initialize | ( | ) | [static] |
Initializes the class.
Definition at line 225 of file Constraint.cc.
References Parma_Polyhedra_Library::Coefficient_one(), Constraint(), construct_epsilon_geq_zero(), epsilon_geq_zero_p, epsilon_leq_one_p, Parma_Polyhedra_Library::Linear_Expression::zero(), zero_dim_false_p, and zero_dim_positivity_p.
00225 { 00226 assert(zero_dim_false_p == 0); 00227 zero_dim_false_p 00228 = new Constraint(Linear_Expression::zero() == Coefficient_one()); 00229 00230 assert(zero_dim_positivity_p == 0); 00231 zero_dim_positivity_p 00232 = new Constraint(Linear_Expression::zero() <= Coefficient_one()); 00233 00234 assert(epsilon_geq_zero_p == 0); 00235 epsilon_geq_zero_p 00236 = new Constraint(construct_epsilon_geq_zero()); 00237 00238 assert(epsilon_leq_one_p == 0); 00239 epsilon_leq_one_p 00240 = new Constraint(Linear_Expression::zero() < Coefficient_one()); 00241 }
void Parma_Polyhedra_Library::Constraint::finalize | ( | ) | [static] |
Finalizes the class.
Definition at line 244 of file Constraint.cc.
References epsilon_geq_zero_p, epsilon_leq_one_p, zero_dim_false_p, and zero_dim_positivity_p.
00244 { 00245 assert(zero_dim_false_p != 0); 00246 delete zero_dim_false_p; 00247 zero_dim_false_p = 0; 00248 00249 assert(zero_dim_positivity_p != 0); 00250 delete zero_dim_positivity_p; 00251 zero_dim_positivity_p = 0; 00252 00253 assert(epsilon_geq_zero_p != 0); 00254 delete epsilon_geq_zero_p; 00255 epsilon_geq_zero_p = 0; 00256 00257 assert(epsilon_leq_one_p != 0); 00258 delete epsilon_leq_one_p; 00259 epsilon_leq_one_p = 0; 00260 }
const Constraint & Parma_Polyhedra_Library::Constraint::zero_dim_false | ( | ) | [inline, static] |
The unsatisfiable (zero-dimension space) constraint .
Definition at line 328 of file Constraint.inlines.hh.
References zero_dim_false_p.
Referenced by Parma_Polyhedra_Library::Constraint_System::initialize().
00328 { 00329 assert(zero_dim_false_p != 0); 00330 return *zero_dim_false_p; 00331 }
const Constraint & Parma_Polyhedra_Library::Constraint::zero_dim_positivity | ( | ) | [inline, static] |
The true (zero-dimension space) constraint , also known as positivity constraint.
Definition at line 334 of file Constraint.inlines.hh.
References zero_dim_positivity_p.
Referenced by Parma_Polyhedra_Library::Constraint_System::add_low_level_constraints(), and Parma_Polyhedra_Library::MIP_Problem::ascii_load().
00334 { 00335 assert(zero_dim_positivity_p != 0); 00336 return *zero_dim_positivity_p; 00337 }
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 129 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::total_memory_in_bytes().
00129 { 00130 return Linear_Row::total_memory_in_bytes(); 00131 }
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 124 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::external_memory_in_bytes().
00124 { 00125 return Linear_Row::external_memory_in_bytes(); 00126 }
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:
Definition at line 97 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::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().
00097 { 00098 assert(size() > 0); 00099 const Constraint& x = *this; 00100 if (x.all_homogeneous_terms_are_zero()) 00101 if (is_equality()) 00102 return x[0] == 0; 00103 else 00104 // Non-strict inequality constraint. 00105 return x[0] >= 0; 00106 else 00107 // There is a non-zero homogeneous coefficient. 00108 if (is_necessarily_closed()) 00109 return false; 00110 else { 00111 // The constraint is NOT necessarily closed. 00112 const dimension_type eps_index = size() - 1; 00113 const int eps_sign = sgn(x[eps_index]); 00114 if (eps_sign > 0) 00115 // We have found the constraint epsilon >= 0. 00116 return true; 00117 if (eps_sign == 0) 00118 // One of the `true' dimensions has a non-zero coefficient. 00119 return false; 00120 else { 00121 // Here the epsilon coefficient is negative: strict inequality. 00122 if (x[0] <= 0) 00123 // A strict inequality such as `lhs - k > 0', 00124 // where k is a non negative integer, cannot be trivially true. 00125 return false; 00126 // Checking for another non-zero coefficient. 00127 for (dimension_type i = eps_index; --i > 0; ) 00128 if (x[i] != 0) 00129 return false; 00130 // We have the inequality `k > 0', 00131 // where k is a positive integer. 00132 return true; 00133 } 00134 } 00135 }
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:
Definition at line 138 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(), 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(), and Parma_Polyhedra_Library::Grid::relation_with().
00138 { 00139 assert(size() > 0); 00140 const Constraint& x = *this; 00141 if (x.all_homogeneous_terms_are_zero()) 00142 // The inhomogeneous term is the only non-zero coefficient. 00143 if (is_equality()) 00144 return x[0] != 0; 00145 else 00146 // Non-strict inequality constraint. 00147 return x[0] < 0; 00148 else 00149 // There is a non-zero homogeneous coefficient. 00150 if (is_necessarily_closed()) 00151 return false; 00152 else { 00153 // The constraint is NOT necessarily closed. 00154 const dimension_type eps_index = size() - 1; 00155 if (x[eps_index] >= 0) 00156 // If positive, we have found the constraint epsilon >= 0. 00157 // If zero, one of the `true' dimensions has a non-zero coefficient. 00158 // In both cases, it is not trivially false. 00159 return false; 00160 else { 00161 // Here the epsilon coefficient is negative: strict inequality. 00162 if (x[0] > 0) 00163 // A strict inequality such as `lhs + k > 0', 00164 // where k is a positive integer, cannot be trivially false. 00165 return false; 00166 // Checking for another non-zero coefficient. 00167 for (dimension_type i = eps_index; --i > 0; ) 00168 if (x[i] != 0) 00169 return false; 00170 // We have the inequality `k > 0', 00171 // where k is zero or a negative integer. 00172 return true; 00173 } 00174 } 00175 }
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 178 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==().
00178 { 00179 const Constraint& x = *this; 00180 const dimension_type x_space_dim = x.space_dimension(); 00181 if (x_space_dim != y.space_dimension()) 00182 return false; 00183 00184 const Type x_type = x.type(); 00185 if (x_type != y.type()) { 00186 // Check for special cases. 00187 if (x.is_tautological()) 00188 return y.is_tautological(); 00189 else 00190 return x.is_inconsistent() && y.is_inconsistent(); 00191 } 00192 00193 if (x_type == STRICT_INEQUALITY) { 00194 // Due to the presence of epsilon-coefficients, syntactically 00195 // different strict inequalities may actually encode the same 00196 // topologically open half-space. 00197 // First, drop the epsilon-coefficient ... 00198 Linear_Expression x_expr(x); 00199 Linear_Expression y_expr(y); 00200 // ... then, re-normalize ... 00201 x_expr.normalize(); 00202 y_expr.normalize(); 00203 // ... and finally check for syntactic equality. 00204 for (dimension_type i = x_space_dim + 1; i-- > 0; ) 00205 if (x_expr[i] != y_expr[i]) 00206 return false; 00207 return true; 00208 } 00209 00210 // `x' and 'y' are of the same type and they are not strict inequalities; 00211 // thus, the epsilon-coefficient, if present, is zero. 00212 // It is sufficient to check for syntactic equality. 00213 for (dimension_type i = x_space_dim + 1; i-- > 0; ) 00214 if (x[i] != y[i]) 00215 return false; 00216 return true; 00217 }
void Parma_Polyhedra_Library::Constraint::ascii_dump | ( | ) | const |
Writes to std::cerr
an ASCII representation of *this
.
Reimplemented from Parma_Polyhedra_Library::Linear_Row.
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 352 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::ascii_dump().
00352 { 00353 Linear_Row::ascii_dump(s); 00354 }
void Parma_Polyhedra_Library::Constraint::print | ( | ) | const |
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 357 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::ascii_load().
Referenced by Parma_Polyhedra_Library::MIP_Problem::ascii_load().
00357 { 00358 return Linear_Row::ascii_load(s); 00359 }
bool Parma_Polyhedra_Library::Constraint::OK | ( | ) | const |
Checks if all the invariants are satisfied.
Reimplemented from Parma_Polyhedra_Library::Linear_Row.
Definition at line 328 of file Constraint.cc.
References is_equality(), Parma_Polyhedra_Library::Linear_Row::is_necessarily_closed(), Parma_Polyhedra_Library::Linear_Row::OK(), Parma_Polyhedra_Library::Row::size(), and Parma_Polyhedra_Library::Linear_Row::strong_normalize().
00328 { 00329 // Check the underlying Linear_Row object. 00330 if (!Linear_Row::OK()) 00331 return false; 00332 00333 // Topology consistency checks. 00334 const dimension_type min_size = is_necessarily_closed() ? 1 : 2; 00335 if (size() < min_size) { 00336 #ifndef NDEBUG 00337 std::cerr << "Constraint has fewer coefficients than the minimum " 00338 << "allowed by its topology:" 00339 << std::endl 00340 << "size is " << size() 00341 << ", minimum is " << min_size << "." 00342 << std::endl; 00343 #endif 00344 return false; 00345 } 00346 00347 if (is_equality() && !is_necessarily_closed() && (*this)[size() - 1] != 0) { 00348 #ifndef NDEBUG 00349 std::cerr << "Illegal constraint: an equality cannot be strict." 00350 << std::endl; 00351 #endif 00352 return false; 00353 } 00354 00355 // Normalization check. 00356 Constraint tmp = *this; 00357 tmp.strong_normalize(); 00358 if (tmp != *this) { 00359 #ifndef NDEBUG 00360 std::cerr << "Constraint is not strongly normalized as it should be." 00361 << std::endl; 00362 #endif 00363 return false; 00364 } 00365 00366 // All tests passed. 00367 return true; 00368 }
void Parma_Polyhedra_Library::Constraint::swap | ( | Constraint & | y | ) | [inline] |
Swaps *this
with y
.
Definition at line 362 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::swap().
Referenced by swap().
00362 { 00363 Linear_Row::swap(y); 00364 }
Parma_Polyhedra_Library::Constraint::Parma_Polyhedra_Library::Linear_Expression::Linear_Expression | ( | const Constraint & | c | ) | [private] |
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 35 of file Constraint.cc.
00036 { 00037 std::ostringstream s; 00038 s << "PPL::Constraint::" << method << ":" << std::endl 00039 << message; 00040 throw std::invalid_argument(s.str()); 00041 }
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 44 of file Constraint.cc.
References Parma_Polyhedra_Library::Variable::space_dimension(), and space_dimension().
Referenced by coefficient().
00046 { 00047 std::ostringstream s; 00048 s << "PPL::Constraint::" << method << ":" << std::endl 00049 << "this->space_dimension() == " << space_dimension() << ", " 00050 << name_var << ".space_dimension() == " << v.space_dimension() << "."; 00051 throw std::invalid_argument(s.str()); 00052 }
PPL::Constraint Parma_Polyhedra_Library::Constraint::construct_epsilon_geq_zero | ( | ) | [static, private] |
Builds a new copy of the zero-dimension space constraint (used to implement NNC polyhedra).
Definition at line 55 of file Constraint.cc.
References NONSTRICT_INEQUALITY, and Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED.
Referenced by initialize().
00055 { 00056 Linear_Expression e = Variable(0); 00057 Constraint c(e, NONSTRICT_INEQUALITY, NOT_NECESSARILY_CLOSED); 00058 return c; 00059 }
const Constraint & Parma_Polyhedra_Library::Constraint::epsilon_geq_zero | ( | ) | [inline, static, private] |
Returns the zero-dimension space constraint .
Definition at line 340 of file Constraint.inlines.hh.
References epsilon_geq_zero_p.
Referenced by Parma_Polyhedra_Library::Constraint_System::add_low_level_constraints().
00340 { 00341 assert(epsilon_geq_zero_p != 0); 00342 return *epsilon_geq_zero_p; 00343 }
const Constraint & Parma_Polyhedra_Library::Constraint::epsilon_leq_one | ( | ) | [inline, static, private] |
The zero-dimension space constraint (used to implement NNC polyhedra).
Definition at line 346 of file Constraint.inlines.hh.
References epsilon_leq_one_p.
Referenced by Parma_Polyhedra_Library::Constraint_System::add_low_level_constraints(), Parma_Polyhedra_Library::Polyhedron::strongly_minimize_constraints(), and Parma_Polyhedra_Library::Polyhedron::topological_closure_assign().
00346 { 00347 assert(epsilon_leq_one_p != 0); 00348 return *epsilon_leq_one_p; 00349 }
void Parma_Polyhedra_Library::Constraint::set_is_equality | ( | ) | [inline, private] |
Sets the constraint type to EQUALITY
.
Definition at line 102 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::set_is_line_or_equality().
Referenced by Parma_Polyhedra_Library::Polyhedron::add_recycled_constraints(), and Parma_Polyhedra_Library::Polyhedron::concatenate_assign().
00102 { 00103 set_is_line_or_equality(); 00104 }
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 107 of file Constraint.inlines.hh.
References Parma_Polyhedra_Library::Linear_Row::set_is_ray_or_point_or_inequality().
00107 { 00108 set_is_ray_or_point_or_inequality(); 00109 }
friend class Parma_Polyhedra_Library::Congruence [friend] |
Definition at line 436 of file Constraint.defs.hh.
friend class Parma_Polyhedra_Library::Scalar_Products [friend] |
Definition at line 437 of file Constraint.defs.hh.
friend class Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Sign [friend] |
Definition at line 438 of file Constraint.defs.hh.
friend class Parma_Polyhedra_Library::Constraint_System [friend] |
Definition at line 439 of file Constraint.defs.hh.
friend class Parma_Polyhedra_Library::Constraint_System::const_iterator [friend] |
Definition at line 440 of file Constraint.defs.hh.
friend class Parma_Polyhedra_Library::Polyhedron [friend] |
Definition at line 442 of file Constraint.defs.hh.
Constraint operator== | ( | const Linear_Expression & | e1, | |
const Linear_Expression & | e2 | |||
) | [friend] |
Returns the constraint e1
= e2
.
Definition at line 147 of file Constraint.inlines.hh.
00147 { 00148 Linear_Expression diff = e1 - e2; 00149 Constraint c(diff, Constraint::EQUALITY, NECESSARILY_CLOSED); 00150 // Enforce normalization. 00151 c.strong_normalize(); 00152 return c; 00153 }
Constraint operator== | ( | Variable | v1, | |
Variable | v2 | |||
) | [friend] |
Returns the constraint v1
= v2
.
Definition at line 157 of file Constraint.inlines.hh.
00157 { 00158 Linear_Expression diff 00159 = (v1.space_dimension() < v2.space_dimension()) ? v1-v2 : v2-v1; 00160 return Constraint(diff, Constraint::EQUALITY, NECESSARILY_CLOSED); 00161 }
Constraint operator== | ( | const Linear_Expression & | e, | |
Coefficient_traits::const_reference | n | |||
) | [friend] |
Returns the constraint e
= n
.
Definition at line 245 of file Constraint.inlines.hh.
00245 { 00246 Linear_Expression diff = e - n; 00247 Constraint c(diff, Constraint::EQUALITY, NECESSARILY_CLOSED); 00248 // Enforce normalization. 00249 c.strong_normalize(); 00250 return c; 00251 }
Constraint operator== | ( | Coefficient_traits::const_reference | n, | |
const Linear_Expression & | e | |||
) | [friend] |
Returns the constraint n
= e
.
Definition at line 211 of file Constraint.inlines.hh.
00211 { 00212 Linear_Expression diff = n - e; 00213 Constraint c(diff, Constraint::EQUALITY, NECESSARILY_CLOSED); 00214 // Enforce normalization. 00215 c.strong_normalize(); 00216 return c; 00217 }
Constraint operator>= | ( | const Linear_Expression & | e1, | |
const Linear_Expression & | e2 | |||
) | [friend] |
Returns the constraint e1
>= e2
.
Definition at line 165 of file Constraint.inlines.hh.
00165 { 00166 Linear_Expression diff = e1 - e2; 00167 Constraint c(diff, Constraint::NONSTRICT_INEQUALITY, NECESSARILY_CLOSED); 00168 // Enforce normalization. 00169 c.normalize(); 00170 return c; 00171 }
Constraint operator>= | ( | Variable | v1, | |
Variable | v2 | |||
) | [friend] |
Returns the constraint v1
>= v2
.
Definition at line 175 of file Constraint.inlines.hh.
00175 { 00176 Linear_Expression diff = v1-v2; 00177 return Constraint(diff, Constraint::NONSTRICT_INEQUALITY, NECESSARILY_CLOSED); 00178 }
Constraint operator>= | ( | const Linear_Expression & | e, | |
Coefficient_traits::const_reference | n | |||
) | [friend] |
Returns the constraint e
>= n
.
Definition at line 255 of file Constraint.inlines.hh.
00255 { 00256 Linear_Expression diff = e - n; 00257 Constraint c(diff, Constraint::NONSTRICT_INEQUALITY, NECESSARILY_CLOSED); 00258 // Enforce normalization. 00259 c.normalize(); 00260 return c; 00261 }
Constraint operator>= | ( | Coefficient_traits::const_reference | n, | |
const Linear_Expression & | e | |||
) | [friend] |
Returns the constraint n
>= e
.
Definition at line 221 of file Constraint.inlines.hh.
00221 { 00222 Linear_Expression diff = n - e; 00223 Constraint c(diff, Constraint::NONSTRICT_INEQUALITY, NECESSARILY_CLOSED); 00224 // Enforce normalization. 00225 c.normalize(); 00226 return c; 00227 }
Constraint operator<= | ( | const Linear_Expression & | e1, | |
const Linear_Expression & | e2 | |||
) | [friend] |
Constraint operator<= | ( | const Linear_Expression & | e, | |
Coefficient_traits::const_reference | n | |||
) | [friend] |
Constraint operator<= | ( | Coefficient_traits::const_reference | n, | |
const Linear_Expression & | e | |||
) | [friend] |
Constraint operator> | ( | const Linear_Expression & | e1, | |
const Linear_Expression & | e2 | |||
) | [friend] |
Returns the constraint e1
> e2
.
Definition at line 182 of file Constraint.inlines.hh.
00182 { 00183 Linear_Expression diff; 00184 // Setting the epsilon coefficient to -1. 00185 // NOTE: this also enforces normalization. 00186 const dimension_type e1_dim = e1.space_dimension(); 00187 const dimension_type e2_dim = e2.space_dimension(); 00188 if (e1_dim > e2_dim) 00189 diff -= Variable(e1_dim); 00190 else 00191 diff -= Variable(e2_dim); 00192 diff += e1; 00193 diff -= e2; 00194 00195 Constraint c(diff, Constraint::STRICT_INEQUALITY, NOT_NECESSARILY_CLOSED); 00196 return c; 00197 }
Constraint operator> | ( | Variable | v1, | |
Variable | v2 | |||
) | [friend] |
Returns the constraint v1
> v2
.
Definition at line 201 of file Constraint.inlines.hh.
00201 { 00202 Linear_Expression diff = v1-v2; 00203 diff -= Variable(std::max(v1.space_dimension(), v2.space_dimension())); 00204 return Constraint(diff, 00205 Constraint::STRICT_INEQUALITY, 00206 NOT_NECESSARILY_CLOSED); 00207 }
Constraint operator> | ( | const Linear_Expression & | e, | |
Coefficient_traits::const_reference | n | |||
) | [friend] |
Returns the constraint e
> n
.
Definition at line 265 of file Constraint.inlines.hh.
00265 { 00266 Linear_Expression diff; 00267 // Setting the epsilon coefficient to -1. 00268 // NOTE: this also enforces normalization. 00269 diff -= Variable(e.space_dimension()); 00270 diff += e; 00271 diff -= n; 00272 00273 Constraint c(diff, Constraint::STRICT_INEQUALITY, NOT_NECESSARILY_CLOSED); 00274 c.set_not_necessarily_closed(); 00275 c.set_is_inequality(); 00276 return c; 00277 }
Constraint operator> | ( | Coefficient_traits::const_reference | n, | |
const Linear_Expression & | e | |||
) | [friend] |
Returns the constraint n
> e
.
Definition at line 231 of file Constraint.inlines.hh.
00231 { 00232 Linear_Expression diff; 00233 // Setting the epsilon coefficient to -1. 00234 // NOTE: this also enforces normalization. 00235 diff -= Variable(e.space_dimension()); 00236 diff += n; 00237 diff -= e; 00238 00239 Constraint c(diff, Constraint::STRICT_INEQUALITY, NOT_NECESSARILY_CLOSED); 00240 return c; 00241 }
Constraint operator< | ( | const Linear_Expression & | e1, | |
const Linear_Expression & | e2 | |||
) | [friend] |
Constraint operator< | ( | const Linear_Expression & | e, | |
Coefficient_traits::const_reference | n | |||
) | [friend] |
Constraint operator< | ( | Coefficient_traits::const_reference | n, | |
const Linear_Expression & | e | |||
) | [friend] |
bool operator== | ( | const Constraint & | x, | |
const Constraint & | y | |||
) | [related] |
Returns true
if and only if x
is equivalent to y
.
Definition at line 135 of file Constraint.inlines.hh.
References is_equivalent_to().
bool operator!= | ( | const Constraint & | x, | |
const Constraint & | y | |||
) | [related] |
Returns true
if and only if x
is not equivalent to y
.
Definition at line 141 of file Constraint.inlines.hh.
References is_equivalent_to().
Constraint operator<= | ( | Variable | v1, | |
Variable | v2 | |||
) | [related] |
Constraint operator< | ( | Variable | v1, | |
Variable | v2 | |||
) | [related] |
void swap | ( | Parma_Polyhedra_Library::Constraint & | x, | |
Parma_Polyhedra_Library::Constraint & | y | |||
) | [related] |
Specializes std::swap
.
Definition at line 372 of file Constraint.inlines.hh.
References swap().
00373 { 00374 x.swap(y); 00375 }
std::ostream & operator<< | ( | std::ostream & | s, | |
const Constraint & | c | |||
) | [related] |
Output operator.
Definition at line 264 of file Constraint.cc.
References coefficient(), Parma_Polyhedra_Library::Coefficient_zero(), EQUALITY, inhomogeneous_term(), Parma_Polyhedra_Library::neg_assign(), NONSTRICT_INEQUALITY, space_dimension(), STRICT_INEQUALITY, TEMP_INTEGER, and type().
00264 { 00265 const dimension_type num_variables = c.space_dimension(); 00266 TEMP_INTEGER(cv); 00267 bool first = true; 00268 for (dimension_type v = 0; v < num_variables; ++v) { 00269 cv = c.coefficient(Variable(v)); 00270 if (cv != 0) { 00271 if (!first) { 00272 if (cv > 0) 00273 s << " + "; 00274 else { 00275 s << " - "; 00276 neg_assign(cv); 00277 } 00278 } 00279 else 00280 first = false; 00281 if (cv == -1) 00282 s << "-"; 00283 else if (cv != 1) 00284 s << cv << "*"; 00285 s << PPL::Variable(v); 00286 } 00287 } 00288 if (first) 00289 s << Coefficient_zero(); 00290 const char* relation_symbol = 0; 00291 switch (c.type()) { 00292 case Constraint::EQUALITY: 00293 relation_symbol = " = "; 00294 break; 00295 case Constraint::NONSTRICT_INEQUALITY: 00296 relation_symbol = " >= "; 00297 break; 00298 case Constraint::STRICT_INEQUALITY: 00299 relation_symbol = " > "; 00300 break; 00301 } 00302 s << relation_symbol << -c.inhomogeneous_term(); 00303 return s; 00304 }
std::ostream & operator<< | ( | std::ostream & | s, | |
const Constraint::Type & | t | |||
) | [related] |
Output operator.
Definition at line 308 of file Constraint.cc.
References EQUALITY, NONSTRICT_INEQUALITY, and STRICT_INEQUALITY.
00308 { 00309 const char* n = 0; 00310 switch (t) { 00311 case Constraint::EQUALITY: 00312 n = "EQUALITY"; 00313 break; 00314 case Constraint::NONSTRICT_INEQUALITY: 00315 n = "NONSTRICT_INEQUALITY"; 00316 break; 00317 case Constraint::STRICT_INEQUALITY: 00318 n = "STRICT_INEQUALITY"; 00319 break; 00320 } 00321 s << n; 00322 return s; 00323 }
const PPL::Constraint * Parma_Polyhedra_Library::Constraint::zero_dim_false_p = 0 [static, private] |
Holds (between class initialization and finalization) a pointer to the unsatisfiable (zero-dimension space) constraint .
Definition at line 414 of file Constraint.defs.hh.
Referenced by finalize(), initialize(), and zero_dim_false().
const PPL::Constraint * Parma_Polyhedra_Library::Constraint::zero_dim_positivity_p = 0 [static, private] |
Holds (between class initialization and finalization) a pointer to the true (zero-dimension space) constraint , also known as positivity constraint.
Definition at line 421 of file Constraint.defs.hh.
Referenced by finalize(), initialize(), and zero_dim_positivity().
const PPL::Constraint * Parma_Polyhedra_Library::Constraint::epsilon_geq_zero_p = 0 [static, private] |
Holds (between class initialization and finalization) a pointer to the zero-dimension space constraint .
Definition at line 427 of file Constraint.defs.hh.
Referenced by epsilon_geq_zero(), finalize(), and initialize().
const PPL::Constraint * Parma_Polyhedra_Library::Constraint::epsilon_leq_one_p = 0 [static, private] |
Holds (between class initialization and finalization) a pointer to the zero-dimension space constraint (used to implement NNC polyhedra).
Definition at line 434 of file Constraint.defs.hh.
Referenced by epsilon_leq_one(), finalize(), and initialize().