Go to the documentation of this file.
44 namespace Test {
namespace Int {
56 if (
dsv[
i]() || (
i == 0))
68 for (
int i =
n;
i--; )
77 for (
int i=
_n1;
i--; )
88 for (
int i=0;
i<
n;
i++)
89 os <<
a[
i] << ((
i!=
n-1) ?
"," :
"}");
93 namespace Test {
namespace Int {
97 test(
t), reified(false) {
106 olog <<
ind(2) <<
"Initial: x[]=" <<
x
113 test(
t), reified(true) {
122 olog <<
ind(2) <<
"Initial: x[]=" <<
x
123 <<
" b=" <<
r.
var() << std::endl;
127 :
Gecode::Space(share,s),
d(s.
d), test(s.test), reified(s.reified) {
131 b.update(*
this, share, sr);
153 olog <<
ind(3) <<
"Posting reified propagator" << std::endl;
157 olog <<
ind(3) <<
"Posting propagator" << std::endl;
164 olog <<
ind(3) <<
"Fixpoint: " <<
x;
166 olog << std::endl <<
ind(3) <<
" --> " <<
x << std::endl;
194 <
unsigned int>(
x[
i].
max()-
a[
i]));
202 <
unsigned int>(
a[
i]-
x[
i].
min()));
212 if (it.
width() > skip) {
215 if (it.
width() == 1) {
217 }
else if (
v < it.
max()) {
225 skip -= it.
width(); ++it;
236 olog <<
ind(4) <<
"x[" <<
i <<
"] ";
245 olog <<
" " <<
n << std::endl;
255 olog <<
ind(4) <<
"b = " <<
n << std::endl;
262 int i = skip ?
static_cast<int>(
Base::rand(
a.size())) : -1;
263 for (
int j=
a.size(); j--; )
302 if (it.
width() > skip) {
303 v = it.
min() + skip;
break;
305 skip -= it.
width(); ++it;
333 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
337 olog <<
ind(4) <<
"Copy failed after posting" << std::endl;
338 delete c;
return false;
341 if (
x[
i].
size() !=
c->x[
i].size()) {
343 olog <<
ind(4) <<
"Different domain size" << std::endl;
344 delete c;
return false;
348 olog <<
ind(4) <<
"Different control variable" << std::endl;
349 delete c;
return false;
352 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
392 olog <<
ind(3) <<
"No failure on disabled copy" << std::endl;
399 olog <<
ind(3) <<
"Failure on disabled copy" << std::endl;
405 olog <<
ind(4) <<
"Different domain size" << std::endl;
410 olog <<
ind(4) <<
"Different control variable" << std::endl;
443 #define CHECK_TEST(T,M) \
445 olog << ind(3) << "Check: " << (M) << std::endl; \
447 problem = (M); delete s; goto failed; \
451 #define START_TEST(T) \
454 olog << ind(2) << "Testing: " << (T) << std::endl; \
470 const char*
test =
"NONE";
471 const char* problem =
"NONE";
479 post(*search_s,search_s->
x);
487 bool sol = solution(
a);
489 olog <<
ind(1) <<
"Assignment: " <<
a
490 << (sol ?
" (solution)" :
" (no solution)")
502 olog <<
ind(3) <<
"No copy" << std::endl;
508 olog <<
ind(3) <<
"Unshared copy" << std::endl;
517 olog <<
ind(3) <<
"Shared copy" << std::endl;
524 default: assert(
false);
535 START_TEST(
"Partial assignment (after posting)");
550 START_TEST(
"Assignment (after posting, disable)");
565 START_TEST(
"Partial assignment (after posting, disable)");
595 START_TEST(
"Partial assignment (before posting)");
615 if (!s->
prune(
a,testfix)) {
616 problem =
"No fixpoint";
633 s->
post();
c->post();
636 problem =
"Different result after re-enable";
640 if (testfix && (s->
failed() !=
c->failed())) {
641 problem =
"Different failure after re-enable";
650 START_TEST(
"Assignment reified (rewrite after post, <=>)");
660 START_TEST(
"Assignment reified (rewrite failure, <=>)");
669 START_TEST(
"Assignment reified (immediate rewrite, <=>)");
679 START_TEST(
"Assignment reified (immediate failure, <=>)");
688 START_TEST(
"Assignment reified (before posting, <=>)");
703 START_TEST(
"Assignment reified (after posting, <=>)");
718 START_TEST(
"Assignment reified (after posting, <=>, disable)");
740 if (!s->
prune(
a,testfix)) {
741 problem =
"No fixpoint";
759 s->
post();
c->post();
763 problem =
"No fixpoint";
770 CHECK_TEST(
c->r.var().assigned(),
"Control variable unassigned");
772 CHECK_TEST(
c->r.var().val()==1,
"Zero on solution");
774 CHECK_TEST(
c->r.var().val()==0,
"One on non-solution");
783 START_TEST(
"Assignment reified (rewrite after post, =>)");
793 START_TEST(
"Assignment reified (rewrite failure, =>)");
807 START_TEST(
"Assignment reified (immediate rewrite, =>)");
817 START_TEST(
"Assignment reified (immediate failure, =>)");
831 START_TEST(
"Assignment reified (before posting, =>)");
846 START_TEST(
"Assignment reified (after posting, =>)");
861 START_TEST(
"Assignment reified (after posting, =>, disable)");
883 if (!s->
prune(
a,testfix)) {
884 problem =
"No fixpoint";
902 s->
post();
c->post();
906 problem =
"No fixpoint";
914 CHECK_TEST(!
c->r.var().assigned(),
"Control variable assigned");
916 CHECK_TEST(
c->r.var().assigned(),
"Control variable unassigned");
917 CHECK_TEST(
c->r.var().val()==0,
"One on non-solution");
926 START_TEST(
"Assignment reified (rewrite after post, <=)");
936 START_TEST(
"Assignment reified (rewrite failure, <=)");
950 START_TEST(
"Assignment reified (immediate rewrite, <=)");
960 START_TEST(
"Assignment reified (immediate failure, <=)");
974 START_TEST(
"Assignment reified (before posting, <=)");
989 START_TEST(
"Assignment reified (after posting, <=)");
1004 START_TEST(
"Assignment reified (after posting, <=, disable)");
1026 if (!s->
prune(
a,testfix)) {
1027 problem =
"No fixpoint";
1045 s->
post();
c->post();
1049 problem =
"No fixpoint";
1055 CHECK_TEST(
c->propagators()==0,
"No subsumption");
1057 CHECK_TEST(
c->r.var().assigned(),
"Control variable unassigned");
1058 CHECK_TEST(
c->r.var().val()==1,
"Zero on solution");
1060 CHECK_TEST(!
c->r.var().assigned(),
"Control variable assigned");
1072 CHECK_TEST(s != NULL,
"Solutions exhausted");
1074 for (
int i=
a.size();
i--; ) {
1087 if (e_s.
next() != NULL) {
1088 problem =
"Excess solutions";
1112 for (
int i = s->
x.
size();
i--; )
1127 for (
int i = s->
x.
size();
i--; )
1145 olog <<
"FAILURE" << std::endl
1146 <<
ind(1) <<
"Test: " <<
test << std::endl
1147 <<
ind(1) <<
"Problem: " << problem << std::endl;
1149 olog <<
ind(1) <<
"Assignment: " <<
a << std::endl;
virtual bool ignore(const Assignment &) const
Whether to ignore assignment for reification.
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
IntRelType
Relation types for integers.
virtual T * next(void)
Return next solution (NULL, if none exists or search has been stopped)
@ RM_PMI
Inverse implication for reification.
Test * test
The test currently run.
virtual void operator++(void)
Move to next assignment.
@ IRT_GQ
Greater or equal ( )
Space * clone(bool share_data=true, bool share_info=true, CloneStatistics &stat=unused_clone) const
Clone space.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
int min(void) const
Return smallest value of range.
Passing integer variables.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Reify eqv(BoolVar x)
Use equivalence for reification.
void rndrel(const Assignment &a, int i, Gecode::IntRelType &irt, int &v)
Randomly select a pruning rel for variable i.
@ IPL_ADVANCED
Use advanced propagation algorithm.
unsigned int size(Space &home) const
Return number of propagators in a group.
int n
Number of variables.
virtual Gecode::Space * copy(bool share)
Copy space during cloning.
@ CTL_DOMAIN
Test for domain-consistency.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
int randval(const Gecode::IntSet &d)
@ CTL_NONE
No consistency-test.
int a
How many assigments still to be generated.
@ RM_IMP
Implication for reification.
Gecode::IntArgs i(4, 1, 2, 3, 4)
@ CTL_BOUNDS_Z
Test for bounds(z)-consistency.
void rel(int i, Gecode::IntRelType irt, int n)
Perform integer tell operation on x[i].
@ IPL_VAL
Value propagation.
void disable(Space &home)
Disable all propagators in a group.
IntPropLevel
Propagation levels for integer propagators.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Depth-first search engine.
Space for executing tests.
virtual void operator++(void)
Move to next assignment.
bool assigned(void) const
Test whether view is assigned.
static Gecode::Support::RandomGenerator rand
Random number generator.
TestSpace(int n, Gecode::IntSet &d, Test *t)
Create test space without reification.
int size(void) const
Return size of array (number of elements)
bool assigned(void) const
Test if all variables are assigned.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)=0
Post constraint.
Gecode toplevel namespace
virtual bool run(void)
Perform test.
void enable(Space &home, bool s=true)
Enable all propagators in a group.
Gecode::Reify r
Reification information.
Reify pmi(BoolVar x)
Use reverse implication for reification.
@ CTL_BOUNDS_D
Test for bounds(d)-consistency.
virtual Assignment * assignment(void) const
Create assignment.
bool failed(void)
Compute a fixpoint and check for failure.
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const FloatView &x)
Print float variable view.
Node * x
Pointer to corresponding Boolean expression node.
BoolOpType
Operation types for Booleans.
bool assigned(void) const
Test whether all variables are assigned.
static PropagatorGroup all
Group of all propagators.
Reification specification.
@ RM_EQV
Equivalence for reification (default)
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Gecode::IntSetValues * dsv
Iterator for each variable.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
@ IPL_BASIC_ADVANCED
Use both.
bool log
Whether to log the tests.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Boolean integer variables.
@ IPL_DOM
Domain propagation Preferences: prefer speed or memory.
int a
How many assigments still to be generated Generate new value according to domain.
void init(const IntSet &s)
Initialize with values for s.
int _n1
How many variables in the second set.
int * vals
The current values for the variables.
void prune(void)
Prune some random values for some random variable.
#define CHECK_TEST(T, M)
Check the test result and handle failed test.
void min(Home home, SetVar s, IntVar x, Reify r)
@ IPL_BND
Bounds propagation.
static bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
void assign(const Assignment &a, bool skip=false)
Assign all (or all but one, if skip is true) variables to values in a.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
int * vals
The current values for the variables.
Generate all assignments.
Base class for assignments
void bound(void)
Assing a random variable to a random bound.
void max(Home home, SetVar s, IntVar x, Reify r)
unsigned int propagators(void)
Return the number of propagators.
void post(void)
Post propagator.
@ IPL_BASIC
Use basic propagation algorithm.
BoolVar var(void) const
Return Boolean control variable.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
virtual void operator++(void)
Move to next assignment.
ReifyMode
Mode for reification.
Simple class for describing identation.
void threads(double n)
Set number of parallel threads.
bool reified
Whether the test is for a reified propagator.
struct Gecode::Space::@56::@58 c
Data available only during copying.
void enable(void)
Enable propagators in space.
#define START_TEST(T)
Start new test.
int max(void) const
Return largest value of range.
ReifyMode mode(void) const
Return reification mode.
void prune(int i, bool bounds_only)
Prune some random values from variable i.
Reify imp(BoolVar x)
Use implication for reification.
Gecode::IntSet _d1
Domain for second set of variables Generate new value according to domain d.
int val(void) const
Return assigned value.
int rndvar(void)
Randomly select an unassigned variable.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Gecode::IntSet d
Initial domain.
void disable(void)
Disable propagators in space and compute fixpoint (make all idle)
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Gecode::IntVarArray x
Variables to be tested.
int n
Number of negative literals for node type.
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.
std::ostringstream olog
Stream used for logging.
@ SS_FAILED
Space is failed
Gecode::IntSet d
Domain for each variable.
@ IRT_LQ
Less or equal ( )
unsigned int size(void) const
Return size (cardinality) of domain.