Go to the documentation of this file.
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;
208 olog <<
ind(4) <<
"x[" <<
i <<
"] ";
221 olog << is << std::endl;
229 olog <<
ind(4) << cmin <<
" <= #(x[" <<
i <<
"]) <= " << cmax
238 olog <<
ind(4) <<
"y[" <<
i <<
"] ";
247 olog <<
" " <<
n << std::endl;
257 olog <<
ind(4) <<
"b = " <<
n << std::endl;
263 for (
int i=
a.size();
i--; ) {
297 for (
int j=0; j<
v; j++, ++diffV) {}
311 for (
int j=0; j<
v; j++, ++diffV) {}
325 for (
int j=0; j<
v; j++, ++interV) {}
339 for (
int j=0; j<
v; j++, ++interV) {}
350 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
353 delete c;
return false;
357 if (
x[
i].glbSize() !=
c->x[
i].glbSize() ||
358 x[
i].lubSize() !=
c->x[
i].lubSize() ||
359 x[
i].cardMin() !=
c->x[
i].cardMin() ||
360 x[
i].cardMax() !=
c->x[
i].cardMax()) {
365 if (
y[
i].
size() !=
c->y[
i].size()) {
366 delete c;
return false;
369 delete c;
return false;
372 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
380 olog <<
ind(3) <<
"Testing whether enabled space is the same"
383 bool cf =
c.failed();
390 if (
x[
i].glbSize() !=
c.x[
i].glbSize() ||
391 x[
i].lubSize() !=
c.x[
i].lubSize() ||
392 x[
i].cardMin() !=
c.x[
i].cardMin() ||
393 x[
i].cardMax() !=
c.x[
i].cardMax())
403 olog <<
ind(3) <<
"Finished testing whether enabled space is the same"
411 bool setsAssigned =
true;
412 for (
int j=
x.
size(); j--; )
414 setsAssigned =
false;
417 bool intsAssigned =
true;
418 for (
int j=
y.
size(); j--; )
420 intsAssigned =
false;
428 }
else if (setsAssigned) {
434 if (setsAssigned ||
i>=
x.
size()) {
445 if (
a.ints()[
i] <
y[
i].max()) {
448 assert((
v >
a.ints()[
i]) && (
v <=
y[
i].max()));
453 if (
a.ints()[
i] >
y[
i].min()) {
456 assert((
v <
a.ints()[
i]) && (
v >=
y[
i].min()));
465 if (it.
width() > skip) {
467 if (
v ==
a.ints()[
i]) {
468 if (it.
width() == 1) {
470 }
else if (
v < it.
max()) {
515 if (
x[
i].cardMin() < aisize) {
516 unsigned int newc =
x[
i].cardMin() + 1 +
518 assert( newc >
x[
i].cardMin() );
519 assert( newc <= aisize );
524 if (
x[
i].cardMax() > aisize) {
525 unsigned int newc =
x[
i].cardMax() - 1 -
527 assert( newc <
x[
i].cardMax() );
528 assert( newc >= aisize );
548 bool setsAssigned =
true;
549 for (
int j=
x.
size(); j--; )
551 setsAssigned =
false;
554 bool intsAssigned =
true;
555 for (
int j=
y.
size(); j--; )
557 intsAssigned =
false;
565 }
else if (setsAssigned) {
571 if (setsAssigned ||
i>=
x.
size()) {
582 if (
a.ints()[
i] <
y[
i].max()) {
585 assert((
v >
a.ints()[
i]) && (
v <=
y[
i].max()));
591 if (
a.ints()[
i] >
y[
i].min()) {
594 assert((
v <
a.ints()[
i]) && (
v >=
y[
i].min()));
604 if (it.
width() > skip) {
606 if (
v ==
a.ints()[
i]) {
607 if (it.
width() == 1) {
609 }
else if (
v < it.
max()) {
656 if (
x[
i].cardMin() < aisize) {
657 unsigned int newc =
x[
i].cardMin() + 1 +
659 assert( newc >
x[
i].cardMin() );
660 assert( newc <= aisize );
666 if (
x[
i].cardMax() > aisize) {
667 unsigned int newc =
x[
i].cardMax() - 1 -
669 assert( newc <
x[
i].cardMax() );
670 assert( newc >= aisize );
672 c.cardinality(
i, 0, newc);
706 #define CHECK_TEST(T,M) \
708 olog << ind(3) << "Check: " << (M) << std::endl; \
710 problem = (M); delete s; goto failed; \
714 #define START_TEST(T) \
717 olog << ind(2) << "Testing: " << (T) << std::endl; \
724 const char*
test =
"NONE";
725 const char* problem =
"NONE";
730 bool is_sol = solution(
a);
732 olog <<
ind(1) <<
"Assignment: " <<
a
733 << (is_sol ?
" (solution)" :
" (no solution)")
743 olog <<
ind(3) <<
"No copy" << std::endl;
749 olog <<
ind(3) <<
"Unshared copy" << std::endl;
758 olog <<
ind(3) <<
"Unshared copy" << std::endl;
765 default: assert(
false);
776 START_TEST(
"Assignment (after posting, disable)");
810 problem =
"No fixpoint";
828 s->
post();
c->post();
831 problem =
"Different result after re-enable";
836 if (s->
failed() !=
c->failed()) {
837 problem =
"Different failure after re-enable";
845 START_TEST(
"Assignment reified (rewrite after post, <=>)");
855 START_TEST(
"Assignment reified (rewrite after post, =>)");
865 START_TEST(
"Assignment reified (rewrite after post, <=)");
876 START_TEST(
"Assignment reified (rewrite failure, <=>)");
885 START_TEST(
"Assignment reified (rewrite failure, =>)");
899 START_TEST(
"Assignment reified (rewrite failure, <=)");
912 START_TEST(
"Assignment reified (immediate rewrite, <=>)");
922 START_TEST(
"Assignment reified (immediate rewrite, =>)");
932 START_TEST(
"Assignment reified (immediate rewrite, <=)");
942 START_TEST(
"Assignment reified (immediate failure, <=>)");
951 START_TEST(
"Assignment reified (immediate failure, =>)");
965 START_TEST(
"Assignment reified (immediate failure, <=)");
979 START_TEST(
"Assignment reified (before posting, <=>)");
994 START_TEST(
"Assignment reified (before posting, =>)");
1009 START_TEST(
"Assignment reified (before posting, <=)");
1024 START_TEST(
"Assignment reified (after posting, <=>)");
1039 START_TEST(
"Assignment reified (after posting, =>)");
1054 START_TEST(
"Assignment reified (after posting, <=)");
1069 START_TEST(
"Assignment reified (after posting, <=>, disable)");
1086 START_TEST(
"Assignment reified (after posting, =>, disable)");
1103 START_TEST(
"Assignment reified (after posting, <=, disable)");
1127 problem =
"No fixpoint";
1148 problem =
"No fixpoint";
1170 problem =
"No fixpoint";
1191 olog <<
"FAILURE" << std::endl
1192 <<
ind(1) <<
"Test: " <<
test << std::endl
1193 <<
ind(1) <<
"Problem: " << problem << std::endl;
1195 olog <<
ind(1) <<
"Assignment: " <<
a << std::endl;
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.
@ RM_PMI
Inverse implication for reification.
void post(void)
Post propagator.
@ IRT_GQ
Greater or equal ( )
Space * clone(bool share_data=true, bool share_info=true, CloneStatistics &stat=unused_clone) const
Clone space.
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.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
@ RM_IMP
Implication for reification.
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::IntVarArray y
Int variables to be tested.
void disable(Space &home)
Disable all propagators in a group.
@ SRT_LQ
Less or equal ( )
SetOpType
Common operations for sets.
#define START_TEST(T)
Start new test.
@ SRT_GQ
Greater or equal ( )
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.
union Gecode::@579::NNF::@61 u
Union depending on nodetype t.
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.
Gecode toplevel namespace
void enable(Space &home, bool s=true)
Enable all propagators in a group.
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.
static PropagatorGroup all
Group of all propagators.
@ RM_EQV
Equivalence for reification (default)
void operator++(void)
Move to next assignment.
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
void rel(int i, Gecode::SetRelType srt, const Gecode::IntSet &is)
Perform set tell operation on x[i].
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
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)
virtual Gecode::Space * copy(bool share)
Copy space during cloning.
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)
@ SOT_DUNION
Disjoint union.
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.
struct Gecode::Space::@56::@58 c
Data available only during copying.
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.
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
CountableSet(void)
Default constructor.
int n
Number of negative literals for node type.
std::ostringstream olog
Stream used for logging.
SetExpr inter(const SetVarArgs &x)
Intersection of set variables.
@ SS_FAILED
Space is failed
SetAssignment(int n, const Gecode::IntSet &d, int i=0)
Initialize with n set variables, initial bound d and i int variables.
const FloatNum max
Largest allowed float value.
bool assigned(void) const
Test whether all variables are assigned.
virtual bool run(void)
Perform test.
bool reified
Whether the test is for a reified propagator.
@ IRT_LQ
Less or equal ( )
unsigned int size(void) const
Return size (cardinality) of domain.