|
PPL
0.12.1
|
00001 /* Constraint class declaration. 00002 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it> 00003 Copyright (C) 2010-2012 BUGSENG srl (http://bugseng.com) 00004 00005 This file is part of the Parma Polyhedra Library (PPL). 00006 00007 The PPL is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 The PPL is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software Foundation, 00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 00020 00021 For the most up-to-date information see the Parma Polyhedra Library 00022 site: http://bugseng.com/products/ppl/ . */ 00023 00024 #ifndef PPL_Constraint_defs_hh 00025 #define PPL_Constraint_defs_hh 1 00026 00027 #include "Constraint.types.hh" 00028 #include "Scalar_Products.types.hh" 00029 #include "Linear_Row.defs.hh" 00030 #include "Variable.defs.hh" 00031 #include "Linear_Expression.defs.hh" 00032 #include "Constraint_System.defs.hh" 00033 #include "Polyhedron.types.hh" 00034 #include "Congruence.types.hh" 00035 #include <iosfwd> 00036 00037 namespace Parma_Polyhedra_Library { 00038 00040 00041 void swap(Constraint& x, Constraint& y); 00042 00043 // Put them in the namespace here to declare them friend later. 00044 00046 00047 bool 00048 operator==(const Constraint& x, const Constraint& y); 00049 00051 00052 bool 00053 operator!=(const Constraint& x, const Constraint& y); 00054 00056 00057 Constraint 00058 operator==(const Linear_Expression& e1, const Linear_Expression& e2); 00059 00061 00062 Constraint 00063 operator==(Variable v1, Variable v2); 00064 00066 00067 Constraint 00068 operator==(const Linear_Expression& e, Coefficient_traits::const_reference n); 00069 00071 00072 Constraint 00073 operator==(Coefficient_traits::const_reference n, const Linear_Expression& e); 00074 00076 00077 Constraint 00078 operator<=(const Linear_Expression& e1, const Linear_Expression& e2); 00079 00081 00082 Constraint 00083 operator<=(Variable v1, Variable v2); 00084 00086 00087 Constraint 00088 operator<=(const Linear_Expression& e, Coefficient_traits::const_reference n); 00089 00091 00092 Constraint 00093 operator<=(Coefficient_traits::const_reference n, const Linear_Expression& e); 00094 00096 00097 Constraint 00098 operator>=(const Linear_Expression& e1, const Linear_Expression& e2); 00099 00101 00102 Constraint 00103 operator>=(Variable v1, Variable v2); 00104 00106 00107 Constraint 00108 operator>=(const Linear_Expression& e, Coefficient_traits::const_reference n); 00109 00111 00112 Constraint 00113 operator>=(Coefficient_traits::const_reference n, const Linear_Expression& e); 00114 00116 00117 Constraint 00118 operator<(const Linear_Expression& e1, const Linear_Expression& e2); 00119 00121 00122 Constraint 00123 operator<(Variable v1, Variable v2); 00124 00126 00127 Constraint 00128 operator<(const Linear_Expression& e, Coefficient_traits::const_reference n); 00129 00131 00132 Constraint 00133 operator<(Coefficient_traits::const_reference n, const Linear_Expression& e); 00134 00136 00137 Constraint 00138 operator>(const Linear_Expression& e1, const Linear_Expression& e2); 00139 00141 00142 Constraint 00143 operator>(Variable v1, Variable v2); 00144 00146 00147 Constraint 00148 operator>(const Linear_Expression& e, Coefficient_traits::const_reference n); 00149 00151 00152 Constraint 00153 operator>(Coefficient_traits::const_reference n, const Linear_Expression& e); 00154 00155 } // namespace Parma_Polyhedra_Library 00156 00158 00255 class Parma_Polyhedra_Library::Constraint : private Linear_Row { 00256 public: 00258 Constraint(const Constraint& c); 00259 00261 00265 explicit Constraint(const Congruence& cg); 00266 00268 ~Constraint(); 00269 00271 Constraint& operator=(const Constraint& c); 00272 00274 static dimension_type max_space_dimension(); 00275 00277 dimension_type space_dimension() const; 00278 00280 enum Type { 00282 EQUALITY, 00284 NONSTRICT_INEQUALITY, 00286 STRICT_INEQUALITY 00287 }; 00288 00290 Type type() const; 00291 00296 bool is_equality() const; 00297 00302 bool is_inequality() const; 00303 00308 bool is_nonstrict_inequality() const; 00309 00314 bool is_strict_inequality() const; 00315 00317 00321 Coefficient_traits::const_reference coefficient(Variable v) const; 00322 00324 Coefficient_traits::const_reference inhomogeneous_term() const; 00325 00327 static void initialize(); 00328 00330 static void finalize(); 00331 00333 static const Constraint& zero_dim_false(); 00334 00339 static const Constraint& zero_dim_positivity(); 00340 00345 memory_size_type total_memory_in_bytes() const; 00346 00348 memory_size_type external_memory_in_bytes() const; 00349 00361 bool is_tautological() const; 00362 00375 bool is_inconsistent() const; 00376 00385 bool is_equivalent_to(const Constraint& y) const; 00386 00387 PPL_OUTPUT_DECLARATIONS 00388 00394 bool ascii_load(std::istream& s); 00395 00397 bool OK() const; 00398 00400 void m_swap(Constraint& y); 00401 00402 private: 00407 static const Constraint* zero_dim_false_p; 00408 00414 static const Constraint* zero_dim_positivity_p; 00415 00420 static const Constraint* epsilon_geq_zero_p; 00421 00427 static const Constraint* epsilon_leq_one_p; 00428 00429 friend class Parma_Polyhedra_Library::Congruence; 00430 friend class Parma_Polyhedra_Library::Scalar_Products; 00431 friend class Parma_Polyhedra_Library::Topology_Adjusted_Scalar_Product_Sign; 00432 friend class Parma_Polyhedra_Library::Constraint_System; 00433 friend class Parma_Polyhedra_Library::Constraint_System::const_iterator; 00434 // FIXME: the following friend declaration should be avoided. 00435 friend class Parma_Polyhedra_Library::Polyhedron; 00436 00437 friend 00438 Parma_Polyhedra_Library 00439 ::Linear_Expression::Linear_Expression(const Constraint& c); 00440 00442 Constraint(); 00443 00448 Constraint(Linear_Expression& e, Type type, Topology topology); 00449 00451 Constraint(const Congruence& cg, dimension_type sz, dimension_type capacity); 00452 00457 void 00458 throw_invalid_argument(const char* method, const char* message) const; 00459 00464 void 00465 throw_dimension_incompatible(const char* method, 00466 const char* name_var, 00467 Variable v) const; 00468 00469 friend Constraint 00470 operator==(const Linear_Expression& e1, const Linear_Expression& e2); 00471 friend Constraint 00472 operator==(Variable v1, Variable v2); 00473 friend Constraint 00474 operator==(const Linear_Expression& e, Coefficient_traits::const_reference n); 00475 friend Constraint 00476 operator==(Coefficient_traits::const_reference n, const Linear_Expression& e); 00477 00478 friend Constraint 00479 operator>=(const Linear_Expression& e1, const Linear_Expression& e2); 00480 friend Constraint 00481 operator>=(Variable v1, Variable v2); 00482 friend Constraint 00483 operator>=(const Linear_Expression& e, Coefficient_traits::const_reference n); 00484 friend Constraint 00485 operator>=(Coefficient_traits::const_reference n, const Linear_Expression& e); 00486 00487 friend Constraint 00488 operator<=(const Linear_Expression& e1, const Linear_Expression& e2); 00489 friend Constraint 00490 operator<=(const Linear_Expression& e, Coefficient_traits::const_reference n); 00491 friend Constraint 00492 operator<=(Coefficient_traits::const_reference n, const Linear_Expression& e); 00493 00494 friend Constraint 00495 operator>(const Linear_Expression& e1, const Linear_Expression& e2); 00496 friend Constraint 00497 operator>(Variable v1, Variable v2); 00498 friend Constraint 00499 operator>(const Linear_Expression& e, Coefficient_traits::const_reference n); 00500 friend Constraint 00501 operator>(Coefficient_traits::const_reference n, const Linear_Expression& e); 00502 00503 friend Constraint 00504 operator<(const Linear_Expression& e1, const Linear_Expression& e2); 00505 friend Constraint 00506 operator<(const Linear_Expression& e, Coefficient_traits::const_reference n); 00507 friend Constraint 00508 operator<(Coefficient_traits::const_reference n, const Linear_Expression& e); 00509 00511 Constraint(const Constraint& c, dimension_type sz); 00512 00517 static Constraint construct_epsilon_geq_zero(); 00518 00520 static const Constraint& epsilon_geq_zero(); 00521 00526 static const Constraint& epsilon_leq_one(); 00527 00529 void set_is_equality(); 00530 00532 00537 void set_is_inequality(); 00538 }; 00539 00540 namespace Parma_Polyhedra_Library { 00541 00542 namespace IO_Operators { 00543 00545 00546 std::ostream& operator<<(std::ostream& s, const Constraint& c); 00547 00549 00550 std::ostream& operator<<(std::ostream& s, const Constraint::Type& t); 00551 00552 } // namespace IO_Operators 00553 00554 } // namespace Parma_Polyhedra_Library 00555 00556 #include "Constraint.inlines.hh" 00557 00558 #endif // !defined(PPL_Constraint_defs_hh)