52 if (
dsv[i]() || (i == 0))
63 for (
int i = this->
n; i--; )
70 for (
int i=
n-
_n1; i--; )
72 for (
int i=
_n1; i--; )
83 for (
int i=0; i<n; i++)
84 os << a[i] << ((i!=n-1) ?
"," :
"}");
101 olog <<
ind(2) <<
"Initial: x[]=" <<
x
117 olog <<
ind(2) <<
"Initial: x[]=" <<
x
118 <<
" b=" <<
r.var() << std::endl;
123 x.update(*
this, s.
x);
137 for (
int i=
x.size(); i--; )
148 olog <<
ind(3) <<
"Posting reified propagator" << std::endl;
152 olog <<
ind(3) <<
"Posting propagator" << std::endl;
159 olog <<
ind(3) <<
"Fixpoint: " <<
x;
161 olog << std::endl <<
ind(3) <<
" --> " <<
x << std::endl;
172 int i =
static_cast<int>(rand(
static_cast<unsigned int>(
x.size())));
174 i = (i+1) %
x.size();
187 if (a[i] <
x[i].
max()) {
189 static_cast<unsigned int>(
x[i].max()) -
static_cast<unsigned int>(a[i]);
190 unsigned int offset = rand(n);
191 v =
static_cast<int>(
static_cast<long long>(a[i]) + 1LL + offset);
192 assert((v > a[i]) && (v <=
x[i].
max()));
197 if (a[i] >
x[i].
min()) {
199 static_cast<unsigned int>(a[i]) -
static_cast<unsigned int>(
x[i].
min());
200 unsigned int offset = rand(n);
201 v =
static_cast<int>(
static_cast<long long>(
x[i].min()) + offset);
202 assert((v < a[i]) && (v >=
x[i].
min()));
209 unsigned int skip = rand(
static_cast<unsigned int>(
x[i].size()-1));
211 if (it.
width() > skip) {
212 v =
static_cast<int>(
static_cast<long long>(it.
min()) + skip);
214 if (it.
width() == 1) {
216 }
else if (v < it.
max()) {
224 skip -= it.
width(); ++it;
235 olog <<
ind(4) <<
"x[" << i <<
"] ";
244 olog <<
" " << n << std::endl;
254 olog <<
ind(4) <<
"b = " << n << std::endl;
262 static_cast<int>(rand(
static_cast<unsigned int>(a.
size()))) : -1;
263 for (
int j=a.
size(); j--; )
286 static_cast<unsigned int>(
x[i].max()) -
287 static_cast<unsigned int>(
x[i].min());
288 unsigned int offset = rand(n);
289 int v =
static_cast<int>(
static_cast<long long>(
x[i].min()) +
291 assert((v >
x[i].
min()) && (v <=
x[i].
max()));
296 static_cast<unsigned int>(
x[i].max()) -
297 static_cast<unsigned int>(
x[i].min());
298 unsigned int offset = rand(n);
299 int v =
static_cast<int>(
static_cast<long long>(
x[i].min()) + offset);
300 assert((v <
x[i].
max()) && (v >=
x[i].
min()));
305 static_cast<int>(rand(
static_cast<unsigned int>(
x[i].size()-1))+1); vals--; ) {
308 unsigned int skip = rand(
x[i].size()-1);
310 if (it.
width() > skip) {
311 v =
static_cast<int>(
static_cast<long long>(it.
min()) + skip);
314 skip -= it.
width(); ++it;
334 rndrel(a, i, irt, v, rand);
342 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
346 olog <<
ind(4) <<
"Copy failed after posting" << std::endl;
347 delete c;
return false;
349 for (
int j=
x.size(); j--; )
350 if (
x[j].size() !=
c->x[j].size()) {
352 olog <<
ind(4) <<
"Different domain size" << std::endl;
353 delete c;
return false;
355 if (
reified && (
r.var().size() !=
c->r.var().size())) {
357 olog <<
ind(4) <<
"Different control variable" << std::endl;
358 delete c;
return false;
361 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
388 rndrel(a, i, irt, v, rand);
400 olog <<
ind(3) <<
"No failure on disabled copy" << std::endl;
407 olog <<
ind(3) <<
"Failure on disabled copy" << std::endl;
410 for (
int j=
x.size(); j--; ) {
411 if (
x[j].size() !=
c.x[j].size()) {
413 olog <<
ind(4) <<
"Different domain size" << std::endl;
416 if (
reified && (
r.var().size() !=
c.r.var().size())) {
418 olog <<
ind(4) <<
"Different control variable" << std::endl;
451#define CHECK_TEST(T,M) \
454 olog << ind(3) << "Check: " << (M) << std::endl; \
456 problem = (M); delete s; goto failed; \
461#define START_TEST(T) \
465 olog << ind(2) << "Testing: " << (T) << std::endl; \
482 const char* test =
"NONE";
483 const char* problem =
"NONE";
491 post(*search_s,search_s->
x);
498 while (a.has_more()) {
501 olog <<
ind(1) <<
"Assignment: " << a
502 << (sol ?
" (solution)" :
" (no solution)")
514 olog <<
ind(3) <<
"No copy" << std::endl;
520 olog <<
ind(3) <<
"Copy" << std::endl;
527 default: assert(
false);
538 START_TEST(
"Partial assignment (after posting)");
553 START_TEST(
"Assignment (after posting, disable)");
568 START_TEST(
"Partial assignment (after posting, disable)");
598 START_TEST(
"Partial assignment (before posting)");
619 problem =
"No fixpoint";
636 s->
post(); c->post();
639 problem =
"Different result after re-enable";
644 problem =
"Different failure after re-enable";
653 START_TEST(
"Assignment reified (rewrite after post, <=>)");
663 START_TEST(
"Assignment reified (rewrite failure, <=>)");
672 START_TEST(
"Assignment reified (immediate rewrite, <=>)");
682 START_TEST(
"Assignment reified (immediate failure, <=>)");
691 START_TEST(
"Assignment reified (before posting, <=>)");
706 START_TEST(
"Assignment reified (after posting, <=>)");
721 START_TEST(
"Assignment reified (after posting, <=>, disable)");
744 problem =
"No fixpoint";
762 s->
post(); c->post();
766 problem =
"No fixpoint";
772 CHECK_TEST(c->propagators()==0,
"No subsumption");
773 CHECK_TEST(c->r.var().assigned(),
"Control variable unassigned");
775 CHECK_TEST(c->r.var().val()==1,
"Zero on solution");
777 CHECK_TEST(c->r.var().val()==0,
"One on non-solution");
786 START_TEST(
"Assignment reified (rewrite after post, =>)");
796 START_TEST(
"Assignment reified (rewrite failure, =>)");
810 START_TEST(
"Assignment reified (immediate rewrite, =>)");
820 START_TEST(
"Assignment reified (immediate failure, =>)");
834 START_TEST(
"Assignment reified (before posting, =>)");
849 START_TEST(
"Assignment reified (after posting, =>)");
864 START_TEST(
"Assignment reified (after posting, =>, disable)");
887 problem =
"No fixpoint";
905 s->
post(); c->post();
909 problem =
"No fixpoint";
915 CHECK_TEST(c->propagators()==0,
"No subsumption");
917 CHECK_TEST(!c->r.var().assigned(),
"Control variable assigned");
919 CHECK_TEST(c->r.var().assigned(),
"Control variable unassigned");
920 CHECK_TEST(c->r.var().val()==0,
"One on non-solution");
929 START_TEST(
"Assignment reified (rewrite after post, <=)");
939 START_TEST(
"Assignment reified (rewrite failure, <=)");
953 START_TEST(
"Assignment reified (immediate rewrite, <=)");
963 START_TEST(
"Assignment reified (immediate failure, <=)");
977 START_TEST(
"Assignment reified (before posting, <=)");
992 START_TEST(
"Assignment reified (after posting, <=)");
1007 START_TEST(
"Assignment reified (after posting, <=, disable)");
1030 problem =
"No fixpoint";
1048 s->
post(); c->post();
1052 problem =
"No fixpoint";
1058 CHECK_TEST(c->propagators()==0,
"No subsumption");
1060 CHECK_TEST(c->r.var().assigned(),
"Control variable unassigned");
1061 CHECK_TEST(c->r.var().val()==1,
"Zero on solution");
1063 CHECK_TEST(!c->r.var().assigned(),
"Control variable assigned");
1075 CHECK_TEST(s !=
nullptr,
"Solutions exhausted");
1077 for (
int i=a.
size(); i--; ) {
1079 CHECK_TEST(a[i] == s->
x[i].val(),
"Wrong value in solution");
1090 if (e_s.
next() !=
nullptr) {
1091 problem =
"Excess solutions";
1115 for (
int i = s->
x.
size(); i--; )
1130 for (
int i = s->
x.
size(); i--; )
1148 olog <<
"FAILURE" << std::endl
1149 <<
ind(1) <<
"Test: " << test << std::endl
1150 <<
ind(1) <<
"Problem: " << problem << std::endl;
1151 if (a.has_more() &&
opt.log)
1152 olog <<
ind(1) <<
"Assignment: " << a << std::endl;
Boolean integer variables.
int val(void) const
Return assigned value.
Depth-first search engine.
FloatNum size(void) const
Return size of float value (distance between maximum and minimum).
Passing integer variables.
Range iterator for integer views.
int max(void) const
Return largest value of range.
int min(void) const
Return smallest value of range.
unsigned int width(void) const
Return width of range (distance between minimum and maximum).
void threads(double n)
Set number of parallel threads.
static PropagatorGroup all
Group of all propagators.
Reification specification.
BoolVar var(void) const
Return Boolean control variable.
ReifyMode mode(void) const
Return reification mode.
virtual T * next(void)
Return next solution (nullptr, if none exists or search has been stopped).
struct Gecode::Space::@055132133326276162005044145100211202071356247106::@155123175027073262103111264343315000271204104107 c
Data available only during copying.
SpaceStatus status(void)
Query space status without collecting statistics.
bool assigned(void) const
Test if all variables are assigned.
int size(void) const
Return size of array (number of elements).
bool assigned(void) const
Test whether view is assigned.
Gecode::Support::RandomGenerator _rand
Random number generator.
bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
Base class for assignments
Gecode::IntSet d
Domain for each variable.
int n
Number of variables.
Generate all assignments.
virtual void next(Gecode::Support::RandomGenerator &rand)
Move to next assignment.
Gecode::IntSetValues * dsv
Iterator for each variable.
int a
How many assignments still to be generated Generate new value according to domain.
int * vals
The current values for the variables.
int randval(Gecode::Support::RandomGenerator &rand)
virtual void next(Gecode::Support::RandomGenerator &rand)
Move to next assignment.
int _n1
How many variables in the second set.
int randval(const Gecode::IntSet &d, Gecode::Support::RandomGenerator &rand)
Gecode::IntSet _d1
Domain for second set of variables Generate new value according to domain d.
virtual void next(Gecode::Support::RandomGenerator &rand)
Move to next assignment.
int a
How many assignments still to be generated.
int * vals
The current values for the variables.
Space for executing tests.
int rndvar(Gecode::Support::RandomGenerator &rand)
Randomly select an unassigned variable.
Gecode::Reify r
Reification information.
void assign(const Assignment &a, bool skip, Gecode::Support::RandomGenerator &rand)
Assign all (or all but one, if skip is true) variables to values in a.
TestSpace(int n, Gecode::IntSet &d, Test *t)
Create test space without reification.
Gecode::IntSet d
Initial domain.
void rndrel(const Assignment &a, int i, Gecode::IntRelType &irt, int &v, Gecode::Support::RandomGenerator &rand)
Randomly select a pruning rel for variable i.
Test * test
The test currently run.
virtual Gecode::Space * copy(void)
Copy space during cloning.
bool disabled(const Assignment &a, TestSpace &c, bool testfix, Gecode::Support::RandomGenerator &rand)
Prune values also in a space c with disabled propagators, but not those in assignment a.
void post(void)
Post propagator.
bool assigned(void) const
Test whether all variables are assigned.
void prune(int i, bool bounds_only, Gecode::Support::RandomGenerator &rand)
Prune some random values from variable i.
bool failed(void)
Compute a fixpoint and check for failure.
bool reified
Whether the test is for a reified propagator.
void disable(void)
Disable propagators in space and compute fixpoint (make all idle).
Gecode::IntVarArray x
Variables to be tested.
void bound(Gecode::Support::RandomGenerator &rand)
Assign a random variable to a random bound.
void enable(void)
Enable propagators in space.
void rel(int i, Gecode::IntRelType irt, int n)
Perform integer tell operation on x[i].
unsigned int propagators(void)
Return the number of propagators.
bool pmi(void) const
Test whether reverse implication as reification mode is supported.
virtual bool run(void)
Perform test.
virtual bool ignore(const Assignment &) const
Whether to ignore assignment for reification.
bool testsearch
Whether to perform search test.
bool testfix
Whether to perform fixpoint test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)=0
Post constraint.
bool eqv(void) const
Test whether equivalence as reification mode is supported.
int arity
Number of variables.
virtual bool solution(const Assignment &) const =0
Check for solution.
virtual Assignment * assignment(void) const
Create assignment.
Gecode::IntSet dom
Domain of variables.
bool imp(void) const
Test whether implication as reification mode is supported.
ConTestLevel contest
Whether to test for certain consistency.
Simple class for describing indentation.
LinearCongruentialGenerator< 2147483647, 48271, 44488, 3399 > RandomGenerator
Default values for linear congruential generator.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
IntRelType
Relation types for integers.
ReifyMode
Mode for reification.
BoolOpType
Operation types for Booleans.
IntPropLevel
Propagation levels for integer propagators.
@ IRT_GQ
Greater or equal ( ).
@ IRT_LQ
Less or equal ( ).
@ RM_IMP
Implication for reification.
@ RM_PMI
Inverse implication for reification.
@ RM_EQV
Equivalence for reification (default).
@ IPL_BASIC
Use basic propagation algorithm.
@ IPL_BASIC_ADVANCED
Use both.
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
@ IPL_VAL
Value propagation.
@ IPL_ADVANCED
Use advanced propagation algorithm.
@ IPL_BND
Bounds propagation.
Space(void)
Default constructor.
Space * clone(void) const
Clone space.
SpaceStatus status(StatusStatistics &stat)
Query space status.
@ SS_FAILED
Space is failed
Gecode toplevel namespace
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
IntValBranch INT_VAL_MIN(void)
Select smallest value.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Testing finite domain integers.
@ CTL_BOUNDS_Z
Test for bounds(z)-consistency.
@ CTL_BOUNDS_D
Test for bounds(d)-consistency.
@ CTL_NONE
No consistency-test.
@ CTL_DOMAIN
Test for domain-consistency.
std::ostringstream olog
Stream used for logging.
#define START_TEST(T)
Start new test.
#define CHECK_TEST(T, M)
Check the test result and handle failed test.
std::ostream & operator<<(std::ostream &os, const Test::Int::Assignment &a)