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
01192 namespace Set {
01193
01194
01203 template <class View>
01204 class OffsetSetView : public DerivedViewBase<View> {
01205 protected:
01206 using DerivedViewBase<View>::view;
01207 int k;
01208 public:
01210
01211
01212 OffsetSetView(void);
01214 OffsetSetView(View& x, int k0);
01216 OffsetSetView(Space* home, const Reflection::VarMap& vars,
01217 Reflection::Arg* arg);
01219
01221
01222
01224 unsigned int cardMin(void) const;
01226 unsigned int cardMax(void) const;
01228 int lubMin(void) const;
01230 int lubMax(void) const;
01232 int lubMinN(int n) const;
01234 int glbMin(void) const;
01236 int glbMax(void) const;
01237
01239 unsigned int glbSize(void) const;
01241 unsigned int lubSize(void) const;
01243 unsigned int unknownSize(void) const;
01245 int offset(void) const;
01247
01249
01250
01251 bool assigned(void) const;
01253 bool contains(int i) const;
01255 bool notContains(int i) const;
01257
01258
01260
01261
01262 ModEvent cardMin(Space* home, unsigned int m);
01264 ModEvent cardMax(Space* home, unsigned int m);
01269 ModEvent include(Space* home,int i,int j);
01274 ModEvent exclude(Space* home,int i,int j);
01276 ModEvent include(Space* home,int i);
01278 ModEvent exclude(Space* home,int i);
01283 ModEvent intersect(Space* home,int i,int j);
01285 ModEvent intersect(Space* home,int i);
01287
01289
01290
01292 template <class I> ModEvent excludeI(Space* home, I& i);
01294 template <class I> ModEvent includeI(Space* home, I& i);
01296 template <class I> ModEvent intersectI(Space* home, I& iter);
01298
01300
01301
01302 static void schedule(Space* home, Propagator* p, ModEvent me);
01304 static ModEvent me(ModEventDelta med);
01306 static ModEventDelta med(ModEvent);
01308
01310
01311
01318 void subscribe(Space* home, Propagator* p, PropCond pc, bool process=true);
01320 void cancel(Space* home, Propagator* p, PropCond pc);
01322 void subscribe(Space* home, Advisor* a);
01324 void cancel(Space* home, Advisor* a);
01326
01327
01329
01330
01331 void update(Space* home, bool share, OffsetSetView& x);
01333
01335
01336
01337 Reflection::Arg* spec(const Space* home, Reflection::VarMap& m) const;
01338 static Support::Symbol type(void);
01340
01342
01343
01344 static ModEvent modevent(const Delta* d);
01346 int glbMin(const Delta* d) const;
01348 int glbMax(const Delta* d) const;
01350 bool glbAny(const Delta* d) const;
01352 int lubMin(const Delta* d) const;
01354 int lubMax(const Delta* d) const;
01356 bool lubAny(const Delta* d) const;
01358
01359 };
01360
01361 }
01362
01367
01368 template <class View>
01369 bool same(const Set::OffsetSetView<View>& x,
01370 const Set::OffsetSetView<View>& y);
01372 template <class View>
01373 bool before(const Set::OffsetSetView<View>& x,
01374 const Set::OffsetSetView<View>& y);
01376
01377
01384 template <class View>
01385 class ViewVarImpTraits<Set::OffsetSetView<View> > {
01386 public:
01388 typedef typename ViewVarImpTraits<View>::VarImp VarImp;
01389 };
01390
01391
01392 }
01393
01394 #include "gecode/set/var/set.icc"
01395 #include "gecode/set/view/set.icc"
01396 #include "gecode/set/view/const.icc"
01397 #include "gecode/set/view/singleton.icc"
01398 #include "gecode/set/view/complement.icc"
01399 #include "gecode/set/view/offset.icc"
01400
01405 GECODE_SET_EXPORT std::ostream&
01406 operator<<(std::ostream&, const Gecode::Set::SetView&);
01407
01408
01413 GECODE_SET_EXPORT std::ostream&
01414 operator<<(std::ostream&, const Gecode::Set::EmptyView&);
01415
01420 GECODE_SET_EXPORT std::ostream&
01421 operator<<(std::ostream&, const Gecode::Set::UniverseView&);
01422
01427 GECODE_SET_EXPORT std::ostream&
01428 operator<<(std::ostream&, const Gecode::Set::ConstantView&);
01429
01434 GECODE_SET_EXPORT std::ostream&
01435 operator<<(std::ostream&, const Gecode::Set::SingletonView&);
01436
01441 template <class View>
01442 std::ostream&
01443 operator<<(std::ostream&, const Gecode::Set::ComplementView<View>&);
01444
01445 inline std::ostream&
01446 operator<<(std::ostream& os, const Gecode::SetVar& x) {
01447 Gecode::Set::SetView vx(x);
01448 return os << vx;
01449 }
01450
01451