Generated on Thu Apr 5 2018 19:44:19 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  * Last modified:
16  * $Date$ by $Author$
17  * $Revision$
18  *
19  * This file is part of Gecode, the generic constraint
20  * development environment:
21  * http://www.gecode.org
22  *
23  * Permission is hereby granted, free of charge, to any person obtaining
24  * a copy of this software and associated documentation files (the
25  * "Software"), to deal in the Software without restriction, including
26  * without limitation the rights to use, copy, modify, merge, publish,
27  * distribute, sublicense, and/or sell copies of the Software, and to
28  * permit persons to whom the Software is furnished to do so, subject to
29  * the following conditions:
30  *
31  * The above copyright notice and this permission notice shall be
32  * included in all copies or substantial portions of the Software.
33  *
34  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
38  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
39  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41  *
42  */
43 
44 #ifndef __GECODE_SET_HH__
45 #define __GECODE_SET_HH__
46 
47 #include <gecode/kernel.hh>
48 #include <gecode/int.hh>
49 #include <gecode/iter.hh>
50 
51 #include <functional>
52 
53 /*
54  * Configure linking
55  *
56  */
57 #if !defined(GECODE_STATIC_LIBS) && \
58  (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
59 
60 #ifdef GECODE_BUILD_SET
61 #define GECODE_SET_EXPORT __declspec( dllexport )
62 #else
63 #define GECODE_SET_EXPORT __declspec( dllimport )
64 #endif
65 
66 #else
67 
68 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
69 #define GECODE_SET_EXPORT __attribute__ ((visibility("default")))
70 #else
71 #define GECODE_SET_EXPORT
72 #endif
73 
74 #endif
75 
76 // Configure auto-linking
77 #ifndef GECODE_BUILD_SET
78 #define GECODE_LIBRARY_NAME "Set"
80 #endif
81 
82 
94 #include <gecode/set/exception.hpp>
95 
96 namespace Gecode { namespace Set {
97 
99  namespace Limits {
101  const int max = (Gecode::Int::Limits::max / 2) - 1;
103  const int min = -max;
105  const unsigned int card = max-min+1;
107  void check(int n, const char* l);
109  void check(unsigned int n, const char* l);
111  void check(const IntSet& s, const char* l);
112  }
113 
114 }}
115 
116 #include <gecode/set/limits.hpp>
117 
118 #include <gecode/set/var-imp.hpp>
119 
120 namespace Gecode {
121 
122  namespace Set {
123  class SetView;
124  }
125 
131  class SetVar : public VarImpVar<Set::SetVarImp> {
132  friend class SetVarArray;
133  friend class SetVarArgs;
135  public:
137 
138  SetVar(void);
141  SetVar(const SetVar& y);
143  SetVar(const Set::SetView& y);
144 
147 
166  SetVar(Space& home,int glbMin,int glbMax,int lubMin,int lubMax,
167  unsigned int cardMin = 0,
168  unsigned int cardMax = Set::Limits::card);
169 
187  SetVar(Space& home,const IntSet& glbD,int lubMin,int lubMax,
188  unsigned int cardMin = 0,
189  unsigned int cardMax = Set::Limits::card);
190 
209  SetVar(Space& home,int glbMin,int glbMax,const IntSet& lubD,
210  unsigned int cardMin = 0,
211  unsigned int cardMax = Set::Limits::card);
212 
231  SetVar(Space& home,const IntSet& glbD,const IntSet& lubD,
232  unsigned int cardMin = 0,
233  unsigned int cardMax = Set::Limits::card);
235 
237 
238  unsigned int glbSize(void) const;
241  unsigned int lubSize(void) const;
243  unsigned int unknownSize(void) const;
245  unsigned int cardMin(void) const;
247  unsigned int cardMax(void) const;
249  int lubMin(void) const;
251  int lubMax(void) const;
253  int glbMin(void) const;
255  int glbMax(void) const;
257 
259 
260  bool contains(int i) const;
263  bool notContains(int i) const;
265  };
266 
272 
275  private:
277  public:
279 
280  SetVarGlbRanges(void);
283  SetVarGlbRanges(const SetVar& x);
285 
287 
288  bool operator ()(void) const;
291  void operator ++(void);
293 
295 
296  int min(void) const;
299  int max(void) const;
301  unsigned int width(void) const;
303  };
304 
307  private:
309  public:
311 
312  SetVarLubRanges(void);
315  SetVarLubRanges(const SetVar& x);
317 
319 
320  bool operator ()(void) const;
323  void operator ++(void);
325 
327 
328  int min(void) const;
331  int max(void) const;
333  unsigned int width(void) const;
335  };
336 
339  private:
341  public:
343 
344  SetVarUnknownRanges(void);
347  SetVarUnknownRanges(const SetVar& x);
349 
351 
352  bool operator ()(void) const;
355  void operator ++(void);
357 
359 
360  int min(void) const;
363  int max(void) const;
365  unsigned int width(void) const;
367  };
368 
371  private:
373  public:
375 
376  SetVarGlbValues(void);
379  SetVarGlbValues(const SetVar& x);
381 
383 
384  bool operator ()(void) const;
387  void operator ++(void);
389 
391 
392  int val(void) const;
395  };
396 
399  private:
401  public:
403 
404  SetVarLubValues(void);
407  SetVarLubValues(const SetVar& x);
409 
411 
412  bool operator ()(void) const;
415  void operator ++(void);
417 
419 
420  int val(void) const;
423  };
424 
427  private:
429  public:
431 
432  SetVarUnknownValues(void);
435  SetVarUnknownValues(const SetVar& x);
437 
439 
440  bool operator ()(void) const;
443  void operator ++(void);
445 
447 
448  int val(void) const;
451  };
452 
454 
459  template<class Char, class Traits>
460  std::basic_ostream<Char,Traits>&
461  operator <<(std::basic_ostream<Char,Traits>& os, const SetVar& x);
462 
463 }
464 
465 #include <gecode/set/view.hpp>
466 
467 namespace Gecode {
477 
478 }
479 
481 
482 namespace Gecode {
483 
492  class SetVarArgs : public VarArgArray<SetVar> {
493  public:
495 
496  SetVarArgs(void);
499  explicit SetVarArgs(int n);
501  SetVarArgs(const SetVarArgs& a);
503  SetVarArgs(const VarArray<SetVar>& a);
505  SetVarArgs(const std::vector<SetVar>& a);
507  template<class InputIterator>
508  SetVarArgs(InputIterator first, InputIterator last);
516  SetVarArgs(Space& home,int n,int glbMin,int glbMax,
517  int lubMin,int lubMax,
518  unsigned int minCard = 0,
519  unsigned int maxCard = Set::Limits::card);
527  SetVarArgs(Space& home,int n,const IntSet& glb,
528  int lubMin, int lubMax,
529  unsigned int minCard = 0,
530  unsigned int maxCard = Set::Limits::card);
538  SetVarArgs(Space& home,int n,int glbMin,int glbMax,
539  const IntSet& lub,
540  unsigned int minCard = 0,
541  unsigned int maxCard = Set::Limits::card);
549  SetVarArgs(Space& home,int n,
550  const IntSet& glb,const IntSet& lub,
551  unsigned int minCard = 0,
552  unsigned int maxCard = Set::Limits::card);
554  };
556 
572  class SetVarArray : public VarArray<SetVar> {
573  public:
575 
576  SetVarArray(void);
579  SetVarArray(const SetVarArray&);
581  SetVarArray(Space& home, const SetVarArgs&);
583  GECODE_SET_EXPORT SetVarArray(Space& home, int n);
591  SetVarArray(Space& home,int n,int glbMin,int glbMax,int lubMin,int lubMax,
592  unsigned int minCard = 0,
593  unsigned int maxCard = Set::Limits::card);
601  SetVarArray(Space& home,int n,const IntSet& glb, int lubMin, int lubMax,
602  unsigned int minCard = 0,
603  unsigned int maxCard = Set::Limits::card);
611  SetVarArray(Space& home,int n,int glbMin,int glbMax,const IntSet& lub,
612  unsigned int minCard = 0,
613  unsigned int maxCard = Set::Limits::card);
621  SetVarArray(Space& home,int n,
622  const IntSet& glb,const IntSet& lub,
623  unsigned int minCard = 0,
624  unsigned int maxCard = Set::Limits::card);
626  };
627 
628 }
629 
630 #include <gecode/set/array.hpp>
631 
632 namespace Gecode {
633 
645  enum SetRelType {
656  };
657 
662  enum SetOpType {
667  };
668 
675  GECODE_SET_EXPORT void
677  dom(Home home, SetVar x, SetRelType r, int i);
679  GECODE_SET_EXPORT void
680  dom(Home home, const SetVarArgs& x, SetRelType r, int i);
682  GECODE_SET_EXPORT void
683  dom(Home home, SetVar x, SetRelType r, int i, int j);
685  GECODE_SET_EXPORT void
686  dom(Home home, const SetVarArgs& x, SetRelType r, int i, int j);
688  GECODE_SET_EXPORT void
689  dom(Home home, SetVar x, SetRelType r, const IntSet& s);
691  GECODE_SET_EXPORT void
692  dom(Home home, const SetVarArgs& x, SetRelType r, const IntSet& s);
694  GECODE_SET_EXPORT void
695  cardinality(Home home, SetVar x, unsigned int i, unsigned int j);
697  GECODE_SET_EXPORT void
698  cardinality(Home home, const SetVarArgs& x, unsigned int i, unsigned int j);
700  GECODE_SET_EXPORT void
701  dom(Home home, SetVar x, SetRelType rt, int i, Reify r);
703  GECODE_SET_EXPORT void
704  dom(Home home, SetVar x, SetRelType rt, int i, int j, Reify r);
706  GECODE_SET_EXPORT void
707  dom(Home home, SetVar x, SetRelType rt, const IntSet& s, Reify r);
709  GECODE_SET_EXPORT void
710  dom(Home home, SetVar x, SetVar d);
712  GECODE_SET_EXPORT void
713  dom(Home home, const SetVarArgs& x, const SetVarArgs& d);
715 
716 
723  GECODE_SET_EXPORT void
725  rel(Home home, SetVar x, SetRelType r, SetVar y);
727  GECODE_SET_EXPORT void
728  rel(Home home, SetVar x, SetRelType rt, SetVar y, Reify r);
730  GECODE_SET_EXPORT void
731  rel(Home home, SetVar s, SetRelType r, IntVar x);
733  GECODE_SET_EXPORT void
734  rel(Home home, IntVar x, SetRelType r, SetVar s);
736  GECODE_SET_EXPORT void
737  rel(Home home, SetVar s, SetRelType rt, IntVar x, Reify r);
739  GECODE_SET_EXPORT void
740  rel(Home home, IntVar x, SetRelType rt, SetVar s, Reify r);
742  GECODE_SET_EXPORT void
743  rel(Home home, SetVar s, IntRelType rt, IntVar x);
745  void
746  rel(Home home, IntVar x, IntRelType rt, SetVar s);
748  GECODE_SET_EXPORT void
749  rel(Home home, SetVar s, IntRelType rt, IntVar x, Reify r);
751  void
752  rel(Home home, IntVar x, IntRelType rt, SetVar s, Reify r);
754 
755 }
756 
757 #include <gecode/set/int.hpp>
758 
759 namespace Gecode {
760 
767  GECODE_SET_EXPORT void
771  GECODE_SET_EXPORT void
772  rel(Home home, SetOpType op, const SetVarArgs& x, SetVar y);
774  GECODE_SET_EXPORT void
775  rel(Home home, SetOpType op, const SetVarArgs& x, const IntSet& z, SetVar y);
777  GECODE_SET_EXPORT void
778  rel(Home home, SetOpType op, const IntVarArgs& x, const IntSet& z, SetVar y);
780  GECODE_SET_EXPORT void
781  rel(Home home, SetOpType op, const IntVarArgs& x, SetVar y);
783  GECODE_SET_EXPORT void
784  rel(Home home, const IntSet& x, SetOpType op, SetVar y,
785  SetRelType r, SetVar z);
787  GECODE_SET_EXPORT void
788  rel(Home home, SetVar x, SetOpType op, const IntSet& y,
789  SetRelType r, SetVar z);
791  GECODE_SET_EXPORT void
792  rel(Home home, SetVar x, SetOpType op, SetVar y,
793  SetRelType r, const IntSet& z);
795  GECODE_SET_EXPORT void
796  rel(Home home, const IntSet& x, SetOpType op, SetVar y, SetRelType r,
797  const IntSet& z);
799  GECODE_SET_EXPORT void
800  rel(Home home, SetVar x, SetOpType op, const IntSet& y, SetRelType r,
801  const IntSet& z);
806  GECODE_SET_EXPORT void
807  ite(Home home, BoolVar b, SetVar x, SetVar y, SetVar z);
809 
810 
817  GECODE_SET_EXPORT void
819  convex(Home home, SetVar x);
821  GECODE_SET_EXPORT void
822  convex(Home home, SetVar x, SetVar y);
824 
825 
832  GECODE_SET_EXPORT void
834  sequence(Home home, const SetVarArgs& x);
836  GECODE_SET_EXPORT void
837  sequence(Home home, const SetVarArgs& y, SetVar x);
839 
840 
847  GECODE_SET_EXPORT void
849  atmostOne(Home home, const SetVarArgs& x, unsigned int c);
851 
860  GECODE_SET_EXPORT void
861  min(Home home, SetVar s, IntVar x);
865  GECODE_SET_EXPORT void
866  notMin(Home home, SetVar s, IntVar x);
870  GECODE_SET_EXPORT void
871  min(Home home, SetVar s, IntVar x, Reify r);
875  GECODE_SET_EXPORT void
876  max(Home home, SetVar s, IntVar x);
880  GECODE_SET_EXPORT void
881  notMax(Home home, SetVar s, IntVar x);
885  GECODE_SET_EXPORT void
886  max(Home home, SetVar s, IntVar x, Reify r);
890  GECODE_SET_EXPORT void
891  cardinality(Home home, SetVar s, IntVar x);
895  GECODE_SET_EXPORT void
896  cardinality(Home home, SetVar s, IntVar x, Reify r);
909  GECODE_SET_EXPORT void
911  SetVar x, IntVar y);
912 
913 
920  GECODE_SET_EXPORT void
922  channel(Home home, const IntVarArgs& x,const SetVarArgs& y);
924  GECODE_SET_EXPORT void
925  channelSorted(Home home, const IntVarArgs& x, SetVar y);
927  GECODE_SET_EXPORT void
928  channel(Home home, const BoolVarArgs& x, SetVar y);
930  GECODE_SET_EXPORT void
931  channel(Home home, const SetVarArgs& x, const SetVarArgs& y);
933 
934 
946  GECODE_SET_EXPORT void
947  precede(Home home, const SetVarArgs& x, int s, int t);
951  GECODE_SET_EXPORT void
952  precede(Home home, const SetVarArgs& x, const IntArgs& c);
953 
954 
976  GECODE_SET_EXPORT void
977  element(Home home, SetOpType op, const SetVarArgs& x, SetVar y, SetVar z,
988  GECODE_SET_EXPORT void
989  element(Home home, SetOpType op, const IntVarArgs& x, SetVar y, SetVar z,
1000  GECODE_SET_EXPORT void
1001  element(Home home, SetOpType op, const IntSetArgs& x, SetVar y, SetVar z,
1012  GECODE_SET_EXPORT void
1013  element(Home home, SetOpType op, const IntArgs& x, SetVar y, SetVar z,
1020  GECODE_SET_EXPORT void
1021  element(Home home, const SetVarArgs& x, IntVar y, SetVar z);
1027  GECODE_SET_EXPORT void
1028  element(Home home, const IntSetArgs& s, IntVar y, SetVar z);
1034  GECODE_SET_EXPORT void
1035  element(Home home, const IntSetArgs& a,
1036  IntVar x, int w, IntVar y, int h, SetVar z);
1042  GECODE_SET_EXPORT void
1043  element(Home home, const SetVarArgs& a,
1044  IntVar x, int w, IntVar y, int h, SetVar z);
1046 
1047 
1058  GECODE_SET_EXPORT void
1060  wait(Home home, SetVar x, std::function<void(Space& home)> c);
1062  GECODE_SET_EXPORT void
1063  wait(Home home, const SetVarArgs& x, std::function<void(Space& home)> c);
1065 
1066 }
1067 
1068 
1069 namespace Gecode {
1070 
1084  typedef std::function<bool(const Space& home, SetVar x, int i)>
1096  typedef std::function<double(const Space& home, SetVar x, int i)>
1098 
1109  typedef std::function<int(const Space& home, SetVar x, int i)>
1111 
1123  typedef std::function<void(Space& home, unsigned int a,
1124  SetVar x, int i, int n)>
1126 
1127 }
1128 
1130 
1131 namespace Gecode {
1132 
1138  class SetAFC : public AFC {
1139  public:
1147  SetAFC(void);
1149  SetAFC(const SetAFC& a);
1151  SetAFC& operator =(const SetAFC& a);
1159  SetAFC(Home home, const SetVarArgs& x, double d=1.0, bool share=true);
1170  void init(Home home, const SetVarArgs& x, double d=1.0, bool share=true);
1171  };
1172 
1173 }
1174 
1175 #include <gecode/set/branch/afc.hpp>
1176 
1177 namespace Gecode {
1178 
1179 
1185  class SetAction : public Action {
1186  public:
1194  SetAction(void);
1196  SetAction(const SetAction& a);
1198  SetAction& operator =(const SetAction& a);
1208  SetAction(Home home, const SetVarArgs& x, double d=1.0,
1209  SetBranchMerit bm=nullptr);
1221  GECODE_SET_EXPORT void
1222  init(Home home, const SetVarArgs& x, double d=1.0,
1223  SetBranchMerit bm=nullptr);
1224  };
1225 
1226 }
1227 
1229 
1230 namespace Gecode {
1231 
1237  class SetCHB : public CHB {
1238  public:
1246  SetCHB(void);
1248  SetCHB(const SetCHB& chb);
1250  SetCHB& operator =(const SetCHB& chb);
1260  SetCHB(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
1272  GECODE_SET_EXPORT void
1273  init(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
1274  };
1275 
1276 }
1277 
1278 #include <gecode/set/branch/chb.hpp>
1279 
1280 namespace Gecode {
1281 
1283  typedef std::function<void(const Space &home, const Brancher& b,
1284  unsigned int a,
1285  SetVar x, int i, const int& n,
1286  std::ostream& o)>
1288 
1289 }
1290 
1291 namespace Gecode {
1292 
1298  class SetVarBranch : public VarBranch<SetVar> {
1299  public:
1301  enum Select {
1302  SEL_NONE = 0,
1327  SEL_CHB_SIZE_MAX
1328  };
1329  protected:
1332  public:
1334  SetVarBranch(void);
1336  SetVarBranch(Rnd r);
1340  SetVarBranch(Select s, double d, BranchTbl t);
1350  Select select(void) const;
1352  void expand(Home home, const SetVarArgs& x);
1353  };
1354 
1360  SetVarBranch SET_VAR_NONE(void);
1373  SetVarBranch SET_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr);
1377  SetVarBranch SET_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr);
1381  SetVarBranch SET_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr);
1385  SetVarBranch SET_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr);
1413  SetVarBranch SET_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
1417  SetVarBranch SET_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
1421  SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
1425  SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
1437 
1438 }
1439 
1440 #include <gecode/set/branch/var.hpp>
1441 
1442 namespace Gecode {
1443 
1449  class SetValBranch : public ValBranch<SetVar> {
1450  public:
1452  enum Select {
1461  SEL_VAL_COMMIT
1462  };
1463  protected:
1466  public:
1468  SetValBranch(Select s = SEL_MIN_INC);
1470  SetValBranch(Select s, Rnd r);
1474  Select select(void) const;
1475  };
1476 
1507 
1508 }
1509 
1510 #include <gecode/set/branch/val.hpp>
1511 
1512 namespace Gecode {
1513 
1519  class SetAssign : public ValBranch<SetVar> {
1520  public:
1522  enum Select {
1531  SEL_VAL_COMMIT
1532  };
1533  protected:
1536  public:
1538  SetAssign(Select s = SEL_MIN_INC);
1540  SetAssign(Select s, Rnd r);
1544  Select select(void) const;
1545  };
1546 
1576 
1577 }
1578 
1580 
1581 namespace Gecode {
1582 
1588  GECODE_SET_EXPORT void
1589  branch(Home home, const SetVarArgs& x,
1590  SetVarBranch vars, SetValBranch vals,
1591  SetBranchFilter bf=nullptr,
1592  SetVarValPrint vvp=nullptr);
1598  GECODE_SET_EXPORT void
1599  branch(Home home, const SetVarArgs& x,
1601  SetBranchFilter bf=nullptr,
1602  SetVarValPrint vvp=nullptr);
1608  GECODE_SET_EXPORT void
1609  branch(Home home, SetVar x, SetValBranch vals,
1610  SetVarValPrint vvp=nullptr);
1616  GECODE_SET_EXPORT void
1617  assign(Home home, const SetVarArgs& x, SetAssign vals,
1618  SetBranchFilter bf=nullptr,
1619  SetVarValPrint vvp=nullptr);
1625  GECODE_SET_EXPORT void
1626  assign(Home home, SetVar x, SetAssign vals,
1627  SetVarValPrint vvp=nullptr);
1628 
1629 }
1630 
1631 // LDSB-related declarations.
1632 namespace Gecode {
1648  GECODE_SET_EXPORT void
1649  branch(Home home, const SetVarArgs& x,
1650  SetVarBranch vars, SetValBranch vals,
1651  const Symmetries& syms,
1652  SetBranchFilter bf=nullptr,
1653  SetVarValPrint vvp=nullptr);
1660  GECODE_SET_EXPORT void
1661  branch(Home home, const SetVarArgs& x,
1663  const Symmetries& syms,
1664  SetBranchFilter bf=nullptr,
1665  SetVarValPrint vvp=nullptr);
1666 }
1667 
1668 namespace Gecode {
1669 
1670  /*
1671  * \brief Relaxed assignment of variables in \a x from values in \a sx
1672  *
1673  * The variables in \a x are assigned values from the assigned variables
1674  * in the solution \a sx with a relaxation probability \a p. That is,
1675  * if \$fp=0.1\f$ approximately 10% of the variables in \a x will be
1676  * assigned a value from \a sx.
1677  *
1678  * The random numbers are generated from the generator \a r. At least
1679  * one variable will not be assigned: in case the relaxation attempt
1680  * would suggest that all variables should be assigned, a single
1681  * variable will be selected randomly to remain unassigned.
1682  *
1683  * Throws an exception of type Set::ArgumentSizeMismatch, if \a x and
1684  * \a sx are of different size.
1685  *
1686  * Throws an exception of type Set::OutOfLimits, if \a p is not between
1687  * \a 0.0 and \a 1.0.
1688  *
1689  * \ingroup TaskModeSet
1690  */
1691  GECODE_SET_EXPORT void
1692  relax(Home home, const SetVarArgs& x, const SetVarArgs& sx,
1693  Rnd r, double p);
1694 
1695 }
1696 
1698 
1699 namespace Gecode {
1700 
1711  protected:
1713  public:
1715  class Glb
1716  : public Iter::Ranges::Diff<Set::GlbRanges<Set::SetView>,
1717  Iter::Ranges::RangeList> {
1718  protected:
1723  public:
1725 
1726  Glb(RangeList* o, Set::SetView n);
1729  };
1732  class Lub
1733  : public Iter::Ranges::Diff<Iter::Ranges::RangeList,
1734  Set::LubRanges<Set::SetView> > {
1735  protected:
1740  public:
1742 
1743  Lub(RangeList* o, Set::SetView n);
1746  };
1749 
1753 
1755  Glb& glb(void);
1758  Lub& lub(void);
1760  };
1761 
1762 }
1763 
1764 #include <gecode/set/trace/delta.hpp>
1765 
1766 #include <gecode/set/trace/traits.hpp>
1767 
1768 namespace Gecode {
1769 
1780 
1785  class GECODE_SET_EXPORT StdSetTracer : public SetTracer {
1786  protected:
1788  std::ostream& os;
1789  public:
1791  StdSetTracer(std::ostream& os0 = std::cerr);
1793  virtual void init(const Space& home, const SetTraceRecorder& t);
1795  virtual void prune(const Space& home, const SetTraceRecorder& t,
1796  const ViewTraceInfo& vti, int i, SetTraceDelta& d);
1798  virtual void fix(const Space& home, const SetTraceRecorder& t);
1800  virtual void fail(const Space& home, const SetTraceRecorder& t);
1802  virtual void done(const Space& home, const SetTraceRecorder& t);
1805  };
1806 
1807 
1812  GECODE_SET_EXPORT void
1813  trace(Home home, const SetVarArgs& x,
1814  TraceFilter tf,
1815  int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
1816  SetTracer& t = StdSetTracer::def);
1821  void
1822  trace(Home home, const SetVarArgs& x,
1823  int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
1824  SetTracer& t = StdSetTracer::def);
1825 
1826 }
1827 
1828 #include <gecode/set/trace.hpp>
1829 
1830 #endif
1831 
1832 // IFDEF: GECODE_HAS_SET_VARS
1833 // STATISTICS: set-post
Which values to select for branching first.
Definition: set.hh:1449
Exclude median element (rounding downwards)
Definition: set.hh:1526
void channelSorted(Home home, const IntVarArgs &x, SetVar y)
Definition: channel.cpp:49
ViewTracer< Set::SetView > SetTracer
Tracer for set variables.
Definition: set.hh:1774
Recording actions for set variables.
Definition: set.hh:1185
Post propagator for SetVar SetOpType op
Definition: set.hh:769
SetVarBranch SET_VAR_CHB_SIZE_MIN(BranchTbl tbl)
Definition: var.hpp:270
Which value to select Select s
Definition: set.hh:1465
SetVarBranch SET_VAR_SIZE_MIN(BranchTbl tbl)
Definition: var.hpp:210
Variables as interfaces to variable implementations.
Definition: var.hpp:51
NodeType t
Type of node.
Definition: bool-expr.cpp:234
Tracer that process view trace information.
Definition: tracer.hpp:55
Combine variable selection criteria for tie-breaking.
Definition: tiebreak.hpp:42
void check(int n, const char *l)
Check whether integer n is in range, otherwise throw overflow exception with information l...
Definition: limits.hpp:41
SetRelType
Common relation types for sets.
Definition: set.hh:645
With highest action.
Definition: set.hh:1311
With lowest CHB Q-score.
Definition: set.hh:1312
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
void notMin(Home home, SetVar s, IntVar x)
Definition: int.cpp:239
Range iterator for the unknown set.
Definition: var-imp.hpp:406
const int min
Smallest allowed integer in integer set.
Definition: set.hh:103
View trace information.
Definition: core.hpp:898
void sequence(Home home, const IntVarArgs &x, const IntSet &s, int q, int l, int u, IntPropLevel)
Post propagator for .
Definition: sequence.cpp:51
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:43
Set::LubRanges< Set::SetView > n
Iterator over new lub.
Definition: set.hh:1739
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
Definition: channel.cpp:45
With largest maximum unknown element.
Definition: set.hh:1317
With largest minimum unknown element.
Definition: set.hh:1315
Include median element (rounding downwards)
Definition: set.hh:1525
With largest action divided by domain size.
Definition: set.hh:1325
SetVarBranch SET_VAR_MERIT_MAX(SetBranchMerit bm, BranchTbl tbl)
Definition: var.hpp:115
With smallest accumulated failure count divided by domain size.
Definition: set.hh:1322
Set::GlbRanges< Set::SetView > n
Iterator over new glb.
Definition: set.hh:1722
Standard set variable tracer.
Definition: set.hh:1785
Range iterator for range lists
Exclude random element.
Definition: set.hh:1460
std::function< double(const Space &home, SetVar x, int i)> SetBranchMerit
Branch merit function type for set variables.
Definition: set.hh:1097
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition: dom.cpp:44
With largest accumulated failure count divided by domain size.
Definition: set.hh:1323
Collection of symmetries.
Definition: int.hh:5022
With smallest degree.
Definition: set.hh:1306
Exclude random element.
Definition: set.hh:1530
SetVarBranch SET_VAR_DEGREE_SIZE_MAX(BranchTbl tbl)
Definition: var.hpp:225
Exclude smallest element.
Definition: set.hh:1524
With smallest CHB Q-score divided by domain size.
Definition: set.hh:1326
Range iterator for the greatest lower bound.
Definition: var-imp.hpp:363
Exclude largest element.
Definition: set.hh:1528
With highest CHB Q-score.
Definition: set.hh:1313
With smallest accumulated failure count.
Definition: set.hh:1308
SetValBranch SET_VAL_MED_INC(void)
Definition: val.hpp:69
SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl)
Definition: var.hpp:205
SetValBranch SET_VAL_RND_INC(Rnd r)
Definition: val.hpp:89
SetOpType
Common operations for sets.
Definition: set.hh:662
Superset ( )
Definition: set.hh:649
Complement.
Definition: set.hh:651
const unsigned int card
Maximum cardinality of an integer set.
Definition: set.hh:105
Iter::Ranges::RangeList o
Iterator over old glb.
Definition: set.hh:1720
With largest degree divided by domain size.
Definition: set.hh:1321
const int max
Largest allowed integer in integer set.
Definition: set.hh:101
SetVarBranch SET_VAR_NONE(void)
Definition: var.hpp:100
Trace init events.
Definition: recorder.hpp:47
const int max
Largest allowed integer value.
Definition: int.hh:116
With smallest action divided by domain size.
Definition: set.hh:1324
SetVarBranch SET_VAR_DEGREE_SIZE_MIN(BranchTbl tbl)
Definition: var.hpp:220
Which variable to select Select s
Definition: set.hh:1331
Computation spaces.
Definition: core.hpp:1668
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
Definition: rel.hpp:268
SetAssign SET_ASSIGN_RND_INC(Rnd r)
Definition: assign.hpp:89
Difference.
Definition: set.hh:666
Include random element.
Definition: set.hh:1529
Range iterator for the least upper bound.
Definition: var-imp.hpp:321
Include largest element.
Definition: set.hh:1527
Iterator for the unknown ranges of a set variable.
Definition: set.hh:338
Duplicate of a set view.
Definition: trace-view.hpp:41
Gecode::IntSet d(v, 7)
Iterator for the values in the unknown set of a set variable.
Definition: set.hh:426
With largest unknown set.
Definition: set.hh:1319
std::string expand(Gecode::IntRelType irt)
Expand relation to abbreviation.
Definition: mm-count.cpp:48
Gecode::FloatVal c(-8, 8)
Trace prune events.
Definition: recorder.hpp:48
Exclude smallest element.
Definition: set.hh:1454
SetVarBranch SET_VAR_AFC_MAX(double d, BranchTbl tbl)
Definition: var.hpp:140
SymmetryHandle VariableSymmetry(const IntVarArgs &vars)
Variables in x are interchangeable.
Definition: ldsb.cpp:66
Which value to select Select s
Definition: set.hh:1535
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
Definition: core.hpp:1368
Class for AFC (accumulated failure count) management.
Definition: afc.hpp:44
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Argument array for non-primitive types.
Definition: array.hpp:715
SetVarBranch SET_VAR_CHB_SIZE_MAX(BranchTbl tbl)
Definition: var.hpp:280
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:1125
A reference-counted pointer to a SymmetryObject.
Definition: int.hh:4985
SetAssign SET_ASSIGN_MAX_INC(void)
Definition: assign.hpp:79
SetVarBranch SET_VAR_DEGREE_MIN(BranchTbl tbl)
Definition: var.hpp:120
IntRelType
Relation types for integers.
Definition: int.hh:904
SetVarBranch SET_VAR_DEGREE_MAX(BranchTbl tbl)
Definition: var.hpp:125
SetVarBranch SET_VAR_CHB_MAX(BranchTbl tbl)
Definition: var.hpp:180
Less or equal ( )
Definition: set.hh:652
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Definition: var.hpp:52
std::ostream & os
Output stream to use.
Definition: set.hh:1788
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:43
Class for CHB management.
Definition: chb.hpp:50
Reification specification.
Definition: int.hh:855
Iter::Ranges::RangeList o
Iterator over old lub.
Definition: set.hh:1737
Iterator for the greatest lower bound ranges of a set variable.
Definition: set.hh:274
Subset ( )
Definition: set.hh:648
Trace filters.
Definition: filter.hpp:137
Recording CHB for set variables.
Definition: set.hh:1237
Intersection
Definition: set.hh:665
union Gecode::@585::NNF::@62 u
Union depending on nodetype t.
Include random element.
Definition: set.hh:1459
Integer sets.
Definition: int.hh:174
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
Definition: set.hh:769
SetVarBranch SET_VAR_AFC_MIN(double d, BranchTbl tbl)
Definition: var.hpp:130
With smallest degree divided by domain size.
Definition: set.hh:1320
Less ( )
Definition: set.hh:653
SetVarBranch SET_VAR_RND(Rnd r)
Definition: var.hpp:105
Recording AFC information for set variables.
Definition: set.hh:1138
Exclude median element (rounding downwards)
Definition: set.hh:1456
SetVarBranch SET_VAR_MERIT_MIN(SetBranchMerit bm, BranchTbl tbl)
Definition: var.hpp:110
void convex(Home home, SetVar x)
Definition: convex.cpp:45
Iterator for the least upper bound ranges of a set variable.
Definition: set.hh:306
Include largest element.
Definition: set.hh:1457
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:1287
SetAssign SET_ASSIGN_MED_INC(void)
Definition: assign.hpp:69
Passing integer variables.
Definition: int.hh:637
SetVarBranch SET_VAR_MIN_MAX(BranchTbl tbl)
Definition: var.hpp:195
SetValBranch SET_VAL_MIN_EXC(void)
Definition: val.hpp:64
Passing integer arguments.
Definition: int.hh:608
Passing Boolean variables.
Definition: int.hh:691
SetValBranch SET_VAL_MIN_INC(void)
Definition: val.hpp:59
Trace delta information for set variables.
Definition: set.hh:1710
Boolean integer variables.
Definition: int.hh:492
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
Definition: set-expr.cpp:818
SetValBranch SET_VAL_MAX_EXC(void)
Definition: val.hpp:84
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:769
With smallest maximum unknown element.
Definition: set.hh:1316
const int v[7]
Definition: distinct.cpp:263
Propagator for recording view trace information.
Definition: recorder.hpp:63
Set view for set variables
Definition: view.hpp:60
void atmostOne(Home home, const SetVarArgs &xa, unsigned int c)
Definition: distinct.cpp:45
SetValBranch SET_VAL_MAX_INC(void)
Definition: val.hpp:79
Union.
Definition: set.hh:663
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
SetVarBranch SET_VAR_MAX_MIN(BranchTbl tbl)
Definition: var.hpp:200
Passing set variables.
Definition: set.hh:492
SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl)
Definition: var.hpp:215
Greater or equal ( )
Definition: set.hh:654
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:769
Value branching information.
Definition: val.hpp:45
Trace done events.
Definition: recorder.hpp:51
SetAssign SET_ASSIGN_RND_EXC(Rnd r)
Definition: assign.hpp:94
void relax(Home home, const FloatVarArgs &x, const FloatVarArgs &sx, Rnd r, double p)
Definition: relax.cpp:61
Variable branching information.
Definition: var.hpp:59
SetValBranch SET_VAL_MED_EXC(void)
Definition: val.hpp:74
Generic domain change information to be supplied to advisors.
Definition: core.hpp:205
Set variables
Definition: set.hh:131
SetValBranch SET_VAL_RND_EXC(Rnd r)
Definition: val.hpp:94
Delta for the least upper bound.
Definition: set.hh:1732
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Disjoint union.
Definition: set.hh:664
SetAssign SET_ASSIGN_MIN_INC(void)
Definition: assign.hpp:59
With largest degree.
Definition: set.hh:1307
SetAssign SET_ASSIGN(SetBranchVal v, SetBranchCommit c)
Select value as defined by the value function v and commit function c.
Definition: assign.hpp:99
void precede(Home home, const IntVarArgs &x, int s, int t, IntPropLevel)
Post propagator that s precedes t in x.
Definition: precede.cpp:47
SetVarBranch SET_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl)
Definition: var.hpp:230
Integer variables.
Definition: int.hh:351
Iterator for the values in the greatest lower bound of a set variable.
Definition: set.hh:370
SetAssign SET_ASSIGN_MED_EXC(void)
Definition: assign.hpp:74
Include smallest element.
Definition: set.hh:1453
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
With lowest action.
Definition: set.hh:1310
Greater ( )
Definition: set.hh:655
Equality ( )
Definition: set.hh:646
Disjoint ( )
Definition: set.hh:650
std::function< bool(const Space &home, SetVar x, int i)> SetBranchFilter
Branch filter function type for set variables.
Definition: set.hh:1085
SetAssign SET_ASSIGN_MAX_EXC(void)
Definition: assign.hpp:84
void notMax(Home home, SetVar s, IntVar x)
Definition: int.cpp:271
Trace fail events.
Definition: recorder.hpp:50
Post propagator for SetVar x
Definition: set.hh:769
Include smallest element.
Definition: set.hh:1523
Trace fixpoint events.
Definition: recorder.hpp:49
void trace(Home home, const FloatVarArgs &x, TraceFilter tf, int te, FloatTracer &t)
Create a tracer for float variables.
Definition: trace.cpp:43
SymmetryHandle VariableSequenceSymmetry(const IntVarArgs &vars, int ss)
Variable sequences in x of size ss are interchangeable.
Definition: ldsb.cpp:94
SetValBranch SET_VAL(SetBranchVal v, SetBranchCommit c)
Select value as defined by the value function v and commit function c.
Definition: val.hpp:99
Set variable array
Definition: set.hh:572
Lists of ranges (intervals)
Definition: range-list.hpp:53
Random (uniform, for tie breaking)
Definition: set.hh:1303
Disequality ( )
Definition: set.hh:647
Which value to select for assignment.
Definition: set.hh:1519
Delta for the greatest lower bound.
Definition: set.hh:1715
SetAssign SET_ASSIGN_MIN_EXC(void)
Definition: assign.hpp:64
Gecode toplevel namespace
Argument array for variables.
Definition: array.hpp:53
void weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y)
Definition: int.cpp:296
With highest merit.
Definition: set.hh:1305
Class for action management.
Definition: action.hpp:46
Range iterator for computing set difference.
Definition: ranges-diff.hpp:47
SetVarBranch SET_VAR_ACTION_MAX(double d, BranchTbl tbl)
Definition: var.hpp:160
SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl)
Definition: var.hpp:190
SetVarBranch SET_VAR_CHB_MIN(BranchTbl tbl)
Definition: var.hpp:170
Which variable to select for branching.
Definition: set.hh:1298
Random number generator.
Definition: rnd.hpp:46
SetVarBranch SET_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl)
Definition: var.hpp:240
ViewTraceRecorder< Set::SetView > SetTraceRecorder
Trace recorder for set variables.
Definition: set.hh:1779
void assign(Home home, const FloatVarArgs &x, FloatAssign fa, FloatBranchFilter bf, FloatVarValPrint vvp)
Assign all x with value selection vals.
Definition: branch.cpp:115
Exclude largest element.
Definition: set.hh:1458
Home class for posting propagators
Definition: core.hpp:846
double tbl(const Gecode::Space &, double w, double b)
Test function for tie-break limit function.
Definition: branch.cpp:65
Include median element (rounding downwards)
Definition: set.hh:1455
With largest accumulated failure count.
Definition: set.hh:1309
SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d, BranchTbl tbl)
Definition: var.hpp:260
std::function< int(const Space &home, SetVar x, int i)> SetBranchVal
Branch value function type for set variables.
Definition: set.hh:1110
Shared array with arbitrary number of elements.
#define GECODE_SET_EXPORT
Definition: set.hh:71
void ite(Home home, BoolVar b, FloatVar x, FloatVar y, FloatVar z)
Post propagator for if-then-else constraint.
Definition: bool.cpp:43
SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d, BranchTbl tbl)
Definition: var.hpp:250
Iterator for the values in the least upper bound of a set variable.
Definition: set.hh:398
static StdSetTracer def
Default tracer (printing to std::cerr)
Definition: set.hh:1804
With smallest unknown set.
Definition: set.hh:1318
void element(Home home, IntSharedArray c, IntVar x0, IntVar x1, IntPropLevel)
Post domain consistent propagator for .
Definition: element.cpp:43
With smallest minimum unknown element.
Definition: set.hh:1314
SetVarBranch SET_VAR_ACTION_MIN(double d, BranchTbl tbl)
Definition: var.hpp:150