43 namespace Test {
namespace Float {
51 using namespace Gecode;
68 using namespace Gecode;
75 if (curPb->extendAssignement(*
this))
return;
90 for (
int i =
n;
i--; )
101 for (
int i=0;
i<
n;
i++)
102 os <<
"[" <<
a[
i].
min() <<
"," <<
a[
i].max() <<
"]" << ((
i!=
n-1) ?
"," :
"}");
106 namespace Test {
namespace Float {
109 using namespace Gecode;
126 using namespace Gecode;
146 x(*this,
n,Gecode::Float::Limits::
min,Gecode::Float::Limits::
max),
156 olog <<
ind(2) <<
"Initial: x[]=" <<
x
166 olog <<
ind(2) <<
"Initial: x[]=" <<
x
172 : Gecode::
Space(s),
d(s.
d),
step(s.
step), test(s.test), reified(s.reified) {
223 olog <<
ind(3) <<
"Posting reified propagator" << std::endl;
227 olog <<
ind(3) <<
"Posting propagator" << std::endl;
234 olog <<
ind(3) <<
"Fixpoint: " <<
x;
236 olog << std::endl <<
ind(3) <<
" --> " <<
x << std::endl;
246 olog <<
ind(4) <<
"x[" <<
i <<
"] ";
255 olog <<
" [" <<
n.min() <<
"," <<
n.max() <<
"]" << std::endl;
265 olog <<
ind(4) <<
"b = " <<
n << std::endl;
271 using namespace Gecode;
272 int i = skip ?
static_cast<int>(
Base::rand(
a.size())) : -1;
274 for (
int j=
a.size(); j--; )
276 if ((
x[j].
min() ==
a[j].
max()) || (
x[j].max() ==
a[j].min()))
289 using namespace Gecode;
304 using namespace Gecode;
309 for (
int j=
x.
size(); j--; ) {
313 if (cutDirections[
i]) {
333 using namespace Gecode;
349 using namespace Gecode;
390 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
393 delete c;
return false;
396 if (
x[
i].
size() !=
c->x[
i].size()) {
397 delete c;
return false;
400 delete c;
return false;
403 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
421 switch (assigmentType) {
442 if (!testsubsumed)
return true;
449 #define CHECK_TEST(T,M) \
451 olog << ind(3) << "Check: " << (M) << std::endl; \
453 problem = (M); delete s; goto failed; \
457 #define START_TEST(T) \
460 olog << ind(2) << "Testing: " << (T) << std::endl; \
475 using namespace Gecode;
476 const char*
test =
"NONE";
477 const char* problem =
"NONE";
485 post(*search_s,search_s->
x);
493 olog <<
ind(1) <<
"Assignment: " <<
a;
509 olog <<
ind(3) <<
"No copy" << std::endl;
515 olog <<
ind(3) <<
"Copy" << std::endl;
522 default: assert(
false);
533 START_TEST(
"Partial assignment (after posting)");
548 START_TEST(
"Assignment (after posting, disable)");
563 START_TEST(
"Partial assignment (after posting, disable)");
593 START_TEST(
"Partial assignment (before posting)");
613 if (!s->
prune(
a,testfix)) {
614 problem =
"No fixpoint";
629 START_TEST(
"Assignment reified (rewrite after post, <=>)");
639 START_TEST(
"Assignment reified (rewrite after post, =>)");
649 START_TEST(
"Assignment reified (rewrite after post, <=)");
659 START_TEST(
"Assignment reified (immediate rewrite, <=>)");
669 START_TEST(
"Assignment reified (immediate rewrite, =>)");
679 START_TEST(
"Assignment reified (immediate rewrite, <=)");
689 START_TEST(
"Assignment reified (before posting, <=>)");
705 START_TEST(
"Assignment reified (before posting, =>)");
719 START_TEST(
"Assignment reified (before posting, <=)");
735 START_TEST(
"Assignment reified (after posting, <=>)");
751 START_TEST(
"Assignment reified (after posting, =>)");
765 START_TEST(
"Assignment reified (after posting, <=)");
786 if (!s->
prune(
a,testfix)) {
787 problem =
"No fixpoint";
809 if (!s->
prune(
a,testfix)) {
810 problem =
"No fixpoint";
830 if (!s->
prune(
a,testfix)) {
831 problem =
"No fixpoint";
849 if (!search_s->
failed()) {
859 for (
int i=
a.size();
i--; ) {
872 if (!search_s->
failed()) {
879 if (e_s->
next() != NULL) {
880 problem =
"Excess solutions";
892 olog <<
"FAILURE" << std::endl
893 <<
ind(1) <<
"Test: " <<
test << std::endl
894 <<
ind(1) <<
"Problem: " << problem << std::endl;
896 olog <<
ind(1) <<
"Assignment: " <<
a << std::endl;
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
union Gecode::@602::NNF::@65 u
Union depending on nodetype t.
int n
Number of negative literals for node type.
Node * x
Pointer to corresponding Boolean expression node.
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
Boolean integer variables.
unsigned int size(void) const
Return size (cardinality) of domain.
int val(void) const
Return assigned value.
Depth-first search engine.
friend FloatVal max(const FloatVal &x, const FloatVal &y)
friend FloatVal min(const FloatVal &x, const FloatVal &y)
Floating point rounding policy.
void threads(double n)
Set number of parallel threads.
unsigned int size(Space &home) const
Return number of propagators in a group.
void disable(Space &home)
Disable all propagators in a group.
void enable(Space &home, bool s=true)
Enable all propagators in a group.
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 (NULL, if none exists or search has been stopped)
struct Gecode::Space::@61::@63 c
Data available only during copying.
bool assigned(void) const
Test if all variables are assigned.
int size(void) const
Return size of array (number of elements)
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
bool assigned(void) const
Test whether view is assigned.
static Gecode::Support::RandomGenerator rand
Random number generator.
static bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
Base class for assignments
int n
Number of variables.
Gecode::FloatVal d
Domain for each variable.
Generate all assignments.
virtual void operator++(void)
Move to next assignment.
Gecode::FloatNum step
Step for next assignment.
Gecode::FloatVal * dsv
Iterator for each variable.
Generate all assignments except the last variable and complete it to get a solution.
virtual void operator++(void)
Move to next assignment.
Generate random selection of assignments.
virtual void operator++(void)
Move to next assignment.
Space for executing tests.
Gecode::FloatVarArray x
Variables to be tested.
void prune(void)
Prune some random values for some random variable.
Gecode::FloatNum cut(int *cutDirections)
Cut the bigger variable to an half sized interval. It returns the new size of the cut interval....
bool matchAssignment(const Assignment &a) const
Test whether all variables match assignment a.
Gecode::Reify r
Reification information.
void bound(void)
Assing a random variable to a random bound.
unsigned int propagators(void)
Return the number of propagators.
void prune(int i)
Prune some random values from variable i.
void disable(void)
Disable propagators in space and compute fixpoint (make all idle)
Gecode::FloatVal d
Initial domain.
void post(void)
Post propagator.
TestSpace(int n, Gecode::FloatVal &d, Gecode::FloatNum s, Test *t)
Create test space.
Test * test
The test currently run.
bool reified
Whether the test is for a reified propagator.
void enable(void)
Enable propagators in space.
bool failed(void)
Compute a fixpoint and check for failure.
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.
Gecode::FloatNum step
Step for going to next solution.
void rel(int i, Gecode::FloatRelType frt, Gecode::FloatVal n)
Perform integer tell operation on x[i].
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 ...
virtual Gecode::Space * copy(void)
Copy space during cloning.
virtual bool extendAssignement(Assignment &a) const
Complete the current assignment to get a feasible one (which satisfies all constraint)....
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)=0
Post constraint.
virtual bool run(void)
Perform test.
Gecode::FloatNum step
Step for going to next solution.
virtual Assignment * assignment(void) const
Create assignment.
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...
bool reified
Does the constraint also exist as reified constraint.
virtual bool ignore(const Assignment &a) const
Whether to ignore assignment for reification.
bool log
Whether to log the tests.
Simple class for describing identation.
FloatValBranch FLOAT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
FloatVarBranch FLOAT_VAR_NONE(void)
Select first unassigned variable.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
double FloatNum
Floating point number base type.
FloatRelType
Relation types for floats.
@ FRT_LQ
Less or equal ( )
@ FRT_GQ
Greater or equal ( )
Reify imp(BoolVar x)
Use implication for reification.
Reify eqv(BoolVar x)
Use equivalence for reification.
ReifyMode
Mode for reification.
Reify pmi(BoolVar x)
Use reverse implication for reification.
@ RM_IMP
Implication for reification.
@ RM_PMI
Inverse implication for reification.
@ RM_EQV
Equivalence for reification (default)
SpaceStatus status(StatusStatistics &stat=unused_status)
Query space status.
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
@ SS_FAILED
Space is failed
const FloatNum max
Largest allowed float value.
const FloatNum min
Smallest allowed float value.
bool overlap(const FloatVal &x, const FloatVal &y)
ExecStatus subsumed(Space &home, Propagator &p, int c, TaskArray< Task > &t)
Check for subsumption (all tasks must be assigned)
unsigned int size(I &i)
Size of all ranges of range iterator i.
const Gecode::FloatNum step
Gecode::FloatNum randFValDown(Gecode::FloatNum l, Gecode::FloatNum u)
MaybeType
Type for comparisons and solutions.
Gecode::FloatNum randFValUp(Gecode::FloatNum l, Gecode::FloatNum u)
Gecode::IntArgs i({1, 2, 3, 4})
std::ostringstream olog
Stream used for logging.
#define GECODE_NEVER
Assert that this command is never executed.
std::ostream & operator<<(std::ostream &os, const Test::Float::Assignment &a)
#define START_TEST(T)
Start new test.
#define CHECK_TEST(T, M)
Check the test result and handle failed test.