00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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& c);
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* pcs = 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 wf,
01082 unsigned max_disjuncts);
01083
01112 template <typename Cert, typename Widening>
01113 void BHZ03_widening_assign(const Pointset_Powerset& y, Widening wf);
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 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 wf);
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
01299
01300
01301
01302 friend class Pointset_Powerset<NNC_Polyhedron>;
01303 };
01304
01305 namespace Parma_Polyhedra_Library {
01306
01308
01327 template <typename PSET>
01328 std::pair<PSET, Pointset_Powerset<NNC_Polyhedron> >
01329 linear_partition(const PSET& p, const PSET& q);
01330
01337 bool
01338 check_containment(const NNC_Polyhedron& ph,
01339 const Pointset_Powerset<NNC_Polyhedron>& ps);
01340
01341
01363 std::pair<Grid, Pointset_Powerset<Grid> >
01364 approximate_partition(const Grid& p, const Grid& q, bool& finite_partition);
01365
01372 bool
01373 check_containment(const Grid& ph,
01374 const Pointset_Powerset<Grid>& ps);
01375
01386 template <typename PSET>
01387 bool
01388 check_containment(const PSET& ph, const Pointset_Powerset<PSET>& ps);
01389
01390
01391
01392
01393
01394 template <>
01395 template <typename QH>
01396 Pointset_Powerset<NNC_Polyhedron>
01397 ::Pointset_Powerset(const Pointset_Powerset<QH>& y,
01398 Complexity_Class);
01399
01400
01401
01402 template <>
01403 template <>
01404 Pointset_Powerset<NNC_Polyhedron>
01405 ::Pointset_Powerset(const Pointset_Powerset<C_Polyhedron>& y,
01406 Complexity_Class);
01407
01408 template <>
01409 template <>
01410 Pointset_Powerset<NNC_Polyhedron>
01411 ::Pointset_Powerset(const Pointset_Powerset<Grid>& y,
01412 Complexity_Class);
01413
01414 template <>
01415 template <>
01416 Pointset_Powerset<C_Polyhedron>
01417 ::Pointset_Powerset(const Pointset_Powerset<NNC_Polyhedron>& y,
01418 Complexity_Class);
01419
01420 template <>
01421 void
01422 Pointset_Powerset<NNC_Polyhedron>
01423 ::difference_assign(const Pointset_Powerset& y);
01424
01425 template <>
01426 void
01427 Pointset_Powerset<Grid>
01428 ::difference_assign(const Pointset_Powerset& y);
01429
01430 template <>
01431 bool
01432 Pointset_Powerset<NNC_Polyhedron>
01433 ::geometrically_covers(const Pointset_Powerset& y) const;
01434
01435 template <>
01436 bool
01437 Pointset_Powerset<Grid>
01438 ::geometrically_covers(const Pointset_Powerset& y) const;
01439
01440 }
01441
01442
01443 namespace std {
01444
01446
01447 template <typename PSET>
01448 void swap(Parma_Polyhedra_Library::Pointset_Powerset<PSET>& x,
01449 Parma_Polyhedra_Library::Pointset_Powerset<PSET>& y);
01450
01451 }
01452
01453 #include "Pointset_Powerset.inlines.hh"
01454 #include "Pointset_Powerset.templates.hh"
01455
01456 #endif // !defined(PPL_Pointset_Powerset_defs_hh)