Go to the documentation of this file.
42 namespace Test {
namespace Set {
47 static_cast<unsigned int>(
pow(static_cast<double>(2.0),
60 static_cast<unsigned int>(
pow(static_cast<double>(2.0),
69 :
n(n0), dsv(new
CountableSet[
n]), ir(_withInt, d0), done(false), lub(d0),
108 for (
int i=0;
i<
n;
i++) {
111 os << icsv << ((
i!=
n-1) ?
"," :
"}");
118 namespace Test {
namespace Set {
122 :
d(d0),
y(*this,
i,
d),
124 reified(false), test(
t) {
130 dom(*
this,
x[0],_x[0]);
134 olog <<
ind(2) <<
"Initial: x[]=" <<
x;
135 olog <<
" y[]=" <<
y;
146 olog <<
ind(2) <<
"Initial: x[]=" <<
x;
147 olog <<
" y[]=" <<
y;
155 reified(s.reified), test(s.test) {
174 olog <<
ind(3) <<
"Posting reified propagator" << std::endl;
178 olog <<
ind(3) <<
"Posting propagator" << std::endl;
185 olog <<
ind(3) <<
"Fixpoint: x[]=" <<
x
186 <<
" y[]=" <<
y << std::endl;
189 <<
" y[]=" <<
y << std::endl;
204 olog <<
ind(4) <<
"x[" <<
i <<
"] ";
217 olog << is << std::endl;
225 olog <<
ind(4) << cmin <<
" <= #(x[" <<
i <<
"]) <= " << cmax
234 olog <<
ind(4) <<
"y[" <<
i <<
"] ";
243 olog <<
" " <<
n << std::endl;
253 olog <<
ind(4) <<
"b = " <<
n << std::endl;
259 for (
int i=
a.size();
i--; ) {
293 for (
int j=0; j<
v; j++, ++diffV) {}
307 for (
int j=0; j<
v; j++, ++diffV) {}
321 for (
int j=0; j<
v; j++, ++interV) {}
335 for (
int j=0; j<
v; j++, ++interV) {}
346 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
349 delete c;
return false;
353 if (
x[
i].glbSize() !=
c->x[
i].glbSize() ||
354 x[
i].lubSize() !=
c->x[
i].lubSize() ||
355 x[
i].cardMin() !=
c->x[
i].cardMin() ||
356 x[
i].cardMax() !=
c->x[
i].cardMax()) {
361 if (
y[
i].
size() !=
c->y[
i].size()) {
362 delete c;
return false;
365 delete c;
return false;
368 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
376 olog <<
ind(3) <<
"Testing whether enabled space is the same"
379 bool cf =
c.failed();
386 if (
x[
i].glbSize() !=
c.x[
i].glbSize() ||
387 x[
i].lubSize() !=
c.x[
i].lubSize() ||
388 x[
i].cardMin() !=
c.x[
i].cardMin() ||
389 x[
i].cardMax() !=
c.x[
i].cardMax())
399 olog <<
ind(3) <<
"Finished testing whether enabled space is the same"
407 bool setsAssigned =
true;
408 for (
int j=
x.
size(); j--; )
410 setsAssigned =
false;
413 bool intsAssigned =
true;
414 for (
int j=
y.
size(); j--; )
416 intsAssigned =
false;
424 }
else if (setsAssigned) {
430 if (setsAssigned ||
i>=
x.
size()) {
441 if (
a.ints()[
i] <
y[
i].max()) {
444 assert((
v >
a.ints()[
i]) && (
v <=
y[
i].
max()));
449 if (
a.ints()[
i] >
y[
i].min()) {
452 assert((
v <
a.ints()[
i]) && (
v >=
y[
i].
min()));
461 if (it.
width() > skip) {
463 if (
v ==
a.ints()[
i]) {
464 if (it.
width() == 1) {
466 }
else if (
v < it.
max()) {
511 if (
x[
i].cardMin() < aisize) {
512 unsigned int newc =
x[
i].cardMin() + 1 +
514 assert( newc >
x[
i].cardMin() );
515 assert( newc <= aisize );
520 if (
x[
i].cardMax() > aisize) {
521 unsigned int newc =
x[
i].cardMax() - 1 -
523 assert( newc <
x[
i].cardMax() );
524 assert( newc >= aisize );
544 bool setsAssigned =
true;
545 for (
int j=
x.
size(); j--; )
547 setsAssigned =
false;
550 bool intsAssigned =
true;
551 for (
int j=
y.
size(); j--; )
553 intsAssigned =
false;
561 }
else if (setsAssigned) {
567 if (setsAssigned ||
i>=
x.
size()) {
578 if (
a.ints()[
i] <
y[
i].max()) {
581 assert((
v >
a.ints()[
i]) && (
v <=
y[
i].
max()));
587 if (
a.ints()[
i] >
y[
i].min()) {
590 assert((
v <
a.ints()[
i]) && (
v >=
y[
i].
min()));
600 if (it.
width() > skip) {
602 if (
v ==
a.ints()[
i]) {
603 if (it.
width() == 1) {
605 }
else if (
v < it.
max()) {
652 if (
x[
i].cardMin() < aisize) {
653 unsigned int newc =
x[
i].cardMin() + 1 +
655 assert( newc >
x[
i].cardMin() );
656 assert( newc <= aisize );
662 if (
x[
i].cardMax() > aisize) {
663 unsigned int newc =
x[
i].cardMax() - 1 -
665 assert( newc <
x[
i].cardMax() );
666 assert( newc >= aisize );
668 c.cardinality(
i, 0, newc);
702 #define CHECK_TEST(T,M) \
704 olog << ind(3) << "Check: " << (M) << std::endl; \
706 problem = (M); delete s; goto failed; \
710 #define START_TEST(T) \
713 olog << ind(2) << "Testing: " << (T) << std::endl; \
720 const char*
test =
"NONE";
721 const char* problem =
"NONE";
726 bool is_sol = solution(
a);
728 olog <<
ind(1) <<
"Assignment: " <<
a
729 << (is_sol ?
" (solution)" :
" (no solution)")
739 olog <<
ind(3) <<
"No copy" << std::endl;
745 olog <<
ind(3) <<
"Copy" << std::endl;
747 sc = static_cast<SetTestSpace*>(s->
clone());
752 default: assert(
false);
763 START_TEST(
"Assignment (after posting, disable)");
797 problem =
"No fixpoint";
815 s->
post();
c->post();
818 problem =
"Different result after re-enable";
823 if (s->
failed() !=
c->failed()) {
824 problem =
"Different failure after re-enable";
832 START_TEST(
"Assignment reified (rewrite after post, <=>)");
842 START_TEST(
"Assignment reified (rewrite after post, =>)");
852 START_TEST(
"Assignment reified (rewrite after post, <=)");
863 START_TEST(
"Assignment reified (rewrite failure, <=>)");
872 START_TEST(
"Assignment reified (rewrite failure, =>)");
886 START_TEST(
"Assignment reified (rewrite failure, <=)");
899 START_TEST(
"Assignment reified (immediate rewrite, <=>)");
909 START_TEST(
"Assignment reified (immediate rewrite, =>)");
919 START_TEST(
"Assignment reified (immediate rewrite, <=)");
929 START_TEST(
"Assignment reified (immediate failure, <=>)");
938 START_TEST(
"Assignment reified (immediate failure, =>)");
952 START_TEST(
"Assignment reified (immediate failure, <=)");
966 START_TEST(
"Assignment reified (before posting, <=>)");
981 START_TEST(
"Assignment reified (before posting, =>)");
996 START_TEST(
"Assignment reified (before posting, <=)");
1011 START_TEST(
"Assignment reified (after posting, <=>)");
1026 START_TEST(
"Assignment reified (after posting, =>)");
1041 START_TEST(
"Assignment reified (after posting, <=)");
1056 START_TEST(
"Assignment reified (after posting, <=>, disable)");
1073 START_TEST(
"Assignment reified (after posting, =>, disable)");
1090 START_TEST(
"Assignment reified (after posting, <=, disable)");
1114 problem =
"No fixpoint";
1135 problem =
"No fixpoint";
1157 problem =
"No fixpoint";
1178 olog <<
"FAILURE" << std::endl
1179 <<
ind(1) <<
"Test: " <<
test << std::endl
1180 <<
ind(1) <<
"Problem: " << problem << std::endl;
1182 olog <<
ind(1) <<
"Assignment: " <<
a << std::endl;
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
void pow(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n\geq 0$.
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
IntRelType
Relation types for integers.
Post propagator for SetVar SetOpType SetVar y
Gecode::SetVarArray x
Set variables to be tested.
Space for executing set tests.
void enable(void)
Enable propagators in space.
Inverse implication for reification.
void post(void)
Post propagator.
bool failed(void)
Compute a fixpoint and check for failure.
int min(void) const
Return smallest value of range.
virtual void post(Gecode::Space &home, Gecode::SetVarArray &x, Gecode::IntVarArray &y)=0
Post propagator.
void log(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
unsigned int size(I &i)
Size of all ranges of range iterator i.
static const IntSet empty
Empty set.
bool disabled(const SetAssignment &a, SetTestSpace &c)
Prune values also in a space c with disabled propagators, but not those in assignment a.
Gecode::IntSet lub
The common superset for all domains.
const int min
Smallest allowed integer in integer set.
unsigned int size(Space &home) const
Return number of propagators in a group.
void removeFromLub(int v, int i, const SetAssignment &a)
Remove value v from the upper bound of x[i].
Gecode::Reify r
Reification information.
Implication for reification.
Gecode::IntVarArray y
Int variables to be tested.
void disable(Space &home)
Disable all propagators in a group.
const FloatNum min
Smallest allowed float value.
SetOpType
Common operations for sets.
#define START_TEST(T)
Start new test.
bool assigned(void) const
Test whether view is assigned.
void init(const Gecode::IntSet &s)
Initialize with set s.
void operator++(void)
Move to next subset.
static Gecode::Support::RandomGenerator rand
Random number generator.
Range iterator for integer sets.
void disable(void)
Disable propagators in space and compute fixpoint (make all idle)
int size(void) const
Return size of array (number of elements)
Generate all set assignments.
struct Gecode::Space::@61::@63 c
Data available only during copying.
union Gecode::@602::NNF::@65 u
Union depending on nodetype t.
Gecode toplevel namespace
void enable(Space &home, bool s=true)
Enable all propagators in a group.
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
bool subsumed(bool b)
Check for subsumption if b is true.
int withInt
How many integer variables to iterate.
const int max
Largest allowed integer in integer set.
const unsigned int card
Maximum cardinality of an integer set.
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const FloatView &x)
Print float variable view.
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
static PropagatorGroup all
Group of all propagators.
Equivalence for reification (default)
void operator++(void)
Move to next assignment.
void rel(int i, Gecode::SetRelType srt, const Gecode::IntSet &is)
Perform set tell operation on x[i].
bool prune(const SetAssignment &a)
Perform random pruning.
Value iterator from range iterator.
bool log
Whether to log the tests.
Range iterator for computing intersection (binary)
int val(void) const
Return current subset.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Range iterator for computing set difference.
Boolean integer variables.
Gecode::IntSet d
Initial domain.
Base class for tests with set constraints
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
#define CHECK_TEST(T, M)
Check the test result and handle failed test.
SetRelType
Common relation types for sets.
unsigned int propagators(void)
Return the number of propagators.
SetTest * test
The test currently run.
static bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
bool fixprob(void)
Perform fixpoint computation.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
ChannelShared csv(Gecode::IPL_VAL)
bool same(SetTestSpace &c)
Check whether propagation is the same as in c.
void cardinality(int i, int cmin, int cmax)
Perform cardinality tell operation on x[i].
BoolVar var(void) const
Return Boolean control variable.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
int withInt
How many integer variables are used by the test.
SetTestSpace(int n, Gecode::IntSet &d0, int i, SetTest *t, bool log=true)
Create test space without reification.
ReifyMode
Mode for reification.
void addToGlb(int v, int i, const SetAssignment &a)
Remove value v from the lower bound of x[i].
Iterate all subsets of a given set.
Simple class for describing identation.
int max(void) const
Return largest value of range.
ReifyMode mode(void) const
Return reification mode.
Range iterator producing subsets of an IntSet.
void assign(const SetAssignment &a)
Assign all variables to values in a.
Iterator for the unknown ranges of a set variable.
int val(void) const
Return assigned value.
CountableSet(void)
Default constructor.
int n
Number of negative literals for node type.
std::ostringstream olog
Stream used for logging.
Gecode::IntArgs i({1, 2, 3, 4})
SetExpr inter(const SetVarArgs &x)
Intersection of set variables.
SetAssignment(int n, const Gecode::IntSet &d, int i=0)
Initialize with n set variables, initial bound d and i int variables.
virtual Gecode::Space * copy(void)
Copy space during cloning.
const FloatNum max
Largest allowed float value.
bool assigned(void) const
Test whether all variables are assigned.
virtual bool run(void)
Perform test.
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
bool reified
Whether the test is for a reified propagator.
unsigned int size(void) const
Return size (cardinality) of domain.