Generated on Fri Jan 28 2022 04:43:06 for Gecode by doxygen 1.8.13
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 
90 #include <gecode/set/exception.hpp>
91 
92 namespace 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 
116 namespace 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  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  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  bool contains(int i) const;
259  bool notContains(int i) const;
261  };
262 
268 
271  private:
273  public:
275 
276  SetVarGlbRanges(void);
279  SetVarGlbRanges(const SetVar& x);
281 
283 
284  bool operator ()(void) const;
287  void operator ++(void);
289 
291 
292  int min(void) const;
295  int max(void) const;
297  unsigned int width(void) const;
299  };
300 
303  private:
305  public:
307 
308  SetVarLubRanges(void);
311  SetVarLubRanges(const SetVar& x);
313 
315 
316  bool operator ()(void) const;
319  void operator ++(void);
321 
323 
324  int min(void) const;
327  int max(void) const;
329  unsigned int width(void) const;
331  };
332 
335  private:
337  public:
339 
340  SetVarUnknownRanges(void);
343  SetVarUnknownRanges(const SetVar& x);
345 
347 
348  bool operator ()(void) const;
351  void operator ++(void);
353 
355 
356  int min(void) const;
359  int max(void) const;
361  unsigned int width(void) const;
363  };
364 
367  private:
369  public:
371 
372  SetVarGlbValues(void);
375  SetVarGlbValues(const SetVar& x);
377 
379 
380  bool operator ()(void) const;
383  void operator ++(void);
385 
387 
388  int val(void) const;
391  };
392 
395  private:
397  public:
399 
400  SetVarLubValues(void);
403  SetVarLubValues(const SetVar& x);
405 
407 
408  bool operator ()(void) const;
411  void operator ++(void);
413 
415 
416  int val(void) const;
419  };
420 
423  private:
425  public:
427 
428  SetVarUnknownValues(void);
431  SetVarUnknownValues(const SetVar& x);
433 
435 
436  bool operator ()(void) const;
439  void operator ++(void);
441 
443 
444  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 
463 namespace Gecode {
473 
474 }
475 
477 
478 namespace Gecode {
479 
488  class SetVarArgs : public VarArgArray<SetVar> {
489  public:
491 
492  SetVarArgs(void);
495  explicit SetVarArgs(int n);
497  SetVarArgs(const SetVarArgs& a);
499  SetVarArgs(const VarArray<SetVar>& 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  SetVarArray(void);
577  SetVarArray(const SetVarArray&);
579  SetVarArray(Space& home, const SetVarArgs&);
581  GECODE_SET_EXPORT SetVarArray(Space& home, int n);
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 
630 namespace Gecode {
631 
643  enum SetRelType {
654  };
655 
660  enum SetOpType {
665  };
666 
673  GECODE_SET_EXPORT void
675  dom(Home home, SetVar x, SetRelType r, int i);
677  GECODE_SET_EXPORT void
678  dom(Home home, const SetVarArgs& x, SetRelType r, int i);
680  GECODE_SET_EXPORT void
681  dom(Home home, SetVar x, SetRelType r, int i, int j);
683  GECODE_SET_EXPORT void
684  dom(Home home, const SetVarArgs& x, SetRelType r, int i, int j);
686  GECODE_SET_EXPORT void
687  dom(Home home, SetVar x, SetRelType r, const IntSet& s);
689  GECODE_SET_EXPORT void
690  dom(Home home, const SetVarArgs& x, SetRelType r, const IntSet& s);
692  GECODE_SET_EXPORT void
693  cardinality(Home home, SetVar x, unsigned int i, unsigned int j);
695  GECODE_SET_EXPORT void
696  cardinality(Home home, const SetVarArgs& x, unsigned int i, unsigned int j);
698  GECODE_SET_EXPORT void
699  dom(Home home, SetVar x, SetRelType rt, int i, Reify r);
701  GECODE_SET_EXPORT void
702  dom(Home home, SetVar x, SetRelType rt, int i, int j, Reify r);
704  GECODE_SET_EXPORT void
705  dom(Home home, SetVar x, SetRelType rt, const IntSet& s, Reify r);
707  GECODE_SET_EXPORT void
708  dom(Home home, SetVar x, SetVar d);
710  GECODE_SET_EXPORT void
711  dom(Home home, const SetVarArgs& x, const SetVarArgs& d);
713 
714 
721  GECODE_SET_EXPORT void
723  rel(Home home, SetVar x, SetRelType r, SetVar y);
725  GECODE_SET_EXPORT void
726  rel(Home home, SetVar x, SetRelType rt, SetVar y, Reify r);
728  GECODE_SET_EXPORT void
729  rel(Home home, SetVar s, SetRelType r, IntVar x);
731  GECODE_SET_EXPORT void
732  rel(Home home, IntVar x, SetRelType r, SetVar s);
734  GECODE_SET_EXPORT void
735  rel(Home home, SetVar s, SetRelType rt, IntVar x, Reify r);
737  GECODE_SET_EXPORT void
738  rel(Home home, IntVar x, SetRelType rt, SetVar s, Reify r);
740  GECODE_SET_EXPORT void
741  rel(Home home, SetVar s, IntRelType rt, IntVar x);
743  void
744  rel(Home home, IntVar x, IntRelType rt, SetVar s);
746  GECODE_SET_EXPORT void
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 
757 namespace Gecode {
758 
765  GECODE_SET_EXPORT void
769  GECODE_SET_EXPORT void
770  rel(Home home, SetOpType op, const SetVarArgs& x, SetVar y);
772  GECODE_SET_EXPORT void
773  rel(Home home, SetOpType op, const SetVarArgs& x, const IntSet& z, SetVar y);
775  GECODE_SET_EXPORT void
776  rel(Home home, SetOpType op, const IntVarArgs& x, const IntSet& z, SetVar y);
778  GECODE_SET_EXPORT void
779  rel(Home home, SetOpType op, const IntVarArgs& x, SetVar y);
781  GECODE_SET_EXPORT void
782  rel(Home home, const IntSet& x, SetOpType op, SetVar y,
783  SetRelType r, SetVar z);
785  GECODE_SET_EXPORT void
786  rel(Home home, SetVar x, SetOpType op, const IntSet& y,
787  SetRelType r, SetVar z);
789  GECODE_SET_EXPORT void
790  rel(Home home, SetVar x, SetOpType op, SetVar y,
791  SetRelType r, const IntSet& z);
793  GECODE_SET_EXPORT void
794  rel(Home home, const IntSet& x, SetOpType op, SetVar y, SetRelType r,
795  const IntSet& z);
797  GECODE_SET_EXPORT void
798  rel(Home home, SetVar x, SetOpType op, const IntSet& y, SetRelType r,
799  const IntSet& z);
804  GECODE_SET_EXPORT void
805  ite(Home home, BoolVar b, SetVar x, SetVar y, SetVar z);
807 
808 
815  GECODE_SET_EXPORT void
817  convex(Home home, SetVar x);
819  GECODE_SET_EXPORT void
820  convex(Home home, SetVar x, SetVar y);
822 
823 
830  GECODE_SET_EXPORT void
832  sequence(Home home, const SetVarArgs& x);
834  GECODE_SET_EXPORT void
835  sequence(Home home, const SetVarArgs& y, SetVar x);
837 
838 
845  GECODE_SET_EXPORT void
847  atmostOne(Home home, const SetVarArgs& x, unsigned int c);
849 
858  GECODE_SET_EXPORT void
859  min(Home home, SetVar s, IntVar x);
863  GECODE_SET_EXPORT void
864  notMin(Home home, SetVar s, IntVar x);
868  GECODE_SET_EXPORT void
869  min(Home home, SetVar s, IntVar x, Reify r);
873  GECODE_SET_EXPORT void
874  max(Home home, SetVar s, IntVar x);
878  GECODE_SET_EXPORT void
879  notMax(Home home, SetVar s, IntVar x);
883  GECODE_SET_EXPORT void
884  max(Home home, SetVar s, IntVar x, Reify r);
888  GECODE_SET_EXPORT void
889  cardinality(Home home, SetVar s, IntVar x);
893  GECODE_SET_EXPORT void
894  cardinality(Home home, SetVar s, IntVar x, Reify r);
907  GECODE_SET_EXPORT void
909  SetVar x, IntVar y);
910 
911 
918  GECODE_SET_EXPORT void
920  channel(Home home, const IntVarArgs& x,const SetVarArgs& y);
922  GECODE_SET_EXPORT void
923  channelSorted(Home home, const IntVarArgs& x, SetVar y);
925  GECODE_SET_EXPORT void
926  channel(Home home, const BoolVarArgs& x, SetVar y);
928  GECODE_SET_EXPORT void
929  channel(Home home, const SetVarArgs& x, const SetVarArgs& y);
931 
932 
944  GECODE_SET_EXPORT void
945  precede(Home home, const SetVarArgs& x, int s, int t);
949  GECODE_SET_EXPORT void
950  precede(Home home, const SetVarArgs& x, const IntArgs& c);
951 
952 
974  GECODE_SET_EXPORT void
975  element(Home home, SetOpType op, const SetVarArgs& x, SetVar y, SetVar z,
986  GECODE_SET_EXPORT void
987  element(Home home, SetOpType op, const IntVarArgs& x, SetVar y, SetVar z,
998  GECODE_SET_EXPORT void
999  element(Home home, SetOpType op, const IntSetArgs& x, SetVar y, SetVar z,
1010  GECODE_SET_EXPORT void
1011  element(Home home, SetOpType op, const IntArgs& x, SetVar y, SetVar z,
1018  GECODE_SET_EXPORT void
1019  element(Home home, const SetVarArgs& x, IntVar y, SetVar z);
1025  GECODE_SET_EXPORT void
1026  element(Home home, const IntSetArgs& s, IntVar y, SetVar z);
1032  GECODE_SET_EXPORT void
1033  element(Home home, const IntSetArgs& a,
1034  IntVar x, int w, IntVar y, int h, SetVar z);
1040  GECODE_SET_EXPORT void
1041  element(Home home, const SetVarArgs& a,
1042  IntVar x, int w, IntVar y, int h, SetVar z);
1044 
1045 
1056  GECODE_SET_EXPORT void
1058  wait(Home home, SetVar x, std::function<void(Space& home)> c);
1060  GECODE_SET_EXPORT void
1061  wait(Home home, const SetVarArgs& x, std::function<void(Space& home)> c);
1063 
1064 }
1065 
1066 
1067 namespace 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 
1129 namespace 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 
1173 #include <gecode/set/branch/afc.hpp>
1174 
1175 namespace Gecode {
1176 
1177 
1183  class SetAction : public Action {
1184  public:
1192  SetAction(void);
1194  SetAction(const SetAction& a);
1196  SetAction& operator =(const SetAction& a);
1206  SetAction(Home home, const SetVarArgs& x, double d=1.0,
1207  SetBranchMerit bm=nullptr);
1219  GECODE_SET_EXPORT void
1220  init(Home home, const SetVarArgs& x, double d=1.0,
1221  SetBranchMerit bm=nullptr);
1222  };
1223 
1224 }
1225 
1227 
1228 namespace 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);
1270  GECODE_SET_EXPORT void
1271  init(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
1272  };
1273 
1274 }
1275 
1276 #include <gecode/set/branch/chb.hpp>
1277 
1278 namespace 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 
1289 namespace Gecode {
1290 
1296  class SetVarBranch : public VarBranch<SetVar> {
1297  public:
1299  enum Select {
1300  SEL_NONE = 0,
1325  SEL_CHB_SIZE_MAX
1326  };
1327  protected:
1330  public:
1332  SetVarBranch(void);
1334  SetVarBranch(Rnd r);
1338  SetVarBranch(Select s, double d, BranchTbl t);
1348  Select select(void) const;
1350  void expand(Home home, const SetVarArgs& x);
1351  };
1352 
1358  SetVarBranch SET_VAR_NONE(void);
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 
1438 #include <gecode/set/branch/var.hpp>
1439 
1440 namespace Gecode {
1441 
1447  class SetValBranch : public ValBranch<SetVar> {
1448  public:
1450  enum Select {
1459  SEL_VAL_COMMIT
1460  };
1461  protected:
1464  public:
1466  SetValBranch(Select s = SEL_MIN_INC);
1468  SetValBranch(Select s, Rnd r);
1472  Select select(void) const;
1473  };
1474 
1505 
1506 }
1507 
1508 #include <gecode/set/branch/val.hpp>
1509 
1510 namespace Gecode {
1511 
1517  class SetAssign : public ValBranch<SetVar> {
1518  public:
1520  enum Select {
1529  SEL_VAL_COMMIT
1530  };
1531  protected:
1534  public:
1536  SetAssign(Select s = SEL_MIN_INC);
1538  SetAssign(Select s, Rnd r);
1542  Select select(void) const;
1543  };
1544 
1574 
1575 }
1576 
1578 
1579 namespace Gecode {
1580 
1586  GECODE_SET_EXPORT void
1587  branch(Home home, const SetVarArgs& x,
1588  SetVarBranch vars, SetValBranch vals,
1589  SetBranchFilter bf=nullptr,
1590  SetVarValPrint vvp=nullptr);
1596  GECODE_SET_EXPORT void
1597  branch(Home home, const SetVarArgs& x,
1599  SetBranchFilter bf=nullptr,
1600  SetVarValPrint vvp=nullptr);
1606  GECODE_SET_EXPORT void
1607  branch(Home home, SetVar x, SetValBranch vals,
1608  SetVarValPrint vvp=nullptr);
1614  GECODE_SET_EXPORT void
1615  assign(Home home, const SetVarArgs& x, SetAssign vals,
1616  SetBranchFilter bf=nullptr,
1617  SetVarValPrint vvp=nullptr);
1623  GECODE_SET_EXPORT void
1624  assign(Home home, SetVar x, SetAssign vals,
1625  SetVarValPrint vvp=nullptr);
1626 
1627 }
1628 
1629 // LDSB-related declarations.
1630 namespace Gecode {
1646  GECODE_SET_EXPORT void
1647  branch(Home home, const SetVarArgs& x,
1648  SetVarBranch vars, SetValBranch vals,
1649  const Symmetries& syms,
1650  SetBranchFilter bf=nullptr,
1651  SetVarValPrint vvp=nullptr);
1658  GECODE_SET_EXPORT void
1659  branch(Home home, const SetVarArgs& x,
1661  const Symmetries& syms,
1662  SetBranchFilter bf=nullptr,
1663  SetVarValPrint vvp=nullptr);
1664 }
1665 
1666 namespace Gecode {
1667 
1668  /*
1669  * \brief Relaxed assignment of variables in \a x from values in \a sx
1670  *
1671  * The variables in \a x are assigned values from the assigned variables
1672  * in the solution \a sx with a relaxation probability \a p. That is,
1673  * if \$fp=0.1\f$ approximately 10% of the variables in \a x will be
1674  * assigned a value from \a sx.
1675  *
1676  * The random numbers are generated from the generator \a r. At least
1677  * one variable will not be assigned: in case the relaxation attempt
1678  * would suggest that all variables should be assigned, a single
1679  * variable will be selected randomly to remain unassigned.
1680  *
1681  * Throws an exception of type Set::ArgumentSizeMismatch, if \a x and
1682  * \a sx are of different size.
1683  *
1684  * Throws an exception of type Set::OutOfLimits, if \a p is not between
1685  * \a 0.0 and \a 1.0.
1686  *
1687  * \ingroup TaskModeSet
1688  */
1689  GECODE_SET_EXPORT void
1690  relax(Home home, const SetVarArgs& x, const SetVarArgs& sx,
1691  Rnd r, double p);
1692 
1693 }
1694 
1696 
1697 namespace Gecode {
1698 
1709  protected:
1711  public:
1713  class Glb
1714  : public Iter::Ranges::Diff<Set::GlbRanges<Set::SetView>,
1715  Iter::Ranges::RangeList> {
1716  protected:
1721  public:
1723 
1724  Glb(RangeList* o, Set::SetView n);
1727  };
1730  class Lub
1731  : public Iter::Ranges::Diff<Iter::Ranges::RangeList,
1732  Set::LubRanges<Set::SetView> > {
1733  protected:
1738  public:
1740 
1741  Lub(RangeList* o, Set::SetView n);
1744  };
1747 
1751 
1753  Glb& glb(void);
1756  Lub& lub(void);
1758  };
1759 
1760 }
1761 
1762 #include <gecode/set/trace/delta.hpp>
1763 
1764 #include <gecode/set/trace/traits.hpp>
1765 
1766 namespace Gecode {
1767 
1778 
1783  class GECODE_SET_EXPORT StdSetTracer : public SetTracer {
1784  protected:
1786  std::ostream& os;
1787  public:
1789  StdSetTracer(std::ostream& os0 = std::cerr);
1791  virtual void init(const Space& home, const SetTraceRecorder& t);
1793  virtual void prune(const Space& home, const SetTraceRecorder& t,
1794  const ViewTraceInfo& vti, int i, SetTraceDelta& d);
1796  virtual void fix(const Space& home, const SetTraceRecorder& t);
1798  virtual void fail(const Space& home, const SetTraceRecorder& t);
1800  virtual void done(const Space& home, const SetTraceRecorder& t);
1803  };
1804 
1805 
1810  GECODE_SET_EXPORT void
1811  trace(Home home, const SetVarArgs& x,
1812  TraceFilter tf,
1813  int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
1814  SetTracer& t = StdSetTracer::def);
1819  void
1820  trace(Home home, const SetVarArgs& x,
1821  int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
1822  SetTracer& t = StdSetTracer::def);
1823 
1824 }
1825 
1826 #include <gecode/set/trace.hpp>
1827 
1828 #endif
1829 
1830 // IFDEF: GECODE_HAS_SET_VARS
1831 // STATISTICS: set-post
Which values to select for branching first.
Definition: set.hh:1447
Exclude median element (rounding downwards)
Definition: set.hh:1524
void channelSorted(Home home, const IntVarArgs &x, SetVar y)
Definition: channel.cpp:45
ViewTracer< Set::SetView > SetTracer
Tracer for set variables.
Definition: set.hh:1772
Recording actions for set variables.
Definition: set.hh:1183
Post propagator for SetVar SetOpType op
Definition: set.hh:767
SetVarBranch SET_VAR_CHB_SIZE_MIN(BranchTbl tbl)
Definition: var.hpp:266
Which value to select Select s
Definition: set.hh:1463
SetVarBranch SET_VAR_SIZE_MIN(BranchTbl tbl)
Definition: var.hpp:206
Variables as interfaces to variable implementations.
Definition: var.hpp:47
NodeType t
Type of node.
Definition: bool-expr.cpp:230
Tracer that process view trace information.
Definition: tracer.hpp:51
Combine variable selection criteria for tie-breaking.
Definition: tiebreak.hpp:38
void check(int n, const char *l)
Check whether integer n is in range, otherwise throw overflow exception with information l...
Definition: limits.hpp:37
SetRelType
Common relation types for sets.
Definition: set.hh:643
With highest action.
Definition: set.hh:1309
With lowest CHB Q-score.
Definition: set.hh:1310
NNF * l
Left subtree.
Definition: bool-expr.cpp:240
void notMin(Home home, SetVar s, IntVar x)
Definition: int.cpp:235
Range iterator for the unknown set.
Definition: var-imp.hpp:402
const int min
Smallest allowed integer in integer set.
Definition: set.hh:99
View trace information.
Definition: core.hpp:905
void sequence(Home home, const IntVarArgs &x, const IntSet &s, int q, int l, int u, IntPropLevel)
Post propagator for .
Definition: sequence.cpp:47
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
Definition: branch.cpp:39
Set::LubRanges< Set::SetView > n
Iterator over new lub.
Definition: set.hh:1737
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
Definition: channel.cpp:41
With largest maximum unknown element.
Definition: set.hh:1315
With largest minimum unknown element.
Definition: set.hh:1313
Include median element (rounding downwards)
Definition: set.hh:1523
With largest action divided by domain size.
Definition: set.hh:1323
SetVarBranch SET_VAR_MERIT_MAX(SetBranchMerit bm, BranchTbl tbl)
Definition: var.hpp:111
With smallest accumulated failure count divided by domain size.
Definition: set.hh:1320
Set::GlbRanges< Set::SetView > n
Iterator over new glb.
Definition: set.hh:1720
Standard set variable tracer.
Definition: set.hh:1783
Range iterator for range lists
Exclude random element.
Definition: set.hh:1458
std::function< double(const Space &home, SetVar x, int i)> SetBranchMerit
Branch merit function type for set variables.
Definition: set.hh:1095
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition: dom.cpp:40
With largest accumulated failure count divided by domain size.
Definition: set.hh:1321
Collection of symmetries.
Definition: int.hh:5162
With smallest degree.
Definition: set.hh:1304
Exclude random element.
Definition: set.hh:1528
SetVarBranch SET_VAR_DEGREE_SIZE_MAX(BranchTbl tbl)
Definition: var.hpp:221
Exclude smallest element.
Definition: set.hh:1522
With smallest CHB Q-score divided by domain size.
Definition: set.hh:1324
Range iterator for the greatest lower bound.
Definition: var-imp.hpp:359
Exclude largest element.
Definition: set.hh:1526
With highest CHB Q-score.
Definition: set.hh:1311
With smallest accumulated failure count.
Definition: set.hh:1306
SetValBranch SET_VAL_MED_INC(void)
Definition: val.hpp:65
SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl)
Definition: var.hpp:201
SetValBranch SET_VAL_RND_INC(Rnd r)
Definition: val.hpp:85
SetOpType
Common operations for sets.
Definition: set.hh:660
Superset ( )
Definition: set.hh:647
Complement.
Definition: set.hh:649
const unsigned int card
Maximum cardinality of an integer set.
Definition: set.hh:101
Iter::Ranges::RangeList o
Iterator over old glb.
Definition: set.hh:1718
With largest degree divided by domain size.
Definition: set.hh:1319
const int max
Largest allowed integer in integer set.
Definition: set.hh:97
SetVarBranch SET_VAR_NONE(void)
Definition: var.hpp:96
Trace init events.
Definition: recorder.hpp:43
const int max
Largest allowed integer value.
Definition: int.hh:116
With smallest action divided by domain size.
Definition: set.hh:1322
SetVarBranch SET_VAR_DEGREE_SIZE_MIN(BranchTbl tbl)
Definition: var.hpp:216
Which variable to select Select s
Definition: set.hh:1329
Computation spaces.
Definition: core.hpp:1701
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
Definition: rel.hpp:264
SetAssign SET_ASSIGN_RND_INC(Rnd r)
Definition: assign.hpp:85
Difference.
Definition: set.hh:664
Include random element.
Definition: set.hh:1527
Range iterator for the least upper bound.
Definition: var-imp.hpp:317
Include largest element.
Definition: set.hh:1525
Iterator for the unknown ranges of a set variable.
Definition: set.hh:334
Duplicate of a set view.
Definition: trace-view.hpp:37
Gecode::IntSet d(v, 7)
Iterator for the values in the unknown set of a set variable.
Definition: set.hh:422
With largest unknown set.
Definition: set.hh:1317
std::string expand(Gecode::IntRelType irt)
Expand relation to abbreviation.
Definition: mm-count.cpp:44
Gecode::FloatVal c(-8, 8)
Trace prune events.
Definition: recorder.hpp:44
Exclude smallest element.
Definition: set.hh:1452
SetVarBranch SET_VAR_AFC_MAX(double d, BranchTbl tbl)
Definition: var.hpp:136
SymmetryHandle VariableSymmetry(const IntVarArgs &vars)
Variables in x are interchangeable.
Definition: ldsb.cpp:62
Which value to select Select s
Definition: set.hh:1533
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
Base-class for branchers.
Definition: core.hpp:1401
Class for AFC (accumulated failure count) management.
Definition: afc.hpp:40
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Argument array for non-primitive types.
Definition: array.hpp:638
SetVarBranch SET_VAR_CHB_SIZE_MAX(BranchTbl tbl)
Definition: var.hpp:276
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
Gecode::IntArgs i({1, 2, 3, 4})
A reference-counted pointer to a SymmetryObject.
Definition: int.hh:5125
SetAssign SET_ASSIGN_MAX_INC(void)
Definition: assign.hpp:75
SetVarBranch SET_VAR_DEGREE_MIN(BranchTbl tbl)
Definition: var.hpp:116
IntRelType
Relation types for integers.
Definition: int.hh:925
SetVarBranch SET_VAR_DEGREE_MAX(BranchTbl tbl)
Definition: var.hpp:121
SetVarBranch SET_VAR_CHB_MAX(BranchTbl tbl)
Definition: var.hpp:176
Less or equal ( )
Definition: set.hh:650
struct Gecode::@593::NNF::@62::@63 b
For binary nodes (and, or, eqv)
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition: var.hpp:48
std::ostream & os
Output stream to use.
Definition: set.hh:1786
Value iterator from range iterator.
void wait(Home home, FloatVar x, std::function< void(Space &home)> c)
Execute c when x becomes assigned.
Definition: exec.cpp:39
Class for CHB management.
Definition: chb.hpp:46
Reification specification.
Definition: int.hh:876
Iter::Ranges::RangeList o
Iterator over old lub.
Definition: set.hh:1735
Iterator for the greatest lower bound ranges of a set variable.
Definition: set.hh:270
Subset ( )
Definition: set.hh:646
Trace filters.
Definition: filter.hpp:133
Recording CHB for set variables.
Definition: set.hh:1235
Intersection
Definition: set.hh:663
Include random element.
Definition: set.hh:1457
Integer sets.
Definition: int.hh:174
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
Definition: set.hh:767
SetVarBranch SET_VAR_AFC_MIN(double d, BranchTbl tbl)
Definition: var.hpp:126
With smallest degree divided by domain size.
Definition: set.hh:1318
Less ( )
Definition: set.hh:651
SetVarBranch SET_VAR_RND(Rnd r)
Definition: var.hpp:101
Recording AFC information for set variables.
Definition: set.hh:1136
Exclude median element (rounding downwards)
Definition: set.hh:1454
SetVarBranch SET_VAR_MERIT_MIN(SetBranchMerit bm, BranchTbl tbl)
Definition: var.hpp:106
void convex(Home home, SetVar x)
Definition: convex.cpp:41
Iterator for the least upper bound ranges of a set variable.
Definition: set.hh:302
Include largest element.
Definition: set.hh:1455
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
SetAssign SET_ASSIGN_MED_INC(void)
Definition: assign.hpp:65
Passing integer variables.
Definition: int.hh:656
SetVarBranch SET_VAR_MIN_MAX(BranchTbl tbl)
Definition: var.hpp:191
SetValBranch SET_VAL_MIN_EXC(void)
Definition: val.hpp:60
Passing integer arguments.
Definition: int.hh:628
Passing Boolean variables.
Definition: int.hh:712
SetValBranch SET_VAL_MIN_INC(void)
Definition: val.hpp:55
Trace delta information for set variables.
Definition: set.hh:1708
union Gecode::@593::NNF::@62 u
Union depending on nodetype t.
Boolean integer variables.
Definition: int.hh:512
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
Definition: set-expr.cpp:815
SetValBranch SET_VAL_MAX_EXC(void)
Definition: val.hpp:80
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:767
With smallest maximum unknown element.
Definition: set.hh:1314
const int v[7]
Definition: distinct.cpp:259
Propagator for recording view trace information.
Definition: recorder.hpp:59
Set view for set variables
Definition: view.hpp:56
void atmostOne(Home home, const SetVarArgs &xa, unsigned int c)
Definition: distinct.cpp:41
SetValBranch SET_VAL_MAX_INC(void)
Definition: val.hpp:75
Union.
Definition: set.hh:661
SetVarBranch SET_VAR_MAX_MIN(BranchTbl tbl)
Definition: var.hpp:196
Passing set variables.
Definition: set.hh:488
SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl)
Definition: var.hpp:211
Greater or equal ( )
Definition: set.hh:652
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
Value branching information.
Definition: val.hpp:41
Trace done events.
Definition: recorder.hpp:47
SetAssign SET_ASSIGN_RND_EXC(Rnd r)
Definition: assign.hpp:90
void relax(Home home, const FloatVarArgs &x, const FloatVarArgs &sx, Rnd r, double p)
Definition: relax.cpp:57
Variable branching information.
Definition: var.hpp:55
SetValBranch SET_VAL_MED_EXC(void)
Definition: val.hpp:70
Generic domain change information to be supplied to advisors.
Definition: core.hpp:203
Set variables
Definition: set.hh:127
SetValBranch SET_VAL_RND_EXC(Rnd r)
Definition: val.hpp:90
Delta for the least upper bound.
Definition: set.hh:1730
Disjoint union.
Definition: set.hh:662
SetAssign SET_ASSIGN_MIN_INC(void)
Definition: assign.hpp:55
With largest degree.
Definition: set.hh:1305
SetAssign SET_ASSIGN(SetBranchVal v, SetBranchCommit c)
Select value as defined by the value function v and commit function c.
Definition: assign.hpp:95
void precede(Home home, const IntVarArgs &x, int s, int t, IntPropLevel)
Post propagator that s precedes t in x.
Definition: precede.cpp:43
SetVarBranch SET_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl)
Definition: var.hpp:226
Integer variables.
Definition: int.hh:371
Iterator for the values in the greatest lower bound of a set variable.
Definition: set.hh:366
SetAssign SET_ASSIGN_MED_EXC(void)
Definition: assign.hpp:70
Include smallest element.
Definition: set.hh:1451
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:43
With lowest action.
Definition: set.hh:1308
Greater ( )
Definition: set.hh:653
Equality ( )
Definition: set.hh:644
Disjoint ( )
Definition: set.hh:648
std::function< bool(const Space &home, SetVar x, int i)> SetBranchFilter
Branch filter function type for set variables.
Definition: set.hh:1083
SetAssign SET_ASSIGN_MAX_EXC(void)
Definition: assign.hpp:80
void notMax(Home home, SetVar s, IntVar x)
Definition: int.cpp:267
Trace fail events.
Definition: recorder.hpp:46
Post propagator for SetVar x
Definition: set.hh:767
Include smallest element.
Definition: set.hh:1521
Trace fixpoint events.
Definition: recorder.hpp:45
void trace(Home home, const FloatVarArgs &x, TraceFilter tf, int te, FloatTracer &t)
Create a tracer for float variables.
Definition: trace.cpp:39
SymmetryHandle VariableSequenceSymmetry(const IntVarArgs &vars, int ss)
Variable sequences in x of size ss are interchangeable.
Definition: ldsb.cpp:90
SetValBranch SET_VAL(SetBranchVal v, SetBranchCommit c)
Select value as defined by the value function v and commit function c.
Definition: val.hpp:95
Set variable array
Definition: set.hh:570
Lists of ranges (intervals)
Definition: range-list.hpp:49
Random (uniform, for tie breaking)
Definition: set.hh:1301
Disequality ( )
Definition: set.hh:645
Which value to select for assignment.
Definition: set.hh:1517
Delta for the greatest lower bound.
Definition: set.hh:1713
SetAssign SET_ASSIGN_MIN_EXC(void)
Definition: assign.hpp:60
Gecode toplevel namespace
Argument array for variables.
Definition: array.hpp:61
void weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y)
Definition: int.cpp:292
With highest merit.
Definition: set.hh:1303
Class for action management.
Definition: action.hpp:42
Range iterator for computing set difference.
Definition: ranges-diff.hpp:43
SetVarBranch SET_VAR_ACTION_MAX(double d, BranchTbl tbl)
Definition: var.hpp:156
SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl)
Definition: var.hpp:186
SetVarBranch SET_VAR_CHB_MIN(BranchTbl tbl)
Definition: var.hpp:166
Which variable to select for branching.
Definition: set.hh:1296
Random number generator.
Definition: rnd.hpp:42
SetVarBranch SET_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl)
Definition: var.hpp:236
ViewTraceRecorder< Set::SetView > SetTraceRecorder
Trace recorder for set variables.
Definition: set.hh:1777
void assign(Home home, const FloatVarArgs &x, FloatAssign fa, FloatBranchFilter bf, FloatVarValPrint vvp)
Assign all x with value selection vals.
Definition: branch.cpp:111
Exclude largest element.
Definition: set.hh:1456
Home class for posting propagators
Definition: core.hpp:853
double tbl(const Gecode::Space &, double w, double b)
Test function for tie-break limit function.
Definition: branch.cpp:61
Include median element (rounding downwards)
Definition: set.hh:1453
With largest accumulated failure count.
Definition: set.hh:1307
SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d, BranchTbl tbl)
Definition: var.hpp:256
std::function< int(const Space &home, SetVar x, int i)> SetBranchVal
Branch value function type for set variables.
Definition: set.hh:1108
Shared array with arbitrary number of elements.
struct Gecode::@593::NNF::@62::@64 a
For atomic nodes.
#define GECODE_SET_EXPORT
Definition: set.hh:67
void ite(Home home, BoolVar b, FloatVar x, FloatVar y, FloatVar z)
Post propagator for if-then-else constraint.
Definition: bool.cpp:39
SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d, BranchTbl tbl)
Definition: var.hpp:246
Iterator for the values in the least upper bound of a set variable.
Definition: set.hh:394
static StdSetTracer def
Default tracer (printing to std::cerr)
Definition: set.hh:1802
With smallest unknown set.
Definition: set.hh:1316
void element(Home home, IntSharedArray c, IntVar x0, IntVar x1, IntPropLevel)
Post domain consistent propagator for .
Definition: element.cpp:39
With smallest minimum unknown element.
Definition: set.hh:1312
SetVarBranch SET_VAR_ACTION_MIN(double d, BranchTbl tbl)
Definition: var.hpp:146