46 namespace Test {
namespace Float {
54 using namespace Gecode;
71 using namespace Gecode;
78 if (curPb->extendAssignement(*
this))
return;
93 for (
int i =
n;
i--; )
104 for (
int i=0;
i<
n;
i++)
105 os <<
"[" << a[
i].
min() <<
"," << a[
i].max() <<
"]" << ((
i!=n-1) ?
"," :
"}");
109 namespace Test {
namespace Float {
112 using namespace Gecode;
113 using namespace Gecode::Float;
129 using namespace Gecode;
130 using namespace Gecode::Float;
149 x(*this,n,Gecode::Float::Limits::
min,Gecode::Float::Limits::
max),
159 olog <<
ind(2) <<
"Initial: x[]=" <<
x
165 :
d(d0),
step(s),
x(*this,n,
d.
min(),
d.
max()), test(t), reified(true) {
169 olog <<
ind(2) <<
"Initial: x[]=" <<
x
175 : Gecode::
Space(share,s),
d(s.
d),
step(s.
step), test(s.test), reified(s.reified) {
179 b.
update(*
this, share, sr);
205 if ((
x[
i].
min() != a[
i].
min()) || (
x[
i].max() != a[
i].max()))
215 olog <<
ind(3) <<
"Posting reified propagator" << std::endl;
219 olog <<
ind(3) <<
"Posting propagator" << std::endl;
226 olog <<
ind(3) <<
"Fixpoint: " <<
x;
228 olog << std::endl <<
ind(3) <<
" --> " << x << std::endl;
238 olog <<
ind(4) <<
"x[" << i <<
"] ";
247 olog <<
" [" << n.
min() <<
"," << n.
max() <<
"]" << std::endl;
257 olog <<
ind(4) <<
"b = " << n << std::endl;
263 using namespace Gecode;
266 for (
int j=a.
size(); j--; )
268 if ((
x[j].
min() == a[j].
max()) || (
x[j].max() == a[j].min()))
281 using namespace Gecode;
296 using namespace Gecode;
297 using namespace Gecode::Float;
301 for (
int j=
x.
size(); j--; ) {
305 if (cutDirections[
i]) {
313 FloatNum m =
r.div_down(
r.add_down(
x[i].min(),
x[
i].max()),2);
325 using namespace Gecode;
329 assert((v >=
x[i].
min()) && (v <=
x[i].
max()));
334 assert((v <=
x[i].
max()) && (v >=
x[i].
min()));
341 using namespace Gecode;
355 i = (i+1) %
x.
size();
361 assert((v >= a[i].
max()) && (v <=
x[i].
max()));
368 assert((v <= a[i].
min()) && (v >=
x[i].
min()));
378 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
381 delete c;
return false;
383 for (
int i=
x.
size(); i--; )
385 delete c;
return false;
388 delete c;
return false;
391 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
404 switch (assigmentType) {
425 if (!testsubsumed)
return true;
432 #define CHECK_TEST(T,M) \
434 olog << ind(3) << "Check: " << (M) << std::endl; \
436 problem = (M); delete s; goto failed; \
440 #define START_TEST(T) \
443 olog << ind(2) << "Testing: " << (T) << std::endl; \
458 using namespace Gecode;
459 const char*
test =
"NONE";
460 const char* problem =
"NONE";
468 post(*search_s,search_s->x);
476 olog <<
ind(1) <<
"Assignment: " <<
a;
492 olog <<
ind(3) <<
"No copy" << std::endl;
498 olog <<
ind(3) <<
"Unshared copy" << std::endl;
507 olog <<
ind(3) <<
"Shared copy" << std::endl;
514 default: assert(
false);
525 START_TEST(
"Partial assignment (after posting)");
553 START_TEST(
"Partial assignment (before posting)");
573 if (!s->
prune(
a,testfix)) {
574 problem =
"No fixpoint";
590 START_TEST(
"Assignment reified (rewrite after post, <=>)");
600 START_TEST(
"Assignment reified (rewrite after post, =>)");
610 START_TEST(
"Assignment reified (rewrite after post, <=)");
620 START_TEST(
"Assignment reified (immediate rewrite, <=>)");
630 START_TEST(
"Assignment reified (immediate rewrite, =>)");
640 START_TEST(
"Assignment reified (immediate rewrite, <=)");
650 START_TEST(
"Assignment reified (before posting, <=>)");
666 START_TEST(
"Assignment reified (before posting, =>)");
680 START_TEST(
"Assignment reified (before posting, <=)");
696 START_TEST(
"Assignment reified (after posting, <=>)");
712 START_TEST(
"Assignment reified (after posting, =>)");
726 START_TEST(
"Assignment reified (after posting, <=)");
747 if (!s->
prune(
a,testfix)) {
748 problem =
"No fixpoint";
770 if (!s->
prune(
a,testfix)) {
771 problem =
"No fixpoint";
791 if (!s->
prune(
a,testfix)) {
792 problem =
"No fixpoint";
810 if (!search_s->failed()) {
820 for (
int i=
a.size();
i--; ) {
833 if (!search_s->failed()) {
840 if (e_s->next() != NULL) {
841 problem =
"Excess solutions";
853 olog <<
"FAILURE" << std::endl
854 <<
ind(1) <<
"Test: " <<
test << std::endl
855 <<
ind(1) <<
"Problem: " << problem << std::endl;
857 olog <<
ind(1) <<
"Assignment: " <<
a << std::endl;
void prune(int i)
Prune some random values from variable i.
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...
const Gecode::FloatNum step
Gecode::FloatNum step
Step for going to next solution.
Inverse implication for reification.
ReifyMode mode(void) const
Return reification mode.
Simple class for describing identation.
const FloatNum max
Largest allowed float value.
#define START_TEST(T)
Start new test.
BoolVar var(void) const
Return Boolean control variable.
union Gecode::@512::NNF::@54 u
Union depending on nodetype t.
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.
Space * clone(bool share=true, CloneStatistics &stat=unused_clone) const
Clone space.
Gecode::FloatNum step
Step for next assignment.
void prune(void)
Prune some random values for some random variable.
Base class for tests with float constraints
bool overlap(const FloatVal &x, const FloatVal &y)
unsigned int size(void) const
Return size (cardinality) of domain.
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.
int val(void) const
Return assigned value.
Test * test
The test currently run.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
Reify imp(BoolVar x)
Use implication for reification.
unsigned int propagators(void) const
Return number of propagators.
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.
TestSpace(int n, Gecode::FloatVal &d, Gecode::FloatNum s, Test *t)
Create test space.
FloatRelType
Relation types for floats.
static bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
bool assigned(void) const
Test whether all variables are assigned.
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.
virtual bool ignore(const Assignment &a) const
Whether to ignore assignment for reification.
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.
Generate random selection of assignments.
struct Gecode::@512::NNF::@54::@55 b
For binary nodes (and, or, eqv)
Reify eqv(BoolVar x)
Use equivalence for reification.
Gecode::Reify r
Reification information.
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const Dictionary &d)
Print statistics summary.
Floating point rounding policy.
Boolean integer variables.
Gecode::FloatVarArray x
Variables to be tested.
Gecode::FloatVal d
Initial domain.
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.
ExecStatus subsumed(Space &home, Propagator &p, TaskArray< Task > &t)
Check tasks t for subsumption.
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.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Gecode::FloatVal d
Domain for each variable.
virtual Assignment * assignment(void) const
Create assignment.
MaybeType
Type for comparisons and solutions.
std::ostringstream olog
Stream used for logging.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
bool matchAssignment(const Assignment &a) const
Test whether all variables match assignment a.
Space for executing tests.
struct Gecode::Space::@49::@51 c
Data available only during copying.
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
int size(void) const
Return number of variables.
bool assigned(void) const
Test whether view is assigned.
virtual bool run(void)
Perform test.
void threads(double n)
Set number of parallel threads.
Implication for reification.
bool failed(void)
Compute a fixpoint and check for failure.
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.
Gecode::FloatVal * dsv
Iterator for each variable.
struct Gecode::@512::NNF::@54::@56 a
For atomic nodes.
bool reified
Does the constraint also exist as reified constraint.
friend FloatVal max(const FloatVal &x, const FloatVal &y)
Generate all assignments.
friend FloatVal min(const FloatVal &x, const FloatVal &y)
int size(void) const
Return size of array (number of elements)
#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...
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(bool share)
Copy space during cloning.
Base class for assignments
Equivalence for reification (default)
Reify pmi(BoolVar x)
Use reverse implication for reification.