40 namespace Test {
namespace Int {
52 if (
dsv[i]() || (i == 0))
64 for (
int i =
n;
i--; )
71 for (
int i=
n-_n1;
i--; )
73 for (
int i=_n1;
i--; )
74 vals[
n-_n1+
i] = randval(_d1);
84 for (
int i=0;
i<
n;
i++)
85 os << a[
i] << ((
i!=n-1) ?
"," :
"}");
89 namespace Test {
namespace Int {
93 test(t), reified(false) {
102 olog <<
ind(2) <<
"Initial: x[]=" <<
x 118 olog <<
ind(2) <<
"Initial: x[]=" <<
x 119 <<
" b=" <<
r.
var() << std::endl;
149 olog <<
ind(3) <<
"Posting reified propagator" << std::endl;
153 olog <<
ind(3) <<
"Posting propagator" << std::endl;
160 olog <<
ind(3) <<
"Fixpoint: " <<
x;
162 olog << std::endl <<
ind(3) <<
" --> " << x << std::endl;
175 i = (i+1) %
x.
size();
188 if (a[i] <
x[i].
max()) {
190 <
unsigned int>(
x[i].
max()-a[i]));
191 assert((v > a[i]) && (v <=
x[i].
max()));
196 if (a[i] >
x[i].
min()) {
198 <
unsigned int>(a[i]-
x[i].
min()));
199 assert((v < a[i]) && (v >=
x[i].
min()));
208 if (it.
width() > skip) {
211 if (it.
width() == 1) {
213 }
else if (v < it.
max()) {
221 skip -= it.
width(); ++it;
232 olog <<
ind(4) <<
"x[" << i <<
"] ";
241 olog <<
" " << n << std::endl;
251 olog <<
ind(4) <<
"b = " << n << std::endl;
259 for (
int j=a.
size(); j--; )
282 <
unsigned int>(
x[i].
max()-
x[i].
min()));
283 assert((v >
x[i].
min()) && (v <=
x[i].
max()));
288 <
unsigned int>(
x[i].
max()-
x[i].
min()));
289 assert((v <
x[i].
max()) && (v >=
x[i].
min()));
298 if (it.
width() > skip) {
299 v = it.
min() + skip;
break;
301 skip -= it.
width(); ++it;
329 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
333 olog <<
ind(4) <<
"Copy failed after posting" << std::endl;
334 delete c;
return false;
336 for (
int i=
x.
size(); i--; )
339 olog <<
ind(4) <<
"Different domain size" << std::endl;
340 delete c;
return false;
344 olog <<
ind(4) <<
"Different control variable" << std::endl;
345 delete c;
return false;
348 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
388 olog <<
ind(3) <<
"No failure on disabled copy" << std::endl;
395 olog <<
ind(3) <<
"Failure on disabled copy" << std::endl;
398 for (
int i=
x.
size(); i--; ) {
401 olog <<
ind(4) <<
"Different domain size" << std::endl;
406 olog <<
ind(4) <<
"Different control variable" << std::endl;
439 #define CHECK_TEST(T,M) \ 441 olog << ind(3) << "Check: " << (M) << std::endl; \ 443 problem = (M); delete s; goto failed; \ 447 #define START_TEST(T) \ 450 olog << ind(2) << "Testing: " << (T) << std::endl; \ 466 const char*
test =
"NONE";
467 const char* problem =
"NONE";
475 post(*search_s,search_s->
x);
483 bool sol = solution(a);
485 olog <<
ind(1) <<
"Assignment: " << a
486 << (sol ?
" (solution)" :
" (no solution)")
498 olog <<
ind(3) <<
"No copy" << std::endl;
504 olog <<
ind(3) <<
"Copy" << std::endl;
511 default: assert(
false);
522 START_TEST(
"Partial assignment (after posting)");
537 START_TEST(
"Assignment (after posting, disable)");
552 START_TEST(
"Partial assignment (after posting, disable)");
582 START_TEST(
"Partial assignment (before posting)");
602 if (!s->
prune(a,testfix)) {
603 problem =
"No fixpoint";
623 problem =
"Different result after re-enable";
628 problem =
"Different failure after re-enable";
637 START_TEST(
"Assignment reified (rewrite after post, <=>)");
647 START_TEST(
"Assignment reified (rewrite failure, <=>)");
656 START_TEST(
"Assignment reified (immediate rewrite, <=>)");
666 START_TEST(
"Assignment reified (immediate failure, <=>)");
675 START_TEST(
"Assignment reified (before posting, <=>)");
690 START_TEST(
"Assignment reified (after posting, <=>)");
705 START_TEST(
"Assignment reified (after posting, <=>, disable)");
727 if (!s->
prune(a,testfix)) {
728 problem =
"No fixpoint";
750 problem =
"No fixpoint";
770 START_TEST(
"Assignment reified (rewrite after post, =>)");
780 START_TEST(
"Assignment reified (rewrite failure, =>)");
794 START_TEST(
"Assignment reified (immediate rewrite, =>)");
804 START_TEST(
"Assignment reified (immediate failure, =>)");
818 START_TEST(
"Assignment reified (before posting, =>)");
833 START_TEST(
"Assignment reified (after posting, =>)");
848 START_TEST(
"Assignment reified (after posting, =>, disable)");
870 if (!s->
prune(a,testfix)) {
871 problem =
"No fixpoint";
893 problem =
"No fixpoint";
913 START_TEST(
"Assignment reified (rewrite after post, <=)");
923 START_TEST(
"Assignment reified (rewrite failure, <=)");
937 START_TEST(
"Assignment reified (immediate rewrite, <=)");
947 START_TEST(
"Assignment reified (immediate failure, <=)");
961 START_TEST(
"Assignment reified (before posting, <=)");
976 START_TEST(
"Assignment reified (after posting, <=)");
991 START_TEST(
"Assignment reified (after posting, <=, disable)");
1013 if (!s->
prune(a,testfix)) {
1014 problem =
"No fixpoint";
1036 problem =
"No fixpoint";
1059 CHECK_TEST(s != NULL,
"Solutions exhausted");
1061 for (
int i=a.
size();
i--; ) {
1063 CHECK_TEST(a[
i] == s->
x[
i].val(),
"Wrong value in solution");
1074 if (e_s.
next() != NULL) {
1075 problem =
"Excess solutions";
1099 for (
int i = s->
x.
size();
i--; )
1114 for (
int i = s->
x.
size();
i--; )
1132 olog <<
"FAILURE" << std::endl
1133 <<
ind(1) <<
"Test: " << test << std::endl
1134 <<
ind(1) <<
"Problem: " << problem << std::endl;
1136 olog <<
ind(1) <<
"Assignment: " << a << std::endl;
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
virtual void operator++(void)
Move to next assignment.
void prune(int i, bool bounds_only)
Prune some random values from variable i.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
#define CHECK_TEST(T, M)
Check the test result and handle failed test.
Gecode::IntSet d
Initial domain.
Gecode::IntVarArray x
Variables to be tested.
Inverse implication for reification.
Simple class for describing identation.
#define START_TEST(T)
Start new test.
int size(void) const
Return size of array (number of elements)
ReifyMode mode(void) const
Return reification mode.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)=0
Post constraint.
int size(void) const
Return number of variables.
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
static Gecode::Support::RandomGenerator rand
Random number generator.
virtual void operator++(void)
Move to next assignment.
BoolOpType
Operation types for Booleans.
unsigned int size(void) const
Return size (cardinality) of domain.
void disable(Space &home)
Disable all propagators in a group.
static PropagatorGroup all
Group of all propagators.
bool assigned(void) const
Test whether view is assigned.
bool assigned(void) const
Test whether all variables are assigned.
Gecode::Reify r
Reification information.
void init(const IntSet &s)
Initialize with values for s.
bool assigned(void) const
Test if all variables are assigned.
virtual T * next(void)
Return next solution (NULL, if none exists or search has been stopped)
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
void max(Home home, SetVar s, IntVar x, Reify r)
bool failed(void)
Compute a fixpoint and check for failure.
void min(Home home, SetVar s, IntVar x, Reify r)
virtual Assignment * assignment(void) const
Create assignment.
Space for executing tests.
unsigned int size(Space &home) const
Return number of propagators in a group.
int n
Number of variables.
Gecode::IntSet d
Domain for each variable.
Reify imp(BoolVar x)
Use implication for reification.
void prune(void)
Prune some random values for some random variable.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
void rndrel(const Assignment &a, int i, Gecode::IntRelType &irt, int &v)
Randomly select a pruning rel for variable i.
virtual bool run(void)
Perform test.
IntRelType
Relation types for integers.
void rel(int i, Gecode::IntRelType irt, int n)
Perform integer tell operation on x[i].
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
void bound(void)
Assing a random variable to a random bound.
static bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Use basic propagation algorithm.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Reification specification.
int min(void) const
Return smallest value of range.
TestSpace(int n, Gecode::IntSet &d, Test *t)
Create test space without reification.
Gecode::IntSetValues * dsv
Iterator for each variable.
struct Gecode::Space::@58::@60 c
Data available only during copying.
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
Test for bounds(z)-consistency.
Test for bounds(d)-consistency.
bool log
Whether to log the tests.
Test for domain-consistency.
Use advanced propagation algorithm.
unsigned int propagators(void)
Return the number of propagators.
Reify eqv(BoolVar x)
Use equivalence for reification.
Passing integer variables.
void disable(void)
Disable propagators in space and compute fixpoint (make all idle)
std::ostream & operator<<(std::ostream &os, const Test::Int::Assignment &a)
Boolean integer variables.
void enable(void)
Enable propagators in space.
IntPropLevel
Propagation levels for integer propagators.
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
virtual Gecode::Space * copy(void)
Copy space during cloning.
Node * x
Pointer to corresponding Boolean expression node.
Space(void)
Default constructor.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
void assign(const Assignment &a, bool skip=false)
Assign all (or all but one, if skip is true) variables to values in a.
Base class for assignments
void enable(Space &home, bool s=true)
Enable all propagators in a group.
std::ostringstream olog
Stream used for logging.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Domain propagation Options: basic versus advanced propagation.
BoolVar var(void) const
Return Boolean control variable.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
int max(void) const
Return largest value of range.
bool disabled(const Assignment &a, TestSpace &c, bool testfix)
Prune values also in a space c with disabled propagators, but not those in assignment a...
void threads(double n)
Set number of parallel threads.
Gecode toplevel namespace
Implication for reification.
virtual bool ignore(const Assignment &) const
Whether to ignore assignment for reification.
virtual void operator++(void)
Move to next assignment.
Test * test
The test currently run.
ReifyMode
Mode for reification.
void post(void)
Post propagator.
Depth-first search engine.
Generate all assignments.
Equivalence for reification (default)
int val(void) const
Return assigned value.
Reify pmi(BoolVar x)
Use reverse implication for reification.
bool reified
Whether the test is for a reified propagator.
int rndvar(void)
Randomly select an unassigned variable.