47 namespace Test {
namespace Float {
79 if (curPb->extendAssignement(*
this))
return;
80 if ((
dsv[i].
max() >=
d.
max()) && (i == 0))
return;
94 for (
int i =
n;
i--; )
105 for (
int i=0;
i<
n;
i++)
106 os <<
"[" << a[
i].
min() <<
"," << a[
i].max() <<
"]" << ((
i!=n-1) ?
"," :
"}");
110 namespace Test {
namespace Float {
151 test(t), reified(false) {
160 olog <<
ind(2) <<
"Initial: x[]=" <<
x 170 olog <<
ind(2) <<
"Initial: x[]=" <<
x 217 if ((
x[
i].
min() < a[
i].
min()) && (
x[
i].max() > a[
i].max()))
227 olog <<
ind(3) <<
"Posting reified propagator" << std::endl;
231 olog <<
ind(3) <<
"Posting propagator" << std::endl;
238 olog <<
ind(3) <<
"Fixpoint: " <<
x;
240 olog << std::endl <<
ind(3) <<
" --> " << x << std::endl;
250 olog <<
ind(4) <<
"x[" << i <<
"] ";
259 olog <<
" [" << n.
min() <<
"," << n.
max() <<
"]" << std::endl;
269 olog <<
ind(4) <<
"b = " << n << std::endl;
278 for (
int j=a.
size(); j--; )
280 if ((
x[j].
min() == a[j].
max()) || (
x[j].max() == a[j].min()))
297 i = (i+1) %
x.
size();
313 for (
int j=
x.
size(); j--; ) {
317 if (cutDirections[i]) {
341 assert((v >=
x[i].
min()) && (v <=
x[i].
max()));
346 assert((v <=
x[i].
max()) && (v >=
x[i].
min()));
357 i = (i+1) %
x.
size();
367 i = (i+1) %
x.
size();
375 assert((v >= a[i].
max()) && (v <=
x[i].
max()));
384 assert((v <= a[i].
min()) && (v >=
x[i].
min()));
394 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
397 delete c;
return false;
399 for (
int i=
x.
size(); i--; )
401 delete c;
return false;
404 delete c;
return false;
407 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
425 switch (assigmentType) {
446 if (!testsubsumed)
return true;
447 if (const_cast<TestSpace&>(ts).
propagators() == 0)
return true;
453 #define CHECK_TEST(T,M) \ 455 olog << ind(3) << "Check: " << (M) << std::endl; \ 457 problem = (M); delete s; goto failed; \ 461 #define START_TEST(T) \ 464 olog << ind(2) << "Testing: " << (T) << std::endl; \ 480 const char*
test =
"NONE";
481 const char* problem =
"NONE";
489 post(*search_s,search_s->
x);
497 olog <<
ind(1) <<
"Assignment: " <<
a;
513 olog <<
ind(3) <<
"No copy" << std::endl;
519 olog <<
ind(3) <<
"Copy" << std::endl;
526 default: assert(
false);
537 START_TEST(
"Partial assignment (after posting)");
552 START_TEST(
"Assignment (after posting, disable)");
567 START_TEST(
"Partial assignment (after posting, disable)");
597 START_TEST(
"Partial assignment (before posting)");
617 if (!s->
prune(a,testfix)) {
618 problem =
"No fixpoint";
633 START_TEST(
"Assignment reified (rewrite after post, <=>)");
643 START_TEST(
"Assignment reified (rewrite after post, =>)");
653 START_TEST(
"Assignment reified (rewrite after post, <=)");
663 START_TEST(
"Assignment reified (immediate rewrite, <=>)");
673 START_TEST(
"Assignment reified (immediate rewrite, =>)");
683 START_TEST(
"Assignment reified (immediate rewrite, <=)");
693 START_TEST(
"Assignment reified (before posting, <=>)");
709 START_TEST(
"Assignment reified (before posting, =>)");
723 START_TEST(
"Assignment reified (before posting, <=)");
739 START_TEST(
"Assignment reified (after posting, <=>)");
755 START_TEST(
"Assignment reified (after posting, =>)");
769 START_TEST(
"Assignment reified (after posting, <=)");
790 if (!s->
prune(a,testfix)) {
791 problem =
"No fixpoint";
813 if (!s->
prune(a,testfix)) {
814 problem =
"No fixpoint";
834 if (!s->
prune(a,testfix)) {
835 problem =
"No fixpoint";
853 if (!search_s->failed()) {
863 for (
int i=a.
size();
i--; ) {
876 if (!search_s->failed()) {
883 if (e_s->
next() != NULL) {
884 problem =
"Excess solutions";
896 olog <<
"FAILURE" << std::endl
897 <<
ind(1) <<
"Test: " << test << std::endl
898 <<
ind(1) <<
"Problem: " << problem << std::endl;
900 olog <<
ind(1) <<
"Assignment: " << a << std::endl;
void prune(int i)
Prune some random values from variable i.
FloatNum add_down(FloatNum x, FloatNum y)
Return lower bound of x plus y (domain: )
bool subsumed(const TestSpace &ts) const
Test if ts is subsumed or not (i.e. if there is no more propagator unless the assignment is an extend...
FloatNum div_up(FloatNum x, FloatNum y)
Return upper bound of x divided y (domain: )
FloatNum mul_down(FloatNum x, FloatNum y)
Return lower bound of x times y (domain: )
Inverse implication for reification.
Simple class for describing identation.
unsigned int propagators(void)
Return the number of propagators.
int size(void) const
Return size of array (number of elements)
const FloatNum max
Largest allowed float value.
#define START_TEST(T)
Start new test.
ReifyMode mode(void) const
Return reification mode.
void enable(void)
Enable propagators in space.
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
static Gecode::Support::RandomGenerator rand
Random number generator.
ExecStatus subsumed(Space &home, Propagator &p, int c, TaskArray< Task > &t)
Check for subsumption (all tasks must be assigned)
unsigned int size(void) const
Return size (cardinality) of domain.
Gecode::FloatNum step
Step for next assignment.
void prune(void)
Prune some random values for some random variable.
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 overlap(const FloatVal &x, const FloatVal &y)
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 .
Gecode::FloatNum randFValDown(Gecode::FloatNum l, Gecode::FloatNum u)
int n
Number of variables.
void post(void)
Post propagator.
void bound(void)
Assing a random variable to a random bound.
virtual void operator++(void)
Move to next assignment.
FloatVarBranch FLOAT_VAR_NONE(void)
Select first unassigned variable.
unsigned int size(Space &home) const
Return number of propagators in a group.
Test * test
The test currently run.
Reify imp(BoolVar x)
Use implication for reification.
const FloatNum min
Smallest allowed float value.
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::FloatNum randFValUp(Gecode::FloatNum l, Gecode::FloatNum u)
int n
Number of negative literals for node type.
Generate all assignments except the last variable and complete it to get a solution.
std::ostream & operator<<(std::ostream &os, const Test::Float::Assignment &a)
virtual bool ignore(const Assignment &a) const
Whether to ignore assignment for reification.
TestSpace(int n, Gecode::FloatVal &d, Gecode::FloatNum s, Test *t)
Create test space.
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
FloatRelType
Relation types for floats.
static bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
void disable(void)
Disable propagators in space and compute fixpoint (make all idle)
virtual bool extendAssignement(Assignment &a) const
Complete the current assignment to get a feasible one (which satisfies all constraint). If such an assignment is computed, it returns true, false otherwise.
virtual void dropUntil(const Assignment &a)
Add constraints to skip solutions to the a assignment.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Reification specification.
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.
virtual void operator++(void)
Move to next assignment.
bool log
Whether to log the tests.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)=0
Post constraint.
FloatValBranch FLOAT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
union Gecode::@585::NNF::@62 u
Union depending on nodetype t.
Generate random selection of assignments.
Reify eqv(BoolVar x)
Use equivalence for reification.
Gecode::Reify r
Reification information.
Floating point rounding policy.
bool assigned(void) const
Test whether all variables are assigned.
Boolean integer variables.
Gecode::FloatVarArray x
Variables to be tested.
Gecode::FloatVal d
Initial domain.
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
void assign(const Assignment &a, MaybeType &sol, bool skip=false)
Assign all (or all but one, if skip is true) variables to values in a If assignment of a variable is ...
Node * x
Pointer to corresponding Boolean expression node.
FloatNum sub_down(FloatNum x, FloatNum y)
Return lower bound of x minus y (domain: )
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Gecode::FloatVal d
Domain for each variable.
bool matchAssignment(const Assignment &a) const
Test whether all variables match assignment a.
void enable(Space &home, bool s=true)
Enable all propagators in a group.
FloatNum div_down(FloatNum x, FloatNum y)
Return lower bound of x divided by y (domain: )
MaybeType
Type for comparisons and solutions.
std::ostringstream olog
Stream used for logging.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Space for executing tests.
BoolVar var(void) const
Return Boolean control variable.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
FloatNum sub_up(FloatNum x, FloatNum y)
Return upper bound of x minus y (domain: )
virtual bool run(void)
Perform test.
void threads(double n)
Set number of parallel threads.
int size(void) const
Return number of variables.
FloatNum add_up(FloatNum x, FloatNum y)
Return upper bound of x plus y (domain: )
Gecode toplevel namespace
Implication for reification.
bool failed(void)
Compute a fixpoint and check for failure.
virtual void operator++(void)
Move to next assignment.
Gecode::FloatVal * dsv
Iterator for each variable.
friend FloatVal max(const FloatVal &x, const FloatVal &y)
Generate all assignments.
friend FloatVal min(const FloatVal &x, const FloatVal &y)
#define CHECK_TEST(T, M)
Check the test result and handle failed test.
double FloatNum
Floating point number base type.
ReifyMode
Mode for reification.
#define GECODE_NEVER
Assert that this command is never executed.
Gecode::FloatNum cut(int *cutDirections)
Cut the bigger variable to an half sized interval. It returns the new size of the cut interval...
virtual Assignment * assignment(void) const
Create assignment.
void rel(int i, Gecode::FloatRelType frt, Gecode::FloatVal n)
Perform integer tell operation on x[i].
Depth-first search engine.
Gecode::FloatNum step
Step for going to next solution.
bool reified
Whether the test is for a reified propagator.
virtual Gecode::Space * copy(void)
Copy space during cloning.
Base class for assignments
Equivalence for reification (default)
int val(void) const
Return assigned value.
Reify pmi(BoolVar x)
Use reverse implication for reification.