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;
176 olog <<
ind(4) <<
"x[" << i <<
"] ";
185 olog <<
" " << n << std::endl;
195 olog <<
ind(4) <<
"b = " << n << std::endl;
203 for (
int j=a.
size(); j--; )
217 i = (i+1) %
x.
size();
230 <
unsigned int>(
x[i].
max()-
x[i].
min()));
231 assert((v >
x[i].
min()) && (v <=
x[i].
max()));
236 <
unsigned int>(
x[i].
max()-
x[i].
min()));
237 assert((v <
x[i].
max()) && (v >=
x[i].
min()));
246 if (it.
width() > skip) {
247 v = it.
min() + skip;
break;
249 skip -= it.
width(); ++it;
262 i = (i+1) %
x.
size();
272 i = (i+1) %
x.
size();
276 if (a[i] <
x[i].
max()) {
278 <
unsigned int>(
x[i].
max()-a[i]));
279 assert((v > a[i]) && (v <=
x[i].
max()));
284 if (a[i] >
x[i].
min()) {
286 <
unsigned int>(a[i]-
x[i].
min()));
287 assert((v < a[i]) && (v >=
x[i].
min()));
297 if (it.
width() > skip) {
300 if (it.
width() == 1) {
302 }
else if (v < it.
max()) {
310 skip -= it.
width(); ++it;
321 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
325 olog <<
ind(4) <<
"Copy failed after posting" << std::endl;
326 delete c;
return false;
328 for (
int i=
x.
size(); i--; )
331 olog <<
ind(4) <<
"Different domain size" << std::endl;
332 delete c;
return false;
336 olog <<
ind(4) <<
"Different control variable" << std::endl;
337 delete c;
return false;
340 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
365 #define CHECK_TEST(T,M) \
367 olog << ind(3) << "Check: " << (M) << std::endl; \
369 problem = (M); delete s; goto failed; \
373 #define START_TEST(T) \
376 olog << ind(2) << "Testing: " << (T) << std::endl; \
392 const char*
test =
"NONE";
393 const char* problem =
"NONE";
401 post(*search_s,search_s->
x);
409 bool sol = solution(a);
411 olog <<
ind(1) <<
"Assignment: " << a
412 << (sol ?
" (solution)" :
" (no solution)")
424 olog <<
ind(3) <<
"No copy" << std::endl;
430 olog <<
ind(3) <<
"Unshared copy" << std::endl;
439 olog <<
ind(3) <<
"Shared copy" << std::endl;
446 default: assert(
false);
457 START_TEST(
"Partial assignment (after posting)");
485 START_TEST(
"Partial assignment (before posting)");
505 if (!s->
prune(a,testfix)) {
506 problem =
"No fixpoint";
522 START_TEST(
"Assignment reified (rewrite after post, <=>)");
532 START_TEST(
"Assignment reified (rewrite after post, =>)");
542 START_TEST(
"Assignment reified (rewrite after post, <=)");
552 START_TEST(
"Assignment reified (rewrite failure, <=>)");
561 START_TEST(
"Assignment reified (rewrite failure, =>)");
575 START_TEST(
"Assignment reified (rewrite failure, <=)");
589 START_TEST(
"Assignment reified (immediate rewrite, <=>)");
599 START_TEST(
"Assignment reified (immediate rewrite, =>)");
609 START_TEST(
"Assignment reified (immediate rewrite, <=)");
619 START_TEST(
"Assignment reified (immediate failure, <=>)");
628 START_TEST(
"Assignment reified (immediate failure, =>)");
642 START_TEST(
"Assignment reified (immediate failure, <=)");
656 START_TEST(
"Assignment reified (before posting, <=>)");
671 START_TEST(
"Assignment reified (before posting, =>)");
686 START_TEST(
"Assignment reified (before posting, <=)");
701 START_TEST(
"Assignment reified (after posting, <=>)");
716 START_TEST(
"Assignment reified (after posting, =>)");
731 START_TEST(
"Assignment reified (after posting, <=)");
751 if (!s->
prune(a,testfix)) {
752 problem =
"No fixpoint";
772 if (!s->
prune(a,testfix)) {
773 problem =
"No fixpoint";
793 if (!s->
prune(a,testfix)) {
794 problem =
"No fixpoint";
816 for (
int i=a.
size();
i--; ) {
818 CHECK_TEST(a[
i] == s->
x[
i].val(),
"Wrong value in solution");
829 if (e_s.
next() != NULL) {
830 problem =
"Excess solutions";
854 for (
int i = s->
x.
size();
i--; )
869 for (
int i = s->
x.
size();
i--; )
887 olog <<
"FAILURE" << std::endl
888 <<
ind(1) <<
"Test: " << test << std::endl
889 <<
ind(1) <<
"Problem: " << problem << std::endl;
891 olog <<
ind(1) <<
"Assignment: " << a << std::endl;
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.
IntConLevel
Consistency levels for integer propagators.
Gecode::IntVarArray x
Variables to be tested.
Inverse implication for reification.
ReifyMode mode(void) const
Return reification mode.
Simple class for describing identation.
#define START_TEST(T)
Start new test.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)=0
Post constraint.
BoolVar var(void) const
Return Boolean control variable.
void update(Space &home, bool share, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
static Gecode::Support::RandomGenerator rand
Random number generator.
virtual void operator++(void)
Move to next assignment.
int a
How many assigments still to be generated Generate new value according to domain. ...
Space * clone(bool share=true, CloneStatistics &stat=unused_clone) const
Clone space.
BoolOpType
Operation types for Booleans.
Value propagation or consistency (naive)
Gecode::Reify r
Reification information.
void init(const IntSet &s)
Initialize with values for s.
unsigned int size(void) const
Return size (cardinality) of domain.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
bool failed(void)
Compute a fixpoint and check for failure.
Space for executing tests.
int _n1
How many variables in the second set.
int n
Number of variables.
int val(void) const
Return assigned value.
bool assigned(void) const
Test whether all variables are assigned.
virtual Gecode::Space * copy(bool share)
Copy space during cloning.
Gecode::IntSet d
Domain for each variable.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
virtual Assignment * assignment(void) const
Create assignment.
Reify imp(BoolVar x)
Use implication for reification.
void prune(void)
Prune some random values for some random variable.
unsigned int propagators(void) const
Return number of propagators.
void max(Home home, SetVar s, IntVar x, Reify r)
Post reified propagator for b iff x is the maximal element of s.
int min(void) const
Return smallest value of range.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
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].
int a
How many assigments still to be generated.
void bound(void)
Assing a random variable to a random bound.
static bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
int * vals
The current values for the variables.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Reification specification.
TestSpace(int n, Gecode::IntSet &d, Test *t)
Create test space without reification.
Gecode::IntSetValues * dsv
Iterator for each variable.
Test for bounds(z)-consistency.
Test for bounds(d)-consistency.
bool log
Whether to log the tests.
Test for domain-consistency.
virtual bool ignore(const Assignment &) const
Whether to ignore assignment for reification.
int randval(const Gecode::IntSet &d)
Reify eqv(BoolVar x)
Use equivalence for reification.
Passing integer variables.
struct Gecode::Space::@52::@54 c
Data available only during copying.
void min(Home home, SetVar s, IntVar x, Reify r)
Post reified propagator for b iff x is the minimal element of s.
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Boolean integer variables.
Gecode::IntSet _d1
Domain for second set of variables Generate new value according to domain d.
Node * x
Pointer to corresponding Boolean expression node.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
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
T * next(void)
Return next solution (NULL, if none exists or search has been stopped)
std::ostringstream olog
Stream used for logging.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
bool assigned(void) const
Test whether view is assigned.
Bounds propagation or consistency.
void threads(double n)
Set number of parallel threads.
int max(void) const
Return largest value of range.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
Implication for reification.
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const FloatView &x)
Print float variable view.
bool assigned(void) const
Test if all variables are assigned.
BrancherHandle 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.
virtual void operator++(void)
Move to next assignment.
Test * test
The test currently run.
int size(void) const
Return size of array (number of elements)
ReifyMode
Mode for reification.
void post(void)
Post propagator.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
int size(void) const
Return number of variables.
Domain propagation or consistency.
Depth-first search engine.
Generate all assignments.
Equivalence for reification (default)
int * vals
The current values for the variables.
Reify pmi(BoolVar x)
Use reverse implication for reification.
bool reified
Whether the test is for a reified propagator.