|
PPL
0.12.1
|
00001 /* Pointset_Powerset 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_Pointset_Powerset_defs_hh 00025 #define PPL_Pointset_Powerset_defs_hh 00026 00027 #include "Pointset_Powerset.types.hh" 00028 #include "globals.defs.hh" 00029 #include "BHRZ03_Certificate.types.hh" 00030 #include "Constraint.types.hh" 00031 #include "Constraint_System.types.hh" 00032 #include "Congruence.types.hh" 00033 #include "Congruence_System.types.hh" 00034 #include "C_Polyhedron.defs.hh" 00035 #include "NNC_Polyhedron.defs.hh" 00036 #include "Polyhedron.defs.hh" 00037 #include "Grid.defs.hh" 00038 #include "Partially_Reduced_Product.defs.hh" 00039 #include "Variables_Set.types.hh" 00040 #include "Determinate.defs.hh" 00041 #include "Powerset.defs.hh" 00042 #include "Poly_Con_Relation.defs.hh" 00043 #include "Poly_Gen_Relation.defs.hh" 00044 #include <iosfwd> 00045 #include <list> 00046 #include <map> 00047 00049 00061 template <typename PSET> 00062 class Parma_Polyhedra_Library::Pointset_Powerset 00063 : public Parma_Polyhedra_Library::Powerset 00064 <Parma_Polyhedra_Library::Determinate<PSET> > { 00065 public: 00066 typedef PSET element_type; 00067 00068 private: 00069 typedef Determinate<PSET> Det_PSET; 00070 typedef Powerset<Det_PSET> Base; 00071 00072 public: 00074 static dimension_type max_space_dimension(); 00075 00077 00078 00080 00087 explicit 00088 Pointset_Powerset(dimension_type num_dimensions = 0, 00089 Degenerate_Element kind = UNIVERSE); 00090 00092 00095 Pointset_Powerset(const Pointset_Powerset& y, 00096 Complexity_Class complexity = ANY_COMPLEXITY); 00097 00108 template <typename QH> 00109 explicit Pointset_Powerset(const Pointset_Powerset<QH>& y, 00110 Complexity_Class complexity = ANY_COMPLEXITY); 00111 00117 template <typename QH1, typename QH2, typename R> 00118 explicit 00119 Pointset_Powerset(const Partially_Reduced_Product<QH1, QH2, R>& prp, 00120 Complexity_Class complexity = ANY_COMPLEXITY); 00121 00126 explicit Pointset_Powerset(const Constraint_System& cs); 00127 00132 explicit Pointset_Powerset(const Congruence_System& cgs); 00133 00134 00136 00153 explicit Pointset_Powerset(const C_Polyhedron& ph, 00154 Complexity_Class complexity = ANY_COMPLEXITY); 00155 00157 00174 explicit Pointset_Powerset(const NNC_Polyhedron& ph, 00175 Complexity_Class complexity = ANY_COMPLEXITY); 00176 00177 00179 00194 explicit Pointset_Powerset(const Grid& gr, 00195 Complexity_Class complexity = ANY_COMPLEXITY); 00196 00198 00214 template <typename T> 00215 explicit Pointset_Powerset(const Octagonal_Shape<T>& os, 00216 Complexity_Class complexity = ANY_COMPLEXITY); 00217 00219 00235 template <typename T> 00236 explicit Pointset_Powerset(const BD_Shape<T>& bds, 00237 Complexity_Class complexity = ANY_COMPLEXITY); 00238 00240 00255 template <typename Interval> 00256 explicit Pointset_Powerset(const Box<Interval>& box, 00257 Complexity_Class complexity = ANY_COMPLEXITY); 00258 00260 00262 00263 00265 dimension_type space_dimension() const; 00266 00268 dimension_type affine_dimension() const; 00269 00274 bool is_empty() const; 00275 00280 bool is_universe() const; 00281 00286 bool is_topologically_closed() const; 00287 00292 bool is_bounded() const; 00293 00295 00300 bool is_disjoint_from(const Pointset_Powerset& y) const; 00301 00303 bool is_discrete() const; 00304 00324 bool constrains(Variable var) const; 00325 00333 bool bounds_from_above(const Linear_Expression& expr) const; 00334 00342 bool bounds_from_below(const Linear_Expression& expr) const; 00343 00368 bool maximize(const Linear_Expression& expr, 00369 Coefficient& sup_n, Coefficient& sup_d, bool& maximum) const; 00370 00399 bool maximize(const Linear_Expression& expr, 00400 Coefficient& sup_n, Coefficient& sup_d, bool& maximum, 00401 Generator& g) const; 00402 00427 bool minimize(const Linear_Expression& expr, 00428 Coefficient& inf_n, Coefficient& inf_d, bool& minimum) const; 00429 00430 00459 bool minimize(const Linear_Expression& expr, 00460 Coefficient& inf_n, Coefficient& inf_d, bool& minimum, 00461 Generator& g) const; 00462 00474 bool geometrically_covers(const Pointset_Powerset& y) const; 00475 00487 bool geometrically_equals(const Pointset_Powerset& y) const; 00488 00497 bool contains(const Pointset_Powerset& y) const; 00498 00507 bool strictly_contains(const Pointset_Powerset& y) const; 00508 00513 bool contains_integer_point() const; 00514 00522 Poly_Con_Relation relation_with(const Constraint& c) const; 00523 00531 Poly_Gen_Relation relation_with(const Generator& g) const; 00532 00540 Poly_Con_Relation relation_with(const Congruence& cg) const; 00541 00546 memory_size_type total_memory_in_bytes() const; 00547 00552 memory_size_type external_memory_in_bytes() const; 00553 00560 int32_t hash_code() const; 00561 00563 bool OK() const; 00564 00566 00568 00569 00571 00575 void add_disjunct(const PSET& ph); 00576 00578 00583 void add_constraint(const Constraint& c); 00584 00594 void refine_with_constraint(const Constraint& c); 00595 00597 00605 void add_constraints(const Constraint_System& cs); 00606 00616 void refine_with_constraints(const Constraint_System& cs); 00617 00619 00624 void add_congruence(const Congruence& cg); 00625 00635 void refine_with_congruence(const Congruence& cg); 00636 00638 00646 void add_congruences(const Congruence_System& cgs); 00647 00657 void refine_with_congruences(const Congruence_System& cgs); 00658 00669 void unconstrain(Variable var); 00670 00683 void unconstrain(const Variables_Set& vars); 00684 00696 void drop_some_non_integer_points(Complexity_Class complexity 00697 = ANY_COMPLEXITY); 00698 00714 void drop_some_non_integer_points(const Variables_Set& vars, 00715 Complexity_Class complexity 00716 = ANY_COMPLEXITY); 00717 00719 void topological_closure_assign(); 00720 00722 00726 void intersection_assign(const Pointset_Powerset& y); 00727 00736 void difference_assign(const Pointset_Powerset& y); 00737 00747 bool simplify_using_context_assign(const Pointset_Powerset& y); 00748 00770 void affine_image(Variable var, 00771 const Linear_Expression& expr, 00772 Coefficient_traits::const_reference denominator 00773 = Coefficient_one()); 00774 00796 void affine_preimage(Variable var, 00797 const Linear_Expression& expr, 00798 Coefficient_traits::const_reference denominator 00799 = Coefficient_one()); 00800 00827 void generalized_affine_image(Variable var, 00828 Relation_Symbol relsym, 00829 const Linear_Expression& expr, 00830 Coefficient_traits::const_reference denominator 00831 = Coefficient_one()); 00832 00859 void 00860 generalized_affine_preimage(Variable var, 00861 Relation_Symbol relsym, 00862 const Linear_Expression& expr, 00863 Coefficient_traits::const_reference denominator 00864 = Coefficient_one()); 00865 00886 void generalized_affine_image(const Linear_Expression& lhs, 00887 Relation_Symbol relsym, 00888 const Linear_Expression& rhs); 00889 00910 void generalized_affine_preimage(const Linear_Expression& lhs, 00911 Relation_Symbol relsym, 00912 const Linear_Expression& rhs); 00913 00940 void bounded_affine_image(Variable var, 00941 const Linear_Expression& lb_expr, 00942 const Linear_Expression& ub_expr, 00943 Coefficient_traits::const_reference denominator 00944 = Coefficient_one()); 00945 00972 void bounded_affine_preimage(Variable var, 00973 const Linear_Expression& lb_expr, 00974 const Linear_Expression& ub_expr, 00975 Coefficient_traits::const_reference denominator 00976 = Coefficient_one()); 00977 00986 void time_elapse_assign(const Pointset_Powerset& y); 00987 01034 void wrap_assign(const Variables_Set& vars, 01035 Bounded_Integer_Type_Width w, 01036 Bounded_Integer_Type_Representation r, 01037 Bounded_Integer_Type_Overflow o, 01038 const Constraint_System* cs_p = 0, 01039 unsigned complexity_threshold = 16, 01040 bool wrap_individually = true); 01041 01050 void pairwise_reduce(); 01051 01079 template <typename Widening> 01080 void BGP99_extrapolation_assign(const Pointset_Powerset& y, 01081 Widening widen_fun, 01082 unsigned max_disjuncts); 01083 01112 template <typename Cert, typename Widening> 01113 void BHZ03_widening_assign(const Pointset_Powerset& y, Widening widen_fun); 01114 01116 01118 01119 01124 Pointset_Powerset& operator=(const Pointset_Powerset& y); 01125 01131 template <typename QH> 01132 Pointset_Powerset& operator=(const Pointset_Powerset<QH>& y); 01133 01135 void m_swap(Pointset_Powerset& y); 01136 01141 void add_space_dimensions_and_embed(dimension_type m); 01142 01147 void add_space_dimensions_and_project(dimension_type m); 01148 01150 01155 void concatenate_assign(const Pointset_Powerset& y); 01156 01158 01167 void remove_space_dimensions(const Variables_Set& vars); 01168 01177 void remove_higher_space_dimensions(dimension_type new_dimension); 01178 01185 template <typename Partial_Function> 01186 void map_space_dimensions(const Partial_Function& pfunc); 01187 01189 01211 void expand_space_dimension(Variable var, dimension_type m); 01212 01214 01237 void fold_space_dimensions(const Variables_Set& vars, Variable dest); 01238 01240 01241 public: 01242 typedef typename Base::size_type size_type; 01243 typedef typename Base::value_type value_type; 01244 typedef typename Base::iterator iterator; 01245 typedef typename Base::const_iterator const_iterator; 01246 typedef typename Base::reverse_iterator reverse_iterator; 01247 typedef typename Base::const_reverse_iterator const_reverse_iterator; 01248 01249 PPL_OUTPUT_DECLARATIONS 01250 01256 bool ascii_load(std::istream& s); 01257 01258 private: 01259 typedef typename Base::Sequence Sequence; 01260 typedef typename Base::Sequence_iterator Sequence_iterator; 01261 typedef typename Base::Sequence_const_iterator Sequence_const_iterator; 01262 01264 dimension_type space_dim; 01265 01275 bool intersection_preserving_enlarge_element(PSET& dest) const; 01276 01281 template <typename Widening> 01282 void BGP99_heuristics_assign(const Pointset_Powerset& y, Widening widen_fun); 01283 01285 template <typename Cert> 01286 void collect_certificates(std::map<Cert, size_type, 01287 typename Cert::Compare>& cert_ms) const; 01288 01293 template <typename Cert> 01294 bool is_cert_multiset_stabilizing(const std::map<Cert, size_type, 01295 typename Cert::Compare>& 01296 y_cert_ms) const; 01297 01298 // FIXME: here it should be enough to befriend the template constructor 01299 // template <typename QH> 01300 // Pointset_Powerset(const Pointset_Powerset<QH>&), 01301 // but, apparently, this cannot be done. 01302 friend class Pointset_Powerset<NNC_Polyhedron>; 01303 }; 01304 01305 namespace Parma_Polyhedra_Library { 01306 01308 01309 template <typename PSET> 01310 void swap(Pointset_Powerset<PSET>& x, Pointset_Powerset<PSET>& y); 01311 01313 01332 template <typename PSET> 01333 std::pair<PSET, Pointset_Powerset<NNC_Polyhedron> > 01334 linear_partition(const PSET& p, const PSET& q); 01335 01342 bool 01343 check_containment(const NNC_Polyhedron& ph, 01344 const Pointset_Powerset<NNC_Polyhedron>& ps); 01345 01346 01368 std::pair<Grid, Pointset_Powerset<Grid> > 01369 approximate_partition(const Grid& p, const Grid& q, bool& finite_partition); 01370 01377 bool 01378 check_containment(const Grid& ph, 01379 const Pointset_Powerset<Grid>& ps); 01380 01391 template <typename PSET> 01392 bool 01393 check_containment(const PSET& ph, const Pointset_Powerset<PSET>& ps); 01394 01395 // CHECKME: according to the Intel compiler, the declaration of the 01396 // following specialization (of the class template parameter) should come 01397 // before the declaration of the corresponding full specialization 01398 // (where the member template parameter is specialized too). 01399 template <> 01400 template <typename QH> 01401 Pointset_Powerset<NNC_Polyhedron> 01402 ::Pointset_Powerset(const Pointset_Powerset<QH>& y, 01403 Complexity_Class); 01404 01405 // Non-inline full specializations should be declared here 01406 // so as to inhibit multiple instantiations of the generic template. 01407 template <> 01408 template <> 01409 Pointset_Powerset<NNC_Polyhedron> 01410 ::Pointset_Powerset(const Pointset_Powerset<C_Polyhedron>& y, 01411 Complexity_Class); 01412 01413 template <> 01414 template <> 01415 Pointset_Powerset<NNC_Polyhedron> 01416 ::Pointset_Powerset(const Pointset_Powerset<Grid>& y, 01417 Complexity_Class); 01418 01419 template <> 01420 template <> 01421 Pointset_Powerset<C_Polyhedron> 01422 ::Pointset_Powerset(const Pointset_Powerset<NNC_Polyhedron>& y, 01423 Complexity_Class); 01424 01425 template <> 01426 void 01427 Pointset_Powerset<NNC_Polyhedron> 01428 ::difference_assign(const Pointset_Powerset& y); 01429 01430 template <> 01431 void 01432 Pointset_Powerset<Grid> 01433 ::difference_assign(const Pointset_Powerset& y); 01434 01435 template <> 01436 bool 01437 Pointset_Powerset<NNC_Polyhedron> 01438 ::geometrically_covers(const Pointset_Powerset& y) const; 01439 01440 template <> 01441 bool 01442 Pointset_Powerset<Grid> 01443 ::geometrically_covers(const Pointset_Powerset& y) const; 01444 01445 } // namespace Parma_Polyhedra_Library 01446 01447 #include "Pointset_Powerset.inlines.hh" 01448 #include "Pointset_Powerset.templates.hh" 01449 01450 #endif // !defined(PPL_Pointset_Powerset_defs_hh)