46 namespace Test {
namespace Set {
51 static_cast<unsigned int>(
pow(static_cast<double>(2.0),
64 static_cast<unsigned int>(
pow(static_cast<double>(2.0),
73 :
n(n0), dsv(new
CountableSet[
n]), ir(_withInt, d0), done(false), lub(d0),
112 for (
int i=0;
i<
n;
i++) {
115 os << icsv << ((i!=n-1) ?
"," :
"}");
122 namespace Test {
namespace Set {
126 :
d(d0), y(*this, i,
d),
128 reified(false), test(t) {
134 dom(*
this,
x[0],_x[0]);
138 olog <<
ind(2) <<
"Initial: x[]=" <<
x;
139 olog <<
" y[]=" <<
y;
150 olog <<
ind(2) <<
"Initial: x[]=" <<
x;
151 olog <<
" y[]=" <<
y;
159 reified(s.reified), test(s.test) {
164 b.
update(*
this, share, sr);
178 olog <<
ind(3) <<
"Posting reified propagator" << std::endl;
182 olog <<
ind(3) <<
"Posting propagator" << std::endl;
189 olog <<
ind(3) <<
"Fixpoint: x[]=" <<
x
190 <<
" y[]=" <<
y << std::endl;
193 <<
" y[]=" <<
y << std::endl;
203 olog <<
ind(4) <<
"x[" << i <<
"] ";
216 olog << is << std::endl;
224 olog <<
ind(4) << cmin <<
" <= #(x[" << i <<
"]) <= " << cmax
233 olog <<
ind(4) <<
"y[" << i <<
"] ";
242 olog <<
" " << n << std::endl;
252 olog <<
ind(4) <<
"b = " << n << std::endl;
258 for (
int i=a.
size();
i--; ) {
292 for (
int j=0; j<
v; j++, ++diffV) {}
305 for (
int j=0; j<
v; j++, ++interV) {}
315 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
318 delete c;
return false;
322 if (
x[
i].glbSize() != c->
x[
i].glbSize() ||
323 x[
i].lubSize() != c->
x[
i].lubSize() ||
324 x[
i].cardMin() != c->
x[
i].cardMin() ||
325 x[
i].cardMax() != c->
x[
i].cardMax()) {
331 delete c;
return false;
334 delete c;
return false;
337 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
345 bool setsAssigned =
true;
346 for (
int j=
x.
size(); j--; )
348 setsAssigned =
false;
351 bool intsAssigned =
true;
352 for (
int j=
y.
size(); j--; )
354 intsAssigned =
false;
362 }
else if (setsAssigned) {
368 if (setsAssigned || i>=
x.
size()) {
372 i = (i+1) %
y.
size();
379 if (a.
ints()[
i] <
y[
i].max()) {
382 assert((v > a.
ints()[
i]) && (v <=
y[i].
max()));
387 if (a.
ints()[
i] >
y[
i].min()) {
390 assert((v < a.
ints()[
i]) && (v >=
y[i].
min()));
399 if (it.
width() > skip) {
401 if (v == a.
ints()[
i]) {
402 if (it.
width() == 1) {
404 }
else if (v < it.
max()) {
420 i = (i+1) %
x.
size();
426 Gecode::SetVarUnknownRanges ur2(
x[i]);
449 if (
x[i].cardMin() < aisize) {
450 unsigned int newc =
x[
i].cardMin() + 1 +
452 assert( newc >
x[i].cardMin() );
453 assert( newc <= aisize );
458 if (
x[i].cardMax() > aisize) {
459 unsigned int newc =
x[
i].cardMax() - 1 -
461 assert( newc <
x[i].cardMax() );
462 assert( newc >= aisize );
480 #define CHECK_TEST(T,M) \
482 olog << ind(3) << "Check: " << (M) << std::endl; \
484 problem = (M); delete s; goto failed; \
488 #define START_TEST(T) \
491 olog << ind(2) << "Testing: " << (T) << std::endl; \
498 const char*
test =
"NONE";
499 const char* problem =
"NONE";
504 bool is_sol = solution(a);
506 olog <<
ind(1) <<
"Assignment: " << a
507 << (is_sol ?
" (solution)" :
" (no solution)")
518 olog <<
ind(3) <<
"No copy" << std::endl;
524 olog <<
ind(3) <<
"Unshared copy" << std::endl;
533 olog <<
ind(3) <<
"Unshared copy" << std::endl;
540 default: assert(
false);
570 problem =
"No fixpoint";
585 START_TEST(
"Assignment reified (rewrite after post, <=>)");
595 START_TEST(
"Assignment reified (rewrite after post, =>)");
605 START_TEST(
"Assignment reified (rewrite after post, <=)");
616 START_TEST(
"Assignment reified (rewrite failure, <=>)");
625 START_TEST(
"Assignment reified (rewrite failure, =>)");
639 START_TEST(
"Assignment reified (rewrite failure, <=)");
652 START_TEST(
"Assignment reified (immediate rewrite, <=>)");
662 START_TEST(
"Assignment reified (immediate rewrite, =>)");
672 START_TEST(
"Assignment reified (immediate rewrite, <=)");
682 START_TEST(
"Assignment reified (immediate failure, <=>)");
691 START_TEST(
"Assignment reified (immediate failure, =>)");
705 START_TEST(
"Assignment reified (immediate failure, <=)");
719 START_TEST(
"Assignment reified (before posting, <=>)");
734 START_TEST(
"Assignment reified (before posting, =>)");
749 START_TEST(
"Assignment reified (before posting, <=)");
764 START_TEST(
"Assignment reified (after posting, <=>)");
779 START_TEST(
"Assignment reified (after posting, =>)");
794 START_TEST(
"Assignment reified (after posting, <=)");
816 problem =
"No fixpoint";
837 problem =
"No fixpoint";
858 problem =
"No fixpoint";
879 olog <<
"FAILURE" << std::endl
880 <<
ind(1) <<
"Test: " << test << std::endl
881 <<
ind(1) <<
"Problem: " << problem << std::endl;
883 olog <<
ind(1) <<
"Assignment: " << a << std::endl;
void removeFromLub(int v, int i, const SetAssignment &a)
Remove value v from the upper bound of x[i].
void operator++(void)
Move to next subset.
void cardinality(int i, int cmin, int cmax)
Perform cardinality tell operation on x[i].
SetRelType
Common relation types for sets.
int size(void) const
Return arity.
Inverse implication for reification.
ReifyMode mode(void) const
Return reification mode.
Simple class for describing identation.
Gecode::Reify r
Reification information.
const int min
Smallest allowed integer in integer set.
Range iterator for integer sets.
void log(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
const FloatNum max
Largest allowed float value.
BoolVar var(void) const
Return Boolean control variable.
void update(Space &home, bool share, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
static Gecode::Support::RandomGenerator rand
Random number generator.
Gecode::SetVarArray x
Set variables to be tested.
Space * clone(bool share=true, CloneStatistics &stat=unused_clone) const
Clone space.
void assign(const SetAssignment &a)
Assign all variables to values in a.
int val(void) const
Return current subset.
void pow(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n 0$.
unsigned int size(void) const
Return size (cardinality) of domain.
CountableSet(void)
Default constructor.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
SetOpType
Common operations for sets.
const unsigned int card
Maximum cardinality of an integer set.
SetAssignment(int n, const Gecode::IntSet &d, int i=0)
Initialize with n set variables, initial bound d and i int variables.
const int max
Largest allowed integer in integer set.
int val(void) const
Return assigned value.
ChannelShared csv(Gecode::ICL_VAL)
Iterator for the unknown ranges of a set variable.
bool reified
Whether the test is for a reified propagator.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
void rel(int i, Gecode::SetRelType srt, const Gecode::IntSet &is)
Perform set tell operation on x[i].
unsigned int propagators(void) const
Return number of propagators.
const FloatNum min
Smallest allowed float value.
int min(void) const
Return smallest value of range.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
bool assigned(void) const
Test whether all variables are assigned.
IntRelType
Relation types for integers.
Range iterator for computing intersection (binary)
const Test::Int::Assignment & ints(void) const
Return assignment for integer variables.
static bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
void post(void)
Post propagator.
bool failed(void)
Compute a fixpoint and check for failure.
Value iterator from range iterator.
unsigned int size(I &i)
Size of all ranges of range iterator i.
virtual bool run(void)
Perform test.
bool log
Whether to log the tests.
Gecode::IntSet lub
The common superset for all domains.
#define START_TEST(T)
Start new test.
struct Gecode::Space::@52::@54 c
Data available only during copying.
static const IntSet empty
Empty set.
Gecode::IntSet d
Initial domain.
SetTestSpace(int n, Gecode::IntSet &d0, int i, SetTest *t, bool log=true)
Create test space without reification.
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Boolean integer variables.
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
SetExpr inter(const SetVarArgs &x)
Intersection of set variables.
union Gecode::@518::NNF::@57 u
Union depending on nodetype t.
bool prune(const SetAssignment &a)
Perform random pruning.
int withInt
How many integer variables to iterate.
void addToGlb(int v, int i, const SetAssignment &a)
Remove value v from the lower bound of x[i].
virtual void post(Gecode::Space &home, Gecode::SetVarArray &x, Gecode::IntVarArray &y)=0
Post propagator.
Base class for tests with set constraints
Generate all set assignments.
void operator++(void)
Move to next assignment.
bool fixprob(void)
Perform fixpoint computation.
std::ostringstream olog
Stream used for logging.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Gecode::IntVarArray y
Int variables to be tested.
Range iterator producing subsets of an IntSet.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
int withInt
How many integer variables are used by the test.
bool assigned(void) const
Test whether view is assigned.
int max(void) const
Return largest value of range.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
Implication for reification.
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const FloatView &x)
Print float variable view.
Range iterator for computing set difference.
#define CHECK_TEST(T, M)
Check the test result and handle failed test.
SetTest * test
The test currently run.
Space for executing set tests.
Iterate all subsets of a given set.
int size(void) const
Return size of array (number of elements)
ReifyMode
Mode for reification.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
virtual Gecode::Space * copy(bool share)
Copy space during cloning.
void init(const Gecode::IntSet &s)
Initialize with set s.
Equivalence for reification (default)