00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <iostream>
00027 #include "iter.hh"
00028
00029 namespace Gecode {
00030
00031 namespace Set {
00032
00047 class SetView : public VariableViewBase<SetVarImp> {
00048 protected:
00049 using VariableViewBase<SetVarImp>::var;
00050 public:
00052
00053
00054 SetView(void);
00056 SetView(const SetVar& x);
00058
00060
00061
00063 unsigned int cardMin(void) const;
00065 unsigned int cardMax(void) const;
00067 int lubMin(void) const;
00069 int lubMax(void) const;
00071 int lubMinN(int n) const;
00073 int lubMaxN(int n) const;
00075 int glbMin(void) const;
00077 int glbMax(void) const;
00078
00080 unsigned int glbSize(void) const;
00082 unsigned int lubSize(void) const;
00084 unsigned int unknownSize(void) const;
00086
00088
00089
00090 bool assigned(void) const;
00092 bool contains(int i) const;
00094 bool notContains(int i) const;
00096
00097
00099
00100
00101 ModEvent cardMin(Space* home, unsigned int m);
00103 ModEvent cardMax(Space* home, unsigned int m);
00108 ModEvent include(Space* home,int i,int j);
00113 ModEvent exclude(Space* home,int i,int j);
00115 ModEvent include(Space* home,int i);
00117 ModEvent exclude(Space* home,int i);
00122 ModEvent intersect(Space* home,int i,int j);
00124 ModEvent intersect(Space* home,int i);
00126
00128
00129
00131 template <class I> ModEvent excludeI(Space* home, I& i);
00133 template <class I> ModEvent includeI(Space* home, I& i);
00135 template <class I> ModEvent intersectI(Space* home, I& iter);
00137
00139
00140
00141 void update(Space* home, bool share, SetView& x);
00143 static bool destruct(void);
00145 };
00146
00147 }
00148
00155 template<>
00156 class ViewVarTraits<Set::SetView> {
00157 public:
00159 typedef Set::SetVarImp Var;
00160 };
00161
00162
00163 namespace Set { class ConstantView; }
00164 bool same(const Set::ConstantView&, const Set::ConstantView&);
00165 bool before(const Set::ConstantView&, const Set::ConstantView&);
00166
00167 namespace Set {
00168
00176 class ConstantView : public ConstantViewBase {
00177 friend class LubRanges<ConstantView>;
00178 friend class GlbRanges<ConstantView>;
00179 friend bool Gecode::same(const Gecode::Set::ConstantView&,
00180 const Gecode::Set::ConstantView&);
00181 friend bool Gecode::before(const Gecode::Set::ConstantView&,
00182 const Gecode::Set::ConstantView&);
00183 private:
00184 int *ranges;
00185 unsigned int size;
00186 unsigned int domSize;
00187 public:
00189
00190
00191 ConstantView(void);
00193 ConstantView(Space* home, const IntSet& s);
00195
00197
00198
00199 unsigned int cardMin(void) const;
00201 unsigned int cardMax(void) const;
00203 int lubMin(void) const;
00205 int lubMax(void) const;
00207 int lubMinN(int n) const;
00209 int lubMaxN(int n) const;
00211 int glbMin(void) const;
00213 int glbMax(void) const;
00214
00216 unsigned int glbSize(void) const;
00218 unsigned int lubSize(void) const;
00220 unsigned int unknownSize(void) const;
00222
00224
00225
00226 bool assigned(void) const;
00228 bool contains(int i) const;
00230 bool notContains(int i) const;
00232
00233
00235
00236
00237 ModEvent cardMin(Space* home, unsigned int m);
00239 ModEvent cardMax(Space* home, unsigned int m);
00244 ModEvent include(Space* home,int i,int j);
00249 ModEvent exclude(Space* home,int i,int j);
00251 ModEvent include(Space* home,int i);
00253 ModEvent exclude(Space* home,int i);
00258 ModEvent intersect(Space* home,int i,int j);
00260 ModEvent intersect(Space* home,int i);
00262
00264
00265
00267 template <class I> ModEvent excludeI(Space* home, I& i);
00269 template <class I> ModEvent includeI(Space* home, I& i);
00271 template <class I> ModEvent intersectI(Space* home, I& iter);
00273
00275
00276
00277 static ModEvent pme(const Propagator* p);
00279 static PropModEvent pme(ModEvent);
00281
00283
00284
00285 void subscribe(Space* home, Propagator* p, PropCond pc);
00287 void cancel(Propagator* p, PropCond pc);
00289
00291
00292
00293 void update(Space* home, bool share, ConstantView& x);
00295 static bool destruct(void);
00297 };
00298
00299 }
00300
00305
00306 bool same(const Set::ConstantView& x, const Set::ConstantView& y);
00308 bool before(const Set::ConstantView& x, const Set::ConstantView& y);
00310
00317 template<>
00318 class ViewVarTraits<Set::ConstantView> {
00319 public:
00321 typedef VarBase Var;
00322 };
00323
00324
00325 namespace Set {
00326
00335 class EmptyView : public ConstantViewBase {
00336 public:
00338
00339
00340 EmptyView(void);
00342
00344
00345
00347 unsigned int cardMin(void) const;
00349 unsigned int cardMax(void) const;
00351 int lubMin(void) const;
00353 int lubMax(void) const;
00355 int lubMinN(int n) const;
00357 int lubMaxN(int n) const;
00359 int glbMin(void) const;
00361 int glbMax(void) const;
00362
00364 unsigned int glbSize(void) const;
00366 unsigned int lubSize(void) const;
00368 unsigned int unknownSize(void) const;
00370
00372
00373
00374 bool assigned(void) const;
00376 bool contains(int i) const;
00378 bool notContains(int i) const;
00380
00381
00383
00384
00385 ModEvent cardMin(Space* home, unsigned int m);
00387 ModEvent cardMax(Space* home, unsigned int m);
00392 ModEvent include(Space* home,int i,int j);
00397 ModEvent exclude(Space* home,int i,int j);
00399 ModEvent include(Space* home,int i);
00401 ModEvent exclude(Space* home,int i);
00406 ModEvent intersect(Space* home,int i,int j);
00408 ModEvent intersect(Space* home,int i);
00410
00412
00413
00415 template <class I> ModEvent excludeI(Space* home, I& i);
00417 template <class I> ModEvent includeI(Space* home, I& i);
00419 template <class I> ModEvent intersectI(Space* home, I& iter);
00421
00423
00424
00425 static ModEvent pme(const Propagator* p);
00427 static PropModEvent pme(ModEvent);
00429
00431
00432
00433 void subscribe(Space* home, Propagator* p, PropCond pc);
00435 void cancel(Propagator* p, PropCond pc);
00437
00439
00440
00441 void update(Space* home, bool share, EmptyView& x);
00443 static bool destruct(void);
00445 };
00446
00447 }
00448
00453
00454 bool same(const Set::EmptyView& x, const Set::EmptyView& y);
00456 bool before(const Set::EmptyView& x, const Set::EmptyView& y);
00458
00465 template<>
00466 class ViewVarTraits<Set::EmptyView> {
00467 public:
00469 typedef VarBase Var;
00470 };
00471
00472 namespace Set {
00473
00474
00483 class UniverseView : public ConstantViewBase {
00484 public:
00486
00487
00488 UniverseView(void);
00490
00492
00493
00495 unsigned int cardMin(void) const;
00497 unsigned int cardMax(void) const;
00499 int lubMin(void) const;
00501 int lubMax(void) const;
00503 int lubMinN(int n) const;
00505 int lubMaxN(int n) const;
00507 int glbMin(void) const;
00509 int glbMax(void) const;
00510
00512 unsigned int glbSize(void) const;
00514 unsigned int lubSize(void) const;
00516 unsigned int unknownSize(void) const;
00518
00520
00521
00522 bool assigned(void) const;
00524 bool contains(int i) const;
00526 bool notContains(int i) const;
00528
00529
00531
00532
00533 ModEvent cardMin(Space* home, unsigned int m);
00535 ModEvent cardMax(Space* home, unsigned int m);
00540 ModEvent include(Space* home,int i,int j);
00545 ModEvent exclude(Space* home,int i,int j);
00547 ModEvent include(Space* home,int i);
00549 ModEvent exclude(Space* home,int i);
00554 ModEvent intersect(Space* home,int i,int j);
00556 ModEvent intersect(Space* home,int i);
00558
00560
00561
00563 template <class I> ModEvent excludeI(Space* home, I& i);
00565 template <class I> ModEvent includeI(Space* home, I& i);
00567 template <class I> ModEvent intersectI(Space* home, I& iter);
00569
00571
00572
00573 static ModEvent pme(const Propagator* p);
00575 static PropModEvent pme(ModEvent);
00577
00579
00580
00581 void subscribe(Space* home, Propagator* p, PropCond pc);
00583 void cancel(Propagator* p, PropCond pc);
00585
00587
00588
00589 void update(Space* home, bool share, UniverseView& x);
00591 static bool destruct(void);
00593 };
00594
00595 }
00596
00601
00602 bool same(const Set::UniverseView& x, const Set::UniverseView& y);
00604 bool before(const Set::UniverseView& x, const Set::UniverseView& y);
00606
00613 template<>
00614 class ViewVarTraits<Set::UniverseView> {
00615 public:
00617 typedef VarBase Var;
00618 };
00619
00620
00621 namespace Set {
00622
00623
00624
00633 class SingletonView :
00634 public DerivedViewBase<Gecode::Int::IntView> {
00635 protected:
00636 using DerivedViewBase<Gecode::Int::IntView>::view;;
00637
00639 static PropCond pc_settoint(PropCond pc);
00641 static ModEvent me_inttoset(ModEvent me);
00642
00643 public:
00645
00646
00647 SingletonView(void);
00649 SingletonView(Gecode::Int::IntView& x);
00651
00653
00654
00656 unsigned int cardMin(void) const;
00658 unsigned int cardMax(void) const;
00660 int lubMin(void) const;
00662 int lubMax(void) const;
00664 int lubMinN(int n) const;
00666 int lubMaxN(int n) const;
00668 int glbMin(void) const;
00670 int glbMax(void) const;
00671
00673 unsigned int glbSize(void) const;
00675 unsigned int lubSize(void) const;
00677 unsigned int unknownSize(void) const;
00679
00681
00682
00683 bool assigned(void) const;
00685 bool contains(int i) const;
00687 bool notContains(int i) const;
00689
00690
00692
00693
00694 ModEvent cardMin(Space* home, unsigned int m);
00696 ModEvent cardMax(Space* home, unsigned int m);
00701 ModEvent include(Space* home,int i,int j);
00706 ModEvent exclude(Space* home,int i,int j);
00708 ModEvent include(Space* home,int i);
00710 ModEvent exclude(Space* home,int i);
00715 ModEvent intersect(Space* home,int i,int j);
00717 ModEvent intersect(Space* home,int i);
00719
00721
00722
00724 template <class I> ModEvent excludeI(Space* home, I& i);
00726 template <class I> ModEvent includeI(Space* home, I& i);
00728 template <class I> ModEvent intersectI(Space* home, I& iter);
00730
00732
00733
00734 static ModEvent pme(const Propagator* p);
00736 static PropModEvent pme(ModEvent);
00738
00740
00741
00742 void subscribe(Space* home, Propagator* p, PropCond pc);
00744 void cancel(Propagator* p, PropCond pc);
00746
00747
00749
00750
00751 void update(Space* home, bool share, SingletonView& x);
00753 static bool destruct(void);
00755 };
00756
00757 }
00758
00763
00764 bool same(const Set::SingletonView& x, const Set::SingletonView& y);
00766 bool before(const Set::SingletonView& x, const Set::SingletonView& y);
00768
00775 template<>
00776 class ViewVarTraits<Set::SingletonView> {
00777 public:
00779 typedef Int::IntVarImp Var;
00780 };
00781
00782
00783 namespace Set {
00784
00785
00795 template <class View>
00796 class ComplementView
00797 : public DerivedViewBase<View> {
00798 protected:
00799 using DerivedViewBase<View>::view;
00800
00802 static PropCond pc_negateset(PropCond pc);
00804 static ModEvent me_negateset(ModEvent me);
00805
00806 public:
00808
00809
00810 ComplementView(void);
00812 ComplementView(View& x);
00814
00816
00817
00819 unsigned int cardMin(void) const;
00821 unsigned int cardMax(void) const;
00823 int lubMin(void) const;
00825 int lubMax(void) const;
00827 int lubMinN(int n) const;
00829 int lubMaxN(int n) const;
00831 int glbMin(void) const;
00833 int glbMax(void) const;
00834
00836 unsigned int glbSize(void) const;
00838 unsigned int lubSize(void) const;
00840 unsigned int unknownSize(void) const;
00842
00844
00845
00846 bool assigned(void) const;
00848 bool contains(int i) const;
00850 bool notContains(int i) const;
00852
00853
00855
00856
00857 ModEvent cardMin(Space* home, unsigned int m);
00859 ModEvent cardMax(Space* home, unsigned int m);
00864 ModEvent include(Space* home,int i,int j);
00869 ModEvent exclude(Space* home,int i,int j);
00871 ModEvent include(Space* home,int i);
00873 ModEvent exclude(Space* home,int i);
00878 ModEvent intersect(Space* home,int i,int j);
00880 ModEvent intersect(Space* home,int i);
00882
00884
00885
00887 template <class I> ModEvent excludeI(Space* home, I& i);
00889 template <class I> ModEvent includeI(Space* home, I& i);
00891 template <class I> ModEvent intersectI(Space* home, I& iter);
00893
00895
00896
00897 static ModEvent pme(const Propagator* p);
00899 static PropModEvent pme(ModEvent);
00901
00903
00904
00905 void subscribe(Space* home, Propagator* p, PropCond pc);
00907 void cancel(Propagator* p, PropCond pc);
00909
00910
00912
00913
00914 void update(Space* home, bool share, ComplementView& x);
00916 static bool destruct(void);
00918 };
00919
00920 }
00921
00926
00927 template <class View>
00928 bool same(const Set::ComplementView<View>& x,
00929 const Set::ComplementView<View>& y);
00931 template <class View>
00932 bool before(const Set::ComplementView<View>& x,
00933 const Set::ComplementView<View>& y);
00935
00936
00943 template <class View>
00944 class ViewVarTraits<Set::ComplementView<View> > {
00945 public:
00947 typedef typename ViewVarTraits<View>::Var Var;
00948 };
00949
00950 namespace Set {
00951
00960 template <class View>
00961 class ComplementView<ComplementView<View> > : public View {
00962 public:
00964
00965
00966 ComplementView(void);
00968 ComplementView(ComplementView<View>& x);
00970 };
00971
00972 }
00973
00978
00979 template <class View>
00980 bool same(const Set::ComplementView<Set::ComplementView<View> >& x,
00981 const Set::ComplementView<Set::ComplementView<View> >& y);
00983 template <class View>
00984 bool before(const Set::ComplementView<Set::ComplementView<View> >& x,
00985 const Set::ComplementView<Set::ComplementView<View> >& y);
00987
00988
00996 template <class View>
00997 class ViewVarTraits<Set::ComplementView<Set::ComplementView<View> > > {
00998 public:
01000 typedef typename ViewVarTraits<View>::Var Var;
01001 };
01002
01003 }
01004
01005 #include "set/view/set.icc"
01006 #include "set/view/const.icc"
01007 #include "set/view/singleton.icc"
01008 #include "set/view/complement.icc"
01009
01014 GECODE_SET_EXPORT std::ostream&
01015 operator<<(std::ostream&, const Gecode::Set::SetView&);
01016
01017
01022 GECODE_SET_EXPORT std::ostream&
01023 operator<<(std::ostream&, const Gecode::Set::EmptyView&);
01024
01029 GECODE_SET_EXPORT std::ostream&
01030 operator<<(std::ostream&, const Gecode::Set::UniverseView&);
01031
01036 GECODE_SET_EXPORT std::ostream&
01037 operator<<(std::ostream&, const Gecode::Set::ConstantView&);
01038
01043 GECODE_SET_EXPORT std::ostream&
01044 operator<<(std::ostream&, const Gecode::Set::SingletonView&);
01045
01050 template <class View>
01051 std::ostream&
01052 operator<<(std::ostream&, const Gecode::Set::ComplementView<View>&);
01053
01054 inline std::ostream&
01055 operator<<(std::ostream& os, const Gecode::SetVar& x) {
01056 Gecode::Set::SetView vx(x);
01057 return os << vx;
01058 }
01059
01060