45 namespace Test {
namespace Int {
48 namespace Extensional {
62 return (((x[0] == 0) || (x[0] == 2)) &&
63 ((x[1] == -1) || (x[1] == 1)) &&
64 ((x[2] == 0) || (x[2] == 1)) &&
65 ((x[3] == 0) || (x[3] == 1)));
85 return (x[0]<x[1]) && (x[1]<x[2]) && (x[2]<x[3]);
109 while (pos < s && x[pos] == 0) ++
pos;
110 if (pos + 4 > s)
return false;
112 for (
int i = 0;
i < 2; ++
i, ++
pos)
113 if (x[pos] != 1)
return false;
114 if (pos + 2 > s)
return false;
116 for (
int i = 0;
i < 1; ++
i, ++
pos)
117 if (x[pos] != 0)
return false;
118 while (pos < s && x[pos] == 0) ++
pos;
119 if (pos + 1 > s)
return false;
121 for (
int i = 0;
i < 1; ++
i, ++
pos)
122 if (x[pos] != 1)
return false;
123 while (pos < s)
if (x[pos++] != 0)
return false;
142 for (
int i=0;
i<x.
size();
i++) {
143 if ((x[
i] < 0) || (x[
i] > 3))
145 for (
int j=
i+1; j<x.
size(); j++)
187 :
Test(
"Extensional::Reg::Roland::"+
str(n),n,0,1) {}
192 ((n > 1) && (x[n-2] == 0)) ||
193 ((n > 0) && (x[n-1] == 0));
211 return (((x[0] == 0) || (x[0] == 2)) &&
212 ((x[1] == -1) || (x[1] == 1)) &&
213 ((x[2] == 0) || (x[2] == 1)) &&
214 ((x[3] == 0) || (x[3] == 1)));
220 for (
int i=0;
i<4;
i++)
238 return (((x[0] == 0) || (x[0] == 2)) &&
239 ((x[1] == -1) || (x[1] == 1)) &&
240 ((x[2] == 0) || (x[2] == 1)) &&
241 ((x[3] == 0) || (x[3] == 1)));
247 for (
int i=0;
i<4;
i++)
248 y[
i]=y[
i+4]=y[
i+8]=x[
i];
265 return (x[1]==1) && (x[2]==0) && (x[3]==1);
271 for (
int i=0;
i<4;
i++)
286 return (x[1]==1) && (x[2]==0) && (x[3]==1);
292 for (
int i=0;
i<4;
i++)
346 :
Test(
"Extensional::Reg::Opt::"+
str(n0),1,0,15), n(n0) {}
349 return (x[0] < n) && ((x[0] & 1) == 0);
356 int* f =
new int[n+1];
358 for (
int i=0;
i<
n;
i++) {
369 DFA d(0, t, f,
false);
385 :
Test(
"Extensional::TupleSet::A::"+
str(epk0),
389 return ((x[0] == 1 && x[1] == 3 && x[2] == 2 && x[3] == 3) ||
390 (x[0] == 2 && x[1] == 1 && x[2] == 2 && x[3] == 4) ||
391 (x[0] == 2 && x[1] == 2 && x[2] == 1 && x[3] == 4) ||
392 (x[0] == 3 && x[1] == 3 && x[2] == 3 && x[3] == 2) ||
393 (x[0] == 4 && x[1] == 3 && x[2] == 4 && x[3] == 1)
436 :
Test(
"Extensional::TupleSet::B::"+
str(epk0),
467 for (
int j = 0; j < t.
arity() &&
same; ++j)
468 if (l[j] != x[j]) same =
false;
469 if (same)
return true;
491 :
Test(
"Extensional::TupleSet::Bool::"+
str(epk0),
499 for (
int i = 5;
i--; ) tuple[
i] = ass[
i];
512 for (
int j = 0; j < t.
arity() &&
same; ++j)
513 if (l[j] != x[j]) same =
false;
514 if (same)
return true;
549 RegOpt ro2(static_cast<int>(UCHAR_MAX-1));
553 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.
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
TupleSetBool tsbools(Gecode::EPK_SPEED, 0.3)
virtual bool solution(const Assignment &x) const
Test whether x is solution
void finalize(void)
Finalize tuple set.
RegEmptyREG(void)
Create and register test.
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Test with regular expression for distinct constraint
virtual bool solution(const Assignment &x) const
Test whether x is solution
static Gecode::Support::RandomGenerator rand
Random number generator.
Regular expressions over integer values.
RegOpt ro3(static_cast< int >(UCHAR_MAX))
int arity(void) const
Arity of tuple set.
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.
Test with simple regular expression and shared variables (uses unsharing)
TupleSetB tsbs(Gecode::EPK_SPEED)
Test with simple regular expression
virtual bool solution(const Assignment &x) const
Test whether x is solution
int tuples(void) const
Number of tuples.
static std::string str(Gecode::ExtensionalPropKind epk)
Map extensional propagation kind to string.
Deterministic finite automaton (DFA)
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.
Prefer speed over memory consumption.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Specification of a DFA transition.
virtual bool solution(const Assignment &x) const
Test whether x is solution
void extensional(Home home, const BoolVarArgs &x, const TupleSet &t, ExtensionalPropKind epk, IntConLevel)
Post propagator for .
RegSharedB(void)
Create and register test.
RegOpt ro7(static_cast< int >(USHRT_MAX))
TupleSetA tsas(Gecode::EPK_SPEED)
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
RegEmptyDFA(void)
Create and register test.
TupleSetB(Gecode::ExtensionalPropKind epk0)
Create and register test.
TupleSetBool tsboolm(Gecode::EPK_MEMORY, 0.3)
virtual bool solution(const Assignment &x) const
Test whether x is solution
int o_state
output state Default constructor
ExtensionalPropKind
Extensional propagation kind.
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
Passing integer variables.
ExecStatus unshare(Home home, VarArgArray< Var > &x, IntConLevel icl)
Replace unassigned shared variables by fresh, yet equal variables.
Passing integer arguments.
Passing Boolean variables.
TupleSetB tsbm(Gecode::EPK_MEMORY)
Class represeting a set of tuples.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
void extensional(Home home, const IntVarArgs &x, DFA dfa, IntConLevel)
Post domain consistent propagator for extensional constraint described by a DFA.
RegSharedD(void)
Create and register test.
Node * x
Pointer to corresponding Boolean expression node.
bool testsearch
Whether to perform search test.
Gecode::ExtensionalPropKind epk
Extensional propagation kind.
Base class for assignments
virtual bool solution(const Assignment &x) const
Test whether x is solution
bool same(const Item &i, const Item &j)
Whether two items are the same.
Test with simple regular expression and shared variables (uses unsharing)
TupleSetA tsam(Gecode::EPK_MEMORY)
The default consistency for a constraint.
TupleSetA(Gecode::ExtensionalPropKind epk0)
Create and register test.
Gecode::ExtensionalPropKind epk
Extensional propagation kind.
RegOpt(int n0)
Create and register test.
Gecode::ExtensionalPropKind epk
Extensional propagation kind.
Test with simple regular expression from Roland Yap
int n
DFA size characteristic.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Prefer little memory over speed.
RegSimpleC(void)
Create and register test.
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
TupleSetBool(Gecode::ExtensionalPropKind epk0, double prob)
Create and register test.
Test for empty regular expression
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
void add(const IntArgs &tuple)
Add tuple to tuple set.
RegOpt ro6(static_cast< int >(USHRT_MAX-1))
virtual bool solution(const Assignment &x) const
Test whether x is solution
RegOpt ro2(static_cast< int >(UCHAR_MAX-1))
int size(void) const
Return size of array (number of elements)
RegSharedA(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
int size(void) const
Return number of variables.
RegSharedC(void)
Create and register test.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Domain propagation or consistency.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Test with simple regular expression and shared variables (uses unsharing)
Generate all assignments.
RegSimpleA(void)
Create and register test.
RegSimpleB(void)
Create and register test.
Test with simple regular expression