50 template<
bool useCount>
56 :
Test(
std::string(useCount ?
"Count::Distinct::" :
"Distinct::")+
60 :
Test(
std::string(useCount ?
"Count::Distinct::" :
"Distinct::")+
61 str(
ipl)+
"::Dense",6,min,max,false,
ipl) {}
64 for (
int i=0; i<x.
size(); i++)
65 for (
int j=i+1; j<x.
size(); j++)
93 :
Test(
"Distinct::Offset::Dense::"+
str(
ipl),6,min,max,false,
ipl) {}
96 for (
int i=0; i<x.
size(); i++)
97 for (
int j=i+1; j<x.
size(); j++)
105 for (
int i=0; i<x.
size(); i++)
120 int n = x.
size() / 2;
121 for (
int i=0; i<n; i++)
122 if ((x[i] < 0) || (x[i] > 1))
124 for (
int i=0; i<n; i++)
125 for (
int j=i+1; j<n; j++)
126 if ((x[i] == 1) && (x[j] == 1) && (x[n+i] == x[n+j]))
132 int n = bx.
size() / 2;
135 for (
int i=0; i<n; i++) {
154 for (
int i=0; i<x.
size(); i++)
155 for (
int j=i+1; j<x.
size(); j++)
156 if ((x[i] != 0) && (x[j] != 0) && (x[i] == x[j]))
180 for (
int i=0; i<x.
size(); i++)
181 for (
int j=i+1; j<x.
size(); j++)
215 :
Base(
"Int::Distinct::Pathological::"+
223 for (
int i=0; i<
n; i++)
227 delete s;
return false;
229 for (
int i=0; i<
n; i++)
230 if (!x[i].assigned() || (x[i].val() != i)) {
231 delete s;
return false;
238 for (
int i=0; i<
n; i++) {
243 for (
int i=
n; i<2*
n; i++)
247 delete s;
return false;
249 for (
int i=0; i<
n; i++)
250 if (!x[i].assigned() || (x[i].val() != i)) {
251 delete s;
return false;
259 const int v[7] = {-1001,-1000,-10,0,10,1000,1001};
Passing Boolean variables.
Passing integer arguments.
Range iterator for integer sets.
Value iterator for integer sets.
Passing integer variables.
int size(void) const
Return size of array (number of elements).
Gecode::Support::RandomGenerator _rand
Random number generator.
Base(std::string s)
Create and register test with name s.
static std::string str(bool b)
Map bool to string.
Base class for assignments
int size(void) const
Return number of variables.
Simple test for distinct constraint.
Distinct(int min, int max, Gecode::IntPropLevel ipl)
Create and register test.
Distinct(const Gecode::IntSet &d0, Gecode::IntPropLevel ipl, int n=6)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
Simple test for distinct except constant constraint.
Except(const Gecode::IntArgs &d, Gecode::IntPropLevel ipl)
Create and register test.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on bx.
Simple test for distinct constraint with offsets.
Offset(const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Offset(int min, int max, Gecode::IntPropLevel ipl)
Create and register test.
Simple test for optional distinct constraint.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &bx)
Post constraint on bx.
Optional(const Gecode::IntArgs &d, Gecode::IntPropLevel ipl)
Create and register test.
virtual Gecode::Space * copy(void)
Copy space during cloning.
TestSpace(TestSpace &s)
Constructor for cloning s.
TestSpace(void)
Constructor.
Testing pathological cases
int n
Number of variables.
virtual bool run(void)
Perform test.
Pathological(int n0, Gecode::IntPropLevel ipl0)
Create and register test.
Gecode::IntPropLevel ipl
Consistency level.
Randomized test for distinct constraint.
virtual Assignment * assignment(void) const
Create and register initial assignment.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Random(int n, int min, int max, Gecode::IntPropLevel ipl)
Create and register test.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
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.
ConTestLevel contest
Whether to test for certain consistency.
IntPropLevel
Propagation levels for integer propagators.
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
@ IPL_VAL
Value propagation.
@ IPL_BND
Bounds propagation.
Space(void)
Default constructor.
SpaceStatus status(StatusStatistics &stat)
Query space status.
@ SS_FAILED
Space is failed
const int min
Smallest allowed integer value.
const int max
Largest allowed integer value.
unsigned int size(I &i)
Size of all ranges of range iterator i.
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 distinct(Home home, const IntVarArgs &x, IntPropLevel ipl=IPL_DEF)
Post propagator for for all .
Except eb2(v2, Gecode::IPL_BND)
Pathological p_16_b(16, Gecode::IPL_BND)
Pathological p_16_v(16, Gecode::IPL_VAL)
Pathological p_32_v(32, Gecode::IPL_VAL)
Distinct< false > val_s(d, Gecode::IPL_VAL)
Optional od2(v2, Gecode::IPL_DOM)
Random val_r(50,-500, 500, Gecode::IPL_VAL)
Optional ob2(v2, Gecode::IPL_BND)
Gecode::IntArgs v4({0, 1, 2})
Distinct< true > count_val_s(d, Gecode::IPL_VAL)
Except ev1(v1, Gecode::IPL_VAL)
Distinct< false > dom_l(dl, Gecode::IPL_DOM, 5)
Optional ov4(v4, Gecode::IPL_VAL)
Except eb1(v1, Gecode::IPL_BND)
Except ev2(v2, Gecode::IPL_VAL)
Offset bnd_os(d, Gecode::IPL_BND)
Offset dom_od(-3, 3, Gecode::IPL_DOM)
Offset val_od(-3, 3, Gecode::IPL_VAL)
Except eb5(v5, Gecode::IPL_BND)
Distinct< true > count_dom_d(-3, 3, Gecode::IPL_DOM)
Distinct< true > count_dom_s(d, Gecode::IPL_DOM)
Gecode::IntArgs v3({0, 1, 2, 3})
Optional ob1(v1, Gecode::IPL_BND)
Except ev5(v5, Gecode::IPL_VAL)
Distinct< false > bnd_s(d, Gecode::IPL_BND)
Random dom_r(20,-50, 50, Gecode::IPL_DOM)
Optional ob5(v5, Gecode::IPL_BND)
Distinct< false > val_l(dl, Gecode::IPL_VAL, 5)
Except ed1(v1, Gecode::IPL_DOM)
Distinct< false > bnd_l(dl, Gecode::IPL_BND, 5)
Gecode::IntArgs v5({0, 1})
Optional ob4(v4, Gecode::IPL_BND)
Pathological p_32_b(32, Gecode::IPL_BND)
Gecode::IntArgs v2({Gecode::Int::Limits::min, 0, 1, Gecode::Int::Limits::max-4})
Distinct< false > val_d(-3, 3, Gecode::IPL_VAL)
Optional ov3(v3, Gecode::IPL_VAL)
Offset dom_os(d, Gecode::IPL_DOM)
Pathological p_32_d(32, Gecode::IPL_DOM)
Distinct< true > count_val_d(-3, 3, Gecode::IPL_VAL)
Gecode::IntArgs v1({Gecode::Int::Limits::min+4, 0, 1, Gecode::Int::Limits::max})
Distinct< false > dom_d(-3, 3, Gecode::IPL_DOM)
Pathological p_16_d(16, Gecode::IPL_DOM)
Except ed5(v5, Gecode::IPL_DOM)
Optional od4(v4, Gecode::IPL_DOM)
Optional ov5(v5, Gecode::IPL_VAL)
Distinct< false > dom_s(d, Gecode::IPL_DOM)
Offset val_os(d, Gecode::IPL_VAL)
Optional ov1(v1, Gecode::IPL_VAL)
Distinct< true > count_bnd_s(d, Gecode::IPL_BND)
Optional od3(v3, Gecode::IPL_DOM)
Optional ob3(v3, Gecode::IPL_BND)
Except ed2(v2, Gecode::IPL_DOM)
Offset bnd_od(-3, 3, Gecode::IPL_BND)
Random bnd_r(50,-500, 500, Gecode::IPL_BND)
Distinct< true > count_bnd_d(-3, 3, Gecode::IPL_BND)
Optional od5(v5, Gecode::IPL_DOM)
Optional ov2(v2, Gecode::IPL_VAL)
Distinct< false > bnd_d(-3, 3, Gecode::IPL_BND)
Optional od1(v1, Gecode::IPL_DOM)
Testing finite domain integers.
@ CTL_NONE
No consistency-test.