Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
set.hh
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Guido Tack <tack@gecode.org>
5 * Christian Schulte <schulte@gecode.org>
6 *
7 * Contributing authors:
8 * Gabor Szokoli <szokoli@gecode.org>
9 *
10 * Copyright:
11 * Guido Tack, 2004
12 * Christian Schulte, 2004
13 * Gabor Szokoli, 2004
14 *
15 * This file is part of Gecode, the generic constraint
16 * development environment:
17 * http://www.gecode.org
18 *
19 * Permission is hereby granted, free of charge, to any person obtaining
20 * a copy of this software and associated documentation files (the
21 * "Software"), to deal in the Software without restriction, including
22 * without limitation the rights to use, copy, modify, merge, publish,
23 * distribute, sublicense, and/or sell copies of the Software, and to
24 * permit persons to whom the Software is furnished to do so, subject to
25 * the following conditions:
26 *
27 * The above copyright notice and this permission notice shall be
28 * included in all copies or substantial portions of the Software.
29 *
30 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 *
38 */
39
40#ifndef __GECODE_SET_HH__
41#define __GECODE_SET_HH__
42
43#include <gecode/kernel.hh>
44#include <gecode/int.hh>
45#include <gecode/iter.hh>
46
47#include <functional>
48
49/*
50 * Configure linking
51 *
52 */
53#if !defined(GECODE_STATIC_LIBS) && \
54 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
55
56#ifdef GECODE_BUILD_SET
57#define GECODE_SET_EXPORT __declspec( dllexport )
58#else
59#define GECODE_SET_EXPORT __declspec( dllimport )
60#endif
61
62#else
63
64#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
65#define GECODE_SET_EXPORT __attribute__ ((visibility("default")))
66#else
67#define GECODE_SET_EXPORT
68#endif
69
70#endif
71
72// Configure auto-linking
73#ifndef GECODE_BUILD_SET
74#define GECODE_LIBRARY_NAME "Set"
76#endif
77
78
91
92namespace Gecode { namespace Set {
93
95 namespace Limits {
97 const int max = (Gecode::Int::Limits::max / 2) - 1;
99 const int min = -max;
101 const unsigned int card = max-min+1;
103 void check(int n, const char* l);
105 void check(unsigned int n, const char* l);
107 void check(const IntSet& s, const char* l);
108 }
109
110}}
111
112#include <gecode/set/limits.hpp>
113
114#include <gecode/set/var-imp.hpp>
115
116namespace Gecode {
117
118 namespace Set {
119 class SetView;
120 }
121
127 class SetVar : public VarImpVar<Set::SetVarImp> {
128 friend class SetVarArray;
129 friend class SetVarArgs;
131 public:
133
134
135 SetVar(void);
137 SetVar(const SetVar& y);
139 SetVar(const Set::SetView& y);
140
143
162 SetVar(Space& home,int glbMin,int glbMax,int lubMin,int lubMax,
163 unsigned int cardMin = 0,
164 unsigned int cardMax = Set::Limits::card);
165
183 SetVar(Space& home,const IntSet& glbD,int lubMin,int lubMax,
184 unsigned int cardMin = 0,
185 unsigned int cardMax = Set::Limits::card);
186
205 SetVar(Space& home,int glbMin,int glbMax,const IntSet& lubD,
206 unsigned int cardMin = 0,
207 unsigned int cardMax = Set::Limits::card);
208
227 SetVar(Space& home,const IntSet& glbD,const IntSet& lubD,
228 unsigned int cardMin = 0,
229 unsigned int cardMax = Set::Limits::card);
231
233
234
235 unsigned int glbSize(void) const;
237 unsigned int lubSize(void) const;
239 unsigned int unknownSize(void) const;
241 unsigned int cardMin(void) const;
243 unsigned int cardMax(void) const;
245 int lubMin(void) const;
247 int lubMax(void) const;
249 int glbMin(void) const;
251 int glbMax(void) const;
253
255
256
257 bool contains(int i) const;
259 bool notContains(int i) const;
261 };
262
268
271 private:
273 public:
275
276
277 SetVarGlbRanges(void);
279 SetVarGlbRanges(const SetVar& x);
281
283
284
285 bool operator ()(void) const;
287 void operator ++(void);
289
291
292
293 int min(void) const;
295 int max(void) const;
297 unsigned int width(void) const;
299 };
300
303 private:
305 public:
307
308
309 SetVarLubRanges(void);
311 SetVarLubRanges(const SetVar& x);
313
315
316
317 bool operator ()(void) const;
319 void operator ++(void);
321
323
324
325 int min(void) const;
327 int max(void) const;
329 unsigned int width(void) const;
331 };
332
335 private:
337 public:
339
340
345
347
348
349 bool operator ()(void) const;
351 void operator ++(void);
353
355
356
357 int min(void) const;
359 int max(void) const;
361 unsigned int width(void) const;
363 };
364
367 private:
369 public:
371
372
375 SetVarGlbValues(const SetVar& x);
377
379
380
381 bool operator ()(void) const;
383 void operator ++(void);
385
387
388
389 int val(void) const;
391 };
392
395 private:
397 public:
399
400
403 SetVarLubValues(const SetVar& x);
405
407
408
409 bool operator ()(void) const;
411 void operator ++(void);
413
415
416
417 int val(void) const;
419 };
420
423 private:
425 public:
427
428
433
435
436
437 bool operator ()(void) const;
439 void operator ++(void);
441
443
444
445 int val(void) const;
447 };
448
450
455 template<class Char, class Traits>
456 std::basic_ostream<Char,Traits>&
457 operator <<(std::basic_ostream<Char,Traits>& os, const SetVar& x);
458
459}
460
461#include <gecode/set/view.hpp>
462
463namespace Gecode {
473
474}
475
477
478namespace Gecode {
479
488 class SetVarArgs : public VarArgArray<SetVar> {
489 public:
491
492
493 SetVarArgs(void);
495 explicit SetVarArgs(int n);
497 SetVarArgs(const SetVarArgs& a);
501 SetVarArgs(const std::vector<SetVar>& a);
503 SetVarArgs(std::initializer_list<SetVar> a);
505 template<class InputIterator>
506 SetVarArgs(InputIterator first, InputIterator last);
514 SetVarArgs(Space& home,int n,int glbMin,int glbMax,
515 int lubMin,int lubMax,
516 unsigned int minCard = 0,
517 unsigned int maxCard = Set::Limits::card);
525 SetVarArgs(Space& home,int n,const IntSet& glb,
526 int lubMin, int lubMax,
527 unsigned int minCard = 0,
528 unsigned int maxCard = Set::Limits::card);
536 SetVarArgs(Space& home,int n,int glbMin,int glbMax,
537 const IntSet& lub,
538 unsigned int minCard = 0,
539 unsigned int maxCard = Set::Limits::card);
547 SetVarArgs(Space& home,int n,
548 const IntSet& glb,const IntSet& lub,
549 unsigned int minCard = 0,
550 unsigned int maxCard = Set::Limits::card);
552 };
554
570 class SetVarArray : public VarArray<SetVar> {
571 public:
573
574
575 SetVarArray(void);
577 SetVarArray(const SetVarArray&);
579 SetVarArray(Space& home, const SetVarArgs&);
589 SetVarArray(Space& home,int n,int glbMin,int glbMax,int lubMin,int lubMax,
590 unsigned int minCard = 0,
591 unsigned int maxCard = Set::Limits::card);
599 SetVarArray(Space& home,int n,const IntSet& glb, int lubMin, int lubMax,
600 unsigned int minCard = 0,
601 unsigned int maxCard = Set::Limits::card);
609 SetVarArray(Space& home,int n,int glbMin,int glbMax,const IntSet& lub,
610 unsigned int minCard = 0,
611 unsigned int maxCard = Set::Limits::card);
619 SetVarArray(Space& home,int n,
620 const IntSet& glb,const IntSet& lub,
621 unsigned int minCard = 0,
622 unsigned int maxCard = Set::Limits::card);
624 };
625
626}
627
628#include <gecode/set/array.hpp>
629
630namespace Gecode {
631
655
666
675 dom(Home home, SetVar x, SetRelType r, int i);
678 dom(Home home, const SetVarArgs& x, SetRelType r, int i);
681 dom(Home home, SetVar x, SetRelType r, int i, int j);
684 dom(Home home, const SetVarArgs& x, SetRelType r, int i, int j);
687 dom(Home home, SetVar x, SetRelType r, const IntSet& s);
690 dom(Home home, const SetVarArgs& x, SetRelType r, const IntSet& s);
693 cardinality(Home home, SetVar x, unsigned int i, unsigned int j);
696 cardinality(Home home, const SetVarArgs& x, unsigned int i, unsigned int j);
699 dom(Home home, SetVar x, SetRelType rt, int i, Reify r);
702 dom(Home home, SetVar x, SetRelType rt, int i, int j, Reify r);
705 dom(Home home, SetVar x, SetRelType rt, const IntSet& s, Reify r);
708 dom(Home home, SetVar x, SetVar d);
711 dom(Home home, const SetVarArgs& x, const SetVarArgs& d);
713
714
723 rel(Home home, SetVar x, SetRelType r, SetVar y);
726 rel(Home home, SetVar x, SetRelType rt, SetVar y, Reify r);
729 rel(Home home, SetVar s, SetRelType r, IntVar x);
732 rel(Home home, IntVar x, SetRelType r, SetVar s);
735 rel(Home home, SetVar s, SetRelType rt, IntVar x, Reify r);
738 rel(Home home, IntVar x, SetRelType rt, SetVar s, Reify r);
741 rel(Home home, SetVar s, IntRelType rt, IntVar x);
743 void
744 rel(Home home, IntVar x, IntRelType rt, SetVar s);
747 rel(Home home, SetVar s, IntRelType rt, IntVar x, Reify r);
749 void
750 rel(Home home, IntVar x, IntRelType rt, SetVar s, Reify r);
752
753}
754
755#include <gecode/set/int.hpp>
756
757namespace Gecode {
758
770 rel(Home home, SetOpType op, const SetVarArgs& x, SetVar y);
773 rel(Home home, SetOpType op, const SetVarArgs& x, const IntSet& z, SetVar y);
776 rel(Home home, SetOpType op, const IntVarArgs& x, const IntSet& z, SetVar y);
779 rel(Home home, SetOpType op, const IntVarArgs& x, SetVar y);
782 rel(Home home, const IntSet& x, SetOpType op, SetVar y,
786 rel(Home home, SetVar x, SetOpType op, const IntSet& y,
791 SetRelType r, const IntSet& z);
794 rel(Home home, const IntSet& x, SetOpType op, SetVar y, SetRelType r,
795 const IntSet& z);
798 rel(Home home, SetVar x, SetOpType op, const IntSet& y, SetRelType r,
799 const IntSet& z);
805 ite(Home home, BoolVar b, SetVar x, SetVar y, SetVar z);
807
808
817 convex(Home home, SetVar x);
820 convex(Home home, SetVar x, SetVar y);
822
823
832 sequence(Home home, const SetVarArgs& x);
835 sequence(Home home, const SetVarArgs& y, SetVar x);
837
838
847 atmostOne(Home home, const SetVarArgs& x, unsigned int c);
849
859 min(Home home, SetVar s, IntVar x);
864 notMin(Home home, SetVar s, IntVar x);
869 min(Home home, SetVar s, IntVar x, Reify r);
874 max(Home home, SetVar s, IntVar x);
879 notMax(Home home, SetVar s, IntVar x);
884 max(Home home, SetVar s, IntVar x, Reify r);
889 cardinality(Home home, SetVar s, IntVar x);
894 cardinality(Home home, SetVar s, IntVar x, Reify r);
909 SetVar x, IntVar y);
910
911
920 channel(Home home, const IntVarArgs& x,const SetVarArgs& y);
923 channelSorted(Home home, const IntVarArgs& x, SetVar y);
926 channel(Home home, const BoolVarArgs& x, SetVar y);
929 channel(Home home, const SetVarArgs& x, const SetVarArgs& y);
931
932
945 precede(Home home, const SetVarArgs& x, int s, int t);
950 precede(Home home, const SetVarArgs& x, const IntArgs& c);
951
952
1011 element(Home home, SetOpType op, const IntArgs& x, SetVar y, SetVar z,
1019 element(Home home, const SetVarArgs& x, IntVar y, SetVar z);
1026 element(Home home, const IntSetArgs& s, IntVar y, SetVar z);
1033 element(Home home, const IntSetArgs& a,
1034 IntVar x, int w, IntVar y, int h, SetVar z);
1041 element(Home home, const SetVarArgs& a,
1042 IntVar x, int w, IntVar y, int h, SetVar z);
1044
1045
1058 wait(Home home, SetVar x, std::function<void(Space& home)> c);
1061 wait(Home home, const SetVarArgs& x, std::function<void(Space& home)> c);
1063
1064}
1065
1066
1067namespace Gecode {
1068
1082 typedef std::function<bool(const Space& home, SetVar x, int i)>
1094 typedef std::function<double(const Space& home, SetVar x, int i)>
1096
1107 typedef std::function<int(const Space& home, SetVar x, int i)>
1109
1121 typedef std::function<void(Space& home, unsigned int a,
1122 SetVar x, int i, int n)>
1124
1125}
1126
1128
1129namespace Gecode {
1130
1136 class SetAFC : public AFC {
1137 public:
1145 SetAFC(void);
1147 SetAFC(const SetAFC& a);
1149 SetAFC& operator =(const SetAFC& a);
1157 SetAFC(Home home, const SetVarArgs& x, double d=1.0, bool share=true);
1168 void init(Home home, const SetVarArgs& x, double d=1.0, bool share=true);
1169 };
1170
1171}
1172
1174
1175namespace Gecode {
1176
1177
1183 class SetAction : public Action {
1184 public:
1192 SetAction(void);
1194 SetAction(const SetAction& a);
1206 SetAction(Home home, const SetVarArgs& x, double d=1.0,
1207 SetBranchMerit bm=nullptr);
1220 init(Home home, const SetVarArgs& x, double d=1.0,
1221 SetBranchMerit bm=nullptr);
1222 };
1223
1224}
1225
1227
1228namespace Gecode {
1229
1235 class SetCHB : public CHB {
1236 public:
1244 SetCHB(void);
1246 SetCHB(const SetCHB& chb);
1248 SetCHB& operator =(const SetCHB& chb);
1258 SetCHB(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
1271 init(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
1272 };
1273
1274}
1275
1277
1278namespace Gecode {
1279
1281 typedef std::function<void(const Space &home, const Brancher& b,
1282 unsigned int a,
1283 SetVar x, int i, const int& n,
1284 std::ostream& o)>
1286
1287}
1288
1289namespace Gecode {
1290
1352
1371 SetVarBranch SET_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr);
1375 SetVarBranch SET_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr);
1379 SetVarBranch SET_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr);
1383 SetVarBranch SET_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr);
1411 SetVarBranch SET_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
1415 SetVarBranch SET_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
1419 SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
1423 SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
1435
1436}
1437
1439
1440namespace Gecode {
1441
1474
1505
1506}
1507
1509
1510namespace Gecode {
1511
1544
1574
1575}
1576
1578
1579namespace Gecode {
1580
1587 branch(Home home, const SetVarArgs& x,
1588 SetVarBranch vars, SetValBranch vals,
1589 SetBranchFilter bf=nullptr,
1590 SetVarValPrint vvp=nullptr);
1597 branch(Home home, const SetVarArgs& x,
1598 TieBreak<SetVarBranch> vars, SetValBranch vals,
1599 SetBranchFilter bf=nullptr,
1600 SetVarValPrint vvp=nullptr);
1607 branch(Home home, SetVar x, SetValBranch vals,
1608 SetVarValPrint vvp=nullptr);
1609
1616 assign(Home home, const SetVarArgs& x,
1617 SetVarBranch vars, SetAssign vals,
1618 SetBranchFilter bf=nullptr,
1619 SetVarValPrint vvp=nullptr);
1626 assign(Home home, const SetVarArgs& x,
1627 TieBreak<SetVarBranch> vars, SetAssign vals,
1628 SetBranchFilter bf=nullptr,
1629 SetVarValPrint vvp=nullptr);
1636 assign(Home home, SetVar x, SetAssign vals,
1637 SetVarValPrint vvp=nullptr);
1638
1639}
1640
1641namespace Gecode {
1642
1648 void
1649 branch(Home home, const SetVarArgs& x,
1650 SetValBranch vals,
1651 SetBranchFilter bf=nullptr,
1652 SetVarValPrint vvp=nullptr);
1653
1659 void
1660 assign(Home home, const SetVarArgs& x,
1661 SetAssign vals,
1662 SetBranchFilter bf=nullptr,
1663 SetVarValPrint vvp=nullptr);
1664
1665}
1666
1667#include <gecode/set/branch.hpp>
1668
1669// LDSB-related declarations.
1670namespace Gecode {
1672 GECODE_SET_EXPORT SymmetryHandle VariableSymmetry(const SetVarArgs& x);
1679 SymmetryHandle VariableSequenceSymmetry(const SetVarArgs& x, int ss);
1687 branch(Home home, const SetVarArgs& x,
1688 SetVarBranch vars, SetValBranch vals,
1689 const Symmetries& syms,
1690 SetBranchFilter bf=nullptr,
1691 SetVarValPrint vvp=nullptr);
1699 branch(Home home, const SetVarArgs& x,
1700 TieBreak<SetVarBranch> vars, SetValBranch vals,
1701 const Symmetries& syms,
1702 SetBranchFilter bf=nullptr,
1703 SetVarValPrint vvp=nullptr);
1704}
1705
1706namespace Gecode {
1707
1708 /*
1709 * \brief Relaxed assignment of variables in \a x from values in \a sx
1710 *
1711 * The variables in \a x are assigned values from the assigned variables
1712 * in the solution \a sx with a relaxation probability \a p. That is,
1713 * if \$fp=0.1\f$ approximately 10% of the variables in \a x will be
1714 * assigned a value from \a sx.
1715 *
1716 * The random numbers are generated from the generator \a r. At least
1717 * one variable will not be assigned: in case the relaxation attempt
1718 * would suggest that all variables should be assigned, a single
1719 * variable will be selected randomly to remain unassigned.
1720 *
1721 * Throws an exception of type Set::ArgumentSizeMismatch, if \a x and
1722 * \a sx are of different size.
1723 *
1724 * Throws an exception of type Set::OutOfLimits, if \a p is not between
1725 * \a 0.0 and \a 1.0.
1726 *
1727 * \ingroup TaskModeSet
1728 */
1730 relax(Home home, const SetVarArgs& x, const SetVarArgs& sx,
1731 Rnd r, double p);
1732
1733}
1734
1736
1737namespace Gecode {
1738
1749 protected:
1751 public:
1753 class Glb
1754 : public Iter::Ranges::Diff<Set::GlbRanges<Set::SetView>,
1755 Iter::Ranges::RangeList> {
1756 protected:
1761 public:
1763
1764
1767 };
1770 class Lub
1771 : public Iter::Ranges::Diff<Iter::Ranges::RangeList,
1772 Set::LubRanges<Set::SetView> > {
1773 protected:
1778 public:
1780
1781
1784 };
1787
1788
1791
1793
1794 Glb& glb(void);
1796 Lub& lub(void);
1798 };
1799
1800}
1801
1803
1805
1806namespace Gecode {
1807
1818
1824 protected:
1826 std::ostream& os;
1827 public:
1829 StdSetTracer(std::ostream& os0 = std::cerr);
1831 virtual void init(const Space& home, const SetTraceRecorder& t);
1833 virtual void prune(const Space& home, const SetTraceRecorder& t,
1834 const ViewTraceInfo& vti, int i, SetTraceDelta& d);
1836 virtual void fix(const Space& home, const SetTraceRecorder& t);
1838 virtual void fail(const Space& home, const SetTraceRecorder& t);
1840 virtual void done(const Space& home, const SetTraceRecorder& t);
1843 };
1844
1845
1851 trace(Home home, const SetVarArgs& x,
1852 TraceFilter tf,
1853 int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
1859 void
1860 trace(Home home, const SetVarArgs& x,
1861 int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
1863
1864}
1865
1866#include <gecode/set/trace.hpp>
1867
1868#endif
1869
1870// IFDEF: GECODE_HAS_SET_VARS
1871// STATISTICS: set-post
NNF * l
Left subtree.
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
union Gecode::@603::NNF::@65 u
Union depending on nodetype t.
NodeType t
Type of node.
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Class for AFC (accumulated failure count) management.
Definition afc.hpp:40
AFC & operator=(const AFC &a)
Assignment operator.
Definition afc.hpp:152
Class for action management.
Definition action.hpp:42
Action & operator=(const Action &a)
Assignment operator.
Definition action.cpp:50
Passing Boolean variables.
Definition int.hh:712
Boolean integer variables.
Definition int.hh:512
Class for CHB management.
Definition chb.hpp:46
CHB & operator=(const CHB &a)
Assignment operator.
Definition chb.cpp:50
Generic domain change information to be supplied to advisors.
Definition core.hpp:204
Home class for posting propagators
Definition core.hpp:856
Passing integer arguments.
Definition int.hh:628
Integer sets.
Definition int.hh:174
Passing integer variables.
Definition int.hh:656
Integer variables.
Definition int.hh:371
Range iterator for computing set difference.
Range iterator for range lists
Value iterator from range iterator.
Lists of ranges (intervals)
Reification specification.
Definition int.hh:876
Random number generator.
Definition rnd.hpp:42
Recording AFC information for set variables.
Definition set.hh:1136
void init(Home home, const SetVarArgs &x, double d=1.0, bool share=true)
Initialize for set variables x with decay factor d.
Definition afc.hpp:54
SetAFC(void)
Construct as not yet initialized.
Definition afc.hpp:37
Recording actions for set variables.
Definition set.hh:1183
SetAction(void)
Construct as not yet initialized.
Definition action.hpp:37
void init(Home home, const SetVarArgs &x, double d=1.0, SetBranchMerit bm=nullptr)
Initialize for set variables x with decay factor d.
Definition action.cpp:45
Which value to select for assignment.
Definition set.hh:1517
Initialize with selection strategy a s SetAssign(Select s=SEL_MIN_INC)
Definition assign.hpp:37
@ SEL_MED_EXC
Exclude median element (rounding downwards)
Definition set.hh:1524
@ SEL_MIN_EXC
Exclude smallest element.
Definition set.hh:1522
@ SEL_RND_EXC
Exclude random element.
Definition set.hh:1528
@ SEL_MIN_INC
Include smallest element.
Definition set.hh:1521
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition set.hh:1529
@ SEL_MAX_INC
Include largest element.
Definition set.hh:1525
@ SEL_MAX_EXC
Exclude largest element.
Definition set.hh:1526
@ SEL_MED_INC
Include median element (rounding downwards)
Definition set.hh:1523
@ SEL_RND_INC
Include random element.
Definition set.hh:1527
Return selection strategy Select select(void) const
Definition assign.hpp:49
Which value to select Select s
Definition set.hh:1533
Recording CHB for set variables.
Definition set.hh:1235
void init(Home home, const SetVarArgs &x, SetBranchMerit bm=nullptr)
Initialize for set variables x.
Definition chb.cpp:44
SetCHB(void)
Construct as not yet initialized.
Definition chb.hpp:37
Delta for the greatest lower bound.
Definition set.hh:1755
Set::GlbRanges< Set::SetView > n
Iterator over new glb.
Definition set.hh:1760
Iter::Ranges::RangeList o
Iterator over old glb.
Definition set.hh:1758
Glb(RangeList *o, Set::SetView n)
Initialize with old glb and new glb.
Definition delta.hpp:37
Delta for the least upper bound.
Definition set.hh:1772
Iter::Ranges::RangeList o
Iterator over old lub.
Definition set.hh:1775
Lub(RangeList *o, Set::SetView n)
Initialize with old lub o and new lub n.
Definition delta.hpp:42
Set::LubRanges< Set::SetView > n
Iterator over new lub.
Definition set.hh:1777
Trace delta information for set variables.
Definition set.hh:1748
Glb & glb(void)
Give access to iterator for delta in greatest lower bound (values that have been included)
Definition delta.hpp:52
SetTraceDelta(Set::SetTraceView o, Set::SetView n, const Delta &d)
Initialize with old trace view o, new view n, and delta d.
Definition delta.hpp:48
Lub & lub(void)
Give access iterator for delta in leat bound (values that have been removed)
Definition delta.hpp:56
Which values to select for branching first.
Definition set.hh:1447
Which value to select Select s
Definition set.hh:1463
Initialize with selection strategy a s SetValBranch(Select s=SEL_MIN_INC)
Definition val.hpp:37
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition set.hh:1459
@ SEL_MAX_INC
Include largest element.
Definition set.hh:1455
@ SEL_MIN_EXC
Exclude smallest element.
Definition set.hh:1452
@ SEL_RND_EXC
Exclude random element.
Definition set.hh:1458
@ SEL_MIN_INC
Include smallest element.
Definition set.hh:1451
@ SEL_MAX_EXC
Exclude largest element.
Definition set.hh:1456
@ SEL_MED_EXC
Exclude median element (rounding downwards)
Definition set.hh:1454
@ SEL_RND_INC
Include random element.
Definition set.hh:1457
@ SEL_MED_INC
Include median element (rounding downwards)
Definition set.hh:1453
Return selection strategy Select select(void) const
Definition val.hpp:49
Passing set variables.
Definition set.hh:488
SetVarArgs(void)
Allocate empty array.
Definition array.hpp:48
Set variable array
Definition set.hh:570
SetVarArray(void)
Default constructor (array of size 0)
Definition array.hpp:77
Which variable to select for branching.
Definition set.hh:1296
Expand and CHB void expand(Home home, const SetVarArgs &x)
Definition var.hpp:74
@ SEL_ACTION_SIZE_MIN
With smallest action divided by domain size.
Definition set.hh:1322
@ SEL_CHB_MIN
With lowest CHB Q-score.
Definition set.hh:1310
@ SEL_CHB_MAX
With highest CHB Q-score.
Definition set.hh:1311
@ SEL_MERIT_MIN
With least merit.
Definition set.hh:1302
@ SEL_DEGREE_SIZE_MAX
With largest degree divided by domain size.
Definition set.hh:1319
@ SEL_AFC_SIZE_MIN
With smallest accumulated failure count divided by domain size.
Definition set.hh:1320
@ SEL_AFC_MIN
With smallest accumulated failure count.
Definition set.hh:1306
@ SEL_CHB_SIZE_MAX
With largest CHB Q-score divided by domain size.
Definition set.hh:1325
@ SEL_NONE
First unassigned.
Definition set.hh:1300
@ SEL_ACTION_SIZE_MAX
With largest action divided by domain size.
Definition set.hh:1323
@ SEL_DEGREE_MAX
With largest degree.
Definition set.hh:1305
@ SEL_AFC_MAX
With largest accumulated failure count.
Definition set.hh:1307
@ SEL_CHB_SIZE_MIN
With smallest CHB Q-score divided by domain size.
Definition set.hh:1324
@ SEL_MERIT_MAX
With highest merit.
Definition set.hh:1303
@ SEL_SIZE_MIN
With smallest unknown set.
Definition set.hh:1316
@ SEL_RND
Random (uniform, for tie breaking)
Definition set.hh:1301
@ SEL_ACTION_MAX
With highest action.
Definition set.hh:1309
@ SEL_AFC_SIZE_MAX
With largest accumulated failure count divided by domain size.
Definition set.hh:1321
@ SEL_ACTION_MIN
With lowest action.
Definition set.hh:1308
@ SEL_MIN_MAX
With largest minimum unknown element.
Definition set.hh:1313
@ SEL_MAX_MAX
With largest maximum unknown element.
Definition set.hh:1315
@ SEL_MAX_MIN
With smallest maximum unknown element.
Definition set.hh:1314
@ SEL_DEGREE_SIZE_MIN
With smallest degree divided by domain size.
Definition set.hh:1318
@ SEL_MIN_MIN
With smallest minimum unknown element.
Definition set.hh:1312
@ SEL_DEGREE_MIN
With smallest degree.
Definition set.hh:1304
@ SEL_SIZE_MAX
With largest unknown set.
Definition set.hh:1317
Initialize with strategy SEL_NONE SetVarBranch(void)
Definition var.hpp:37
Initialize with selection strategy a decay factor a d
Definition set.hh:1337
Which variable to select Select s
Definition set.hh:1329
Initialize with selection strategy a afc a a
Definition set.hh:1339
Initialize with selection strategy a CHB a c
Definition set.hh:1343
Initialize with selection strategy a branch merit function a mf
Definition set.hh:1345
Return selection strategy Select select(void) const
Definition var.hpp:69
Iterator for the greatest lower bound ranges of a set variable.
Definition set.hh:270
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition set.hpp:111
int max(void) const
Return largest value of range.
Definition set.hpp:123
void operator++(void)
Move iterator to next range (if possible)
Definition set.hpp:115
int min(void) const
Return smallest value of range.
Definition set.hpp:119
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition set.hpp:127
SetVarGlbRanges(void)
Default constructor.
Definition set.hpp:103
Iterator for the values in the greatest lower bound of a set variable.
Definition set.hh:366
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition set.hpp:191
int val(void) const
Return current value.
Definition set.hpp:201
void operator++(void)
Move iterator to next value (if possible)
Definition set.hpp:196
SetVarGlbValues(void)
Default constructor.
Iterator for the least upper bound ranges of a set variable.
Definition set.hh:302
void operator++(void)
Move iterator to next range (if possible)
Definition set.hpp:142
SetVarLubRanges(void)
Default constructor.
Definition set.hpp:130
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition set.hpp:154
int max(void) const
Return largest value of range.
Definition set.hpp:150
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition set.hpp:138
int min(void) const
Return smallest value of range.
Definition set.hpp:146
Iterator for the values in the least upper bound of a set variable.
Definition set.hh:394
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition set.hpp:212
int val(void) const
Return current value.
Definition set.hpp:222
SetVarLubValues(void)
Default constructor.
void operator++(void)
Move iterator to next value (if possible)
Definition set.hpp:217
Iterator for the unknown ranges of a set variable.
Definition set.hh:334
int max(void) const
Return largest value of range.
Definition set.hpp:178
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition set.hpp:166
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition set.hpp:182
void operator++(void)
Move iterator to next range (if possible)
Definition set.hpp:170
int min(void) const
Return smallest value of range.
Definition set.hpp:174
SetVarUnknownRanges(void)
Default constructor.
Definition set.hpp:157
Iterator for the values in the unknown set of a set variable.
Definition set.hh:422
int val(void) const
Return current value.
Definition set.hpp:243
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition set.hpp:233
SetVarUnknownValues(void)
Default constructor.
void operator++(void)
Move iterator to next value (if possible)
Definition set.hpp:238
Set variables
Definition set.hh:127
unsigned int cardMax(void) const
Return cardinality maximum.
Definition set.hpp:81
SetVar(void)
Default constructor.
Definition set.hpp:46
bool notContains(int i) const
Test whether i is not in the least upper bound.
Definition set.hpp:75
int lubMin(void) const
Return minimum element of least upper bound.
Definition set.hpp:84
unsigned int lubSize(void) const
Return number of elements in the least upper bound.
Definition set.hpp:66
int lubMax(void) const
Return maximum element of least upper bound.
Definition set.hpp:87
unsigned int glbSize(void) const
Return number of elements in the greatest lower bound.
Definition set.hpp:63
int glbMin(void) const
Return minimum element of greatest lower bound.
Definition set.hpp:90
unsigned int unknownSize(void) const
Return number of unknown elements (elements in lub but not in glb)
Definition set.hpp:69
int glbMax(void) const
Return maximum of greatest lower bound.
Definition set.hpp:93
bool contains(int i) const
Test whether i is in greatest lower bound.
Definition set.hpp:72
unsigned int cardMin(void) const
Return cardinality minimum.
Definition set.hpp:78
Range iterator for the greatest lower bound.
Definition var-imp.hpp:359
Range iterator for the least upper bound.
Definition var-imp.hpp:317
Duplicate of a set view.
Finite integer set variable implementation.
Definition var-imp.hpp:430
Set view for set variables
Definition view.hpp:56
Range iterator for the unknown set.
Definition var-imp.hpp:402
Computation spaces.
Definition core.hpp:1742
Standard set variable tracer.
Definition set.hh:1823
std::ostream & os
Output stream to use.
Definition set.hh:1826
static StdSetTracer def
Default tracer (printing to std::cerr)
Definition set.hh:1842
Trace filters.
Definition filter.hpp:133
Value branching information.
Definition val.hpp:41
Argument array for variables.
Definition array.hpp:774
Variable arrays
Definition array.hpp:112
Variable branching information.
Definition var.hpp:55
Variables as interfaces to variable implementations.
Definition var.hpp:47
View trace information.
Definition core.hpp:908
Propagator for recording view trace information.
Definition tracer.hpp:44
Tracer that process view trace information.
Definition tracer.hpp:51
#define GECODE_SET_EXPORT
Definition set.hh:67
GECODE_FLOAT_EXPORT void trace(Home home, const FloatVarArgs &x, TraceFilter tf, int te=(TE_INIT|TE_PRUNE|TE_FIX|TE_FAIL|TE_DONE), FloatTracer &t=StdFloatTracer::def)
Create a tracer for float variables.
Definition trace.cpp:39
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition var.hpp:48
void assign(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatAssign vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Assign all x with variable selection vars and value selection vals.
Definition branch.cpp:111
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
Definition branch.cpp:39
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
Definition rel.cpp:68
void ite(Home home, BoolVar b, FloatVar x, FloatVar y, FloatVar z)
Post propagator for if-then-else constraint.
Definition bool.cpp:39
void precede(Home home, const IntVarArgs &x, int s, int t, IntPropLevel=IPL_DEF)
Post propagator that s precedes t in x.
Definition precede.cpp:43
IntRelType
Relation types for integers.
Definition int.hh:925
std::function< bool(const Space &home, SetVar x, int i)> SetBranchFilter
Branch filter function type for set variables.
Definition set.hh:1083
std::function< double(const Space &home, SetVar x, int i)> SetBranchMerit
Branch merit function type for set variables.
Definition set.hh:1095
std::function< int(const Space &home, SetVar x, int i)> SetBranchVal
Branch value function type for set variables.
Definition set.hh:1108
std::function< void(Space &home, unsigned int a, SetVar x, int i, int n)> SetBranchCommit
Branch commit function type for set variables.
Definition set.hh:1123
SetOpType
Common operations for sets.
Definition set.hh:660
SetRelType
Common relation types for sets.
Definition set.hh:643
@ SOT_MINUS
Difference.
Definition set.hh:664
@ SOT_DUNION
Disjoint union.
Definition set.hh:662
@ SOT_UNION
Union.
Definition set.hh:661
@ SOT_INTER
Intersection
Definition set.hh:663
@ SRT_GQ
Greater or equal ( )
Definition set.hh:652
@ SRT_CMPL
Complement.
Definition set.hh:649
@ SRT_GR
Greater ( )
Definition set.hh:653
@ SRT_LQ
Less or equal ( )
Definition set.hh:650
@ SRT_NQ
Disequality ( )
Definition set.hh:645
@ SRT_LE
Less ( )
Definition set.hh:651
@ SRT_EQ
Equality ( )
Definition set.hh:644
@ SRT_SUP
Superset ( )
Definition set.hh:647
@ SRT_DISJ
Disjoint ( )
Definition set.hh:648
@ SRT_SUB
Subset ( )
Definition set.hh:646
ViewTracer< Set::SetView > SetTracer
Tracer for set variables.
Definition set.hh:1812
ViewTraceRecorder< Set::SetView > SetTraceRecorder
Trace recorder for set variables.
Definition set.hh:1817
@ TE_INIT
Trace init events.
Definition recorder.hpp:43
@ TE_PRUNE
Trace prune events.
Definition recorder.hpp:44
@ TE_FIX
Trace fixpoint events.
Definition recorder.hpp:45
@ TE_FAIL
Trace fail events.
Definition recorder.hpp:46
@ TE_DONE
Trace done events.
Definition recorder.hpp:47
void check(int n, const char *l)
Check whether n is in range, otherwise throw out of limits with information l.
Definition limits.hpp:46
const int min
Smallest allowed integer value.
Definition int.hh:118
const int max
Largest allowed integer value.
Definition int.hh:116
const int min
Smallest allowed integer in integer set.
Definition set.hh:99
const unsigned int card
Maximum cardinality of an integer set.
Definition set.hh:101
const int max
Largest allowed integer in integer set.
Definition set.hh:97
Gecode toplevel namespace
Select variable with highest merit according to branch merit function a bm SetVarBranch SET_VAR_MERIT_MAX(SetBranchMerit bm, BranchTbl tbl=nullptr)
Definition var.hpp:111
SetValBranch SET_VAL_MED_INC(void)
Definition val.hpp:65
Select variable with smallest action divided by domain size with decay factor a d SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr)
Definition var.hpp:246
Select variable with smallest CHB Q score divided by domain size SetVarBranch SET_VAR_CHB_SIZE_MIN(BranchTbl tbl=nullptr)
Definition var.hpp:266
Select variable with largest action divided by domain size with decay factor a d SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr)
Definition var.hpp:256
void weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y)
Definition int.cpp:292
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition set.hh:767
Exclude random element SetAssign SET_ASSIGN_RND_EXC(Rnd r)
Definition assign.hpp:90
void notMin(Home home, SetVar s, IntVar x)
Definition int.cpp:235
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
Definition channel.cpp:41
Select first unassigned variable SetVarBranch SET_VAR_NONE(void)
Definition var.hpp:96
Include random element SetValBranch SET_VAL_RND_INC(Rnd r)
Definition val.hpp:85
Select variable with largest degree divided by domain size SetVarBranch SET_VAR_DEGREE_SIZE_MAX(BranchTbl tbl=nullptr)
Definition var.hpp:221
void sequence(Home home, const IntVarArgs &x, const IntSet &s, int q, int l, int u, IntPropLevel ipl=IPL_DEF)
Post propagator for .
Definition sequence.cpp:47
void channelSorted(Home home, const IntVarArgs &x, SetVar y)
Definition channel.cpp:45
void atmostOne(Home home, const SetVarArgs &xa, unsigned int c)
Definition distinct.cpp:41
Archive & operator<<(Archive &e, FloatNumBranch nl)
Definition val-sel.hpp:39
Exclude random element SetValBranch SET_VAL_RND_EXC(Rnd r)
Definition val.hpp:90
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Select variable with lowest CHB Q score SetVarBranch SET_VAR_CHB_MIN(BranchTbl tbl=nullptr)
Definition var.hpp:166
Select variable with largest minimum unknown element SetVarBranch SET_VAR_MIN_MAX(BranchTbl tbl=nullptr)
Definition var.hpp:191
SetAssign SET_ASSIGN_MED_EXC(void)
Definition assign.hpp:70
Select variable with highest CHB Q score SetVarBranch SET_VAR_CHB_MAX(BranchTbl tbl=nullptr)
Definition var.hpp:176
SetAssign SET_ASSIGN_MED_INC(void)
Definition assign.hpp:65
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition dom.cpp:40
void element(Home home, IntSharedArray n, IntVar x0, IntVar x1, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for .
Definition element.cpp:39
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
Definition set.hh:767
SetValBranch SET_VAL(SetBranchVal v, SetBranchCommit c=nullptr)
Select value as defined by the value function v and commit function c.
Definition val.hpp:95
Select variable with smallest unknown set SetVarBranch SET_VAR_SIZE_MIN(BranchTbl tbl=nullptr)
Definition var.hpp:206
Function type for printing branching alternatives for set variables typedef std::function< void(const Space &home, const Brancher &b, unsigned int a, SetVar x, int i, const int &n, std::ostream &o)> SetVarValPrint
Definition set.hh:1285
SetVarBranch SET_VAR_RND(Rnd r)
Definition var.hpp:101
Select variable with largest maximum unknown element SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl=nullptr)
Definition var.hpp:201
Post propagator for SetVar SetOpType SetVar y
Definition set.hh:767
Select variable with largest accumulated failure count with decay factor a d SetVarBranch SET_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr)
Definition var.hpp:136
Include largest element SetAssign SET_ASSIGN_MAX_INC(void)
Definition assign.hpp:75
Select variable with smallest minimum unknown element SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl=nullptr)
Definition var.hpp:186
SetValBranch SET_VAL_MED_EXC(void)
Definition val.hpp:70
Include largest element SetValBranch SET_VAL_MAX_INC(void)
Definition val.hpp:75
Include random element SetAssign SET_ASSIGN_RND_INC(Rnd r)
Definition assign.hpp:85
Select variable with largest CHB Q score divided by domain size SetVarBranch SET_VAR_CHB_SIZE_MAX(BranchTbl tbl=nullptr)
Definition var.hpp:276
Select variable with smallest degree SetVarBranch SET_VAR_DEGREE_MIN(BranchTbl tbl=nullptr)
Definition var.hpp:116
SymmetryHandle VariableSymmetry(const IntVarArgs &x)
Variables in x are interchangeable.
Definition ldsb.cpp:62
GECODE_FLOAT_EXPORT void relax(Home home, const FloatVarArgs &x, const FloatVarArgs &sx, Rnd r, double p)
Definition relax.cpp:57
Post propagator that propagates that a x is convex void convex(Home home, SetVar x)
Definition convex.cpp:41
void notMax(Home home, SetVar s, IntVar x)
Definition int.cpp:267
Select variable with smallest accumulated failure count with decay factor a d SetVarBranch SET_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr)
Definition var.hpp:126
Select variable with smallest maximum unknown element SetVarBranch SET_VAR_MAX_MIN(BranchTbl tbl=nullptr)
Definition var.hpp:196
void wait(Home home, FloatVar x, std::function< void(Space &home)> c)
Execute c when x becomes assigned.
Definition exec.cpp:39
Select variable with largest degree SetVarBranch SET_VAR_DEGREE_MAX(BranchTbl tbl=nullptr)
Definition var.hpp:121
Include smallest element SetValBranch SET_VAL_MIN_INC(void)
Definition val.hpp:55
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Select variable with smallest accumulated failure count divided by domain size with decay factor a d SetVarBranch SET_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr)
Definition var.hpp:226
SymmetryHandle VariableSequenceSymmetry(const IntVarArgs &x, int ss)
Variable sequences in x of size ss are interchangeable.
Definition ldsb.cpp:90
Exclude smallest element SetAssign SET_ASSIGN_MIN_EXC(void)
Definition assign.hpp:60
Include smallest element SetAssign SET_ASSIGN_MIN_INC(void)
Definition assign.hpp:55
Exclude largest element SetValBranch SET_VAL_MAX_EXC(void)
Definition val.hpp:80
SetAssign SET_ASSIGN(SetBranchVal v, SetBranchCommit c=nullptr)
Select value as defined by the value function v and commit function c.
Definition assign.hpp:95
Exclude largest element SetAssign SET_ASSIGN_MAX_EXC(void)
Definition assign.hpp:80
Select variable with largest accumulated failure count divided by domain size with decay factor a d SetVarBranch SET_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr)
Definition var.hpp:236
Select variable with lowest action with decay factor a d SetVarBranch SET_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr)
Definition var.hpp:146
LinIntExpr cardinality(const SetExpr &)
Cardinality of set expression.
Definition set-expr.cpp:817
Select variable with least merit according to branch merit function a bm SetVarBranch SET_VAR_MERIT_MIN(SetBranchMerit bm, BranchTbl tbl=nullptr)
Definition var.hpp:106
Post propagator for SetVar x
Definition set.hh:767
Select variable with smallest degree divided by domain size SetVarBranch SET_VAR_DEGREE_SIZE_MIN(BranchTbl tbl=nullptr)
Definition var.hpp:216
Exclude smallest element SetValBranch SET_VAL_MIN_EXC(void)
Definition val.hpp:60
Post propagator for SetVar SetOpType op
Definition set.hh:767
Select variable with largest unknown set SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl=nullptr)
Definition var.hpp:211
Select variable with highest action with decay factor a d SetVarBranch SET_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr)
Definition var.hpp:156