59 case Gecode::EPK_DENSE:
61 case Gecode::EPK_SPARSE:
63 case Gecode::EPK_DENSE_COMPRESSED:
64 return "DenseCompressed";
65 case Gecode::EPK_AUTO:
80 return (((x[0] == 0) || (x[0] == 2)) &&
81 ((x[1] == -1) || (x[1] == 1)) &&
82 ((x[2] == 0) || (x[2] == 1)) &&
83 ((x[3] == 0) || (x[3] == 1)));
103 return (x[0]<x[1]) && (x[1]<x[2]) && (x[2]<x[3]);
127 while (pos < s && x[pos] == 0) ++pos;
128 if (pos + 4 > s)
return false;
130 for (
int i = 0; i < 2; ++i, ++pos)
131 if (x[pos] != 1)
return false;
132 if (pos + 2 > s)
return false;
134 for (
int i = 0; i < 1; ++i, ++pos)
135 if (x[pos] != 0)
return false;
136 while (pos < s && x[pos] == 0) ++pos;
137 if (pos + 1 > s)
return false;
139 for (
int i = 0; i < 1; ++i, ++pos)
140 if (x[pos] != 1)
return false;
141 while (pos < s)
if (x[pos++] != 0)
return false;
160 for (
int i=0; i<x.
size(); i++) {
161 if ((x[i] < 0) || (x[i] > 3))
163 for (
int j=i+1; j<x.
size(); j++)
205 :
Test(
"Extensional::Reg::Roland::"+
str(n),n,0,1) {}
210 ((n > 1) && (x[n-2] == 0)) ||
211 ((n > 0) && (x[n-1] == 0));
229 return (((x[0] == 0) || (x[0] == 2)) &&
230 ((x[1] == -1) || (x[1] == 1)) &&
231 ((x[2] == 0) || (x[2] == 1)) &&
232 ((x[3] == 0) || (x[3] == 1)));
238 for (
int i=0; i<4; i++)
256 return (((x[0] == 0) || (x[0] == 2)) &&
257 ((x[1] == -1) || (x[1] == 1)) &&
258 ((x[2] == 0) || (x[2] == 1)) &&
259 ((x[3] == 0) || (x[3] == 1)));
265 for (
int i=0; i<4; i++)
266 y[i]=y[i+4]=y[i+8]=x[i];
283 return (x[1]==1) && (x[2]==0) && (x[3]==1);
289 for (
int i=0; i<4; i++)
290 y[i]=y[i+4]=
channel(home,x[i]);
304 return (x[1]==1) && (x[2]==0) && (x[3]==1);
310 for (
int i=0; i<4; i++)
311 y[i]=y[i+4]=y[i+8]=
channel(home,x[i]);
364 :
Test(
"Extensional::Reg::Opt::"+
str(n0),1,0,15),
n(n0) {}
367 return (x[0] <
n) && ((x[0] & 1) == 0);
374 int* f =
new int[
n+1];
376 for (
int i=0; i<
n; i++) {
387 DFA d(0, t, f,
false);
399 for (
int i = 0; i<ts.
tuples(); i++) {
401 for (
int j = 0; j<ts.
arity(); j++) {
423 "::" +
str(p) +
"::Base",
432 t.add(t1).add(t1).add(t2).add(t2)
433 .add(t3).add(t3).add(t4).add(t4)
434 .add(t5).add(t5).add(t5).add(t5)
435 .add(t5).add(t5).add(t5).add(t5)
436 .add(t1).add(t1).add(t2).add(t2)
437 .add(t3).add(t3).add(t4).add(t4)
438 .add(t5).add(t5).add(t5).add(t5)
439 .add(t5).add(t5).add(t5).add(t5)
444 return pos == ((x[0] == 1 && x[1] == 3 && x[2] == 2 && x[3] == 3) ||
445 (x[0] == 2 && x[1] == 1 && x[2] == 2 && x[3] == 4) ||
446 (x[0] == 2 && x[1] == 2 && x[2] == 1 && x[3] == 4) ||
447 (x[0] == 3 && x[1] == 3 && x[2] == 3 && x[3] == 2) ||
448 (x[0] == 4 && x[1] == 3 && x[2] == 4 && x[3] == 1));
482 "::" +
str(p) +
"::" + s,
489 for (
int i=
ts.tuples(); i--; ) {
492 for (
int j=0; (j <
ts.arity()) &&
same; j++)
538 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::Unary") {}
545 for (
int i=0; i<n; i++)
550 std::cerr <<
"ERROR: TupleSet did not select sparse support"
555 class SparseUnarySpace :
public Space {
558 SparseUnarySpace(
const TupleSet& t,
int n0)
559 : x(*
this,1,0,n0-1) {
563 SparseUnarySpace(SparseUnarySpace& s)
569 return new SparseUnarySpace(*
this);
573 SparseUnarySpace* root =
new SparseUnarySpace(ts,n);
577 SparseUnarySpace* sol = e.
next();
580 const bool ok = sol->x[0].assigned() && (sol->x[0].val() == 0);
590 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::Ternary") {}
597 for (
int i=0; i<n; i++)
602 std::cerr <<
"ERROR: Ternary TupleSet did not select sparse support"
607 class SparseTernarySpace :
public Space {
610 SparseTernarySpace(
const TupleSet& t,
int n0)
611 : x(*
this,3,0,n0-1) {
615 SparseTernarySpace(SparseTernarySpace& s)
621 return new SparseTernarySpace(*
this);
625 SparseTernarySpace* root =
new SparseTernarySpace(ts,n);
629 SparseTernarySpace* sol = e.
next();
632 const int a = sol->x[0].val();
633 const int b = sol->x[1].val();
634 const int c = sol->x[2].val();
636 return (b == ((a*7) % n)) && (
c == ((a*11) % n));
644 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::HighArity") {}
651 for (
int i=0; i<n; i++)
653 (i*7) % n, (i*11) % n, (i*13) % n}));
657 std::cerr <<
"ERROR: High-arity TupleSet did not select sparse support"
662 class SparseHighAritySpace :
public Space {
665 SparseHighAritySpace(
const TupleSet& t,
int n0)
666 : x(*
this,6,0,n0-1) {
670 SparseHighAritySpace(SparseHighAritySpace& s)
676 return new SparseHighAritySpace(*
this);
680 SparseHighAritySpace* root =
new SparseHighAritySpace(ts,n);
684 SparseHighAritySpace* sol = e.
next();
687 const int a = sol->x[0].val();
688 const int b = sol->x[1].val();
689 const int c = sol->x[2].val();
690 const int d = sol->x[3].val();
691 const int e0 = sol->x[4].val();
692 const int f = sol->x[5].val();
694 return (b == ((a*3) % n)) &&
695 (
c == ((a*5) % n)) &&
696 (d == ((a*7) % n)) &&
697 (e0 == ((a*11) % n)) &&
706 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::Nullary") {}
711 class SparseNullarySpace :
public Space {
714 SparseNullarySpace(
const TupleSet& t)
718 SparseNullarySpace(SparseNullarySpace& s)
724 return new SparseNullarySpace(*
this);
732 std::cerr <<
"ERROR: Nullary sat table not sparse" << std::endl;
735 SparseNullarySpace* sat_root =
new SparseNullarySpace(sat);
738 SparseNullarySpace* sat_sol = sat_engine.
next();
739 if (sat_sol ==
nullptr) {
740 std::cerr <<
"ERROR: Nullary sat table produced no solution"
748 SparseNullarySpace* unsat_root =
new SparseNullarySpace(unsat);
751 SparseNullarySpace* unsat_sol = unsat_engine.
next();
752 const bool ok = (unsat_sol ==
nullptr);
754 std::cerr <<
"ERROR: Nullary empty table unexpectedly satisfiable"
765 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::IncrementalDelta") {}
770 class SparseDeltaSpace :
public Space {
781 SparseDeltaSpace(SparseDeltaSpace& s)
787 return new SparseDeltaSpace(*
this);
798 SparseDeltaSpace* root =
new SparseDeltaSpace(ts);
802 SparseDeltaSpace* sol = e.
next();
805 SparseDeltaSpace* extra = e.
next();
806 const bool ok = sol->x[0].assigned() && sol->x[1].assigned() &&
807 (sol->x[0].val() == 2) && (sol->x[1].val() == 2) &&
819 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::IncrementalAssign") {}
824 class SparseAssignSpace :
public Space {
827 SparseAssignSpace(
const TupleSet& t)
834 SparseAssignSpace(SparseAssignSpace& s)
840 return new SparseAssignSpace(*
this);
851 SparseAssignSpace* root =
new SparseAssignSpace(ts);
854 SparseAssignSpace* sol = e.
next();
855 const bool ok = (sol ==
nullptr);
865 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::IncrementalBool") {}
870 class SparseBoolSpace :
public Space {
879 SparseBoolSpace(SparseBoolSpace& s)
885 return new SparseBoolSpace(*
this);
895 SparseBoolSpace* root =
new SparseBoolSpace(ts);
899 SparseBoolSpace* sol = e.
next();
902 SparseBoolSpace* extra = e.
next();
903 const bool ok = sol->x[0].assigned() && sol->x[1].assigned() &&
904 (sol->x[0].val() == 1) && (sol->x[1].val() == 0) &&
916 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::DisabledFailure") {}
921 class DisabledSpace :
public Space {
928 DisabledSpace(DisabledSpace& s)
932 virtual Space* copy(
void) {
933 return new DisabledSpace(*
this);
941 DisabledSpace* s =
new DisabledSpace(ts);
955 const bool failed = (s->status() ==
SS_FAILED);
965 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::WideDelta") {}
970 const int gap = 1000000000;
971 const int lower = gap / 2;
976 class NegativeSpace :
public Space {
979 NegativeSpace(
const TupleSet& t,
int gap0,
int lower0)
984 NegativeSpace(NegativeSpace& s)
988 virtual Space* copy(
void) {
989 return new NegativeSpace(*
this);
993 NegativeSpace* n =
new NegativeSpace(ts,gap,lower);
995 (n->x.min() != lower) || (n->x.max() != gap-1)) {
1001 class ReifiedSpace :
public Space {
1005 ReifiedSpace(
const TupleSet& t,
int gap0,
int lower0)
1006 : x(*
this,0,gap0), b(*
this,0,1) {
1011 ReifiedSpace(ReifiedSpace& s)
1014 b.update(*
this,s.b);
1016 virtual Space* copy(
void) {
1017 return new ReifiedSpace(*
this);
1021 ReifiedSpace*
r =
new ReifiedSpace(ts,gap,lower);
1022 const bool ok = (
r->status() !=
SS_FAILED) &&
1023 (
r->x.min() == lower) && (
r->x.max() == gap) &&
1034 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::Negative") {}
1039 class SparseNegativeSpace :
public Space {
1042 SparseNegativeSpace(
const TupleSet& t)
1047 SparseNegativeSpace(SparseNegativeSpace& s)
1053 return new SparseNegativeSpace(*
this);
1061 SparseNegativeSpace* root =
new SparseNegativeSpace(ts);
1066 while (SparseNegativeSpace* sol = e.
next()) {
1067 if (sol->x[0].val() == sol->x[1].val()) {
1082 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::Reified") {}
1087 class SparseReifiedSpace :
public Space {
1091 SparseReifiedSpace(
const TupleSet& t)
1092 : x(*
this,2,0,1), b(*
this,0,1) {
1097 SparseReifiedSpace(SparseReifiedSpace& s)
1100 b.update(*
this,s.b);
1104 return new SparseReifiedSpace(*
this);
1112 SparseReifiedSpace* root =
new SparseReifiedSpace(ts);
1117 while (SparseReifiedSpace* sol = e.
next()) {
1118 if (sol->x[0].val() != sol->x[1].val()) {
1133 : ::
Test::
Base(
"Int::Extensional::TupleSet::Support::SingleRepresentation") {}
1138 for (
int i=0; i<100; i++)
1142 std::cerr <<
"ERROR: Sparse support not available" << std::endl;
1146 std::cerr <<
"ERROR: Sparse range exposed dense support"
1152 for (
int i=0; i<100; i++)
1156 std::cerr <<
"ERROR: Compressed support not available" << std::endl;
1160 std::cerr <<
"ERROR: Compressed range exposed dense support"
1166 for (
int i=0; i<100; i++)
1170 std::cerr <<
"ERROR: Default finalize did not keep dense support"
1175 std::cerr <<
"ERROR: Dense range lost support data" << std::endl;
1182 std::cerr <<
"ERROR: Empty sparse table forgot representation"
1187 empty_compressed.
finalize(EPK_DENSE_COMPRESSED);
1189 std::cerr <<
"ERROR: Empty compressed table forgot representation"
1202 "Int::Extensional::TupleSet::Support::OffsetBoundary") {}
1206 const unsigned long long max =
1207 static_cast<unsigned long long>
1208 (std::numeric_limits<unsigned int>::max());
1209 unsigned int n_offsets = 0U;
1210 if (!support_offsets_size(
max-1ULL,n_offsets) ||
1211 (n_offsets != std::numeric_limits<unsigned int>::max()))
1213 if (support_offsets_size(
max,n_offsets))
1215 return !support_offsets_size(
max+1ULL,n_offsets);
1224 "Int::Extensional::TupleSet::Support::TerminalFailure") {}
1229 const int n = 371000;
1231 for (
int i=0; i<n; i++)
1234 bool rejected =
false;
1261 class PostingSpace :
public Space {
1268 PostingSpace(PostingSpace& s)
1272 virtual Space* copy(
void) {
1273 return new PostingSpace(*
this);
1278 PostingSpace* s =
new PostingSpace(ts);
1292 "Int::Extensional::TupleSet::Support::DFARepresentation") {}
1303 TupleSet compressed(2,dfa,EPK_DENSE_COMPRESSED);
1305 (compressed.
tuples() != 2))
1323 "Int::Extensional::TupleSet::Support::DisabledClone") {}
1334 class CloneSpace :
public Space {
1338 CloneSpace(
const TupleSet& t, Mode mode)
1339 : x(*
this,2,0,2), b(*
this,0,1) {
1340 if (mode == MODE_REIFIED)
1345 CloneSpace(CloneSpace& s)
1348 b.update(*
this,s.b);
1350 virtual Space* copy(
void) {
1351 return new CloneSpace(*
this);
1360 CloneSpace* source =
new CloneSpace(ts,MODE_POSITIVE);
1368 !source->x[0].assigned() || (source->x[0].val() != 1) ||
1369 (source->x[1].size() != 3)) {
1374 CloneSpace* clone =
static_cast<CloneSpace*
>(source->clone());
1376 const bool clone_ok = (clone->status() !=
SS_FAILED) &&
1377 clone->x[1].assigned() && (clone->x[1].val() == 1);
1381 const bool source_ok = (source->status() !=
SS_FAILED) &&
1382 source->x[1].assigned() && (source->x[1].val() == 1);
1384 return clone_ok && source_ok;
1392 CloneSpace* source =
new CloneSpace(ts,mode);
1398 if (mode == MODE_NEGATIVE) {
1409 auto verify = [mode](CloneSpace& s) {
1411 if (mode == MODE_POSITIVE)
1415 if (mode == MODE_REIFIED)
1416 return s.b.assigned() && (s.b.val() == 0);
1417 return s.x[1].size() == 3;
1420 CloneSpace* clone =
static_cast<CloneSpace*
>(source->clone());
1422 const bool clone_ok = verify(*clone);
1426 const bool source_ok = verify(*source);
1428 return clone_ok && source_ok;
1432 {EPK_DENSE,EPK_DENSE_COMPRESSED}) {
1435 for (Mode mode : {MODE_POSITIVE,MODE_NEGATIVE,MODE_REIFIED})
1436 if (!check_empty(epk,mode))
1447 : ::
Test::
Base(
"Int::Extensional::TupleSet::Auto::DefaultDispatch") {}
1456 std::cerr <<
"ERROR: Small AUTO table did not select dense"
1461 class PositiveSpace :
public Space {
1464 PositiveSpace(
const TupleSet& t) : x(*
this,2,0,1) {
1468 PositiveSpace(PositiveSpace& s) :
Space(s) {
1471 virtual Space* copy(
void) {
1472 return new PositiveSpace(*
this);
1476 PositiveSpace* dense_root =
new PositiveSpace(dense);
1479 int dense_solutions = 0;
1480 while (PositiveSpace* sol = dense_engine.
next()) {
1481 if (sol->x[0].val() != sol->x[1].val()) {
1488 if (dense_solutions != 2)
1493 for (
int i=0; i<n; i++)
1497 std::cerr <<
"ERROR: Large AUTO table did not select compressed"
1502 class ReifiedSpace :
public Space {
1506 ReifiedSpace(
const TupleSet& t,
int n0)
1507 : x(*
this,2,0,n0-1), b(*
this,0,1) {
1513 ReifiedSpace(ReifiedSpace& s) :
Space(s) {
1515 b.update(*
this,s.b);
1517 virtual Space* copy(
void) {
1518 return new ReifiedSpace(*
this);
1522 ReifiedSpace* compressed_root =
new ReifiedSpace(compressed,n);
1524 delete compressed_root;
1525 ReifiedSpace* compressed_sol = compressed_engine.
next();
1526 if (compressed_sol ==
nullptr)
1529 (compressed_sol->x[0].val() == 3) &&
1530 (compressed_sol->x[1].val() == ((3*7) % n));
1531 delete compressed_sol;
1532 ReifiedSpace* extra = compressed_engine.
next();
1533 const bool no_extra = (extra ==
nullptr);
1535 return ok && no_extra;
1543 : ::
Test::
Base(
"Int::Extensional::TupleSet::DenseCompressed::WideGap") {}
1548 const int gap = 1000000000;
1553 class NegativeSpace :
public Space {
1556 NegativeSpace(
const TupleSet& t,
int gap0)
1560 NegativeSpace(NegativeSpace& s) :
Space(s) {
1563 virtual Space* copy(
void) {
1564 return new NegativeSpace(*
this);
1568 NegativeSpace* ns =
new NegativeSpace(ts,gap);
1573 if (ns->x.in(0) || ns->x.in(gap)) {
1579 class ReifiedSpace :
public Space {
1583 ReifiedSpace(
const TupleSet& t,
int gap0,
bool force)
1584 : x(*
this,0,gap0), b(*
this,0,1) {
1592 ReifiedSpace(ReifiedSpace& s) :
Space(s) {
1594 b.update(*
this,s.b);
1596 virtual Space* copy(
void) {
1597 return new ReifiedSpace(*
this);
1601 ReifiedSpace* rs =
new ReifiedSpace(ts,gap,
false);
1608 ReifiedSpace* rfs =
new ReifiedSpace(ts,gap,
true);
1613 if (!rfs->x.assigned() || (rfs->x.val() != 0) ||
1614 !rfs->b.assigned() || (rfs->b.val() != 1)) {
1620 class PositiveDeltaSpace :
public Space {
1623 PositiveDeltaSpace(
const TupleSet& t,
int gap0)
1628 PositiveDeltaSpace(PositiveDeltaSpace& s) :
Space(s) {
1631 virtual Space* copy(
void) {
1632 return new PositiveDeltaSpace(*
this);
1636 PositiveDeltaSpace* ps =
new PositiveDeltaSpace(ts,gap);
1641 if (!ps->x.assigned() || (ps->x.val() != gap)) {
1655 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::NegativeFail") {}
1659 class NegativeFailSpace :
public Space {
1662 NegativeFailSpace(
const TupleSet& t)
1667 NegativeFailSpace(NegativeFailSpace& s)
1671 virtual Space* copy(
void) {
1672 return new NegativeFailSpace(*
this);
1681 NegativeFailSpace* root =
new NegativeFailSpace(ts);
1684 NegativeFailSpace* sol = e.
next();
1685 const bool ok = (sol ==
nullptr);
1695 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::NegativePrune") {}
1699 class NegativePruneSpace :
public Space {
1702 NegativePruneSpace(
const TupleSet& t)
1707 NegativePruneSpace(NegativePruneSpace& s)
1711 virtual Space* copy(
void) {
1712 return new NegativePruneSpace(*
this);
1720 NegativePruneSpace* root =
new NegativePruneSpace(ts);
1725 while (NegativePruneSpace* sol = e.
next()) {
1726 if (sol->x[0].val() != 1) {
1741 : ::
Test::
Base(
"Int::Extensional::TupleSet::Sparse::ReifiedModes") {}
1745 class ReifModeSpace :
public Space {
1750 : x(*
this,2,0,1), b(*
this,0,1) {
1755 ReifModeSpace(ReifModeSpace& s)
1758 b.update(*
this,s.b);
1760 virtual Space* copy(
void) {
1761 return new ReifModeSpace(*
this);
1773 ReifModeSpace* root =
new ReifModeSpace(ts,pos,rm,bv);
1777 while (ReifModeSpace* sol = e.
next()) {
1778 const bool eq = (sol->x[0].val() == 0) && (sol->x[1].val() == 0);
1779 if (must_equal != eq) {
1819 "::" +
str(p) +
"::Large",
1826 if (
_rand(100) <= prob*100) {
1828 for (
int i = 5; i--; ) tuple[i] = ass[i];
1838 for (
int i = 0; i <
t.tuples(); ++i) {
1841 for (
int j = 0; j <
t.arity() &&
same; ++j)
1842 if (l[j] != x[j])
same =
false;
1874 "::" +
str(p) +
"::Bool",
1875 5,0,1,true),
pos(p),
epk(epk0),
t(5) {
1880 if (
_rand(100) <= prob*100) {
1882 for (
int i = 5; i--; ) tuple[i] = ass[i];
1892 for (
int i = 0; i <
t.tuples(); ++i) {
1895 for (
int j = 0; j <
t.arity() &&
same; ++j)
1907 for (
int i = x.
size(); i--; )
1916 for (
int i = x.
size(); i--; )
1932 while (n_tuples < size) {
1939 for (
int i = size; i--; ) {
1942 for (
int j = arity; j--; ) tuple[j] = ass[j];
1947 assert(ts.
tuples() == size);
1961 if (rand(100) <= prob*100) {
1963 for (
int i = n; i--; ) tuple[i] = ass[i];
1986 { EPK_DENSE, EPK_SPARSE, EPK_DENSE_COMPRESSED }) {
1987 for (
bool pos : {
false,
true }) {
1990 ts.
add({2, 1, 2, 4}).add({2, 2, 1, 4})
1991 .add({4, 3, 4, 1}).add({1, 3, 2, 3})
1992 .add({3, 3, 3, 2}).add({5, 1, 4, 4})
1993 .add({2, 5, 1, 5}).add({4, 3, 5, 1})
1994 .add({1, 5, 2, 5}).add({5, 3, 3, 2})
2005 for (
int n=1024*16; n--; )
2012 ts.
add({1}).add({2}).add({3}).finalize(epk);
2018 ts.
add({m+0,m+1,m+2}).add({m+4,m+1,m+3})
2019 .add({m+2,m+3,m+0}).add({m+2,m+3,m+0})
2020 .add({m+1,m+2,m+5}).add({m+2,m+3,m+0})
2021 .add({m+3,m+6,m+5}).finalize(epk);
2027 ts.
add({M-0,M-1,M-2}).add({M-4,M-1,M-3})
2028 .add({M-2,M-3,M-0}).add({M-2,M-3,M-0})
2029 .add({M-1,M-2,M-5}).add({M-2,M-3,M-0})
2030 .add({M-3,M-6,M-5}).finalize(epk);
2037 ts.
add({M-0,m+1,M-2}).add({m+4,M-1,M-3})
2038 .add({m+2,M-3,m+0}).add({M-2,M-3,M-0})
2046 const int triangle_tuples =
2047 (epk == EPK_DENSE) ? 10000 : 1000;
2048 for (
int i = 0; i < triangle_tuples; i++) {
2050 for (
int j = 0; j < 7; j++) {
2051 tuple[j] = rand(j+1);
2059 for (
int i = 0; i <= 64*6; i+=32)
2063 const double prob_small =
2064 (epk == EPK_DENSE) ? 0.05 : 0.01;
2070 if (epk == EPK_DENSE)
2083 for (
int i = 4; i--; ) tuple[i] = ass[i];
2095 t.
add({ass[0],0,ass[1],ass[2]});
2102 if (epk == EPK_DENSE) {
2106 if (rand(100) <= 0.25*100) {
2109 for (
int i = 9; i--; )
2110 tuple[i+1] = ass[i];
2115 t.
add({1,1,1,1,1,1,1,1,1,1});
2116 t.
add({1,2,3,4,4,2,1,2,3,3});
Passing Boolean variables.
Boolean integer variables.
Specification of a DFA transition.
int o_state
output state Default constructor
Deterministic finite automaton (DFA).
Depth-first search engine.
Passing integer arguments.
Passing integer variables.
Exception: Tuple set already finalized
Exception: Tuple set not yet finalized
Exception: Value out of limits
static PropagatorGroup all
Group of all propagators.
Regular expressions over integer values.
Reification specification.
virtual T * next(void)
Return next solution (nullptr, if none exists or search has been stopped).
const BitSetData * supports(unsigned int n_words, int n) const
Return the dense supports for value n.
Class representing a set of tuples.
bool failed(void) const
Has tuple-set finalization failed.
int tuples(void) const
Number of tuples.
bool finalized(void) const
Is tuple set successfully finalized.
ExtensionalPropKind representation(void) const
Return materialized tuple-set representation.
TupleSet & add(const IntArgs &t)
Add tuple t to tuple set.
int * Tuple
Type of a tuple.
void finalize(void)
Finalize tuple set with dense support data.
const Range * fst(int i) const
Return first range for position i.
unsigned int words(void) const
Return number of required bit set words.
int arity(void) const
Arity of tuple set.
int size(void) const
Return size of array (number of elements).
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
Gecode::Support::RandomGenerator _rand
Random number generator.
Base(std::string s)
Create and register test with name s.
Base class for assignments
int size(void) const
Return number of variables.
Generate all assignments.
virtual void next(Gecode::Support::RandomGenerator &rand)
Move to next assignment.
virtual bool has_more(void) const
Test whether all assignments have been iterated.
Help class to create and register tests.
Create(void)
Perform creation and registration.
Dense-compressed iterators should skip unsupported value gaps.
DenseCompressedTupleSetWideGap(void)
virtual bool run(void)
Run test.
RandomTupleSetTest(const std::string &s, bool p, Gecode::IntSet d0, Gecode::TupleSet ts0, Gecode::ExtensionalPropKind epk0)
Create and register test.
virtual Assignment * assignment(void) const
Create and register initial assignment.
Test with regular expression for distinct constraint
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegDistinct(void)
Create and register test.
virtual bool solution(const Assignment &x) const
Test whether x is solution
RegEmptyDFA(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Test for empty regular expression
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegEmptyREG(void)
Create and register test.
virtual bool solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual bool solution(const Assignment &x) const
Test whether x is solution
RegOpt(int n0)
Create and register test.
int n
DFA size characteristic.
Test with simple regular expression from Roland Yap
virtual bool solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegRoland(int n)
Create and register test.
Test with simple regular expression and shared variables (uses unsharing)
virtual bool solution(const Assignment &x) const
Test whether x is solution
RegSharedA(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Test with simple regular expression and shared variables (uses unsharing)
RegSharedB(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Test with simple regular expression and shared variables (uses unsharing)
virtual bool solution(const Assignment &x) const
Test whether x is solution
RegSharedC(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Test with simple regular expression and shared variables (uses unsharing)
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegSharedD(void)
Create and register test.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Test with simple regular expression
virtual bool solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegSimpleA(void)
Create and register test.
Test with simple regular expression
virtual bool solution(const Assignment &x) const
Test whether x is solution
RegSimpleB(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Test with simple regular expression
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegSimpleC(void)
Create and register test.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Disabled sparse propagators must defer failure until re-enabled.
virtual bool run(void)
Run test.
SparseTupleSetDisabledFailure(void)
Sparse smoke test for low-density higher-arity tuple sets.
virtual bool run(void)
Run test.
SparseTupleSetHighArity(void)
Sparse incremental test for assigned-variable advisor updates.
SparseTupleSetIncrementalAssign(void)
virtual bool run(void)
Run test.
Sparse incremental test for BoolView specialization.
SparseTupleSetIncrementalBool(void)
virtual bool run(void)
Run test.
Sparse incremental smoke test for repeated and mixed delta updates.
SparseTupleSetIncrementalDelta(void)
virtual bool run(void)
Run test.
Sparse negative should fail if all combinations are forbidden.
virtual bool run(void)
Run test.
SparseTupleSetNegativeFail(void)
Sparse negative should prune values whose completions are all forbidden.
virtual bool run(void)
Run test.
SparseTupleSetNegativePrune(void)
Sparse smoke test for negative tuple-set posting.
virtual bool run(void)
Run test.
SparseTupleSetNegative(void)
Sparse smoke test for nullary tuple sets.
virtual bool run(void)
Run test.
SparseTupleSetNullary(void)
Sparse reified posting should support all reify modes for positive/negative.
virtual bool run(void)
Run test.
SparseTupleSetReifiedModes(void)
Sparse smoke test for reified tuple-set posting.
SparseTupleSetReified(void)
virtual bool run(void)
Run test.
Sparse smoke test for low-density ternary tuple sets.
virtual bool run(void)
Run test.
SparseTupleSetTernary(void)
Sparse smoke test for very low-density unary tuple sets.
virtual bool run(void)
Run test.
SparseTupleSetUnary(void)
Sparse delta processing must depend on supports, not numeric width.
virtual bool run(void)
Run test.
SparseTupleSetWideDelta(void)
AUTO finalization should work with default tuple-set posting overloads.
TupleSetAutoDefaultDispatch(void)
virtual bool run(void)
Run test.
bool pos
Whether the table is positive or negative.
TupleSetBase(bool p, Gecode::ExtensionalPropKind epk0)
Create and register test.
virtual bool solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
Gecode::TupleSet t
Simple test tupleset.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Gecode::ExtensionalPropKind epk
Support representation.
Gecode::TupleSet t
Tupleset used for testing.
Gecode::ExtensionalPropKind epk
Support representation.
TupleSetBool(double prob, bool p, Gecode::ExtensionalPropKind epk0)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual bool solution(const Assignment &x) const
Test whether x is solution
bool pos
Whether the table is positive or negative.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
DFA-derived tuple sets preserve the requested support representation.
TupleSetDFARepresentation(void)
virtual bool run(void)
Run test.
Disabled compact propagators preserve pending work when cloned.
TupleSetDisabledClone(void)
virtual bool run(void)
Run test.
Test with large tuple set
bool pos
Whether the table is positive or negative.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
TupleSetLarge(double prob, bool p, Gecode::ExtensionalPropKind epk0)
Create and register test.
Gecode::ExtensionalPropKind epk
Support representation.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Gecode::TupleSet t
Tupleset used for testing.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Sparse/compressed tuplesets should materialize only requested support.
virtual bool run(void)
Run test.
TupleSetSingleRepresentation(void)
Sparse offset arrays need a representable terminal entry.
TupleSetSupportOffsetBoundary(void)
virtual bool run(void)
Run test.
Failed finalization is terminal and cannot expose partial support data.
virtual bool run(void)
Run test.
TupleSetTerminalFinalizationFailure(void)
Help class to create and register tests with a fixed table size.
TupleSetTestSize(int size, bool pos, Gecode::ExtensionalPropKind epk, Gecode::Support::RandomGenerator &rand)
Perform creation and registration.
virtual bool solution(const Assignment &x) const
Test whether x is solution
TupleSetTest(const std::string &s, bool p, Gecode::IntSet d0, Gecode::TupleSet ts0, bool td, Gecode::ExtensionalPropKind epk0)
Create and register test.
bool toDFA
Whether to validate dfa2tupleset.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
Gecode::TupleSet ts
The tuple set to use.
bool pos
Whether the table is positive or negative.
Gecode::ExtensionalPropKind epk
Support representation.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Generate random selection of assignments.
bool testsearch
Whether to perform search test.
static std::string str(bool b)
Map bool to string.
Gecode::IntPropLevel ipl
Propagation level.
int arity
Number of variables.
Gecode::IntSet dom
Domain of variables.
LinearCongruentialGenerator< 2147483647, 48271, 44488, 3399 > RandomGenerator
Default values for linear congruential generator.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
ExtensionalPropKind
Support representation selection for extensional tuple sets.
void extensional(Home home, const IntVarArgs &x, DFA d, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for extensional constraint described by a DFA.
ReifyMode
Mode for reification.
@ IRT_GQ
Greater or equal ( ).
@ RM_IMP
Implication for reification.
@ RM_PMI
Inverse implication for reification.
@ RM_EQV
Equivalence for reification (default).
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
@ SS_FAILED
Space is failed
bool support_offsets_size(unsigned long long n_vals, unsigned int &n_offsets)
const int min
Smallest allowed integer value.
const int max
Largest allowed integer value.
Gecode toplevel namespace
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel ipl=IPL_DEF)
Post propagator for .
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
BoolValBranch BOOL_VAL_MIN(void)
Select smallest value.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
BoolVarBranch BOOL_VAR_NONE(void)
Select first unassigned variable.
bool same(VarArgArray< Var > x, VarArgArray< Var > y)
IntValBranch INT_VAL_MIN(void)
Select smallest value.
void unshare(Home home, IntVarArgs &x, IntPropLevel ipl=IPL_DEF)
Replace multiple variable occurrences in x by fresh variables.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Tests for extensional (relation) constraints
TupleSetSupportOffsetBoundary tuple_set_support_offset_boundary
SparseTupleSetWideDelta sparse_tuple_set_wide_delta
TupleSetSingleRepresentation tuple_set_single_representation
TupleSetDisabledClone tuple_set_disabled_clone
SparseTupleSetTernary sparse_tuple_set_ternary
SparseTupleSetUnary sparse_tuple_set_unary
SparseTupleSetNegative sparse_tuple_set_negative
SparseTupleSetNullary sparse_tuple_set_nullary
TupleSetAutoDefaultDispatch tuple_set_auto_default_dispatch
std::string extensional_kind_name(Gecode::ExtensionalPropKind epk)
Gecode::DFA tupleset2dfa(Gecode::TupleSet ts)
% Transform a TupleSet into a DFA
RegOpt ro7(static_cast< int >(USHRT_MAX))
SparseTupleSetIncrementalBool sparse_tuple_set_incremental_bool
SparseTupleSetReified sparse_tuple_set_reified
SparseTupleSetIncrementalAssign sparse_tuple_set_incremental_assign
RegOpt ro2(static_cast< int >(UCHAR_MAX-1))
SparseTupleSetNegativePrune sparse_tuple_set_negative_prune
TupleSetDFARepresentation tuple_set_dfa_representation
SparseTupleSetHighArity sparse_tuple_set_high_arity
RegOpt ro6(static_cast< int >(USHRT_MAX-1))
SparseTupleSetReifiedModes sparse_tuple_set_reified_modes
SparseTupleSetDisabledFailure sparse_tuple_set_disabled_failure
SparseTupleSetIncrementalDelta sparse_tuple_set_incremental_delta
SparseTupleSetNegativeFail sparse_tuple_set_negative_fail
Gecode::TupleSet randomTupleSet(int n, int min, int max, double prob, Gecode::ExtensionalPropKind epk, Gecode::Support::RandomGenerator &rand)
TupleSetTerminalFinalizationFailure tuple_set_terminal_failure
RegOpt ro3(static_cast< int >(UCHAR_MAX))
DenseCompressedTupleSetWideGap dense_compressed_tuple_set_wide_gap
Testing finite domain integers.
#define GECODE_NEVER
Assert that this command is never executed.