49 namespace Test {
namespace Int {
52 namespace Extensional {
66 return (((x[0] == 0) || (x[0] == 2)) &&
67 ((x[1] == -1) || (x[1] == 1)) &&
68 ((x[2] == 0) || (x[2] == 1)) &&
69 ((x[3] == 0) || (x[3] == 1)));
89 return (x[0]<x[1]) && (x[1]<x[2]) && (x[2]<x[3]);
113 while (pos < s && x[pos] == 0) ++
pos;
114 if (pos + 4 > s)
return false;
116 for (
int i = 0;
i < 2; ++
i, ++
pos)
117 if (x[pos] != 1)
return false;
118 if (pos + 2 > s)
return false;
120 for (
int i = 0;
i < 1; ++
i, ++
pos)
121 if (x[pos] != 0)
return false;
122 while (pos < s && x[pos] == 0) ++
pos;
123 if (pos + 1 > s)
return false;
125 for (
int i = 0;
i < 1; ++
i, ++
pos)
126 if (x[pos] != 1)
return false;
127 while (pos < s)
if (x[pos++] != 0)
return false;
146 for (
int i=0;
i<x.
size();
i++) {
147 if ((x[
i] < 0) || (x[
i] > 3))
149 for (
int j=
i+1; j<x.
size(); j++)
191 :
Test(
"Extensional::Reg::Roland::"+
str(n),n,0,1) {}
196 ((n > 1) && (x[n-2] == 0)) ||
197 ((n > 0) && (x[n-1] == 0));
215 return (((x[0] == 0) || (x[0] == 2)) &&
216 ((x[1] == -1) || (x[1] == 1)) &&
217 ((x[2] == 0) || (x[2] == 1)) &&
218 ((x[3] == 0) || (x[3] == 1)));
224 for (
int i=0;
i<4;
i++)
242 return (((x[0] == 0) || (x[0] == 2)) &&
243 ((x[1] == -1) || (x[1] == 1)) &&
244 ((x[2] == 0) || (x[2] == 1)) &&
245 ((x[3] == 0) || (x[3] == 1)));
251 for (
int i=0;
i<4;
i++)
252 y[
i]=y[
i+4]=y[
i+8]=x[
i];
269 return (x[1]==1) && (x[2]==0) && (x[3]==1);
275 for (
int i=0;
i<4;
i++)
290 return (x[1]==1) && (x[2]==0) && (x[3]==1);
296 for (
int i=0;
i<4;
i++)
350 :
Test(
"Extensional::Reg::Opt::"+
str(n0),1,0,15), n(n0) {}
353 return (x[0] < n) && ((x[0] & 1) == 0);
360 int*
f =
new int[n+1];
362 for (
int i=0;
i<
n;
i++) {
373 DFA d(0, t, f,
false);
387 for (
int j = 0; j<ts.
arity(); j++) {
401 :
Test(
"Extensional::TupleSet::Base",
405 return ((x[0] == 1 && x[1] == 3 && x[2] == 2 && x[3] == 3) ||
406 (x[0] == 2 && x[1] == 1 && x[2] == 2 && x[3] == 4) ||
407 (x[0] == 2 && x[1] == 2 && x[2] == 1 && x[3] == 4) ||
408 (x[0] == 3 && x[1] == 3 && x[2] == 3 && x[3] == 2) ||
409 (x[0] == 4 && x[1] == 3 && x[2] == 4 && x[3] == 1)
448 :
Test(
"Extensional::TupleSet::"+s,
458 for (
int j=0; (j < ts.
arity()) && same; j++)
499 :
Test(
"Extensional::TupleSet::Large",
507 for (
int i = 5;
i--; ) tuple[
i] = ass[
i];
520 for (
int j = 0; j < t.
arity() &&
same; ++j)
521 if (l[j] != x[j]) same =
false;
522 if (same)
return true;
539 :
Test(
"Extensional::TupleSet::Bool",
547 for (
int i = 5;
i--; ) tuple[
i] = ass[
i];
560 for (
int j = 0; j < t.
arity() &&
same; ++j)
561 if (l[j] != x[j]) same =
false;
562 if (same)
return true;
570 for (
int i = x.
size();
i--; )
585 while (n_tuples < size) {
592 for (
int i = size;
i--; ) {
595 for (
int j = arity; j--; ) tuple[j] = ass[j];
614 for (
int i = n;
i--; ) tuple[
i] = ass[
i];
631 ts.
add(2, 1, 2, 4).
add(2, 2, 1, 4)
632 .
add(4, 3, 4, 1).
add(1, 3, 2, 3)
633 .
add(3, 3, 3, 2).
add(5, 1, 4, 4)
634 .
add(2, 5, 1, 5).
add(4, 3, 5, 1)
635 .
add(1, 5, 2, 5).
add(5, 3, 3, 2)
646 for (
int n=1024*16;
n--; )
659 ts.
add(m+0,m+1,m+2).
add(m+4,m+1,m+3)
660 .
add(m+2,m+3,m+0).
add(m+2,m+3,m+0)
661 .
add(m+1,m+2,m+5).
add(m+2,m+3,m+0)
668 ts.
add(M-0,M-1,M-2).
add(M-4,M-1,M-3)
669 .
add(M-2,M-3,M-0).
add(M-2,M-3,M-0)
670 .
add(M-1,M-2,M-5).
add(M-2,M-3,M-0)
678 ts.
add(M-0,m+1,M-2).
add(m+4,M-1,M-3)
679 .
add(m+2,M-3,m+0).
add(M-2,M-3,M-0)
687 for (
int i = 0;
i < 10000;
i++) {
689 for (
int j = 0; j < 7; j++) {
698 for (
int i = 0;
i <= 64*6;
i+=32)
713 for (
int i = 4;
i--; ) tuple[
i] = ass[
i];
725 t.
add(ass[0],0,ass[1],ass[2]);
739 for (
int i = 9;
i--; ) tuple[
i+1] = ass[
i];
744 t.
add(1,1,1,1,1,1,1,1,1,1);
745 t.
add(1,2,3,4,4,2,1,2,3,3);
775 RegOpt ro2(static_cast<int>(UCHAR_MAX-1));
779 RegOpt ro6(static_cast<int>(USHRT_MAX-1));
RegRoland(int n)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
TupleSetLarge(double prob)
Create and register test.
Test with simple regular expression and shared variables (uses unsharing)
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
Gecode::TupleSet randomTupleSet(int n, int min, int max, double prob)
void finalize(void)
Finalize tuple set.
RegEmptyREG(void)
Create and register test.
RandomTupleSetTest(const std::string &s, Gecode::IntSet d0, Gecode::TupleSet ts0)
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
Create(void)
Perform creation and registration.
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
int size(void) const
Return size of array (number of elements)
const FloatNum max
Largest allowed float value.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
TupleSetTest(const std::string &s, Gecode::IntSet d0, Gecode::TupleSet ts0, bool td)
Create and register test.
int size(void) const
Return number of variables.
int arity(void) const
Arity of tuple set.
Test with regular expression for distinct constraint
static Gecode::Support::RandomGenerator rand
Random number generator.
Regular expressions over integer values.
RegOpt ro3(static_cast< int >(UCHAR_MAX))
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegDistinct(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
bool pos(const View &x)
Test whether x is postive.
Test with simple regular expression
int * Tuple
Type of a tuple.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual Assignment * assignment(void) const
Create and register initial assignment.
Gecode::IntSet dom
Domain of variables.
void unshare(Home home, VarArgArray< Var > &x, IntPropLevel ipl)
Replace unassigned shared variables by fresh, yet equal variables.
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
Test with simple regular expression
const int max
Largest allowed integer value.
Generate random selection of assignments.
const int min
Smallest allowed integer value.
virtual bool solution(const Assignment &x) const
Test whether x is solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
int tuples(void) const
Number of tuples.
virtual bool solution(const Assignment &x) const
Test whether x is solution
virtual bool solution(const Assignment &x) const
Test whether x is solution
Deterministic finite automaton (DFA)
const FloatNum min
Smallest allowed float value.
Gecode::IntArgs i(4, 1, 2, 3, 4)
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
int n
Number of negative literals for node type.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
void extensional(Home home, const IntVarArgs &x, DFA dfa, IntPropLevel)
Post domain consistent propagator for extensional constraint described by a DFA.
Specification of a DFA transition.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Gecode::TupleSet ts
The tuple set to use.
RegSharedB(void)
Create and register test.
RegOpt ro7(static_cast< int >(USHRT_MAX))
Gecode::DFA tupleset2dfa(Gecode::TupleSet ts)
% Transform a TupleSet into a DFA
bool toDFA
Whether to validate dfa2tupleset.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegEmptyDFA(void)
Create and register test.
int o_state
output state Default constructor
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
TupleSetBase(void)
Create and register test.
Gecode::IntPropLevel ipl
Propagation level.
Passing integer variables.
Passing integer arguments.
Passing Boolean variables.
virtual bool solution(const Assignment &x) const
Test whether x is solution
TupleSetBool(double prob)
Create and register test.
Class represeting a set of tuples.
RegSharedD(void)
Create and register test.
Post propagator for SetVar SetOpType SetVar y
virtual bool solution(const Assignment &x) const
Test whether x is solution
Node * x
Pointer to corresponding Boolean expression node.
virtual bool solution(const Assignment &x) const
Test whether x is solution
bool testsearch
Whether to perform search test.
Base class for assignments
void extensional(Home home, const BoolVarArgs &x, const TupleSet &t, IntPropLevel)
Post propagator for .
bool same(const Item &i, const Item &j)
Whether two items are the same.
Test with simple regular expression and shared variables (uses unsharing)
Domain propagation Options: basic versus advanced propagation.
Help class to create and register tests with a fixed table size.
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.
TupleSet & add(const IntArgs &t)
Add tuple t to tuple set.
Test with simple regular expression from Roland Yap
int n
DFA size characteristic.
RegSimpleC(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.
Gecode toplevel namespace
virtual bool solution(const Assignment &x) const
Test whether x is solution
Test for empty regular expression
Help class to create and register tests.
int arity
Number of variables.
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 ro6(static_cast< int >(USHRT_MAX-1))
RegOpt ro2(static_cast< int >(UCHAR_MAX-1))
RegSharedA(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
TupleSetTestSize(int size)
Perform creation and registration.
RegSharedC(void)
Create and register test.
Test with large tuple set
Test with simple regular expression and shared variables (uses unsharing)
Generate all assignments.
virtual bool solution(const Assignment &x) const
Test whether x is solution
RegSimpleA(void)
Create and register test.
RegSimpleB(void)
Create and register test.
Test with simple regular expression