Go to the documentation of this file.
43 namespace Test {
namespace Int {
46 namespace Extensional {
60 return (((
x[0] == 0) || (
x[0] == 2)) &&
61 ((
x[1] == -1) || (
x[1] == 1)) &&
62 ((
x[2] == 0) || (
x[2] == 1)) &&
63 ((
x[3] == 0) || (
x[3] == 1)));
83 return (
x[0]<
x[1]) && (
x[1]<
x[2]) && (
x[2]<
x[3]);
108 if (
pos + 4 > s)
return false;
110 for (
int i = 0;
i < 2; ++
i, ++
pos)
111 if (
x[
pos] != 1)
return false;
112 if (
pos + 2 > s)
return false;
114 for (
int i = 0;
i < 1; ++
i, ++
pos)
115 if (
x[
pos] != 0)
return false;
117 if (
pos + 1 > s)
return false;
119 for (
int i = 0;
i < 1; ++
i, ++
pos)
120 if (
x[
pos] != 1)
return false;
121 while (
pos < s)
if (
x[
pos++] != 0)
return false;
140 for (
int i=0;
i<
x.size();
i++) {
141 if ((
x[
i] < 0) || (
x[
i] > 3))
143 for (
int j=
i+1; j<
x.size(); j++)
185 :
Test(
"Extensional::Reg::Roland::"+
str(
n),
n,0,1) {}
190 ((
n > 1) && (
x[
n-2] == 0)) ||
191 ((
n > 0) && (
x[
n-1] == 0));
209 return (((
x[0] == 0) || (
x[0] == 2)) &&
210 ((
x[1] == -1) || (
x[1] == 1)) &&
211 ((
x[2] == 0) || (
x[2] == 1)) &&
212 ((
x[3] == 0) || (
x[3] == 1)));
218 for (
int i=0;
i<4;
i++)
236 return (((
x[0] == 0) || (
x[0] == 2)) &&
237 ((
x[1] == -1) || (
x[1] == 1)) &&
238 ((
x[2] == 0) || (
x[2] == 1)) &&
239 ((
x[3] == 0) || (
x[3] == 1)));
245 for (
int i=0;
i<4;
i++)
263 return (
x[1]==1) && (
x[2]==0) && (
x[3]==1);
269 for (
int i=0;
i<4;
i++)
284 return (
x[1]==1) && (
x[2]==0) && (
x[3]==1);
290 for (
int i=0;
i<4;
i++)
344 :
Test(
"Extensional::Reg::Opt::"+
str(n0),1,0,15),
n(n0) {}
347 return (
x[0] <
n) && ((
x[0] & 1) == 0);
354 int*
f =
new int[
n+1];
356 for (
int i=0;
i<
n;
i++) {
381 for (
int j = 0; j<ts.
arity(); j++) {
400 :
Test(
"Extensional::TupleSet::" +
str(
p) +
"::Base",
408 t.add(t1).add(t1).add(t2).add(t2)
409 .add(t3).add(t3).add(t4).add(t4)
410 .add(t5).add(t5).add(t5).add(t5)
411 .add(t5).add(t5).add(t5).add(t5)
412 .add(t1).add(t1).add(t2).add(t2)
413 .add(t3).add(t3).add(t4).add(t4)
414 .add(t5).add(t5).add(t5).add(t5)
415 .add(t5).add(t5).add(t5).add(t5)
420 return pos == ((
x[0] == 1 &&
x[1] == 3 &&
x[2] == 2 &&
x[3] == 3) ||
421 (
x[0] == 2 &&
x[1] == 1 &&
x[2] == 2 &&
x[3] == 4) ||
422 (
x[0] == 2 &&
x[1] == 2 &&
x[2] == 1 &&
x[3] == 4) ||
423 (
x[0] == 3 &&
x[1] == 3 &&
x[2] == 3 &&
x[3] == 2) ||
424 (
x[0] == 4 &&
x[1] == 3 &&
x[2] == 4 &&
x[3] == 1));
453 :
Test(
"Extensional::TupleSet::" +
str(
p) +
"::" + s,
455 pos(
p), ts(ts0), toDFA(td) {
463 for (
int j=0; (j < ts.
arity()) &&
same; j++)
513 :
Test(
"Extensional::TupleSet::" +
str(
p) +
"::Large",
521 for (
int i = 5;
i--; ) tuple[
i] = ass[
i];
531 for (
int i = 0;
i <
t.tuples(); ++
i) {
534 for (
int j = 0; j <
t.arity() &&
same; ++j)
535 if (
l[j] !=
x[j])
same =
false;
564 :
Test(
"Extensional::TupleSet::" +
str(
p) +
"::Bool",
565 5,0,1,true),
pos(
p),
t(5) {
572 for (
int i = 5;
i--; ) tuple[
i] = ass[
i];
582 for (
int i = 0;
i <
t.tuples(); ++
i) {
585 for (
int j = 0; j <
t.arity() &&
same; ++j)
597 for (
int i =
x.size();
i--; )
606 for (
int i =
x.size();
i--; )
621 while (n_tuples <
size) {
628 for (
int i =
size;
i--; ) {
631 for (
int j =
arity; j--; ) tuple[j] = ass[j];
650 for (
int i =
n;
i--; ) tuple[
i] = ass[
i];
665 for (
bool pos : {
false,
true }) {
668 ts.
add({2, 1, 2, 4}).add({2, 2, 1, 4})
669 .add({4, 3, 4, 1}).add({1, 3, 2, 3})
670 .add({3, 3, 3, 2}).add({5, 1, 4, 4})
671 .add({2, 5, 1, 5}).add({4, 3, 5, 1})
672 .add({1, 5, 2, 5}).add({5, 3, 3, 2})
683 for (
int n=1024*16;
n--; )
690 ts.
add({1}).add({2}).add({3}).finalize();
696 ts.
add({m+0,m+1,m+2}).add({m+4,m+1,m+3})
697 .add({m+2,m+3,m+0}).add({m+2,m+3,m+0})
698 .add({m+1,m+2,m+5}).add({m+2,m+3,m+0})
699 .add({m+3,m+6,m+5}).finalize();
705 ts.
add({M-0,M-1,M-2}).add({M-4,M-1,M-3})
706 .add({M-2,M-3,M-0}).add({M-2,M-3,M-0})
707 .add({M-1,M-2,M-5}).add({M-2,M-3,M-0})
708 .add({M-3,M-6,M-5}).finalize();
715 ts.
add({M-0,m+1,M-2}).add({m+4,M-1,M-3})
716 .add({m+2,M-3,m+0}).add({M-2,M-3,M-0})
724 for (
int i = 0;
i < 10000;
i++) {
726 for (
int j = 0; j < 7; j++) {
735 for (
int i = 0;
i <= 64*6;
i+=32)
752 for (
int i = 4;
i--; ) tuple[
i] = ass[
i];
764 t.add({ass[0],0,ass[1],ass[2]});
778 for (
int i = 9;
i--; ) tuple[
i+1] = ass[
i];
783 t.add({1,1,1,1,1,1,1,1,1,1});
784 t.add({1,2,3,4,4,2,1,2,3,3});
818 RegOpt ro2(
static_cast<int>(UCHAR_MAX-1));
822 RegOpt ro6(
static_cast<int>(USHRT_MAX-1));
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.
Gecode::TupleSet t
Tupleset used for testing.
RegDistinct(void)
Create and register test.
Post propagator for SetVar SetOpType SetVar y
bool testsearch
Whether to perform search test.
TupleSet & add(const IntArgs &t)
Add tuple t to tuple set.
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
Gecode::IntPropLevel ipl
Propagation level.
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
Generate random selection of assignments.
RegEmptyREG(void)
Create and register test.
Passing integer variables.
virtual bool solution(const Assignment &x) const
Test whether x is solution
unsigned int size(I &i)
Size of all ranges of range iterator i.
TupleSetLarge(double prob, bool p)
Create and register test.
virtual bool solution(const Assignment &x) const
Test whether x is solution
RegOpt ro6(static_cast< int >(USHRT_MAX-1))
RandomTupleSetTest(const std::string &s, bool p, Gecode::IntSet d0, Gecode::TupleSet ts0)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
const FloatNum min
Smallest allowed float value.
Gecode::TupleSet t
Simple test tupleset.
RegSharedB(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Regular expressions over integer values.
RegOpt(int n0)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
static Gecode::Support::RandomGenerator rand
Random number generator.
TupleSetTestSize(int size, bool pos)
Perform creation and registration.
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)
Post constraint on x.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
bool toDFA
Whether to validate dfa2tupleset.
virtual bool solution(const Assignment &x) const
Test whether x is solution
RegSimpleB(void)
Create and register test.
Gecode toplevel namespace
RegSimpleC(void)
Create and register test.
RegEmptyDFA(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
Node * x
Pointer to corresponding Boolean expression node.
virtual bool solution(const Assignment &x) const
Test whether x is solution
void finalize(void)
Finalize tuple set.
TupleSetBool(double prob, bool p)
Create and register test.
TupleSetBase(bool p)
Create and register test.
Reification specification.
Passing Boolean variables.
RegRoland(int n)
Create and register test.
Test with simple regular expression
Test with regular expression for distinct constraint
Specification of a DFA transition.
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, Gecode::Reify r)
Post reified constraint on x for r.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Test with simple regular expression and shared variables (uses unsharing)
int o_state
output state Default constructor
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
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)
Create and register test.
Help class to create and register tests with a fixed table size.
virtual bool solution(const Assignment &x) const
Test whether x is solution
int * Tuple
Type of a tuple.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x, Gecode::Reify r)
Post reified constraint on x for r.
Gecode::DFA tupleset2dfa(Gecode::TupleSet ts)
% Transform a TupleSet into a DFA
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
const int max
Largest allowed integer value.
RegSharedA(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegOpt ro2(static_cast< int >(UCHAR_MAX-1))
Test with large tuple set
Class represeting a set of tuples.
virtual bool solution(const Assignment &x) const
Test whether x is solution
int arity
Number of variables.
RegSimpleA(void)
Create and register test.
int n
DFA size characteristic.
Create(void)
Perform creation and registration.
Gecode::TupleSet ts
The tuple set to use.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegOpt ro3(static_cast< int >(UCHAR_MAX))
Generate all assignments.
bool pos
Whether the table is positive or negative.
Base class for assignments
Test with simple regular expression
Deterministic finite automaton (DFA)
Test with simple regular expression and shared variables (uses unsharing)
bool pos
Whether the table is positive or negative.
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.
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
Test with simple regular expression
Help class to create and register tests.
RegOpt ro7(static_cast< int >(USHRT_MAX))
RegSharedD(void)
Create and register test.
Test with simple regular expression and shared variables (uses unsharing)
Test with simple regular expression from Roland Yap
void unshare(Home home, VarArgArray< Var > &x, IntPropLevel ipl)
Replace unassigned shared variables by fresh, yet equal variables.
virtual Assignment * assignment(void) const
Create and register initial assignment.
int tuples(void) const
Number of tuples.
const int min
Smallest allowed integer value.
int arity(void) const
Arity of tuple set.
void extensional(Home home, const IntVarArgs &x, DFA dfa, IntPropLevel)
Post domain consistent propagator for extensional constraint described by a DFA.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
bool same(VarArgArray< Var > x, VarArgArray< Var > y)
virtual bool solution(const Assignment &x) const
Test whether x is solution
int n
Number of negative literals for node type.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Passing integer arguments.
Gecode::IntArgs i({1, 2, 3, 4})
bool pos(const View &x)
Test whether x is postive.
Gecode::TupleSet t
Tupleset used for testing.
int p
Number of positive literals for node type.
virtual bool solution(const Assignment &x) const
Test whether x is solution
const FloatNum max
Largest allowed float value.
virtual bool solution(const Assignment &x) const
Test whether x is solution
RegSharedC(void)
Create and register test.
bool pos
Whether the table is positive or negative.
Gecode::IntSet dom
Domain of variables.
Test for empty regular expression
Gecode::TupleSet randomTupleSet(int n, int min, int max, double prob)
Test with simple regular expression and shared variables (uses unsharing)
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.