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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <iostream>
00039
00040 namespace Gecode { namespace Set {
00041
00056 class SetView : public VarImpView<SetVar> {
00057 protected:
00058 using VarImpView<SetVar>::x;
00059 public:
00061
00062
00063 SetView(void);
00065 SetView(const SetVar& y);
00067 SetView(SetVarImp* y);
00069
00071
00072
00074 unsigned int cardMin(void) const;
00076 unsigned int cardMax(void) const;
00078 int lubMin(void) const;
00080 int lubMax(void) const;
00082 int lubMinN(unsigned int n) const;
00084 int glbMin(void) const;
00086 int glbMax(void) const;
00087
00089 unsigned int glbSize(void) const;
00091 unsigned int lubSize(void) const;
00093 unsigned int unknownSize(void) const;
00095
00097
00098
00099 bool contains(int i) const;
00101 bool notContains(int i) const;
00103
00104
00106
00107
00108 ModEvent cardMin(Space& home, unsigned int m);
00110 ModEvent cardMax(Space& home, unsigned int m);
00115 ModEvent include(Space& home,int i,int j);
00120 ModEvent exclude(Space& home,int i,int j);
00122 ModEvent include(Space& home,int i);
00124 ModEvent exclude(Space& home,int i);
00129 ModEvent intersect(Space& home,int i,int j);
00131 ModEvent intersect(Space& home,int i);
00133
00135
00136
00138 template<class I> ModEvent excludeI(Space& home, I& i);
00140 template<class I> ModEvent includeI(Space& home, I& i);
00142 template<class I> ModEvent intersectI(Space& home, I& iter);
00144
00146
00147
00148 static ModEvent modevent(const Delta& d);
00150 int glbMin(const Delta& d) const;
00152 int glbMax(const Delta& d) const;
00154 bool glbAny(const Delta& d) const;
00156 int lubMin(const Delta& d) const;
00158 int lubMax(const Delta& d) const;
00160 bool lubAny(const Delta& d) const;
00162 };
00163
00168 template<class Char, class Traits>
00169 std::basic_ostream<Char,Traits>&
00170 operator <<(std::basic_ostream<Char,Traits>& os, const SetView& x);
00171
00172
00173
00174
00175 class ConstSetView;
00176 bool same(const ConstSetView&, const ConstSetView&);
00177 bool before(const ConstSetView&, const ConstSetView&);
00178
00186 class ConstSetView : public ConstView<SetView> {
00187 friend class LubRanges<ConstSetView>;
00188 friend class GlbRanges<ConstSetView>;
00189 friend bool Gecode::Set::same(const Gecode::Set::ConstSetView&,
00190 const Gecode::Set::ConstSetView&);
00191 friend bool Gecode::Set::before(const Gecode::Set::ConstSetView&,
00192 const Gecode::Set::ConstSetView&);
00193 private:
00194 int *ranges;
00195 int size;
00196 unsigned int domSize;
00197 public:
00199
00200
00201 ConstSetView(void);
00203 ConstSetView(Space& home, const IntSet& s);
00205
00207
00208
00209 unsigned int cardMin(void) const;
00211 unsigned int cardMax(void) const;
00213 int lubMin(void) const;
00215 int lubMax(void) const;
00217 int lubMinN(unsigned int n) const;
00219 int glbMin(void) const;
00221 int glbMax(void) const;
00222
00224 unsigned int glbSize(void) const;
00226 unsigned int lubSize(void) const;
00228 unsigned int unknownSize(void) const;
00230
00232
00233
00234 bool contains(int i) const;
00236 bool notContains(int i) const;
00238
00239
00241
00242
00243 ModEvent cardMin(Space& home, unsigned int m);
00245 ModEvent cardMax(Space& home, unsigned int m);
00250 ModEvent include(Space& home,int i,int j);
00255 ModEvent exclude(Space& home,int i,int j);
00257 ModEvent include(Space& home,int i);
00259 ModEvent exclude(Space& home,int i);
00264 ModEvent intersect(Space& home,int i,int j);
00266 ModEvent intersect(Space& home,int i);
00268
00270
00271
00273 template<class I> ModEvent excludeI(Space& home, I& i);
00275 template<class I> ModEvent includeI(Space& home, I& i);
00277 template<class I> ModEvent intersectI(Space& home, I& iter);
00279
00281
00282
00283 void update(Space& home, ConstSetView& y);
00285
00287
00288
00289 int glbMin(const Delta& d) const;
00291 int glbMax(const Delta& d) const;
00293 bool glbAny(const Delta& d) const;
00295 int lubMin(const Delta& d) const;
00297 int lubMax(const Delta& d) const;
00299 bool lubAny(const Delta& d) const;
00301
00302 };
00303
00308 template<class Char, class Traits>
00309 std::basic_ostream<Char,Traits>&
00310 operator <<(std::basic_ostream<Char,Traits>& os, const ConstSetView& x);
00311
00316
00317 bool same(const ConstSetView& x, const ConstSetView& y);
00319 bool before(const ConstSetView& x, const ConstSetView& y);
00321
00322
00331 class EmptyView : public ConstView<SetView> {
00332 public:
00334
00335
00336 EmptyView(void);
00338
00340
00341
00342 unsigned int cardMin(void) const;
00344 unsigned int cardMax(void) const;
00346 int lubMin(void) const;
00348 int lubMax(void) const;
00350 int lubMinN(unsigned int n) const;
00352 int glbMin(void) const;
00354 int glbMax(void) const;
00355
00357 unsigned int glbSize(void) const;
00359 unsigned int lubSize(void) const;
00361 unsigned int unknownSize(void) const;
00363
00365
00366
00367 bool contains(int i) const;
00369 bool notContains(int i) const;
00371
00372
00374
00375
00376 ModEvent cardMin(Space& home, unsigned int m);
00378 ModEvent cardMax(Space& home, unsigned int m);
00383 ModEvent include(Space& home,int i,int j);
00388 ModEvent exclude(Space& home,int i,int j);
00390 ModEvent include(Space& home,int i);
00392 ModEvent exclude(Space& home,int i);
00397 ModEvent intersect(Space& home,int i,int j);
00399 ModEvent intersect(Space& home,int i);
00401
00403
00404
00406 template<class I> ModEvent excludeI(Space& home, I& i);
00408 template<class I> ModEvent includeI(Space& home, I& i);
00410 template<class I> ModEvent intersectI(Space& home, I& iter);
00412
00414
00415
00416 int glbMin(const Delta& d) const;
00418 int glbMax(const Delta& d) const;
00420 bool glbAny(const Delta& d) const;
00422 int lubMin(const Delta& d) const;
00424 int lubMax(const Delta& d) const;
00426 bool lubAny(const Delta& d) const;
00428
00429 };
00430
00435 template<class Char, class Traits>
00436 std::basic_ostream<Char,Traits>&
00437 operator <<(std::basic_ostream<Char,Traits>& os, const EmptyView& x);
00438
00439
00444
00445 bool same(const EmptyView& x, const EmptyView& y);
00447
00448
00457 class UniverseView : public ConstView<SetView> {
00458 public:
00460
00461
00462 UniverseView(void);
00464
00466
00467
00469 unsigned int cardMin(void) const;
00471 unsigned int cardMax(void) const;
00473 int lubMin(void) const;
00475 int lubMax(void) const;
00477 int lubMinN(unsigned int n) const;
00479 int glbMin(void) const;
00481 int glbMax(void) const;
00482
00484 unsigned int glbSize(void) const;
00486 unsigned int lubSize(void) const;
00488 unsigned int unknownSize(void) const;
00490
00492
00493
00494 bool contains(int i) const;
00496 bool notContains(int i) const;
00498
00499
00501
00502
00503 ModEvent cardMin(Space& home, unsigned int m);
00505 ModEvent cardMax(Space& home, unsigned int m);
00510 ModEvent include(Space& home,int i,int j);
00515 ModEvent exclude(Space& home,int i,int j);
00517 ModEvent include(Space& home,int i);
00519 ModEvent exclude(Space& home,int i);
00524 ModEvent intersect(Space& home,int i,int j);
00526 ModEvent intersect(Space& home,int i);
00528
00530
00531
00533 template<class I> ModEvent excludeI(Space& home, I& i);
00535 template<class I> ModEvent includeI(Space& home, I& i);
00537 template<class I> ModEvent intersectI(Space& home, I& iter);
00539
00541
00542
00543 int glbMin(const Delta& d) const;
00545 int glbMax(const Delta& d) const;
00547 bool glbAny(const Delta& d) const;
00549 int lubMin(const Delta& d) const;
00551 int lubMax(const Delta& d) const;
00553 bool lubAny(const Delta& d) const;
00555
00556 };
00557
00562 template<class Char, class Traits>
00563 std::basic_ostream<Char,Traits>&
00564 operator <<(std::basic_ostream<Char,Traits>& os, const UniverseView& x);
00565
00566
00571
00572 bool same(const UniverseView& x, const UniverseView& y);
00574
00575
00576
00585 class SingletonView :
00586 public DerivedView<Gecode::Int::IntView> {
00587 protected:
00588 using DerivedView<Gecode::Int::IntView>::x;
00589
00591 static PropCond pc_settoint(PropCond pc);
00593 static ModEvent me_inttoset(ModEvent me);
00595 static ModEvent me_settoint(ModEvent me);
00596
00597 public:
00599
00600
00601 SingletonView(void);
00603 SingletonView(Gecode::Int::IntView& y);
00605 SingletonView(const Gecode::IntVar& y);
00607
00609
00610
00612 unsigned int cardMin(void) const;
00614 unsigned int cardMax(void) const;
00616 int lubMin(void) const;
00618 int lubMax(void) const;
00620 int lubMinN(unsigned int n) const;
00622 int glbMin(void) const;
00624 int glbMax(void) const;
00625
00627 unsigned int glbSize(void) const;
00629 unsigned int lubSize(void) const;
00631 unsigned int unknownSize(void) const;
00633
00635
00636
00637 bool contains(int i) const;
00639 bool notContains(int i) const;
00641
00642
00644
00645
00646 ModEvent cardMin(Space& home, unsigned int m);
00648 ModEvent cardMax(Space& home, unsigned int m);
00653 ModEvent include(Space& home,int i,int j);
00658 ModEvent exclude(Space& home,int i,int j);
00660 ModEvent include(Space& home,int i);
00662 ModEvent exclude(Space& home,int i);
00667 ModEvent intersect(Space& home,int i,int j);
00669 ModEvent intersect(Space& home,int i);
00671
00673
00674
00676 template<class I> ModEvent excludeI(Space& home, I& i);
00678 template<class I> ModEvent includeI(Space& home, I& i);
00680 template<class I> ModEvent intersectI(Space& home, I& iter);
00682
00684
00685
00686 static void schedule(Space& home, Propagator& p, ModEvent me);
00688 static ModEvent me(const ModEventDelta& med);
00690 static ModEventDelta med(ModEvent);
00692
00694
00695
00702 void subscribe(Space& home, Propagator& p, PropCond pc, bool schedule=true);
00704 void cancel(Space& home, Propagator& p, PropCond pc);
00706 void reschedule(Space& home, Propagator& p, PropCond pc);
00708 void subscribe(Space& home, Advisor& a);
00710 void cancel(Space& home, Advisor& a);
00712
00714
00715
00716 static ModEvent modevent(const Delta& d);
00718 int glbMin(const Delta& d) const;
00720 int glbMax(const Delta& d) const;
00722 bool glbAny(const Delta& d) const;
00724 int lubMin(const Delta& d) const;
00726 int lubMax(const Delta& d) const;
00728 bool lubAny(const Delta& d) const;
00730
00731 };
00732
00737 template<class Char, class Traits>
00738 std::basic_ostream<Char,Traits>&
00739 operator <<(std::basic_ostream<Char,Traits>& os, const SingletonView& x);
00740
00741
00751 template<class View>
00752 class ComplementView
00753 : public DerivedView<View> {
00754 protected:
00755 using DerivedView<View>::x;
00756
00757 public:
00759 static PropCond pc_negateset(PropCond pc);
00761 static ModEvent me_negateset(ModEvent me);
00762
00764
00765
00766 ComplementView(void);
00768 explicit ComplementView(View& y);
00770
00772
00773
00775 unsigned int cardMin(void) const;
00777 unsigned int cardMax(void) const;
00779 int lubMin(void) const;
00781 int lubMax(void) const;
00783 int lubMinN(unsigned int n) const;
00785 int glbMin(void) const;
00787 int glbMax(void) const;
00788
00790 unsigned int glbSize(void) const;
00792 unsigned int lubSize(void) const;
00794 unsigned int unknownSize(void) const;
00796
00798
00799
00800 bool contains(int i) const;
00802 bool notContains(int i) const;
00804
00805
00807
00808
00809 ModEvent cardMin(Space& home, unsigned int m);
00811 ModEvent cardMax(Space& home, unsigned int m);
00816 ModEvent include(Space& home,int i,int j);
00821 ModEvent exclude(Space& home,int i,int j);
00823 ModEvent include(Space& home,int i);
00825 ModEvent exclude(Space& home,int i);
00830 ModEvent intersect(Space& home,int i,int j);
00832 ModEvent intersect(Space& home,int i);
00834
00836
00837
00839 template<class I> ModEvent excludeI(Space& home, I& i);
00841 template<class I> ModEvent includeI(Space& home, I& i);
00843 template<class I> ModEvent intersectI(Space& home, I& iter);
00845
00847
00848
00849 static void schedule(Space& home, Propagator& p, ModEvent me);
00851 static ModEvent me(const ModEventDelta& med);
00853 static ModEventDelta med(ModEvent);
00855
00857
00858
00865 void subscribe(Space& home, Propagator& p, PropCond pc, bool schedule=true);
00867 void cancel(Space& home, Propagator& p, PropCond pc);
00869 void subscribe(Space& home, Advisor& a);
00871 void cancel(Space& home, Advisor& a);
00873
00875
00876
00877 static ModEvent modevent(const Delta& d);
00879 int glbMin(const Delta& d) const;
00881 int glbMax(const Delta& d) const;
00883 bool glbAny(const Delta& d) const;
00885 int lubMin(const Delta& d) const;
00887 int lubMax(const Delta& d) const;
00889 bool lubAny(const Delta& d) const;
00891
00892 };
00893
00898 template<class Char, class Traits, class View>
00899 std::basic_ostream<Char,Traits>&
00900 operator <<(std::basic_ostream<Char,Traits>& os,
00901 const ComplementView<View>& x);
00902
00903
00904 template<class View> class LubDiffRanges;
00905 template<class View> class GlbDiffRanges;
00906
00918 template<class View>
00919 class CachedView
00920 : public DerivedView<View> {
00921 friend class LubDiffRanges<View>;
00922 friend class GlbDiffRanges<View>;
00923 protected:
00924 using DerivedView<View>::x;
00925
00927 LUBndSet lubCache;
00929 GLBndSet glbCache;
00930
00931 public:
00932
00934
00935
00936 CachedView(void);
00938 explicit CachedView(const View& y);
00940
00942
00943
00945 unsigned int cardMin(void) const;
00947 unsigned int cardMax(void) const;
00949 int lubMin(void) const;
00951 int lubMax(void) const;
00953 int lubMinN(unsigned int n) const;
00955 int glbMin(void) const;
00957 int glbMax(void) const;
00958
00960 unsigned int glbSize(void) const;
00962 unsigned int lubSize(void) const;
00964 unsigned int unknownSize(void) const;
00966
00968
00969
00970 bool contains(int i) const;
00972 bool notContains(int i) const;
00974
00975
00977
00978
00979 ModEvent cardMin(Space& home, unsigned int m);
00981 ModEvent cardMax(Space& home, unsigned int m);
00986 ModEvent include(Space& home,int i,int j);
00991 ModEvent exclude(Space& home,int i,int j);
00993 ModEvent include(Space& home,int i);
00995 ModEvent exclude(Space& home,int i);
01000 ModEvent intersect(Space& home,int i,int j);
01002 ModEvent intersect(Space& home,int i);
01004
01006
01007
01009 template<class I> ModEvent excludeI(Space& home, I& i);
01011 template<class I> ModEvent includeI(Space& home, I& i);
01013 template<class I> ModEvent intersectI(Space& home, I& iter);
01015
01017
01018
01019 static void schedule(Space& home, Propagator& p, ModEvent me);
01021 static ModEvent me(const ModEventDelta& med);
01023 static ModEventDelta med(ModEvent);
01025
01027
01028
01035 void subscribe(Space& home, Propagator& p, PropCond pc, bool schedule=true);
01037 void cancel(Space& home, Propagator& p, PropCond pc);
01039 void subscribe(Space& home, Advisor& a);
01041 void cancel(Space& home, Advisor& a);
01043
01045
01046
01047 static ModEvent modevent(const Delta& d);
01049 int glbMin(const Delta& d) const;
01051 int glbMax(const Delta& d) const;
01053 bool glbAny(const Delta& d) const;
01055 int lubMin(const Delta& d) const;
01057 int lubMax(const Delta& d) const;
01059 bool lubAny(const Delta& d) const;
01061
01063
01064
01065 void initCache(Space& home, const IntSet& glb, const IntSet& lub);
01067 void cacheGlb(Space& home);
01069 void cacheLub(Space& home);
01071 bool glbModified(void) const;
01073 bool lubModified(void) const;
01075
01077
01078
01079 void update(Space& home, CachedView<View>& y);
01081 };
01082
01087 template<class Char, class Traits, class View>
01088 std::basic_ostream<Char,Traits>&
01089 operator <<(std::basic_ostream<Char,Traits>& os,
01090 const CachedView<View>& x);
01091
01096 template<class View>
01097 class GlbDiffRanges
01098 : public Iter::Ranges::Diff<GlbRanges<View>,BndSetRanges> {
01099 protected:
01101 GlbRanges<View> gr;
01103 BndSetRanges cr;
01104 public:
01106 GlbDiffRanges(const CachedView<View>& x);
01107 };
01108
01113 template<class View>
01114 class LubDiffRanges
01115 : public Iter::Ranges::Diff<BndSetRanges,LubRanges<View> > {
01116 protected:
01118 BndSetRanges cr;
01120 LubRanges<View> lr;
01121 public:
01123 LubDiffRanges(const CachedView<View>& x);
01124 };
01125
01126 }}
01127
01128 #include <gecode/set/var/set.hpp>
01129
01130 #include <gecode/set/view/set.hpp>
01131
01132 #include <gecode/set/view/const.hpp>
01133 #include <gecode/set/view/singleton.hpp>
01134 #include <gecode/set/view/complement.hpp>
01135 #include <gecode/set/view/cached.hpp>
01136
01137 #include <gecode/set/view/print.hpp>
01138 #include <gecode/set/var/print.hpp>
01139
01140