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
00039
00040
00041
00042 #include <iostream>
00043
00044 namespace Gecode {
00045
00046 namespace Set {
00047
00062 class SetView : public VarViewBase<SetVarImp> {
00063 protected:
00064 using VarViewBase<SetVarImp>::varimp;
00065 public:
00067
00068
00069 SetView(void);
00071 SetView(const SetVar& x);
00073 SetView(SetVarImp* x);
00075
00077
00078
00080 unsigned int cardMin(void) const;
00082 unsigned int cardMax(void) const;
00084 int lubMin(void) const;
00086 int lubMax(void) const;
00088 int lubMinN(unsigned int n) const;
00090 int glbMin(void) const;
00092 int glbMax(void) const;
00093
00095 unsigned int glbSize(void) const;
00097 unsigned int lubSize(void) const;
00099 unsigned int unknownSize(void) const;
00101
00103
00104
00105 bool assigned(void) const;
00107 bool contains(int i) const;
00109 bool notContains(int i) const;
00111
00112
00114
00115
00116 ModEvent cardMin(Space& home, unsigned int m);
00118 ModEvent cardMax(Space& home, unsigned int m);
00123 ModEvent include(Space& home,int i,int j);
00128 ModEvent exclude(Space& home,int i,int j);
00130 ModEvent include(Space& home,int i);
00132 ModEvent exclude(Space& home,int i);
00137 ModEvent intersect(Space& home,int i,int j);
00139 ModEvent intersect(Space& home,int i);
00141
00143
00144
00146 template<class I> ModEvent excludeI(Space& home, I& i);
00148 template<class I> ModEvent includeI(Space& home, I& i);
00150 template<class I> ModEvent intersectI(Space& home, I& iter);
00152
00154
00155
00156 void update(Space& home, bool share, SetView& x);
00158
00160
00161
00162 static ModEvent modevent(const Delta& d);
00164 int glbMin(const Delta& d) const;
00166 int glbMax(const Delta& d) const;
00168 bool glbAny(const Delta& d) const;
00170 int lubMin(const Delta& d) const;
00172 int lubMax(const Delta& d) const;
00174 bool lubAny(const Delta& d) const;
00176 };
00177
00182 template<class Char, class Traits>
00183 std::basic_ostream<Char,Traits>&
00184 operator <<(std::basic_ostream<Char,Traits>& os, const SetView& x);
00185
00186 }
00187
00194 template<>
00195 class ViewVarImpTraits<Set::SetView> {
00196 public:
00198 typedef Set::SetVarImp VarImp;
00199 };
00200
00201
00207 template<>
00208 class VarViewTraits<SetVar> {
00209 public:
00211 typedef Set::SetView View;
00212 };
00213
00214
00215 namespace Set { class ConstantView; }
00216 bool same(const Set::ConstantView&, const Set::ConstantView&);
00217 bool before(const Set::ConstantView&, const Set::ConstantView&);
00218
00219 namespace Set {
00220
00228 class ConstantView : public ConstViewBase {
00229 friend class LubRanges<ConstantView>;
00230 friend class GlbRanges<ConstantView>;
00231 friend bool Gecode::same(const Gecode::Set::ConstantView&,
00232 const Gecode::Set::ConstantView&);
00233 friend bool Gecode::before(const Gecode::Set::ConstantView&,
00234 const Gecode::Set::ConstantView&);
00235 private:
00236 int *ranges;
00237 int size;
00238 unsigned int domSize;
00240 void init(Space& home, const IntSet& s);
00241 public:
00243
00244
00245 ConstantView(void);
00247 ConstantView(Space& home, const IntSet& s);
00249
00251
00252
00253 unsigned int cardMin(void) const;
00255 unsigned int cardMax(void) const;
00257 int lubMin(void) const;
00259 int lubMax(void) const;
00261 int lubMinN(unsigned int n) const;
00263 int glbMin(void) const;
00265 int glbMax(void) const;
00266
00268 unsigned int glbSize(void) const;
00270 unsigned int lubSize(void) const;
00272 unsigned int unknownSize(void) const;
00274
00276
00277
00278 bool assigned(void) const;
00280 bool contains(int i) const;
00282 bool notContains(int i) const;
00284
00285
00287
00288
00289 ModEvent cardMin(Space& home, unsigned int m);
00291 ModEvent cardMax(Space& home, unsigned int m);
00296 ModEvent include(Space& home,int i,int j);
00301 ModEvent exclude(Space& home,int i,int j);
00303 ModEvent include(Space& home,int i);
00305 ModEvent exclude(Space& home,int i);
00310 ModEvent intersect(Space& home,int i,int j);
00312 ModEvent intersect(Space& home,int i);
00314
00316
00317
00319 template<class I> ModEvent excludeI(Space& home, I& i);
00321 template<class I> ModEvent includeI(Space& home, I& i);
00323 template<class I> ModEvent intersectI(Space& home, I& iter);
00325
00327
00328
00329 static void schedule(Space& home, Propagator& p, ModEvent me);
00331 static ModEvent me(const ModEventDelta& med);
00333 static ModEventDelta med(ModEvent);
00335
00337
00338
00345 void subscribe(Space& home, Propagator& p, PropCond pc, bool process=true);
00347 void cancel(Space& home, Propagator& p, PropCond pc);
00349 void subscribe(Space& home, Advisor& a);
00351 void cancel(Space& home, Advisor& a);
00353
00355
00356
00357 void update(Space& home, bool share, ConstantView& x);
00359
00361
00362
00363 static ModEvent modevent(const Delta& d);
00365 int glbMin(const Delta& d) const;
00367 int glbMax(const Delta& d) const;
00369 bool glbAny(const Delta& d) const;
00371 int lubMin(const Delta& d) const;
00373 int lubMax(const Delta& d) const;
00375 bool lubAny(const Delta& d) const;
00377
00378 };
00379
00384 template<class Char, class Traits>
00385 std::basic_ostream<Char,Traits>&
00386 operator <<(std::basic_ostream<Char,Traits>& os, const ConstantView& x);
00387 }
00388
00393
00394 bool same(const Set::ConstantView& x, const Set::ConstantView& y);
00396 bool before(const Set::ConstantView& x, const Set::ConstantView& y);
00398
00405 template<>
00406 class ViewVarImpTraits<Set::ConstantView> {
00407 public:
00409 typedef VarImpBase VarImp;
00410 };
00411
00412 namespace Set {
00413
00422 class EmptyView : public ConstViewBase {
00423 public:
00425
00426
00427 EmptyView(void);
00429
00431
00432
00433 unsigned int cardMin(void) const;
00435 unsigned int cardMax(void) const;
00437 int lubMin(void) const;
00439 int lubMax(void) const;
00441 int lubMinN(unsigned int n) const;
00443 int glbMin(void) const;
00445 int glbMax(void) const;
00446
00448 unsigned int glbSize(void) const;
00450 unsigned int lubSize(void) const;
00452 unsigned int unknownSize(void) const;
00454
00456
00457
00458 bool assigned(void) const;
00460 bool contains(int i) const;
00462 bool notContains(int i) const;
00464
00465
00467
00468
00469 ModEvent cardMin(Space& home, unsigned int m);
00471 ModEvent cardMax(Space& home, unsigned int m);
00476 ModEvent include(Space& home,int i,int j);
00481 ModEvent exclude(Space& home,int i,int j);
00483 ModEvent include(Space& home,int i);
00485 ModEvent exclude(Space& home,int i);
00490 ModEvent intersect(Space& home,int i,int j);
00492 ModEvent intersect(Space& home,int i);
00494
00496
00497
00499 template<class I> ModEvent excludeI(Space& home, I& i);
00501 template<class I> ModEvent includeI(Space& home, I& i);
00503 template<class I> ModEvent intersectI(Space& home, I& iter);
00505
00507
00508
00509 static void schedule(Space& home, Propagator& p, ModEvent me);
00511 static ModEvent me(const ModEventDelta& med);
00513 static ModEventDelta med(ModEvent);
00515
00517
00518
00525 void subscribe(Space& home, Propagator& p, PropCond pc, bool process=true);
00527 void cancel(Space& home, Propagator& p, PropCond pc);
00529 void subscribe(Space& home, Advisor& a);
00531 void cancel(Space& home, Advisor& a);
00533
00535
00536
00537 void update(Space& home, bool share, EmptyView& x);
00539
00541
00542
00543 static ModEvent modevent(const Delta& d);
00545 int glbMin(const Delta& d) const;
00547 int glbMax(const Delta& d) const;
00549 bool glbAny(const Delta& d) const;
00551 int lubMin(const Delta& d) const;
00553 int lubMax(const Delta& d) const;
00555 bool lubAny(const Delta& d) const;
00557
00558 };
00559
00564 template<class Char, class Traits>
00565 std::basic_ostream<Char,Traits>&
00566 operator <<(std::basic_ostream<Char,Traits>& os, const EmptyView& x);
00567
00568 }
00569
00574
00575 bool same(const Set::EmptyView& x, const Set::EmptyView& y);
00577 bool before(const Set::EmptyView& x, const Set::EmptyView& y);
00579
00586 template<>
00587 class ViewVarImpTraits<Set::EmptyView> {
00588 public:
00590 typedef VarImpBase VarImp;
00591 };
00592
00593 namespace Set {
00594
00595
00604 class UniverseView : public ConstViewBase {
00605 public:
00607
00608
00609 UniverseView(void);
00611
00613
00614
00616 unsigned int cardMin(void) const;
00618 unsigned int cardMax(void) const;
00620 int lubMin(void) const;
00622 int lubMax(void) const;
00624 int lubMinN(unsigned int n) const;
00626 int glbMin(void) const;
00628 int glbMax(void) const;
00629
00631 unsigned int glbSize(void) const;
00633 unsigned int lubSize(void) const;
00635 unsigned int unknownSize(void) const;
00637
00639
00640
00641 bool assigned(void) const;
00643 bool contains(int i) const;
00645 bool notContains(int i) const;
00647
00648
00650
00651
00652 ModEvent cardMin(Space& home, unsigned int m);
00654 ModEvent cardMax(Space& home, unsigned int m);
00659 ModEvent include(Space& home,int i,int j);
00664 ModEvent exclude(Space& home,int i,int j);
00666 ModEvent include(Space& home,int i);
00668 ModEvent exclude(Space& home,int i);
00673 ModEvent intersect(Space& home,int i,int j);
00675 ModEvent intersect(Space& home,int i);
00677
00679
00680
00682 template<class I> ModEvent excludeI(Space& home, I& i);
00684 template<class I> ModEvent includeI(Space& home, I& i);
00686 template<class I> ModEvent intersectI(Space& home, I& iter);
00688
00690
00691
00692 static void schedule(Space& home, Propagator& p, ModEvent me);
00694 static ModEvent me(const ModEventDelta& med);
00696 static ModEventDelta med(ModEvent);
00698
00700
00701
00708 void subscribe(Space& home, Propagator& p, PropCond pc, bool process=true);
00710 void cancel(Space& home, Propagator& p, PropCond pc);
00712 void subscribe(Space& home, Advisor& a);
00714 void cancel(Space& home, Advisor& a);
00716
00718
00719
00720 void update(Space& home, bool share, UniverseView& x);
00722
00724
00725
00726 static ModEvent modevent(const Delta& d);
00728 int glbMin(const Delta& d) const;
00730 int glbMax(const Delta& d) const;
00732 bool glbAny(const Delta& d) const;
00734 int lubMin(const Delta& d) const;
00736 int lubMax(const Delta& d) const;
00738 bool lubAny(const Delta& d) const;
00740
00741 };
00742
00747 template<class Char, class Traits>
00748 std::basic_ostream<Char,Traits>&
00749 operator <<(std::basic_ostream<Char,Traits>& os, const UniverseView& x);
00750
00751 }
00752
00757
00758 bool same(const Set::UniverseView& x, const Set::UniverseView& y);
00760 bool before(const Set::UniverseView& x, const Set::UniverseView& y);
00762
00769 template<>
00770 class ViewVarImpTraits<Set::UniverseView> {
00771 public:
00773 typedef VarImpBase VarImp;
00774 };
00775
00776 namespace Set {
00777
00778
00779
00788 class SingletonView :
00789 public DerivedViewBase<Gecode::Int::IntView> {
00790 protected:
00791 using DerivedViewBase<Gecode::Int::IntView>::view;
00792
00794 static PropCond pc_settoint(PropCond pc);
00796 static ModEvent me_inttoset(ModEvent me);
00798 static ModEvent me_settoint(ModEvent me);
00799
00800 public:
00802
00803
00804 SingletonView(void);
00806 SingletonView(Gecode::Int::IntView& x);
00808
00810
00811
00813 unsigned int cardMin(void) const;
00815 unsigned int cardMax(void) const;
00817 int lubMin(void) const;
00819 int lubMax(void) const;
00821 int lubMinN(unsigned int n) const;
00823 int glbMin(void) const;
00825 int glbMax(void) const;
00826
00828 unsigned int glbSize(void) const;
00830 unsigned int lubSize(void) const;
00832 unsigned int unknownSize(void) const;
00834
00836
00837
00838 bool assigned(void) const;
00840 bool contains(int i) const;
00842 bool notContains(int i) const;
00844
00845
00847
00848
00849 ModEvent cardMin(Space& home, unsigned int m);
00851 ModEvent cardMax(Space& home, unsigned int m);
00856 ModEvent include(Space& home,int i,int j);
00861 ModEvent exclude(Space& home,int i,int j);
00863 ModEvent include(Space& home,int i);
00865 ModEvent exclude(Space& home,int i);
00870 ModEvent intersect(Space& home,int i,int j);
00872 ModEvent intersect(Space& home,int i);
00874
00876
00877
00879 template<class I> ModEvent excludeI(Space& home, I& i);
00881 template<class I> ModEvent includeI(Space& home, I& i);
00883 template<class I> ModEvent intersectI(Space& home, I& iter);
00885
00887
00888
00889 static void schedule(Space& home, Propagator& p, ModEvent me);
00891 static ModEvent me(const ModEventDelta& med);
00893 static ModEventDelta med(ModEvent);
00895
00897
00898
00905 void subscribe(Space& home, Propagator& p, PropCond pc, bool process=true);
00907 void cancel(Space& home, Propagator& p, PropCond pc);
00909 void subscribe(Space& home, Advisor& a);
00911 void cancel(Space& home, Advisor& a);
00913
00914
00916
00917
00918 void update(Space& home, bool share, SingletonView& x);
00920
00922
00923
00924 static ModEvent modevent(const Delta& d);
00926 int glbMin(const Delta& d) const;
00928 int glbMax(const Delta& d) const;
00930 bool glbAny(const Delta& d) const;
00932 int lubMin(const Delta& d) const;
00934 int lubMax(const Delta& d) const;
00936 bool lubAny(const Delta& d) const;
00938
00939 };
00940
00945 template<class Char, class Traits>
00946 std::basic_ostream<Char,Traits>&
00947 operator <<(std::basic_ostream<Char,Traits>& os, const SingletonView& x);
00948
00949 }
00950
00955
00956 bool same(const Set::SingletonView& x, const Set::SingletonView& y);
00958 bool before(const Set::SingletonView& x, const Set::SingletonView& y);
00960
00967 template<>
00968 class ViewVarImpTraits<Set::SingletonView> {
00969 public:
00971 typedef Int::IntVarImp VarImp;
00972 };
00973
00974 namespace Set {
00975
00976
00986 template<class View>
00987 class ComplementView
00988 : public DerivedViewBase<View> {
00989 protected:
00990 using DerivedViewBase<View>::view;
00991
00992 public:
00994 static PropCond pc_negateset(PropCond pc);
00996 static ModEvent me_negateset(ModEvent me);
00997
00999
01000
01001 ComplementView(void);
01003 explicit ComplementView(View& x);
01005
01007
01008
01010 unsigned int cardMin(void) const;
01012 unsigned int cardMax(void) const;
01014 int lubMin(void) const;
01016 int lubMax(void) const;
01018 int lubMinN(unsigned int n) const;
01020 int glbMin(void) const;
01022 int glbMax(void) const;
01023
01025 unsigned int glbSize(void) const;
01027 unsigned int lubSize(void) const;
01029 unsigned int unknownSize(void) const;
01031
01033
01034
01035 bool assigned(void) const;
01037 bool contains(int i) const;
01039 bool notContains(int i) const;
01041
01042
01044
01045
01046 ModEvent cardMin(Space& home, unsigned int m);
01048 ModEvent cardMax(Space& home, unsigned int m);
01053 ModEvent include(Space& home,int i,int j);
01058 ModEvent exclude(Space& home,int i,int j);
01060 ModEvent include(Space& home,int i);
01062 ModEvent exclude(Space& home,int i);
01067 ModEvent intersect(Space& home,int i,int j);
01069 ModEvent intersect(Space& home,int i);
01071
01073
01074
01076 template<class I> ModEvent excludeI(Space& home, I& i);
01078 template<class I> ModEvent includeI(Space& home, I& i);
01080 template<class I> ModEvent intersectI(Space& home, I& iter);
01082
01084
01085
01086 static void schedule(Space& home, Propagator& p, ModEvent me);
01088 static ModEvent me(const ModEventDelta& med);
01090 static ModEventDelta med(ModEvent);
01092
01094
01095
01102 void subscribe(Space& home, Propagator& p, PropCond pc, bool process=true);
01104 void cancel(Space& home, Propagator& p, PropCond pc);
01106 void subscribe(Space& home, Advisor& a);
01108 void cancel(Space& home, Advisor& a);
01110
01111
01113
01114
01115 void update(Space& home, bool share, ComplementView& x);
01117
01119
01120
01121 static ModEvent modevent(const Delta& d);
01123 int glbMin(const Delta& d) const;
01125 int glbMax(const Delta& d) const;
01127 bool glbAny(const Delta& d) const;
01129 int lubMin(const Delta& d) const;
01131 int lubMax(const Delta& d) const;
01133 bool lubAny(const Delta& d) const;
01135
01136 };
01137
01142 template<class Char, class Traits, class View>
01143 std::basic_ostream<Char,Traits>&
01144 operator <<(std::basic_ostream<Char,Traits>& os,
01145 const ComplementView<View>& x);
01146 }
01147
01152
01153 template<class View>
01154 bool same(const Set::ComplementView<View>& x,
01155 const Set::ComplementView<View>& y);
01157 template<class View>
01158 bool before(const Set::ComplementView<View>& x,
01159 const Set::ComplementView<View>& y);
01161
01162
01169 template<class View>
01170 class ViewVarImpTraits<Set::ComplementView<View> > {
01171 public:
01173 typedef typename ViewVarImpTraits<View>::VarImp VarImp;
01174 };
01175
01176
01177 namespace Set {
01178
01179
01188 template<class View>
01189 class OffsetSetView : public DerivedViewBase<View> {
01190 protected:
01191 using DerivedViewBase<View>::view;
01193 int k;
01194 public:
01196
01197
01198 OffsetSetView(void);
01200 OffsetSetView(View& x, int k0);
01202
01204
01205
01206 unsigned int cardMin(void) const;
01208 unsigned int cardMax(void) const;
01210 int lubMin(void) const;
01212 int lubMax(void) const;
01214 int lubMinN(unsigned int n) const;
01216 int glbMin(void) const;
01218 int glbMax(void) const;
01219
01221 unsigned int glbSize(void) const;
01223 unsigned int lubSize(void) const;
01225 unsigned int unknownSize(void) const;
01227 int offset(void) const;
01229
01231
01232
01233 bool assigned(void) const;
01235 bool contains(int i) const;
01237 bool notContains(int i) const;
01239
01240
01242
01243
01244 ModEvent cardMin(Space& home, unsigned int m);
01246 ModEvent cardMax(Space& home, unsigned int m);
01251 ModEvent include(Space& home,int i,int j);
01256 ModEvent exclude(Space& home,int i,int j);
01258 ModEvent include(Space& home,int i);
01260 ModEvent exclude(Space& home,int i);
01265 ModEvent intersect(Space& home,int i,int j);
01267 ModEvent intersect(Space& home,int i);
01269
01271
01272
01274 template<class I> ModEvent excludeI(Space& home, I& i);
01276 template<class I> ModEvent includeI(Space& home, I& i);
01278 template<class I> ModEvent intersectI(Space& home, I& iter);
01280
01282
01283
01284 static void schedule(Space& home, Propagator& p, ModEvent me);
01286 static ModEvent me(const ModEventDelta& med);
01288 static ModEventDelta med(ModEvent);
01290
01292
01293
01300 void subscribe(Space& home, Propagator& p, PropCond pc, bool process=true);
01302 void cancel(Space& home, Propagator& p, PropCond pc);
01304 void subscribe(Space& home, Advisor& a);
01306 void cancel(Space& home, Advisor& a);
01308
01309
01311
01312
01313 void update(Space& home, bool share, OffsetSetView& x);
01315
01317
01318
01319 static ModEvent modevent(const Delta& d);
01321 int glbMin(const Delta& d) const;
01323 int glbMax(const Delta& d) const;
01325 bool glbAny(const Delta& d) const;
01327 int lubMin(const Delta& d) const;
01329 int lubMax(const Delta& d) const;
01331 bool lubAny(const Delta& d) const;
01333 };
01334
01339 template<class Char, class Traits, class View>
01340 std::basic_ostream<Char,Traits>&
01341 operator <<(std::basic_ostream<Char,Traits>& os,
01342 const OffsetSetView<View>& x);
01343
01344 }
01345
01350
01351 template<class View>
01352 bool same(const Set::OffsetSetView<View>& x,
01353 const Set::OffsetSetView<View>& y);
01355 template<class View>
01356 bool before(const Set::OffsetSetView<View>& x,
01357 const Set::OffsetSetView<View>& y);
01359
01360
01367 template<class View>
01368 class ViewVarImpTraits<Set::OffsetSetView<View> > {
01369 public:
01371 typedef typename ViewVarImpTraits<View>::VarImp VarImp;
01372 };
01373
01374
01375 }
01376
01377 #include <gecode/set/var/set.hpp>
01378
01379 #include <gecode/set/view/set.hpp>
01380
01381 #include <gecode/set/view/const.hpp>
01382 #include <gecode/set/view/singleton.hpp>
01383 #include <gecode/set/view/complement.hpp>
01384 #include <gecode/set/view/offset.hpp>
01385
01386 #include <gecode/set/view/print.hpp>
01387 #include <gecode/set/var/print.hpp>
01388
01389