43 namespace Test {
namespace Int {
53 template<
bool useCount>
60 :
Test(
std::string(useCount ?
"Count::Distinct::" :
"Distinct::")+
61 str(ipl)+
"::Sparse::"+
str(
n),
n,d0,false,ipl) {}
64 :
Test(
std::string(useCount ?
"Count::Distinct::" :
"Distinct::")+
65 str(ipl)+
"::Dense",6,min,max,false,ipl) {}
69 for (
int j=
i+1; j<x.
size(); j++)
94 :
Test(
"Distinct::Offset::Sparse::"+
str(ipl),6,d,false,ipl) {}
97 :
Test(
"Distinct::Offset::Dense::"+
str(ipl),6,min,max,false,ipl) {}
101 for (
int j=
i+1; j<x.
size(); j++)
120 :
Test(
"Distinct::Optional::"+
str(ipl)+
"::"+
str(d),
121 6,
Gecode::IntSet(d),false,ipl) {}
124 int n = x.
size() / 2;
125 for (
int i=0;
i<
n;
i++)
126 if ((x[
i] < 0) || (x[
i] > 1))
128 for (
int i=0;
i<
n;
i++)
129 for (
int j=
i+1; j<
n; j++)
130 if ((x[
i] == 1) && (x[j] == 1) && (x[n+
i] == x[n+j]))
136 int n = bx.
size() / 2;
139 for (
int i=0;
i<
n;
i++) {
152 :
Test(
"Distinct::Except::"+
str(ipl)+
"::"+
str(d),
153 3,
Gecode::IntSet(d),false,ipl) {
159 for (
int j=
i+1; j<x.
size(); j++)
160 if ((x[
i] != 0) && (x[j] != 0) && (x[
i] == x[j]))
175 :
Test(
"Distinct::Random::"+
str(ipl),n,min,max,false,ipl) {
185 for (
int j=
i+1; j<x.
size(); j++)
210 :
Gecode::Space(share,s) {}
219 :
Base(
"Int::Distinct::Pathological::"+
227 for (
int i=0;
i<
n;
i++)
231 delete s;
return false;
233 for (
int i=0;
i<
n;
i++)
235 delete s;
return false;
242 for (
int i=0;
i<
n;
i++) {
247 for (
int i=n;
i<2*
n;
i++)
251 delete s;
return false;
253 for (
int i=0;
i<
n;
i++)
255 delete s;
return false;
263 const int v[7] = {-1001,-1000,-10,0,10,1000,1001};
267 Gecode::Int::Limits::min+2,
269 Gecode::Int::Limits::max-1,
270 Gecode::Int::Limits::max-0};
300 Gecode::Int::Limits::max);
303 Gecode::Int::Limits::max-4);
Gecode::IntArgs v3(4, 0, 1, 2, 3)
void distinct(Home home, const IntVarArgs &x, int c, IntPropLevel ipl)
Post propagator for for all .
Optional od5(v5, Gecode::IPL_DOM)
TestSpace(void)
Constructor.
Optional ob4(v4, Gecode::IPL_BND)
static std::string str(Gecode::IntPropLevel ipl)
Map integer propagation level to string.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Distinct< true > count_val_s(d, Gecode::IPL_VAL)
Distinct< true > count_bnd_s(d, Gecode::IPL_BND)
Range iterator for integer sets.
virtual Assignment * assignment(void) const
Create and register initial assignment.
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.
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel)
Post propagator for .
Distinct< false > dom_d(-3, 3, Gecode::IPL_DOM)
int size(void) const
Return number of variables.
Random bnd_r(50,-500, 500, Gecode::IPL_BND)
Distinct< true > count_bnd_d(-3, 3, Gecode::IPL_BND)
virtual bool solution(const Assignment &x) const
Check whether x is solution.
Distinct(const Gecode::IntSet &d0, Gecode::IntPropLevel ipl, int n=6)
Create and register test.
Optional ob2(v2, Gecode::IPL_BND)
Except ed5(v5, Gecode::IPL_DOM)
virtual void post(Gecode::Space &home, Gecode::IntVarArray &bx)
Post constraint on bx.
Optional od1(v1, Gecode::IPL_DOM)
Gecode::IntSet dom
Domain of variables.
Distinct< true > count_dom_d(-3, 3, Gecode::IPL_DOM)
virtual bool solution(const Assignment &x) const
Check whether x is solution.
Pathological p_16_d(16, Gecode::IPL_DOM)
Optional od3(v3, Gecode::IPL_DOM)
Except(const Gecode::IntArgs &d, Gecode::IntPropLevel ipl)
Create and register test.
Offset val_od(-3, 3, Gecode::IPL_VAL)
Distinct< false > bnd_l(dl, Gecode::IPL_BND, 5)
TestSpace(bool share, TestSpace &s)
Constructor for cloning s.
Optional ob3(v3, Gecode::IPL_BND)
ConTestLevel contest
Whether to test for certain consistency.
const int max
Largest allowed integer value.
Optional(const Gecode::IntArgs &d, Gecode::IntPropLevel ipl)
Create and register test.
Gecode::IntArgs v4(3, 0, 1, 2)
Generate random selection of assignments.
Optional ov5(v5, Gecode::IPL_VAL)
const int min
Smallest allowed integer value.
Gecode::FloatVal c(-8, 8)
Except eb2(v2, Gecode::IPL_BND)
const FloatNum min
Smallest allowed float value.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Randomized test for distinct constraint.
virtual Gecode::Space * copy(bool share)
Copy space during cloning.
Distinct< false > dom_s(d, Gecode::IPL_DOM)
Gecode::IntArgs v5(2, 0, 1)
Simple test for distinct constraint.
Except ed1(v1, Gecode::IPL_DOM)
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Except ev5(v5, Gecode::IPL_VAL)
Except ed2(v2, Gecode::IPL_DOM)
unsigned int size(I &i)
Size of all ranges of range iterator i.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
Base class for all tests to be run
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl)
Post propagator for for all .
Offset dom_os(d, Gecode::IPL_DOM)
Pathological p_16_v(16, Gecode::IPL_VAL)
Except eb1(v1, Gecode::IPL_BND)
Optional ov1(v1, Gecode::IPL_VAL)
Except eb5(v5, Gecode::IPL_BND)
Offset(const Gecode::IntSet &d, Gecode::IntPropLevel ipl)
Create and register test.
Pathological(int n0, Gecode::IntPropLevel ipl0)
Create and register test.
Simple test for optional distinct constraint.
Except ev1(v1, Gecode::IPL_VAL)
Gecode::IntPropLevel ipl
Propagation level.
Passing integer variables.
Offset val_os(d, Gecode::IPL_VAL)
Optional ob5(v5, Gecode::IPL_BND)
Passing integer arguments.
Passing Boolean variables.
Distinct< false > dom_l(dl, Gecode::IPL_DOM, 5)
Optional ov4(v4, Gecode::IPL_VAL)
Random val_r(50,-500, 500, Gecode::IPL_VAL)
Pathological p_32_v(32, Gecode::IPL_VAL)
IntPropLevel
Propagation levels for integer propagators.
Distinct< false > val_s(d, Gecode::IPL_VAL)
Gecode::IntArgs v1(4, Gecode::Int::Limits::min+4, 0, 1, Gecode::Int::Limits::max)
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.
Pathological p_32_d(32, Gecode::IPL_DOM)
Node * x
Pointer to corresponding Boolean expression node.
bool testsearch
Whether to perform search test.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
Offset bnd_os(d, Gecode::IPL_BND)
Base class for assignments
bool assigned(View x, int v)
Whether x is assigned to value v.
Random dom_r(20,-50, 50, Gecode::IPL_DOM)
Distinct< false > val_l(dl, Gecode::IPL_VAL, 5)
Domain propagation Preferences: prefer speed or memory.
Optional od2(v2, Gecode::IPL_DOM)
Value iterator for integer sets.
Optional ob1(v1, Gecode::IPL_BND)
Offset(int min, int max, Gecode::IntPropLevel ipl)
Create and register test.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Distinct< true > count_dom_s(d, Gecode::IPL_DOM)
Except ev2(v2, Gecode::IPL_VAL)
Optional od4(v4, Gecode::IPL_DOM)
Gecode::IntPropLevel ipl
Consistency level.
Distinct(int min, int max, Gecode::IntPropLevel ipl)
Create and register test.
virtual bool solution(const Assignment &x) const
Check whether x is solution.
Simple test for distinct except constant constraint.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on bx.
Testing pathological cases
Pathological p_16_b(16, Gecode::IPL_BND)
Offset dom_od(-3, 3, Gecode::IPL_DOM)
Gecode toplevel namespace
Optional ov3(v3, Gecode::IPL_VAL)
int arity
Number of variables.
virtual bool run(void)
Perform test.
Distinct< false > bnd_d(-3, 3, Gecode::IPL_BND)
Distinct< true > count_val_d(-3, 3, Gecode::IPL_VAL)
Offset bnd_od(-3, 3, Gecode::IPL_BND)
Simple test for distinct constraint with offsets.
Optional ov2(v2, Gecode::IPL_VAL)
Distinct< false > val_d(-3, 3, Gecode::IPL_VAL)
Random(int n, int min, int max, Gecode::IntPropLevel ipl)
Create and register test.
Gecode::IntArgs v2(4, Gecode::Int::Limits::min, 0, 1, Gecode::Int::Limits::max-4)
int n
Number of variables.
Distinct< false > bnd_s(d, Gecode::IPL_BND)
Pathological p_32_b(32, Gecode::IPL_BND)