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 #ifndef __GECODE_SET_HH__
00041 #define __GECODE_SET_HH__
00042
00043 #include <gecode/kernel.hh>
00044 #include <gecode/int.hh>
00045 #include <gecode/iter.hh>
00046
00047 #include <functional>
00048
00049
00050
00051
00052
00053 #if !defined(GECODE_STATIC_LIBS) && \
00054 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00055
00056 #ifdef GECODE_BUILD_SET
00057 #define GECODE_SET_EXPORT __declspec( dllexport )
00058 #else
00059 #define GECODE_SET_EXPORT __declspec( dllimport )
00060 #endif
00061
00062 #else
00063
00064 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00065 #define GECODE_SET_EXPORT __attribute__ ((visibility("default")))
00066 #else
00067 #define GECODE_SET_EXPORT
00068 #endif
00069
00070 #endif
00071
00072
00073 #ifndef GECODE_BUILD_SET
00074 #define GECODE_LIBRARY_NAME "Set"
00075 #include <gecode/support/auto-link.hpp>
00076 #endif
00077
00078
00090 #include <gecode/set/exception.hpp>
00091
00092 namespace Gecode { namespace Set {
00093
00095 namespace Limits {
00097 const int max = (Gecode::Int::Limits::max / 2) - 1;
00099 const int min = -max;
00101 const unsigned int card = max-min+1;
00103 void check(int n, const char* l);
00105 void check(unsigned int n, const char* l);
00107 void check(const IntSet& s, const char* l);
00108 }
00109
00110 }}
00111
00112 #include <gecode/set/limits.hpp>
00113
00114 #include <gecode/set/var-imp.hpp>
00115
00116 namespace Gecode {
00117
00118 namespace Set {
00119 class SetView;
00120 }
00121
00127 class SetVar : public VarImpVar<Set::SetVarImp> {
00128 friend class SetVarArray;
00129 friend class SetVarArgs;
00130 using VarImpVar<Set::SetVarImp>::x;
00131 public:
00133
00134
00135 SetVar(void);
00137 SetVar(const SetVar& y);
00139 SetVar(const Set::SetView& y);
00140
00142 GECODE_SET_EXPORT SetVar(Space& home);
00143
00161 GECODE_SET_EXPORT
00162 SetVar(Space& home,int glbMin,int glbMax,int lubMin,int lubMax,
00163 unsigned int cardMin = 0,
00164 unsigned int cardMax = Set::Limits::card);
00165
00182 GECODE_SET_EXPORT
00183 SetVar(Space& home,const IntSet& glbD,int lubMin,int lubMax,
00184 unsigned int cardMin = 0,
00185 unsigned int cardMax = Set::Limits::card);
00186
00204 GECODE_SET_EXPORT
00205 SetVar(Space& home,int glbMin,int glbMax,const IntSet& lubD,
00206 unsigned int cardMin = 0,
00207 unsigned int cardMax = Set::Limits::card);
00208
00226 GECODE_SET_EXPORT
00227 SetVar(Space& home,const IntSet& glbD,const IntSet& lubD,
00228 unsigned int cardMin = 0,
00229 unsigned int cardMax = Set::Limits::card);
00231
00233
00234
00235 unsigned int glbSize(void) const;
00237 unsigned int lubSize(void) const;
00239 unsigned int unknownSize(void) const;
00241 unsigned int cardMin(void) const;
00243 unsigned int cardMax(void) const;
00245 int lubMin(void) const;
00247 int lubMax(void) const;
00249 int glbMin(void) const;
00251 int glbMax(void) const;
00253
00255
00256
00257 bool contains(int i) const;
00259 bool notContains(int i) const;
00261 };
00262
00268
00270 class SetVarGlbRanges {
00271 private:
00272 Set::GlbRanges<Set::SetVarImp*> iter;
00273 public:
00275
00276
00277 SetVarGlbRanges(void);
00279 SetVarGlbRanges(const SetVar& x);
00281
00283
00284
00285 bool operator ()(void) const;
00287 void operator ++(void);
00289
00291
00292
00293 int min(void) const;
00295 int max(void) const;
00297 unsigned int width(void) const;
00299 };
00300
00302 class SetVarLubRanges {
00303 private:
00304 Set::LubRanges<Set::SetVarImp*> iter;
00305 public:
00307
00308
00309 SetVarLubRanges(void);
00311 SetVarLubRanges(const SetVar& x);
00313
00315
00316
00317 bool operator ()(void) const;
00319 void operator ++(void);
00321
00323
00324
00325 int min(void) const;
00327 int max(void) const;
00329 unsigned int width(void) const;
00331 };
00332
00334 class SetVarUnknownRanges {
00335 private:
00336 Set::UnknownRanges<Set::SetVarImp*> iter;
00337 public:
00339
00340
00341 SetVarUnknownRanges(void);
00343 SetVarUnknownRanges(const SetVar& x);
00345
00347
00348
00349 bool operator ()(void) const;
00351 void operator ++(void);
00353
00355
00356
00357 int min(void) const;
00359 int max(void) const;
00361 unsigned int width(void) const;
00363 };
00364
00366 class SetVarGlbValues {
00367 private:
00368 Iter::Ranges::ToValues<SetVarGlbRanges> iter;
00369 public:
00371
00372
00373 SetVarGlbValues(void);
00375 SetVarGlbValues(const SetVar& x);
00377
00379
00380
00381 bool operator ()(void) const;
00383 void operator ++(void);
00385
00387
00388
00389 int val(void) const;
00391 };
00392
00394 class SetVarLubValues {
00395 private:
00396 Iter::Ranges::ToValues<SetVarLubRanges> iter;
00397 public:
00399
00400
00401 SetVarLubValues(void);
00403 SetVarLubValues(const SetVar& x);
00405
00407
00408
00409 bool operator ()(void) const;
00411 void operator ++(void);
00413
00415
00416
00417 int val(void) const;
00419 };
00420
00422 class SetVarUnknownValues {
00423 private:
00424 Iter::Ranges::ToValues<SetVarUnknownRanges> iter;
00425 public:
00427
00428
00429 SetVarUnknownValues(void);
00431 SetVarUnknownValues(const SetVar& x);
00433
00435
00436
00437 bool operator ()(void) const;
00439 void operator ++(void);
00441
00443
00444
00445 int val(void) const;
00447 };
00448
00450
00455 template<class Char, class Traits>
00456 std::basic_ostream<Char,Traits>&
00457 operator <<(std::basic_ostream<Char,Traits>& os, const SetVar& x);
00458
00459 }
00460
00461 #include <gecode/set/view.hpp>
00462
00463 namespace Gecode {
00473
00474 }
00475
00476 #include <gecode/set/array-traits.hpp>
00477
00478 namespace Gecode {
00479
00488 class SetVarArgs : public VarArgArray<SetVar> {
00489 public:
00491
00492
00493 SetVarArgs(void);
00495 explicit SetVarArgs(int n);
00497 SetVarArgs(const SetVarArgs& a);
00499 SetVarArgs(const VarArray<SetVar>& a);
00501 SetVarArgs(const std::vector<SetVar>& a);
00503 SetVarArgs(std::initializer_list<SetVar> a);
00505 template<class InputIterator>
00506 SetVarArgs(InputIterator first, InputIterator last);
00513 GECODE_SET_EXPORT
00514 SetVarArgs(Space& home,int n,int glbMin,int glbMax,
00515 int lubMin,int lubMax,
00516 unsigned int minCard = 0,
00517 unsigned int maxCard = Set::Limits::card);
00524 GECODE_SET_EXPORT
00525 SetVarArgs(Space& home,int n,const IntSet& glb,
00526 int lubMin, int lubMax,
00527 unsigned int minCard = 0,
00528 unsigned int maxCard = Set::Limits::card);
00535 GECODE_SET_EXPORT
00536 SetVarArgs(Space& home,int n,int glbMin,int glbMax,
00537 const IntSet& lub,
00538 unsigned int minCard = 0,
00539 unsigned int maxCard = Set::Limits::card);
00546 GECODE_SET_EXPORT
00547 SetVarArgs(Space& home,int n,
00548 const IntSet& glb,const IntSet& lub,
00549 unsigned int minCard = 0,
00550 unsigned int maxCard = Set::Limits::card);
00552 };
00554
00570 class SetVarArray : public VarArray<SetVar> {
00571 public:
00573
00574
00575 SetVarArray(void);
00577 SetVarArray(const SetVarArray&);
00579 SetVarArray(Space& home, const SetVarArgs&);
00581 GECODE_SET_EXPORT SetVarArray(Space& home, int n);
00588 GECODE_SET_EXPORT
00589 SetVarArray(Space& home,int n,int glbMin,int glbMax,int lubMin,int lubMax,
00590 unsigned int minCard = 0,
00591 unsigned int maxCard = Set::Limits::card);
00598 GECODE_SET_EXPORT
00599 SetVarArray(Space& home,int n,const IntSet& glb, int lubMin, int lubMax,
00600 unsigned int minCard = 0,
00601 unsigned int maxCard = Set::Limits::card);
00608 GECODE_SET_EXPORT
00609 SetVarArray(Space& home,int n,int glbMin,int glbMax,const IntSet& lub,
00610 unsigned int minCard = 0,
00611 unsigned int maxCard = Set::Limits::card);
00618 GECODE_SET_EXPORT
00619 SetVarArray(Space& home,int n,
00620 const IntSet& glb,const IntSet& lub,
00621 unsigned int minCard = 0,
00622 unsigned int maxCard = Set::Limits::card);
00624 };
00625
00626 }
00627
00628 #include <gecode/set/array.hpp>
00629
00630 namespace Gecode {
00631
00643 enum SetRelType {
00644 SRT_EQ,
00645 SRT_NQ,
00646 SRT_SUB,
00647 SRT_SUP,
00648 SRT_DISJ,
00649 SRT_CMPL,
00650 SRT_LQ,
00651 SRT_LE,
00652 SRT_GQ,
00653 SRT_GR
00654 };
00655
00660 enum SetOpType {
00661 SOT_UNION,
00662 SOT_DUNION,
00663 SOT_INTER,
00664 SOT_MINUS
00665 };
00666
00673
00674 GECODE_SET_EXPORT void
00675 dom(Home home, SetVar x, SetRelType r, int i);
00677 GECODE_SET_EXPORT void
00678 dom(Home home, const SetVarArgs& x, SetRelType r, int i);
00680 GECODE_SET_EXPORT void
00681 dom(Home home, SetVar x, SetRelType r, int i, int j);
00683 GECODE_SET_EXPORT void
00684 dom(Home home, const SetVarArgs& x, SetRelType r, int i, int j);
00686 GECODE_SET_EXPORT void
00687 dom(Home home, SetVar x, SetRelType r, const IntSet& s);
00689 GECODE_SET_EXPORT void
00690 dom(Home home, const SetVarArgs& x, SetRelType r, const IntSet& s);
00692 GECODE_SET_EXPORT void
00693 cardinality(Home home, SetVar x, unsigned int i, unsigned int j);
00695 GECODE_SET_EXPORT void
00696 cardinality(Home home, const SetVarArgs& x, unsigned int i, unsigned int j);
00698 GECODE_SET_EXPORT void
00699 dom(Home home, SetVar x, SetRelType rt, int i, Reify r);
00701 GECODE_SET_EXPORT void
00702 dom(Home home, SetVar x, SetRelType rt, int i, int j, Reify r);
00704 GECODE_SET_EXPORT void
00705 dom(Home home, SetVar x, SetRelType rt, const IntSet& s, Reify r);
00707 GECODE_SET_EXPORT void
00708 dom(Home home, SetVar x, SetVar d);
00710 GECODE_SET_EXPORT void
00711 dom(Home home, const SetVarArgs& x, const SetVarArgs& d);
00713
00714
00721
00722 GECODE_SET_EXPORT void
00723 rel(Home home, SetVar x, SetRelType r, SetVar y);
00725 GECODE_SET_EXPORT void
00726 rel(Home home, SetVar x, SetRelType rt, SetVar y, Reify r);
00728 GECODE_SET_EXPORT void
00729 rel(Home home, SetVar s, SetRelType r, IntVar x);
00731 GECODE_SET_EXPORT void
00732 rel(Home home, IntVar x, SetRelType r, SetVar s);
00734 GECODE_SET_EXPORT void
00735 rel(Home home, SetVar s, SetRelType rt, IntVar x, Reify r);
00737 GECODE_SET_EXPORT void
00738 rel(Home home, IntVar x, SetRelType rt, SetVar s, Reify r);
00740 GECODE_SET_EXPORT void
00741 rel(Home home, SetVar s, IntRelType rt, IntVar x);
00743 void
00744 rel(Home home, IntVar x, IntRelType rt, SetVar s);
00746 GECODE_SET_EXPORT void
00747 rel(Home home, SetVar s, IntRelType rt, IntVar x, Reify r);
00749 void
00750 rel(Home home, IntVar x, IntRelType rt, SetVar s, Reify r);
00752
00753 }
00754
00755 #include <gecode/set/int.hpp>
00756
00757 namespace Gecode {
00758
00765
00766 GECODE_SET_EXPORT void
00767 rel(Home home, SetVar x, SetOpType op, SetVar y, SetRelType r, SetVar z);
00769 GECODE_SET_EXPORT void
00770 rel(Home home, SetOpType op, const SetVarArgs& x, SetVar y);
00772 GECODE_SET_EXPORT void
00773 rel(Home home, SetOpType op, const SetVarArgs& x, const IntSet& z, SetVar y);
00775 GECODE_SET_EXPORT void
00776 rel(Home home, SetOpType op, const IntVarArgs& x, const IntSet& z, SetVar y);
00778 GECODE_SET_EXPORT void
00779 rel(Home home, SetOpType op, const IntVarArgs& x, SetVar y);
00781 GECODE_SET_EXPORT void
00782 rel(Home home, const IntSet& x, SetOpType op, SetVar y,
00783 SetRelType r, SetVar z);
00785 GECODE_SET_EXPORT void
00786 rel(Home home, SetVar x, SetOpType op, const IntSet& y,
00787 SetRelType r, SetVar z);
00789 GECODE_SET_EXPORT void
00790 rel(Home home, SetVar x, SetOpType op, SetVar y,
00791 SetRelType r, const IntSet& z);
00793 GECODE_SET_EXPORT void
00794 rel(Home home, const IntSet& x, SetOpType op, SetVar y, SetRelType r,
00795 const IntSet& z);
00797 GECODE_SET_EXPORT void
00798 rel(Home home, SetVar x, SetOpType op, const IntSet& y, SetRelType r,
00799 const IntSet& z);
00804 GECODE_SET_EXPORT void
00805 ite(Home home, BoolVar b, SetVar x, SetVar y, SetVar z);
00807
00808
00815
00816 GECODE_SET_EXPORT void
00817 convex(Home home, SetVar x);
00819 GECODE_SET_EXPORT void
00820 convex(Home home, SetVar x, SetVar y);
00822
00823
00830
00831 GECODE_SET_EXPORT void
00832 sequence(Home home, const SetVarArgs& x);
00834 GECODE_SET_EXPORT void
00835 sequence(Home home, const SetVarArgs& y, SetVar x);
00837
00838
00845
00846 GECODE_SET_EXPORT void
00847 atmostOne(Home home, const SetVarArgs& x, unsigned int c);
00849
00858 GECODE_SET_EXPORT void
00859 min(Home home, SetVar s, IntVar x);
00863 GECODE_SET_EXPORT void
00864 notMin(Home home, SetVar s, IntVar x);
00868 GECODE_SET_EXPORT void
00869 min(Home home, SetVar s, IntVar x, Reify r);
00873 GECODE_SET_EXPORT void
00874 max(Home home, SetVar s, IntVar x);
00878 GECODE_SET_EXPORT void
00879 notMax(Home home, SetVar s, IntVar x);
00883 GECODE_SET_EXPORT void
00884 max(Home home, SetVar s, IntVar x, Reify r);
00888 GECODE_SET_EXPORT void
00889 cardinality(Home home, SetVar s, IntVar x);
00893 GECODE_SET_EXPORT void
00894 cardinality(Home home, SetVar s, IntVar x, Reify r);
00907 GECODE_SET_EXPORT void
00908 weights(Home home, IntSharedArray elements, IntSharedArray weights,
00909 SetVar x, IntVar y);
00910
00911
00918
00919 GECODE_SET_EXPORT void
00920 channel(Home home, const IntVarArgs& x,const SetVarArgs& y);
00922 GECODE_SET_EXPORT void
00923 channelSorted(Home home, const IntVarArgs& x, SetVar y);
00925 GECODE_SET_EXPORT void
00926 channel(Home home, const BoolVarArgs& x, SetVar y);
00928 GECODE_SET_EXPORT void
00929 channel(Home home, const SetVarArgs& x, const SetVarArgs& y);
00931
00932
00944 GECODE_SET_EXPORT void
00945 precede(Home home, const SetVarArgs& x, int s, int t);
00949 GECODE_SET_EXPORT void
00950 precede(Home home, const SetVarArgs& x, const IntArgs& c);
00951
00952
00974 GECODE_SET_EXPORT void
00975 element(Home home, SetOpType op, const SetVarArgs& x, SetVar y, SetVar z,
00976 const IntSet& u = IntSet(Set::Limits::min,Set::Limits::max));
00986 GECODE_SET_EXPORT void
00987 element(Home home, SetOpType op, const IntVarArgs& x, SetVar y, SetVar z,
00988 const IntSet& u = IntSet(Set::Limits::min,Set::Limits::max));
00998 GECODE_SET_EXPORT void
00999 element(Home home, SetOpType op, const IntSetArgs& x, SetVar y, SetVar z,
01000 const IntSet& u = IntSet(Set::Limits::min,Set::Limits::max));
01010 GECODE_SET_EXPORT void
01011 element(Home home, SetOpType op, const IntArgs& x, SetVar y, SetVar z,
01012 const IntSet& u = IntSet(Set::Limits::min,Set::Limits::max));
01018 GECODE_SET_EXPORT void
01019 element(Home home, const SetVarArgs& x, IntVar y, SetVar z);
01025 GECODE_SET_EXPORT void
01026 element(Home home, const IntSetArgs& s, IntVar y, SetVar z);
01032 GECODE_SET_EXPORT void
01033 element(Home home, const IntSetArgs& a,
01034 IntVar x, int w, IntVar y, int h, SetVar z);
01040 GECODE_SET_EXPORT void
01041 element(Home home, const SetVarArgs& a,
01042 IntVar x, int w, IntVar y, int h, SetVar z);
01044
01045
01056
01057 GECODE_SET_EXPORT void
01058 wait(Home home, SetVar x, std::function<void(Space& home)> c);
01060 GECODE_SET_EXPORT void
01061 wait(Home home, const SetVarArgs& x, std::function<void(Space& home)> c);
01063
01064 }
01065
01066
01067 namespace Gecode {
01068
01082 typedef std::function<bool(const Space& home, SetVar x, int i)>
01083 SetBranchFilter;
01094 typedef std::function<double(const Space& home, SetVar x, int i)>
01095 SetBranchMerit;
01096
01107 typedef std::function<int(const Space& home, SetVar x, int i)>
01108 SetBranchVal;
01109
01121 typedef std::function<void(Space& home, unsigned int a,
01122 SetVar x, int i, int n)>
01123 SetBranchCommit;
01124
01125 }
01126
01127 #include <gecode/set/branch/traits.hpp>
01128
01129 namespace Gecode {
01130
01136 class SetAFC : public AFC {
01137 public:
01145 SetAFC(void);
01147 SetAFC(const SetAFC& a);
01149 SetAFC& operator =(const SetAFC& a);
01157 SetAFC(Home home, const SetVarArgs& x, double d=1.0, bool share=true);
01168 void init(Home home, const SetVarArgs& x, double d=1.0, bool share=true);
01169 };
01170
01171 }
01172
01173 #include <gecode/set/branch/afc.hpp>
01174
01175 namespace Gecode {
01176
01177
01183 class SetAction : public Action {
01184 public:
01192 SetAction(void);
01194 SetAction(const SetAction& a);
01196 SetAction& operator =(const SetAction& a);
01205 GECODE_SET_EXPORT
01206 SetAction(Home home, const SetVarArgs& x, double d=1.0,
01207 SetBranchMerit bm=nullptr);
01219 GECODE_SET_EXPORT void
01220 init(Home home, const SetVarArgs& x, double d=1.0,
01221 SetBranchMerit bm=nullptr);
01222 };
01223
01224 }
01225
01226 #include <gecode/set/branch/action.hpp>
01227
01228 namespace Gecode {
01229
01235 class SetCHB : public CHB {
01236 public:
01244 SetCHB(void);
01246 SetCHB(const SetCHB& chb);
01248 SetCHB& operator =(const SetCHB& chb);
01257 GECODE_SET_EXPORT
01258 SetCHB(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
01270 GECODE_SET_EXPORT void
01271 init(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
01272 };
01273
01274 }
01275
01276 #include <gecode/set/branch/chb.hpp>
01277
01278 namespace Gecode {
01279
01281 typedef std::function<void(const Space &home, const Brancher& b,
01282 unsigned int a,
01283 SetVar x, int i, const int& n,
01284 std::ostream& o)>
01285 SetVarValPrint;
01286
01287 }
01288
01289 namespace Gecode {
01290
01296 class SetVarBranch : public VarBranch<SetVar> {
01297 public:
01299 enum Select {
01300 SEL_NONE = 0,
01301 SEL_RND,
01302 SEL_MERIT_MIN,
01303 SEL_MERIT_MAX,
01304 SEL_DEGREE_MIN,
01305 SEL_DEGREE_MAX,
01306 SEL_AFC_MIN,
01307 SEL_AFC_MAX,
01308 SEL_ACTION_MIN,
01309 SEL_ACTION_MAX,
01310 SEL_CHB_MIN,
01311 SEL_CHB_MAX,
01312 SEL_MIN_MIN,
01313 SEL_MIN_MAX,
01314 SEL_MAX_MIN,
01315 SEL_MAX_MAX,
01316 SEL_SIZE_MIN,
01317 SEL_SIZE_MAX,
01318 SEL_DEGREE_SIZE_MIN,
01319 SEL_DEGREE_SIZE_MAX,
01320 SEL_AFC_SIZE_MIN,
01321 SEL_AFC_SIZE_MAX,
01322 SEL_ACTION_SIZE_MIN,
01323 SEL_ACTION_SIZE_MAX,
01324 SEL_CHB_SIZE_MIN,
01325 SEL_CHB_SIZE_MAX
01326 };
01327 protected:
01329 Select s;
01330 public:
01332 SetVarBranch(void);
01334 SetVarBranch(Rnd r);
01336 SetVarBranch(Select s, BranchTbl t);
01338 SetVarBranch(Select s, double d, BranchTbl t);
01340 SetVarBranch(Select s, SetAFC a, BranchTbl t);
01342 SetVarBranch(Select s, SetAction a, BranchTbl t);
01344 SetVarBranch(Select s, SetCHB c, BranchTbl t);
01346 SetVarBranch(Select s, SetBranchMerit mf, BranchTbl t);
01348 Select select(void) const;
01350 void expand(Home home, const SetVarArgs& x);
01351 };
01352
01358
01359 SetVarBranch SET_VAR_NONE(void);
01361 SetVarBranch SET_VAR_RND(Rnd r);
01363 SetVarBranch SET_VAR_MERIT_MIN(SetBranchMerit bm, BranchTbl tbl=nullptr);
01365 SetVarBranch SET_VAR_MERIT_MAX(SetBranchMerit bm, BranchTbl tbl=nullptr);
01367 SetVarBranch SET_VAR_DEGREE_MIN(BranchTbl tbl=nullptr);
01369 SetVarBranch SET_VAR_DEGREE_MAX(BranchTbl tbl=nullptr);
01371 SetVarBranch SET_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr);
01373 SetVarBranch SET_VAR_AFC_MIN(SetAFC a, BranchTbl tbl=nullptr);
01375 SetVarBranch SET_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr);
01377 SetVarBranch SET_VAR_AFC_MAX(SetAFC a, BranchTbl tbl=nullptr);
01379 SetVarBranch SET_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr);
01381 SetVarBranch SET_VAR_ACTION_MIN(SetAction a, BranchTbl tbl=nullptr);
01383 SetVarBranch SET_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr);
01385 SetVarBranch SET_VAR_ACTION_MAX(SetAction a, BranchTbl tbl=nullptr);
01387 SetVarBranch SET_VAR_CHB_MIN(BranchTbl tbl=nullptr);
01389 SetVarBranch SET_VAR_CHB_MIN(SetCHB c, BranchTbl tbl=nullptr);
01391 SetVarBranch SET_VAR_CHB_MAX(BranchTbl tbl=nullptr);
01393 SetVarBranch SET_VAR_CHB_MAX(SetCHB c, BranchTbl tbl=nullptr);
01395 SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl=nullptr);
01397 SetVarBranch SET_VAR_MIN_MAX(BranchTbl tbl=nullptr);
01399 SetVarBranch SET_VAR_MAX_MIN(BranchTbl tbl=nullptr);
01401 SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl=nullptr);
01403 SetVarBranch SET_VAR_SIZE_MIN(BranchTbl tbl=nullptr);
01405 SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl=nullptr);
01407 SetVarBranch SET_VAR_DEGREE_SIZE_MIN(BranchTbl tbl=nullptr);
01409 SetVarBranch SET_VAR_DEGREE_SIZE_MAX(BranchTbl tbl=nullptr);
01411 SetVarBranch SET_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
01413 SetVarBranch SET_VAR_AFC_SIZE_MIN(SetAFC a, BranchTbl tbl=nullptr);
01415 SetVarBranch SET_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
01417 SetVarBranch SET_VAR_AFC_SIZE_MAX(SetAFC a, BranchTbl tbl=nullptr);
01419 SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
01421 SetVarBranch SET_VAR_ACTION_SIZE_MIN(SetAction a, BranchTbl tbl=nullptr);
01423 SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
01425 SetVarBranch SET_VAR_ACTION_SIZE_MAX(SetAction a, BranchTbl tbl=nullptr);
01427 SetVarBranch SET_VAR_CHB_SIZE_MIN(BranchTbl tbl=nullptr);
01429 SetVarBranch SET_VAR_CHB_SIZE_MIN(SetCHB c, BranchTbl tbl=nullptr);
01431 SetVarBranch SET_VAR_CHB_SIZE_MAX(BranchTbl tbl=nullptr);
01433 SetVarBranch SET_VAR_CHB_SIZE_MAX(SetCHB c, BranchTbl tbl=nullptr);
01435
01436 }
01437
01438 #include <gecode/set/branch/var.hpp>
01439
01440 namespace Gecode {
01441
01447 class SetValBranch : public ValBranch<SetVar> {
01448 public:
01450 enum Select {
01451 SEL_MIN_INC,
01452 SEL_MIN_EXC,
01453 SEL_MED_INC,
01454 SEL_MED_EXC,
01455 SEL_MAX_INC,
01456 SEL_MAX_EXC,
01457 SEL_RND_INC,
01458 SEL_RND_EXC,
01459 SEL_VAL_COMMIT
01460 };
01461 protected:
01463 Select s;
01464 public:
01466 SetValBranch(Select s = SEL_MIN_INC);
01468 SetValBranch(Select s, Rnd r);
01470 SetValBranch(SetBranchVal v, SetBranchCommit c);
01472 Select select(void) const;
01473 };
01474
01480
01481 SetValBranch SET_VAL_MIN_INC(void);
01483 SetValBranch SET_VAL_MIN_EXC(void);
01485 SetValBranch SET_VAL_MED_INC(void);
01487 SetValBranch SET_VAL_MED_EXC(void);
01489 SetValBranch SET_VAL_MAX_INC(void);
01491 SetValBranch SET_VAL_MAX_EXC(void);
01493 SetValBranch SET_VAL_RND_INC(Rnd r);
01495 SetValBranch SET_VAL_RND_EXC(Rnd r);
01503 SetValBranch SET_VAL(SetBranchVal v, SetBranchCommit c=nullptr);
01505
01506 }
01507
01508 #include <gecode/set/branch/val.hpp>
01509
01510 namespace Gecode {
01511
01517 class SetAssign : public ValBranch<SetVar> {
01518 public:
01520 enum Select {
01521 SEL_MIN_INC,
01522 SEL_MIN_EXC,
01523 SEL_MED_INC,
01524 SEL_MED_EXC,
01525 SEL_MAX_INC,
01526 SEL_MAX_EXC,
01527 SEL_RND_INC,
01528 SEL_RND_EXC,
01529 SEL_VAL_COMMIT
01530 };
01531 protected:
01533 Select s;
01534 public:
01536 SetAssign(Select s = SEL_MIN_INC);
01538 SetAssign(Select s, Rnd r);
01540 SetAssign(SetBranchVal v, SetBranchCommit c);
01542 Select select(void) const;
01543 };
01544
01550
01551 SetAssign SET_ASSIGN_MIN_INC(void);
01553 SetAssign SET_ASSIGN_MIN_EXC(void);
01555 SetAssign SET_ASSIGN_MED_INC(void);
01557 SetAssign SET_ASSIGN_MED_EXC(void);
01559 SetAssign SET_ASSIGN_MAX_INC(void);
01561 SetAssign SET_ASSIGN_MAX_EXC(void);
01563 SetAssign SET_ASSIGN_RND_INC(Rnd r);
01565 SetAssign SET_ASSIGN_RND_EXC(Rnd r);
01572 SetAssign SET_ASSIGN(SetBranchVal v, SetBranchCommit c=nullptr);
01574
01575 }
01576
01577 #include <gecode/set/branch/assign.hpp>
01578
01579 namespace Gecode {
01580
01586 GECODE_SET_EXPORT void
01587 branch(Home home, const SetVarArgs& x,
01588 SetVarBranch vars, SetValBranch vals,
01589 SetBranchFilter bf=nullptr,
01590 SetVarValPrint vvp=nullptr);
01596 GECODE_SET_EXPORT void
01597 branch(Home home, const SetVarArgs& x,
01598 TieBreak<SetVarBranch> vars, SetValBranch vals,
01599 SetBranchFilter bf=nullptr,
01600 SetVarValPrint vvp=nullptr);
01606 GECODE_SET_EXPORT void
01607 branch(Home home, SetVar x, SetValBranch vals,
01608 SetVarValPrint vvp=nullptr);
01614 GECODE_SET_EXPORT void
01615 assign(Home home, const SetVarArgs& x, SetAssign vals,
01616 SetBranchFilter bf=nullptr,
01617 SetVarValPrint vvp=nullptr);
01623 GECODE_SET_EXPORT void
01624 assign(Home home, SetVar x, SetAssign vals,
01625 SetVarValPrint vvp=nullptr);
01626
01627 }
01628
01629
01630 namespace Gecode {
01632 GECODE_SET_EXPORT SymmetryHandle VariableSymmetry(const SetVarArgs& x);
01638 GECODE_SET_EXPORT
01639 SymmetryHandle VariableSequenceSymmetry(const SetVarArgs& x, int ss);
01646 GECODE_SET_EXPORT void
01647 branch(Home home, const SetVarArgs& x,
01648 SetVarBranch vars, SetValBranch vals,
01649 const Symmetries& syms,
01650 SetBranchFilter bf=nullptr,
01651 SetVarValPrint vvp=nullptr);
01658 GECODE_SET_EXPORT void
01659 branch(Home home, const SetVarArgs& x,
01660 TieBreak<SetVarBranch> vars, SetValBranch vals,
01661 const Symmetries& syms,
01662 SetBranchFilter bf=nullptr,
01663 SetVarValPrint vvp=nullptr);
01664 }
01665
01666 namespace Gecode {
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689 GECODE_SET_EXPORT void
01690 relax(Home home, const SetVarArgs& x, const SetVarArgs& sx,
01691 Rnd r, double p);
01692
01693 }
01694
01695 #include <gecode/set/trace/trace-view.hpp>
01696
01697 namespace Gecode {
01698
01708 class SetTraceDelta {
01709 protected:
01711 public:
01713 class Glb
01714 : public Iter::Ranges::Diff<Set::GlbRanges<Set::SetView>,
01715 Iter::Ranges::RangeList> {
01716 protected:
01718 Iter::Ranges::RangeList o;
01720 Set::GlbRanges<Set::SetView> n;
01721 public:
01723
01724
01725 Glb(RangeList* o, Set::SetView n);
01727 };
01728 Glb _glb;
01730 class Lub
01731 : public Iter::Ranges::Diff<Iter::Ranges::RangeList,
01732 Set::LubRanges<Set::SetView> > {
01733 protected:
01735 Iter::Ranges::RangeList o;
01737 Set::LubRanges<Set::SetView> n;
01738 public:
01740
01741
01742 Lub(RangeList* o, Set::SetView n);
01744 };
01745 Lub _lub;
01747
01748
01749 SetTraceDelta(Set::SetTraceView o, Set::SetView n, const Delta& d);
01751
01752
01753
01754 Glb& glb(void);
01756 Lub& lub(void);
01758 };
01759
01760 }
01761
01762 #include <gecode/set/trace/delta.hpp>
01763
01764 #include <gecode/set/trace/traits.hpp>
01765
01766 namespace Gecode {
01767
01772 typedef ViewTracer<Set::SetView> SetTracer;
01777 typedef ViewTraceRecorder<Set::SetView> SetTraceRecorder;
01778
01783 class GECODE_SET_EXPORT StdSetTracer : public SetTracer {
01784 protected:
01786 std::ostream& os;
01787 public:
01789 StdSetTracer(std::ostream& os0 = std::cerr);
01791 virtual void init(const Space& home, const SetTraceRecorder& t);
01793 virtual void prune(const Space& home, const SetTraceRecorder& t,
01794 const ViewTraceInfo& vti, int i, SetTraceDelta& d);
01796 virtual void fix(const Space& home, const SetTraceRecorder& t);
01798 virtual void fail(const Space& home, const SetTraceRecorder& t);
01800 virtual void done(const Space& home, const SetTraceRecorder& t);
01802 static StdSetTracer def;
01803 };
01804
01805
01810 GECODE_SET_EXPORT void
01811 trace(Home home, const SetVarArgs& x,
01812 TraceFilter tf,
01813 int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
01814 SetTracer& t = StdSetTracer::def);
01819 void
01820 trace(Home home, const SetVarArgs& x,
01821 int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
01822 SetTracer& t = StdSetTracer::def);
01823
01824 }
01825
01826 #include <gecode/set/trace.hpp>
01827
01828 #endif
01829
01830
01831