56 if ((
dsv[i].
max() <
d.max()) || (i == 0))
74 if ((
dsv[i].
max() <
d.max()) || (i == 0)) {
75 if (
curPb->extendAssignment(*
this))
return;
76 if ((
dsv[i].
max() >=
d.max()) && (i == 0))
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) ?
"," :
"}");
156 olog <<
ind(2) <<
"Initial: x[]=" <<
x
166 olog <<
ind(2) <<
"Initial: x[]=" <<
x
173 x.update(*
this, s.
x);
198 for (
int i =
x.size(); i--; )
204 for (
int i=
x.size(); i--; )
212 for (
int i=
x.size(); i--; )
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;
272 int i = skip ?
static_cast<int>(rand(a.
size())) : -1;
274 for (
int j=a.
size(); j--; )
291 int i = rand(
x.size());
293 i = (i+1) %
x.size();
309 for (
int j=
x.size(); j--; ) {
310 if (!
x[j].
assigned() && (
x[j].size() >
x[i].size())) i = j;
313 if (cutDirections[i]) {
337 assert((v >=
x[i].
min()) && (v <=
x[i].
max()));
342 assert((v <=
x[i].
max()) && (v >=
x[i].
min()));
351 int i = rand(
x.size());
353 i = (i+1) %
x.size();
361 int i = rand(
x.size());
363 i = (i+1) %
x.size();
371 assert((v >= a[i].
max()) && (v <=
x[i].
max()));
380 assert((v <= a[i].
min()) && (v >=
x[i].
min()));
390 olog <<
ind(3) <<
"Testing fixpoint on copy" << std::endl;
393 delete c;
return false;
395 for (
int j=
x.size(); j--; )
396 if (
x[j].size() !=
c->x[j].size()) {
397 delete c;
return false;
399 if (
reified && (
r.var().size() !=
c->r.var().size())) {
400 delete c;
return false;
403 olog <<
ind(3) <<
"Finished testing fixpoint on copy" << std::endl;
443 if (
const_cast<TestSpace&
>(ts).propagators() == 0)
return true;
449#define CHECK_TEST(T,M) \
452 olog << ind(3) << "Check: " << (M) << std::endl; \
454 problem = (M); delete s; goto failed; \
459#define START_TEST(T) \
463 olog << ind(2) << "Testing: " << (T) << std::endl; \
480 const char* test =
"NONE";
481 const char* problem =
"NONE";
489 post(*search_s,search_s->
x);
494 while (a.has_more()) {
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)");
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, <=)");
791 problem =
"No fixpoint";
814 problem =
"No fixpoint";
835 problem =
"No fixpoint";
853 if (!search_s->
failed()) {
861 CHECK_TEST(s !=
nullptr,
"Solutions exhausted");
863 for (
int i=a.
size(); i--; ) {
876 if (!search_s->
failed()) {
883 if (e_s->
next() !=
nullptr) {
884 problem =
"Excess solutions";
896 olog <<
"FAILURE" << std::endl
897 <<
ind(1) <<
"Test: " << test << std::endl
898 <<
ind(1) <<
"Problem: " << problem << std::endl;
899 if (a.has_more() &&
opt.log)
900 olog <<
ind(1) <<
"Assignment: " << a << std::endl;
Boolean integer variables.
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)
FloatNum size(void) const
Return size of float value (distance between maximum and minimum).
Floating point rounding policy.
FloatNum add_up(FloatNum x, FloatNum y)
Return upper bound of x plus y (domain: ).
FloatNum div_up(FloatNum x, FloatNum y)
Return upper bound of x divided y (domain: ).
FloatNum div_down(FloatNum x, FloatNum y)
Return lower bound of x divided by y (domain: ).
FloatNum add_down(FloatNum x, FloatNum y)
Return lower bound of x plus y (domain: ).
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.
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
int n
Number of variables.
Gecode::FloatVal d
Domain for each variable.
Generate all assignments.
virtual void next(Gecode::Support::RandomGenerator &rand)
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.
Gecode::FloatVal * dsv
Iterator for each variable.
virtual void next(Gecode::Support::RandomGenerator &rand)
Move to next assignment.
Gecode::FloatNum step
Step for next assignment.
const Test * curPb
Current problem used to complete assignment.
Generate random selection of assignments.
virtual void next(Gecode::Support::RandomGenerator &rand)
Move to next assignment.
Gecode::FloatNum randval(Gecode::Support::RandomGenerator &rand)
Gecode::FloatVal * vals
The current values for the variables.
int a
How many assignments still to be generated Generate new value according to domain.
Space for executing tests.
void bound(Gecode::Support::RandomGenerator &rand)
Assign a random variable to a random bound.
void prune(int i, Gecode::Support::RandomGenerator &rand)
Prune some random values from variable i.
Gecode::FloatVarArray x
Variables to be tested.
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.
unsigned int propagators(void)
Return the number of propagators.
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 assign(const Assignment &a, MaybeType &sol, bool skip, Gecode::Support::RandomGenerator &rand)
Assign all (or all but one, if skip is true) variables to values in a If assignment of a variable is ...
void rel(int i, Gecode::FloatRelType frt, Gecode::FloatVal n)
Perform integer tell operation on x[i].
virtual Gecode::Space * copy(void)
Copy space during cloning.
virtual bool extendAssignment(Assignment &a) const
Complete the current assignment to get a feasible one (which satisfies all constraint)....
bool testsubsumed
Whether to test for subsumption.
bool testfix
Whether to perform fixpoint test.
bool eqv(void) const
Test whether equivalence as reification mode is supported.
int arity
Number of variables.
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.
AssignmentType assignmentType
Gives the type of assignment to use.
bool pmi(void) const
Test whether reverse implication as reification mode is supported.
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.
bool testsearch
Whether to perform search test.
virtual bool ignore(const Assignment &a) const
Whether to ignore assignment for reification.
virtual MaybeType solution(const Assignment &) const =0
Check for solution.
Gecode::FloatVal dom
Domain of variables.
bool imp(void) const
Test whether implication as reification mode is supported.
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 .
double FloatNum
Floating point number base type.
FloatRelType
Relation types for floats.
@ FRT_LQ
Less or equal ( ).
@ FRT_GQ
Greater or equal ( ).
ReifyMode
Mode for reification.
@ RM_IMP
Implication for reification.
@ RM_PMI
Inverse implication for reification.
@ RM_EQV
Equivalence for reification (default).
Space(void)
Default constructor.
Space * clone(void) const
Clone space.
SpaceStatus status(StatusStatistics &stat)
Query space status.
@ SS_FAILED
Space is failed
bool overlap(const FloatVal &x, const FloatVal &y)
Numerical limits for integer variables.
const int max
Largest allowed integer value.
Gecode toplevel namespace
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
FloatVarBranch FLOAT_VAR_NONE(void)
Select first unassigned variable.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
FloatValBranch FLOAT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
MaybeType
Type for comparisons and solutions.
Gecode::FloatNum randFValUp(Gecode::FloatNum l, Gecode::FloatNum u, Gecode::Support::RandomGenerator &rand)
Gecode::FloatNum randFValDown(Gecode::FloatNum l, Gecode::FloatNum u, Gecode::Support::RandomGenerator &rand)
std::ostringstream olog
Stream used for logging.
#define GECODE_NEVER
Assert that this command is never executed.
#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::Float::Assignment &a)