Generated on Sat Jun 2 2018 07:17:44 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  template<class InputIterator>
504  SetVarArgs(InputIterator first, InputIterator last);
512  SetVarArgs(Space& home,int n,int glbMin,int glbMax,
513  int lubMin,int lubMax,
514  unsigned int minCard = 0,
515  unsigned int maxCard = Set::Limits::card);
523  SetVarArgs(Space& home,int n,const IntSet& glb,
524  int lubMin, int lubMax,
525  unsigned int minCard = 0,
526  unsigned int maxCard = Set::Limits::card);
534  SetVarArgs(Space& home,int n,int glbMin,int glbMax,
535  const IntSet& lub,
536  unsigned int minCard = 0,
537  unsigned int maxCard = Set::Limits::card);
545  SetVarArgs(Space& home,int n,
546  const IntSet& glb,const IntSet& lub,
547  unsigned int minCard = 0,
548  unsigned int maxCard = Set::Limits::card);
550  };
552 
568  class SetVarArray : public VarArray<SetVar> {
569  public:
571 
572  SetVarArray(void);
575  SetVarArray(const SetVarArray&);
577  SetVarArray(Space& home, const SetVarArgs&);
579  GECODE_SET_EXPORT SetVarArray(Space& home, int n);
587  SetVarArray(Space& home,int n,int glbMin,int glbMax,int lubMin,int lubMax,
588  unsigned int minCard = 0,
589  unsigned int maxCard = Set::Limits::card);
597  SetVarArray(Space& home,int n,const IntSet& glb, int lubMin, int lubMax,
598  unsigned int minCard = 0,
599  unsigned int maxCard = Set::Limits::card);
607  SetVarArray(Space& home,int n,int glbMin,int glbMax,const IntSet& lub,
608  unsigned int minCard = 0,
609  unsigned int maxCard = Set::Limits::card);
617  SetVarArray(Space& home,int n,
618  const IntSet& glb,const IntSet& lub,
619  unsigned int minCard = 0,
620  unsigned int maxCard = Set::Limits::card);
622  };
623 
624 }
625 
626 #include <gecode/set/array.hpp>
627 
628 namespace Gecode {
629 
641  enum SetRelType {
652  };
653 
658  enum SetOpType {
663  };
664 
671  GECODE_SET_EXPORT void
673  dom(Home home, SetVar x, SetRelType r, int i);
675  GECODE_SET_EXPORT void
676  dom(Home home, const SetVarArgs& x, SetRelType r, int i);
678  GECODE_SET_EXPORT void
679  dom(Home home, SetVar x, SetRelType r, int i, int j);
681  GECODE_SET_EXPORT void
682  dom(Home home, const SetVarArgs& x, SetRelType r, int i, int j);
684  GECODE_SET_EXPORT void
685  dom(Home home, SetVar x, SetRelType r, const IntSet& s);
687  GECODE_SET_EXPORT void
688  dom(Home home, const SetVarArgs& x, SetRelType r, const IntSet& s);
690  GECODE_SET_EXPORT void
691  cardinality(Home home, SetVar x, unsigned int i, unsigned int j);
693  GECODE_SET_EXPORT void
694  cardinality(Home home, const SetVarArgs& x, unsigned int i, unsigned int j);
696  GECODE_SET_EXPORT void
697  dom(Home home, SetVar x, SetRelType rt, int i, Reify r);
699  GECODE_SET_EXPORT void
700  dom(Home home, SetVar x, SetRelType rt, int i, int j, Reify r);
702  GECODE_SET_EXPORT void
703  dom(Home home, SetVar x, SetRelType rt, const IntSet& s, Reify r);
705  GECODE_SET_EXPORT void
706  dom(Home home, SetVar x, SetVar d);
708  GECODE_SET_EXPORT void
709  dom(Home home, const SetVarArgs& x, const SetVarArgs& d);
711 
712 
719  GECODE_SET_EXPORT void
721  rel(Home home, SetVar x, SetRelType r, SetVar y);
723  GECODE_SET_EXPORT void
724  rel(Home home, SetVar x, SetRelType rt, SetVar y, Reify r);
726  GECODE_SET_EXPORT void
727  rel(Home home, SetVar s, SetRelType r, IntVar x);
729  GECODE_SET_EXPORT void
730  rel(Home home, IntVar x, SetRelType r, SetVar s);
732  GECODE_SET_EXPORT void
733  rel(Home home, SetVar s, SetRelType rt, IntVar x, Reify r);
735  GECODE_SET_EXPORT void
736  rel(Home home, IntVar x, SetRelType rt, SetVar s, Reify r);
738  GECODE_SET_EXPORT void
739  rel(Home home, SetVar s, IntRelType rt, IntVar x);
741  void
742  rel(Home home, IntVar x, IntRelType rt, SetVar s);
744  GECODE_SET_EXPORT void
745  rel(Home home, SetVar s, IntRelType rt, IntVar x, Reify r);
747  void
748  rel(Home home, IntVar x, IntRelType rt, SetVar s, Reify r);
750 
751 }
752 
753 #include <gecode/set/int.hpp>
754 
755 namespace Gecode {
756 
763  GECODE_SET_EXPORT void
767  GECODE_SET_EXPORT void
768  rel(Home home, SetOpType op, const SetVarArgs& x, SetVar y);
770  GECODE_SET_EXPORT void
771  rel(Home home, SetOpType op, const SetVarArgs& x, const IntSet& z, SetVar y);
773  GECODE_SET_EXPORT void
774  rel(Home home, SetOpType op, const IntVarArgs& x, const IntSet& z, SetVar y);
776  GECODE_SET_EXPORT void
777  rel(Home home, SetOpType op, const IntVarArgs& x, SetVar y);
779  GECODE_SET_EXPORT void
780  rel(Home home, const IntSet& x, SetOpType op, SetVar y,
781  SetRelType r, SetVar z);
783  GECODE_SET_EXPORT void
784  rel(Home home, SetVar x, SetOpType op, const IntSet& y,
785  SetRelType r, SetVar z);
787  GECODE_SET_EXPORT void
788  rel(Home home, SetVar x, SetOpType op, SetVar y,
789  SetRelType r, const IntSet& z);
791  GECODE_SET_EXPORT void
792  rel(Home home, const IntSet& x, SetOpType op, SetVar y, SetRelType r,
793  const IntSet& z);
795  GECODE_SET_EXPORT void
796  rel(Home home, SetVar x, SetOpType op, const IntSet& y, SetRelType r,
797  const IntSet& z);
802  GECODE_SET_EXPORT void
803  ite(Home home, BoolVar b, SetVar x, SetVar y, SetVar z);
805 
806 
813  GECODE_SET_EXPORT void
815  convex(Home home, SetVar x);
817  GECODE_SET_EXPORT void
818  convex(Home home, SetVar x, SetVar y);
820 
821 
828  GECODE_SET_EXPORT void
830  sequence(Home home, const SetVarArgs& x);
832  GECODE_SET_EXPORT void
833  sequence(Home home, const SetVarArgs& y, SetVar x);
835 
836 
843  GECODE_SET_EXPORT void
845  atmostOne(Home home, const SetVarArgs& x, unsigned int c);
847 
856  GECODE_SET_EXPORT void
857  min(Home home, SetVar s, IntVar x);
861  GECODE_SET_EXPORT void
862  notMin(Home home, SetVar s, IntVar x);
866  GECODE_SET_EXPORT void
867  min(Home home, SetVar s, IntVar x, Reify r);
871  GECODE_SET_EXPORT void
872  max(Home home, SetVar s, IntVar x);
876  GECODE_SET_EXPORT void
877  notMax(Home home, SetVar s, IntVar x);
881  GECODE_SET_EXPORT void
882  max(Home home, SetVar s, IntVar x, Reify r);
886  GECODE_SET_EXPORT void
887  cardinality(Home home, SetVar s, IntVar x);
891  GECODE_SET_EXPORT void
892  cardinality(Home home, SetVar s, IntVar x, Reify r);
905  GECODE_SET_EXPORT void
907  SetVar x, IntVar y);
908 
909 
916  GECODE_SET_EXPORT void
918  channel(Home home, const IntVarArgs& x,const SetVarArgs& y);
920  GECODE_SET_EXPORT void
921  channelSorted(Home home, const IntVarArgs& x, SetVar y);
923  GECODE_SET_EXPORT void
924  channel(Home home, const BoolVarArgs& x, SetVar y);
926  GECODE_SET_EXPORT void
927  channel(Home home, const SetVarArgs& x, const SetVarArgs& y);
929 
930 
942  GECODE_SET_EXPORT void
943  precede(Home home, const SetVarArgs& x, int s, int t);
947  GECODE_SET_EXPORT void
948  precede(Home home, const SetVarArgs& x, const IntArgs& c);
949 
950 
972  GECODE_SET_EXPORT void
973  element(Home home, SetOpType op, const SetVarArgs& x, SetVar y, SetVar z,
984  GECODE_SET_EXPORT void
985  element(Home home, SetOpType op, const IntVarArgs& x, SetVar y, SetVar z,
996  GECODE_SET_EXPORT void
997  element(Home home, SetOpType op, const IntSetArgs& x, SetVar y, SetVar z,
1008  GECODE_SET_EXPORT void
1009  element(Home home, SetOpType op, const IntArgs& x, SetVar y, SetVar z,
1016  GECODE_SET_EXPORT void
1017  element(Home home, const SetVarArgs& x, IntVar y, SetVar z);
1023  GECODE_SET_EXPORT void
1024  element(Home home, const IntSetArgs& s, IntVar y, SetVar z);
1030  GECODE_SET_EXPORT void
1031  element(Home home, const IntSetArgs& a,
1032  IntVar x, int w, IntVar y, int h, SetVar z);
1038  GECODE_SET_EXPORT void
1039  element(Home home, const SetVarArgs& a,
1040  IntVar x, int w, IntVar y, int h, SetVar z);
1042 
1043 
1054  GECODE_SET_EXPORT void
1056  wait(Home home, SetVar x, std::function<void(Space& home)> c);
1058  GECODE_SET_EXPORT void
1059  wait(Home home, const SetVarArgs& x, std::function<void(Space& home)> c);
1061 
1062 }
1063 
1064 
1065 namespace Gecode {
1066 
1080  typedef std::function<bool(const Space& home, SetVar x, int i)>
1092  typedef std::function<double(const Space& home, SetVar x, int i)>
1094 
1105  typedef std::function<int(const Space& home, SetVar x, int i)>
1107 
1119  typedef std::function<void(Space& home, unsigned int a,
1120  SetVar x, int i, int n)>
1122 
1123 }
1124 
1126 
1127 namespace Gecode {
1128 
1134  class SetAFC : public AFC {
1135  public:
1143  SetAFC(void);
1145  SetAFC(const SetAFC& a);
1147  SetAFC& operator =(const SetAFC& a);
1155  SetAFC(Home home, const SetVarArgs& x, double d=1.0, bool share=true);
1166  void init(Home home, const SetVarArgs& x, double d=1.0, bool share=true);
1167  };
1168 
1169 }
1170 
1171 #include <gecode/set/branch/afc.hpp>
1172 
1173 namespace Gecode {
1174 
1175 
1181  class SetAction : public Action {
1182  public:
1190  SetAction(void);
1192  SetAction(const SetAction& a);
1194  SetAction& operator =(const SetAction& a);
1204  SetAction(Home home, const SetVarArgs& x, double d=1.0,
1205  SetBranchMerit bm=nullptr);
1217  GECODE_SET_EXPORT void
1218  init(Home home, const SetVarArgs& x, double d=1.0,
1219  SetBranchMerit bm=nullptr);
1220  };
1221 
1222 }
1223 
1225 
1226 namespace Gecode {
1227 
1233  class SetCHB : public CHB {
1234  public:
1242  SetCHB(void);
1244  SetCHB(const SetCHB& chb);
1246  SetCHB& operator =(const SetCHB& chb);
1256  SetCHB(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
1268  GECODE_SET_EXPORT void
1269  init(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
1270  };
1271 
1272 }
1273 
1274 #include <gecode/set/branch/chb.hpp>
1275 
1276 namespace Gecode {
1277 
1279  typedef std::function<void(const Space &home, const Brancher& b,
1280  unsigned int a,
1281  SetVar x, int i, const int& n,
1282  std::ostream& o)>
1284 
1285 }
1286 
1287 namespace Gecode {
1288 
1294  class SetVarBranch : public VarBranch<SetVar> {
1295  public:
1297  enum Select {
1298  SEL_NONE = 0,
1323  SEL_CHB_SIZE_MAX
1324  };
1325  protected:
1328  public:
1330  SetVarBranch(void);
1332  SetVarBranch(Rnd r);
1336  SetVarBranch(Select s, double d, BranchTbl t);
1346  Select select(void) const;
1348  void expand(Home home, const SetVarArgs& x);
1349  };
1350 
1356  SetVarBranch SET_VAR_NONE(void);
1369  SetVarBranch SET_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr);
1373  SetVarBranch SET_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr);
1377  SetVarBranch SET_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr);
1381  SetVarBranch SET_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr);
1409  SetVarBranch SET_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
1413  SetVarBranch SET_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
1417  SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
1421  SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
1433 
1434 }
1435 
1436 #include <gecode/set/branch/var.hpp>
1437 
1438 namespace Gecode {
1439 
1445  class SetValBranch : public ValBranch<SetVar> {
1446  public:
1448  enum Select {
1457  SEL_VAL_COMMIT
1458  };
1459  protected:
1462  public:
1464  SetValBranch(Select s = SEL_MIN_INC);
1466  SetValBranch(Select s, Rnd r);
1470  Select select(void) const;
1471  };
1472 
1503 
1504 }
1505 
1506 #include <gecode/set/branch/val.hpp>
1507 
1508 namespace Gecode {
1509 
1515  class SetAssign : public ValBranch<SetVar> {
1516  public:
1518  enum Select {
1527  SEL_VAL_COMMIT
1528  };
1529  protected:
1532  public:
1534  SetAssign(Select s = SEL_MIN_INC);
1536  SetAssign(Select s, Rnd r);
1540  Select select(void) const;
1541  };
1542 
1572 
1573 }
1574 
1576 
1577 namespace Gecode {
1578 
1584  GECODE_SET_EXPORT void
1585  branch(Home home, const SetVarArgs& x,
1586  SetVarBranch vars, SetValBranch vals,
1587  SetBranchFilter bf=nullptr,
1588  SetVarValPrint vvp=nullptr);
1594  GECODE_SET_EXPORT void
1595  branch(Home home, const SetVarArgs& x,
1597  SetBranchFilter bf=nullptr,
1598  SetVarValPrint vvp=nullptr);
1604  GECODE_SET_EXPORT void
1605  branch(Home home, SetVar x, SetValBranch vals,
1606  SetVarValPrint vvp=nullptr);
1612  GECODE_SET_EXPORT void
1613  assign(Home home, const SetVarArgs& x, SetAssign vals,
1614  SetBranchFilter bf=nullptr,
1615  SetVarValPrint vvp=nullptr);
1621  GECODE_SET_EXPORT void
1622  assign(Home home, SetVar x, SetAssign vals,
1623  SetVarValPrint vvp=nullptr);
1624 
1625 }
1626 
1627 // LDSB-related declarations.
1628 namespace Gecode {
1644  GECODE_SET_EXPORT void
1645  branch(Home home, const SetVarArgs& x,
1646  SetVarBranch vars, SetValBranch vals,
1647  const Symmetries& syms,
1648  SetBranchFilter bf=nullptr,
1649  SetVarValPrint vvp=nullptr);
1656  GECODE_SET_EXPORT void
1657  branch(Home home, const SetVarArgs& x,
1659  const Symmetries& syms,
1660  SetBranchFilter bf=nullptr,
1661  SetVarValPrint vvp=nullptr);
1662 }
1663 
1664 namespace Gecode {
1665 
1666  /*
1667  * \brief Relaxed assignment of variables in \a x from values in \a sx
1668  *
1669  * The variables in \a x are assigned values from the assigned variables
1670  * in the solution \a sx with a relaxation probability \a p. That is,
1671  * if \$fp=0.1\f$ approximately 10% of the variables in \a x will be
1672  * assigned a value from \a sx.
1673  *
1674  * The random numbers are generated from the generator \a r. At least
1675  * one variable will not be assigned: in case the relaxation attempt
1676  * would suggest that all variables should be assigned, a single
1677  * variable will be selected randomly to remain unassigned.
1678  *
1679  * Throws an exception of type Set::ArgumentSizeMismatch, if \a x and
1680  * \a sx are of different size.
1681  *
1682  * Throws an exception of type Set::OutOfLimits, if \a p is not between
1683  * \a 0.0 and \a 1.0.
1684  *
1685  * \ingroup TaskModeSet
1686  */
1687  GECODE_SET_EXPORT void
1688  relax(Home home, const SetVarArgs& x, const SetVarArgs& sx,
1689  Rnd r, double p);
1690 
1691 }
1692 
1694 
1695 namespace Gecode {
1696 
1707  protected:
1709  public:
1711  class Glb
1712  : public Iter::Ranges::Diff<Set::GlbRanges<Set::SetView>,
1713  Iter::Ranges::RangeList> {
1714  protected:
1719  public:
1721 
1722  Glb(RangeList* o, Set::SetView n);
1725  };
1728  class Lub
1729  : public Iter::Ranges::Diff<Iter::Ranges::RangeList,
1730  Set::LubRanges<Set::SetView> > {
1731  protected:
1736  public:
1738 
1739  Lub(RangeList* o, Set::SetView n);
1742  };
1745 
1749 
1751  Glb& glb(void);
1754  Lub& lub(void);
1756  };
1757 
1758 }
1759 
1760 #include <gecode/set/trace/delta.hpp>
1761 
1762 #include <gecode/set/trace/traits.hpp>
1763 
1764 namespace Gecode {
1765 
1776 
1781  class GECODE_SET_EXPORT StdSetTracer : public SetTracer {
1782  protected:
1784  std::ostream& os;
1785  public:
1787  StdSetTracer(std::ostream& os0 = std::cerr);
1789  virtual void init(const Space& home, const SetTraceRecorder& t);
1791  virtual void prune(const Space& home, const SetTraceRecorder& t,
1792  const ViewTraceInfo& vti, int i, SetTraceDelta& d);
1794  virtual void fix(const Space& home, const SetTraceRecorder& t);
1796  virtual void fail(const Space& home, const SetTraceRecorder& t);
1798  virtual void done(const Space& home, const SetTraceRecorder& t);
1801  };
1802 
1803 
1808  GECODE_SET_EXPORT void
1809  trace(Home home, const SetVarArgs& x,
1810  TraceFilter tf,
1811  int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
1812  SetTracer& t = StdSetTracer::def);
1817  void
1818  trace(Home home, const SetVarArgs& x,
1819  int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
1820  SetTracer& t = StdSetTracer::def);
1821 
1822 }
1823 
1824 #include <gecode/set/trace.hpp>
1825 
1826 #endif
1827 
1828 // IFDEF: GECODE_HAS_SET_VARS
1829 // STATISTICS: set-post
Which values to select for branching first.
Definition: set.hh:1445
Exclude median element (rounding downwards)
Definition: set.hh:1522
void channelSorted(Home home, const IntVarArgs &x, SetVar y)
Definition: channel.cpp:45
ViewTracer< Set::SetView > SetTracer
Tracer for set variables.
Definition: set.hh:1770
Recording actions for set variables.
Definition: set.hh:1181
Post propagator for SetVar SetOpType op
Definition: set.hh:765
SetVarBranch SET_VAR_CHB_SIZE_MIN(BranchTbl tbl)
Definition: var.hpp:266
Which value to select Select s
Definition: set.hh:1461
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:641
With highest action.
Definition: set.hh:1307
With lowest CHB Q-score.
Definition: set.hh:1308
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:1735
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:1313
With largest minimum unknown element.
Definition: set.hh:1311
Include median element (rounding downwards)
Definition: set.hh:1521
With largest action divided by domain size.
Definition: set.hh:1321
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:1318
Set::GlbRanges< Set::SetView > n
Iterator over new glb.
Definition: set.hh:1718
Standard set variable tracer.
Definition: set.hh:1781
Range iterator for range lists
Exclude random element.
Definition: set.hh:1456
std::function< double(const Space &home, SetVar x, int i)> SetBranchMerit
Branch merit function type for set variables.
Definition: set.hh:1093
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:1319
Collection of symmetries.
Definition: int.hh:5018
With smallest degree.
Definition: set.hh:1302
Exclude random element.
Definition: set.hh:1526
SetVarBranch SET_VAR_DEGREE_SIZE_MAX(BranchTbl tbl)
Definition: var.hpp:221
Exclude smallest element.
Definition: set.hh:1520
With smallest CHB Q-score divided by domain size.
Definition: set.hh:1322
Range iterator for the greatest lower bound.
Definition: var-imp.hpp:359
Exclude largest element.
Definition: set.hh:1524
With highest CHB Q-score.
Definition: set.hh:1309
With smallest accumulated failure count.
Definition: set.hh:1304
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:658
Superset ( )
Definition: set.hh:645
Complement.
Definition: set.hh:647
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:1716
With largest degree divided by domain size.
Definition: set.hh:1317
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:112
With smallest action divided by domain size.
Definition: set.hh:1320
SetVarBranch SET_VAR_DEGREE_SIZE_MIN(BranchTbl tbl)
Definition: var.hpp:216
Which variable to select Select s
Definition: set.hh:1327
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:662
Include random element.
Definition: set.hh:1525
Range iterator for the least upper bound.
Definition: var-imp.hpp:317
Include largest element.
Definition: set.hh:1523
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:1315
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:1450
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:1531
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
Gecode::IntArgs i(4, 1, 2, 3, 4)
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:711
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:1121
A reference-counted pointer to a SymmetryObject.
Definition: int.hh:4981
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:900
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:648
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:1784
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:851
Iter::Ranges::RangeList o
Iterator over old lub.
Definition: set.hh:1733
Iterator for the greatest lower bound ranges of a set variable.
Definition: set.hh:270
Subset ( )
Definition: set.hh:644
Trace filters.
Definition: filter.hpp:133
Recording CHB for set variables.
Definition: set.hh:1233
Intersection
Definition: set.hh:661
union Gecode::@585::NNF::@62 u
Union depending on nodetype t.
Include random element.
Definition: set.hh:1455
Integer sets.
Definition: int.hh:170
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
Definition: set.hh:765
SetVarBranch SET_VAR_AFC_MIN(double d, BranchTbl tbl)
Definition: var.hpp:126
With smallest degree divided by domain size.
Definition: set.hh:1316
Less ( )
Definition: set.hh:649
SetVarBranch SET_VAR_RND(Rnd r)
Definition: var.hpp:101
Recording AFC information for set variables.
Definition: set.hh:1134
Exclude median element (rounding downwards)
Definition: set.hh:1452
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:1453
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:1283
SetAssign SET_ASSIGN_MED_INC(void)
Definition: assign.hpp:65
Passing integer variables.
Definition: int.hh:633
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:604
Passing Boolean variables.
Definition: int.hh:687
SetValBranch SET_VAL_MIN_INC(void)
Definition: val.hpp:55
Trace delta information for set variables.
Definition: set.hh:1706
Boolean integer variables.
Definition: int.hh:488
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
Definition: set-expr.cpp:814
SetValBranch SET_VAL_MAX_EXC(void)
Definition: val.hpp:80
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:765
With smallest maximum unknown element.
Definition: set.hh:1312
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:659
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
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:650
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:765
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:1728
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Disjoint union.
Definition: set.hh:660
SetAssign SET_ASSIGN_MIN_INC(void)
Definition: assign.hpp:55
With largest degree.
Definition: set.hh:1303
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:347
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:1449
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:43
With lowest action.
Definition: set.hh:1306
Greater ( )
Definition: set.hh:651
Equality ( )
Definition: set.hh:642
Disjoint ( )
Definition: set.hh:646
std::function< bool(const Space &home, SetVar x, int i)> SetBranchFilter
Branch filter function type for set variables.
Definition: set.hh:1081
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:765
Include smallest element.
Definition: set.hh:1519
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:568
Lists of ranges (intervals)
Definition: range-list.hpp:49
Random (uniform, for tie breaking)
Definition: set.hh:1299
Disequality ( )
Definition: set.hh:643
Which value to select for assignment.
Definition: set.hh:1515
Delta for the greatest lower bound.
Definition: set.hh:1711
SetAssign SET_ASSIGN_MIN_EXC(void)
Definition: assign.hpp:60
Gecode toplevel namespace
Argument array for variables.
Definition: array.hpp:49
void weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y)
Definition: int.cpp:292
With highest merit.
Definition: set.hh:1301
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:1294
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:1775
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:1454
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:1451
With largest accumulated failure count.
Definition: set.hh:1305
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:1106
Shared array with arbitrary number of elements.
#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:1800
With smallest unknown set.
Definition: set.hh:1314
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:1310
SetVarBranch SET_VAR_ACTION_MIN(double d, BranchTbl tbl)
Definition: var.hpp:146