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 SetView(Space* home, const Reflection::VarMap& vars,
00076 Reflection::Arg* arg);
00078
00080
00081
00083 unsigned int cardMin(void) const;
00085 unsigned int cardMax(void) const;
00087 int lubMin(void) const;
00089 int lubMax(void) const;
00091 int lubMinN(int n) const;
00093 int glbMin(void) const;
00095 int glbMax(void) const;
00096
00098 unsigned int glbSize(void) const;
00100 unsigned int lubSize(void) const;
00102 unsigned int unknownSize(void) const;
00104
00106
00107
00108 bool assigned(void) const;
00110 bool contains(int i) const;
00112 bool notContains(int i) const;
00114
00115
00117
00118
00119 ModEvent cardMin(Space* home, unsigned int m);
00121 ModEvent cardMax(Space* home, unsigned int m);
00126 ModEvent include(Space* home,int i,int j);
00131 ModEvent exclude(Space* home,int i,int j);
00133 ModEvent include(Space* home,int i);
00135 ModEvent exclude(Space* home,int i);
00140 ModEvent intersect(Space* home,int i,int j);
00142 ModEvent intersect(Space* home,int i);
00144
00146
00147
00149 template <class I> ModEvent excludeI(Space* home, I& i);
00151 template <class I> ModEvent includeI(Space* home, I& i);
00153 template <class I> ModEvent intersectI(Space* home, I& iter);
00155
00157
00158
00159 void update(Space* home, bool share, SetView& x);
00161
00163
00164
00165 Reflection::Arg* spec(const Space* home, Reflection::VarMap& m) const;
00166 static Support::Symbol type(void);
00168
00170
00171
00172 static ModEvent modevent(const Delta* d);
00174 int glbMin(const Delta* d) const;
00176 int glbMax(const Delta* d) const;
00178 bool glbAny(const Delta* d) const;
00180 int lubMin(const Delta* d) const;
00182 int lubMax(const Delta* d) const;
00184 bool lubAny(const Delta* d) const;
00186
00187 };
00188
00189 }
00190
00197 template<>
00198 class ViewVarImpTraits<Set::SetView> {
00199 public:
00201 typedef Set::SetVarImp VarImp;
00202 };
00203
00204
00210 template<>
00211 class VarViewTraits<SetVar> {
00212 public:
00214 typedef Set::SetView View;
00215 };
00216
00217
00218 namespace Set { class ConstantView; }
00219 bool same(const Set::ConstantView&, const Set::ConstantView&);
00220 bool before(const Set::ConstantView&, const Set::ConstantView&);
00221
00222 namespace Set {
00223
00231 class ConstantView : public ConstViewBase {
00232 friend class LubRanges<ConstantView>;
00233 friend class GlbRanges<ConstantView>;
00234 friend bool Gecode::same(const Gecode::Set::ConstantView&,
00235 const Gecode::Set::ConstantView&);
00236 friend bool Gecode::before(const Gecode::Set::ConstantView&,
00237 const Gecode::Set::ConstantView&);
00238 private:
00239 int *ranges;
00240 unsigned int size;
00241 unsigned int domSize;
00243 void init(Space* home, const IntSet& s);
00244 public:
00246
00247
00248 ConstantView(void);
00250 ConstantView(Space* home, const IntSet& s);
00252 ConstantView(Space* home, const Reflection::VarMap& vars,
00253 Reflection::Arg* arg);
00255
00257
00258
00259 unsigned int cardMin(void) const;
00261 unsigned int cardMax(void) const;
00263 int lubMin(void) const;
00265 int lubMax(void) const;
00267 int lubMinN(int n) const;
00269 int glbMin(void) const;
00271 int glbMax(void) const;
00272
00274 unsigned int glbSize(void) const;
00276 unsigned int lubSize(void) const;
00278 unsigned int unknownSize(void) const;
00280
00282
00283
00284 bool assigned(void) const;
00286 bool contains(int i) const;
00288 bool notContains(int i) const;
00290
00291
00293
00294
00295 ModEvent cardMin(Space* home, unsigned int m);
00297 ModEvent cardMax(Space* home, unsigned int m);
00302 ModEvent include(Space* home,int i,int j);
00307 ModEvent exclude(Space* home,int i,int j);
00309 ModEvent include(Space* home,int i);
00311 ModEvent exclude(Space* home,int i);
00316 ModEvent intersect(Space* home,int i,int j);
00318 ModEvent intersect(Space* home,int i);
00320
00322
00323
00325 template <class I> ModEvent excludeI(Space* home, I& i);
00327 template <class I> ModEvent includeI(Space* home, I& i);
00329 template <class I> ModEvent intersectI(Space* home, I& iter);
00331
00333
00334
00335 static void schedule(Space* home, Propagator* p, ModEvent me);
00337 static ModEvent me(ModEventDelta med);
00339 static ModEventDelta med(ModEvent);
00341
00343
00344
00351 void subscribe(Space* home, Propagator* p, PropCond pc, bool process=true);
00353 void cancel(Space* home, Propagator* p, PropCond pc);
00355 void subscribe(Space* home, Advisor* a);
00357 void cancel(Space* home, Advisor* a);
00359
00361
00362
00363 void update(Space* home, bool share, ConstantView& x);
00365
00367
00368
00369 Reflection::Arg* spec(const Space* home, Reflection::VarMap& m) const;
00370 static Support::Symbol type(void);
00372
00374
00375
00376 static ModEvent modevent(const Delta* d);
00378 int glbMin(const Delta* d) const;
00380 int glbMax(const Delta* d) const;
00382 bool glbAny(const Delta* d) const;
00384 int lubMin(const Delta* d) const;
00386 int lubMax(const Delta* d) const;
00388 bool lubAny(const Delta* d) const;
00390
00391 };
00392
00393 }
00394
00399
00400 bool same(const Set::ConstantView& x, const Set::ConstantView& y);
00402 bool before(const Set::ConstantView& x, const Set::ConstantView& y);
00404
00411 template<>
00412 class ViewVarImpTraits<Set::ConstantView> {
00413 public:
00415 typedef VarImpBase VarImp;
00416 };
00417
00418 namespace Set {
00419
00428 class EmptyView : public ConstViewBase {
00429 public:
00431
00432
00433 EmptyView(void);
00435 EmptyView(Space* home, const Reflection::VarMap& vars,
00436 Reflection::Arg* arg);
00438
00440
00441
00443 unsigned int cardMin(void) const;
00445 unsigned int cardMax(void) const;
00447 int lubMin(void) const;
00449 int lubMax(void) const;
00451 int lubMinN(int n) const;
00453 int glbMin(void) const;
00455 int glbMax(void) const;
00456
00458 unsigned int glbSize(void) const;
00460 unsigned int lubSize(void) const;
00462 unsigned int unknownSize(void) const;
00464
00466
00467
00468 bool assigned(void) const;
00470 bool contains(int i) const;
00472 bool notContains(int i) const;
00474
00475
00477
00478
00479 ModEvent cardMin(Space* home, unsigned int m);
00481 ModEvent cardMax(Space* home, unsigned int m);
00486 ModEvent include(Space* home,int i,int j);
00491 ModEvent exclude(Space* home,int i,int j);
00493 ModEvent include(Space* home,int i);
00495 ModEvent exclude(Space* home,int i);
00500 ModEvent intersect(Space* home,int i,int j);
00502 ModEvent intersect(Space* home,int i);
00504
00506
00507
00509 template <class I> ModEvent excludeI(Space* home, I& i);
00511 template <class I> ModEvent includeI(Space* home, I& i);
00513 template <class I> ModEvent intersectI(Space* home, I& iter);
00515
00517
00518
00519 static void schedule(Space* home, Propagator* p, ModEvent me);
00521 static ModEvent me(ModEventDelta med);
00523 static ModEventDelta med(ModEvent);
00525
00527
00528
00535 void subscribe(Space* home, Propagator* p, PropCond pc, bool process=true);
00537 void cancel(Space* home, Propagator* p, PropCond pc);
00539 void subscribe(Space* home, Advisor* a);
00541 void cancel(Space* home, Advisor* a);
00543
00545
00546
00547 void update(Space* home, bool share, EmptyView& x);
00549
00551
00552
00553 Reflection::Arg* spec(const Space* home, Reflection::VarMap& m) const;
00554 static Support::Symbol type(void);
00556
00558
00559
00560 static ModEvent modevent(const Delta* d);
00562 int glbMin(const Delta* d) const;
00564 int glbMax(const Delta* d) const;
00566 bool glbAny(const Delta* d) const;
00568 int lubMin(const Delta* d) const;
00570 int lubMax(const Delta* d) const;
00572 bool lubAny(const Delta* d) const;
00574
00575 };
00576
00577 }
00578
00583
00584 bool same(const Set::EmptyView& x, const Set::EmptyView& y);
00586 bool before(const Set::EmptyView& x, const Set::EmptyView& y);
00588
00595 template<>
00596 class ViewVarImpTraits<Set::EmptyView> {
00597 public:
00599 typedef VarImpBase VarImp;
00600 };
00601
00602 namespace Set {
00603
00604
00613 class UniverseView : public ConstViewBase {
00614 public:
00616
00617
00618 UniverseView(void);
00620 UniverseView(Space* home, const Reflection::VarMap& vars,
00621 Reflection::Arg* arg);
00623
00625
00626
00628 unsigned int cardMin(void) const;
00630 unsigned int cardMax(void) const;
00632 int lubMin(void) const;
00634 int lubMax(void) const;
00636 int lubMinN(int n) const;
00638 int glbMin(void) const;
00640 int glbMax(void) const;
00641
00643 unsigned int glbSize(void) const;
00645 unsigned int lubSize(void) const;
00647 unsigned int unknownSize(void) const;
00649
00651
00652
00653 bool assigned(void) const;
00655 bool contains(int i) const;
00657 bool notContains(int i) const;
00659
00660
00662
00663
00664 ModEvent cardMin(Space* home, unsigned int m);
00666 ModEvent cardMax(Space* home, unsigned int m);
00671 ModEvent include(Space* home,int i,int j);
00676 ModEvent exclude(Space* home,int i,int j);
00678 ModEvent include(Space* home,int i);
00680 ModEvent exclude(Space* home,int i);
00685 ModEvent intersect(Space* home,int i,int j);
00687 ModEvent intersect(Space* home,int i);
00689
00691
00692
00694 template <class I> ModEvent excludeI(Space* home, I& i);
00696 template <class I> ModEvent includeI(Space* home, I& i);
00698 template <class I> ModEvent intersectI(Space* home, I& iter);
00700
00702
00703
00704 static void schedule(Space* home, Propagator* p, ModEvent me);
00706 static ModEvent me(ModEventDelta med);
00708 static ModEventDelta med(ModEvent);
00710
00712
00713
00720 void subscribe(Space* home, Propagator* p, PropCond pc, bool process=true);
00722 void cancel(Space* home, Propagator* p, PropCond pc);
00724 void subscribe(Space* home, Advisor* a);
00726 void cancel(Space* home, Advisor* a);
00728
00730
00731
00732 void update(Space* home, bool share, UniverseView& x);
00734
00736
00737
00738 Reflection::Arg* spec(const Space* home, Reflection::VarMap& m) const;
00739 static Support::Symbol type(void);
00741
00743
00744
00745 static ModEvent modevent(const Delta* d);
00747 int glbMin(const Delta* d) const;
00749 int glbMax(const Delta* d) const;
00751 bool glbAny(const Delta* d) const;
00753 int lubMin(const Delta* d) const;
00755 int lubMax(const Delta* d) const;
00757 bool lubAny(const Delta* d) const;
00759
00760 };
00761
00762 }
00763
00768
00769 bool same(const Set::UniverseView& x, const Set::UniverseView& y);
00771 bool before(const Set::UniverseView& x, const Set::UniverseView& y);
00773
00780 template<>
00781 class ViewVarImpTraits<Set::UniverseView> {
00782 public:
00784 typedef VarImpBase VarImp;
00785 };
00786
00787 namespace Set {
00788
00789
00790
00799 class SingletonView :
00800 public DerivedViewBase<Gecode::Int::IntView> {
00801 protected:
00802 using DerivedViewBase<Gecode::Int::IntView>::view;;
00803
00805 static PropCond pc_settoint(PropCond pc);
00807 static ModEvent me_inttoset(ModEvent me);
00809 static ModEvent me_settoint(ModEvent me);
00810
00811 public:
00813
00814
00815 SingletonView(void);
00817 SingletonView(Gecode::Int::IntView& x);
00819 SingletonView(Space* home, const Reflection::VarMap& vars,
00820 Reflection::Arg* arg);
00822
00824
00825
00827 unsigned int cardMin(void) const;
00829 unsigned int cardMax(void) const;
00831 int lubMin(void) const;
00833 int lubMax(void) const;
00835 int lubMinN(int n) const;
00837 int glbMin(void) const;
00839 int glbMax(void) const;
00840
00842 unsigned int glbSize(void) const;
00844 unsigned int lubSize(void) const;
00846 unsigned int unknownSize(void) const;
00848
00850
00851
00852 bool assigned(void) const;
00854 bool contains(int i) const;
00856 bool notContains(int i) const;
00858
00859
00861
00862
00863 ModEvent cardMin(Space* home, unsigned int m);
00865 ModEvent cardMax(Space* home, unsigned int m);
00870 ModEvent include(Space* home,int i,int j);
00875 ModEvent exclude(Space* home,int i,int j);
00877 ModEvent include(Space* home,int i);
00879 ModEvent exclude(Space* home,int i);
00884 ModEvent intersect(Space* home,int i,int j);
00886 ModEvent intersect(Space* home,int i);
00888
00890
00891
00893 template <class I> ModEvent excludeI(Space* home, I& i);
00895 template <class I> ModEvent includeI(Space* home, I& i);
00897 template <class I> ModEvent intersectI(Space* home, I& iter);
00899
00901
00902
00903 static void schedule(Space* home, Propagator* p, ModEvent me);
00905 static ModEvent me(ModEventDelta med);
00907 static ModEventDelta med(ModEvent);
00909
00911
00912
00919 void subscribe(Space* home, Propagator* p, PropCond pc, bool process=true);
00921 void cancel(Space* home, Propagator* p, PropCond pc);
00923 void subscribe(Space* home, Advisor* a);
00925 void cancel(Space* home, Advisor* a);
00927
00928
00930
00931
00932 void update(Space* home, bool share, SingletonView& x);
00934
00936
00937
00938 Reflection::Arg* spec(const Space* home, Reflection::VarMap& m) const;
00939 static Support::Symbol type(void);
00941
00943
00944
00945 static ModEvent modevent(const Delta* d);
00947 int glbMin(const Delta* d) const;
00949 int glbMax(const Delta* d) const;
00951 bool glbAny(const Delta* d) const;
00953 int lubMin(const Delta* d) const;
00955 int lubMax(const Delta* d) const;
00957 bool lubAny(const Delta* d) const;
00959
00960 };
00961
00962 }
00963
00968
00969 bool same(const Set::SingletonView& x, const Set::SingletonView& y);
00971 bool before(const Set::SingletonView& x, const Set::SingletonView& y);
00973
00980 template<>
00981 class ViewVarImpTraits<Set::SingletonView> {
00982 public:
00984 typedef Int::IntVarImp VarImp;
00985 };
00986
00987 namespace Set {
00988
00989
00999 template <class View>
01000 class ComplementView
01001 : public DerivedViewBase<View> {
01002 protected:
01003 using DerivedViewBase<View>::view;
01004
01005 public:
01007 static PropCond pc_negateset(PropCond pc);
01009 static ModEvent me_negateset(ModEvent me);
01010
01012
01013
01014 ComplementView(void);
01016 ComplementView(View& x);
01018 ComplementView(Space* home, const Reflection::VarMap& vars,
01019 Reflection::Arg* arg);
01021
01023
01024
01026 unsigned int cardMin(void) const;
01028 unsigned int cardMax(void) const;
01030 int lubMin(void) const;
01032 int lubMax(void) const;
01034 int lubMinN(int n) const;
01036 int glbMin(void) const;
01038 int glbMax(void) const;
01039
01041 unsigned int glbSize(void) const;
01043 unsigned int lubSize(void) const;
01045 unsigned int unknownSize(void) const;
01047
01049
01050
01051 bool assigned(void) const;
01053 bool contains(int i) const;
01055 bool notContains(int i) const;
01057
01058
01060
01061
01062 ModEvent cardMin(Space* home, unsigned int m);
01064 ModEvent cardMax(Space* home, unsigned int m);
01069 ModEvent include(Space* home,int i,int j);
01074 ModEvent exclude(Space* home,int i,int j);
01076 ModEvent include(Space* home,int i);
01078 ModEvent exclude(Space* home,int i);
01083 ModEvent intersect(Space* home,int i,int j);
01085 ModEvent intersect(Space* home,int i);
01087
01089
01090
01092 template <class I> ModEvent excludeI(Space* home, I& i);
01094 template <class I> ModEvent includeI(Space* home, I& i);
01096 template <class I> ModEvent intersectI(Space* home, I& iter);
01098
01100
01101
01102 static void schedule(Space* home, Propagator* p, ModEvent me);
01104 static ModEvent me(ModEventDelta med);
01106 static ModEventDelta med(ModEvent);
01108
01110
01111
01118 void subscribe(Space* home, Propagator* p, PropCond pc, bool process=true);
01120 void cancel(Space* home, Propagator* p, PropCond pc);
01122 void subscribe(Space* home, Advisor* a);
01124 void cancel(Space* home, Advisor* a);
01126
01127
01129
01130
01131 void update(Space* home, bool share, ComplementView& x);
01133
01135
01136
01137 Reflection::Arg* spec(const Space* home, Reflection::VarMap& m) const;
01138 static Support::Symbol type(void);
01140
01142
01143
01144 static ModEvent modevent(const Delta* d);
01146 int glbMin(const Delta* d) const;
01148 int glbMax(const Delta* d) const;
01150 bool glbAny(const Delta* d) const;
01152 int lubMin(const Delta* d) const;
01154 int lubMax(const Delta* d) const;
01156 bool lubAny(const Delta* d) const;
01158
01159 };
01160
01161 }
01162
01167
01168 template <class View>
01169 bool same(const Set::ComplementView<View>& x,
01170 const Set::ComplementView<View>& y);
01172 template <class View>
01173 bool before(const Set::ComplementView<View>& x,
01174 const Set::ComplementView<View>& y);
01176
01177
01184 template <class View>
01185 class ViewVarImpTraits<Set::ComplementView<View> > {
01186 public:
01188 typedef typename ViewVarImpTraits<View>::VarImp VarImp;
01189 };
01190
01191 namespace Set {
01192
01201 template <class View>
01202 class ComplementView<ComplementView<View> > : public View {
01203 public:
01205
01206
01207 ComplementView(void);
01209 ComplementView(ComplementView<View>& x);
01211 };
01212
01213 }
01214
01219
01220 template <class View>
01221 bool same(const Set::ComplementView<Set::ComplementView<View> >& x,
01222 const Set::ComplementView<Set::ComplementView<View> >& y);
01224 template <class View>
01225 bool before(const Set::ComplementView<Set::ComplementView<View> >& x,
01226 const Set::ComplementView<Set::ComplementView<View> >& y);
01228
01229
01237 template <class View>
01238 class ViewVarImpTraits<Set::ComplementView<Set::ComplementView<View> > > {
01239 public:
01241 typedef typename ViewVarImpTraits<View>::VarImp VarImp;
01242 };
01243
01244 namespace Set {
01245
01246
01255 template <class View>
01256 class OffsetSetView : public DerivedViewBase<View> {
01257 protected:
01258 using DerivedViewBase<View>::view;
01259 int k;
01260 public:
01262
01263
01264 OffsetSetView(void);
01266 OffsetSetView(View& x, int k0);
01268 OffsetSetView(Space* home, const Reflection::VarMap& vars,
01269 Reflection::Arg* arg);
01271
01273
01274
01276 unsigned int cardMin(void) const;
01278 unsigned int cardMax(void) const;
01280 int lubMin(void) const;
01282 int lubMax(void) const;
01284 int lubMinN(int n) const;
01286 int glbMin(void) const;
01288 int glbMax(void) const;
01289
01291 unsigned int glbSize(void) const;
01293 unsigned int lubSize(void) const;
01295 unsigned int unknownSize(void) const;
01297 int offset(void) const;
01299
01301
01302
01303 bool assigned(void) const;
01305 bool contains(int i) const;
01307 bool notContains(int i) const;
01309
01310
01312
01313
01314 ModEvent cardMin(Space* home, unsigned int m);
01316 ModEvent cardMax(Space* home, unsigned int m);
01321 ModEvent include(Space* home,int i,int j);
01326 ModEvent exclude(Space* home,int i,int j);
01328 ModEvent include(Space* home,int i);
01330 ModEvent exclude(Space* home,int i);
01335 ModEvent intersect(Space* home,int i,int j);
01337 ModEvent intersect(Space* home,int i);
01339
01341
01342
01344 template <class I> ModEvent excludeI(Space* home, I& i);
01346 template <class I> ModEvent includeI(Space* home, I& i);
01348 template <class I> ModEvent intersectI(Space* home, I& iter);
01350
01352
01353
01354 static void schedule(Space* home, Propagator* p, ModEvent me);
01356 static ModEvent me(ModEventDelta med);
01358 static ModEventDelta med(ModEvent);
01360
01362
01363
01370 void subscribe(Space* home, Propagator* p, PropCond pc, bool process=true);
01372 void cancel(Space* home, Propagator* p, PropCond pc);
01374 void subscribe(Space* home, Advisor* a);
01376 void cancel(Space* home, Advisor* a);
01378
01379
01381
01382
01383 void update(Space* home, bool share, OffsetSetView& x);
01385
01387
01388
01389 Reflection::Arg* spec(const Space* home, Reflection::VarMap& m) const;
01390 static Support::Symbol type(void);
01392
01394
01395
01396 static ModEvent modevent(const Delta* d);
01398 int glbMin(const Delta* d) const;
01400 int glbMax(const Delta* d) const;
01402 bool glbAny(const Delta* d) const;
01404 int lubMin(const Delta* d) const;
01406 int lubMax(const Delta* d) const;
01408 bool lubAny(const Delta* d) const;
01410
01411 };
01412
01413 }
01414
01419
01420 template <class View>
01421 bool same(const Set::OffsetSetView<View>& x,
01422 const Set::OffsetSetView<View>& y);
01424 template <class View>
01425 bool before(const Set::OffsetSetView<View>& x,
01426 const Set::OffsetSetView<View>& y);
01428
01429
01436 template <class View>
01437 class ViewVarImpTraits<Set::OffsetSetView<View> > {
01438 public:
01440 typedef typename ViewVarImpTraits<View>::VarImp VarImp;
01441 };
01442
01443
01444 }
01445
01446 #include "gecode/set/var/set.icc"
01447 #include "gecode/set/view/set.icc"
01448 #include "gecode/set/view/const.icc"
01449 #include "gecode/set/view/singleton.icc"
01450 #include "gecode/set/view/complement.icc"
01451 #include "gecode/set/view/offset.icc"
01452
01457 GECODE_SET_EXPORT std::ostream&
01458 operator<<(std::ostream&, const Gecode::Set::SetView&);
01459
01460
01465 GECODE_SET_EXPORT std::ostream&
01466 operator<<(std::ostream&, const Gecode::Set::EmptyView&);
01467
01472 GECODE_SET_EXPORT std::ostream&
01473 operator<<(std::ostream&, const Gecode::Set::UniverseView&);
01474
01479 GECODE_SET_EXPORT std::ostream&
01480 operator<<(std::ostream&, const Gecode::Set::ConstantView&);
01481
01486 GECODE_SET_EXPORT std::ostream&
01487 operator<<(std::ostream&, const Gecode::Set::SingletonView&);
01488
01493 template <class View>
01494 std::ostream&
01495 operator<<(std::ostream&, const Gecode::Set::ComplementView<View>&);
01496
01497 inline std::ostream&
01498 operator<<(std::ostream& os, const Gecode::SetVar& x) {
01499 Gecode::Set::SetView vx(x);
01500 return os << vx;
01501 }
01502
01503