42namespace Test {
namespace Assign {
70 :
x(*this,
n, 0, 1) {}
82#ifdef GECODE_HAS_SET_VARS
91 :
x(*this,
n,
Gecode::IntSet::empty, d) {}
105#ifdef GECODE_HAS_FLOAT_VARS
114 :
x(*this,
n, d.min(), d.max()) {}
134 const char* int_assign_name[] = {
142 const int n_int_assign =
143 sizeof(int_assign_name)/
sizeof(
const char*);
156 const char* bool_assign_name[] = {
163 const int n_bool_assign =
164 sizeof(bool_assign_name)/
sizeof(
const char*);
172 :
Base(
"Int::Assign::"+s), arity(
a), dom(d) {
178 IntTestSpace* root =
new IntTestSpace(
arity,
dom);
179 post(*root, root->x);
180 (void) root->status();
182 for (
int val = 0; val<n_int_assign; val++) {
183 IntTestSpace* clone =
static_cast<IntTestSpace*
>(root->clone());
191 case 0: ia = INT_ASSIGN_MIN();
break;
192 case 1: ia = INT_ASSIGN_MED();
break;
193 case 2: ia = INT_ASSIGN_MAX();
break;
194 case 3: ia = INT_ASSIGN_RND(
r);
break;
195 case 4: ia = INT_ASSIGN(&
int_val);
break;
199 assign(*clone, clone->x, ia);
205 while (
Space* s = e_s.next()) {
206 delete s; solutions++;
208 if (solutions != 1) {
209 std::cout <<
"FAILURE" << std::endl
210 <<
"\tc_d=" << o.
c_d <<
", a_d=" << o.
a_d << std::endl
211 <<
"\t" << int_assign_name[val] << std::endl;
221 : Base(
"Bool::Assign::"+s), arity(
a) {
227 BoolTestSpace* root =
new BoolTestSpace(
arity);
228 post(*root, root->x);
229 (void) root->status();
231 for (
int val = n_bool_assign; val--; ) {
232 BoolTestSpace*
clone =
static_cast<BoolTestSpace*
>(root->clone());
252 while (
Space* s = e_s.next()) {
255 if (solutions != 1) {
256 std::cout <<
"FAILURE" << std::endl
257 <<
"\tc_d=" << o.
c_d <<
", a_d=" << o.
a_d << std::endl
258 <<
"\t" << int_assign_name[val] << std::endl;
267#ifdef GECODE_HAS_SET_VARS
275 const char* set_assign_name[] = {
276 "SET_ASSIGN_MIN_INC",
277 "SET_ASSIGN_MIN_EXC",
278 "SET_ASSIGN_MED_INC",
279 "SET_ASSIGN_MED_EXC",
280 "SET_ASSIGN_MAX_INC",
281 "SET_ASSIGN_MAX_EXC",
282 "SET_ASSIGN_RND_INC",
283 "SET_ASSIGN_RND_EXC",
287 const int n_set_assign =
288 sizeof(set_assign_name)/
sizeof(
const char*);
297 :
Base(
"Set::Assign::"+s), arity(
a), dom(d) {
303 SetTestSpace* root =
new SetTestSpace(
arity,
dom);
304 post(*root, root->x);
305 (void) root->status();
307 for (
int val = n_set_assign; val--; ) {
308 SetTestSpace* clone =
static_cast<SetTestSpace*
>(root->clone());
317 case 0: sa = SET_ASSIGN_MIN_INC();
break;
318 case 1: sa = SET_ASSIGN_MIN_EXC();
break;
319 case 2: sa = SET_ASSIGN_MED_INC();
break;
320 case 3: sa = SET_ASSIGN_MED_EXC();
break;
321 case 4: sa = SET_ASSIGN_MAX_INC();
break;
322 case 5: sa = SET_ASSIGN_MAX_EXC();
break;
323 case 6: sa = SET_ASSIGN_RND_INC(
r);
break;
324 case 7: sa = SET_ASSIGN_RND_EXC(
r);
break;
325 case 8: sa = SET_ASSIGN(&
set_val);
break;
329 assign(*clone, clone->x, sa);
335 while (
Space* s = e_s.next()) {
336 delete s; solutions++;
338 if (solutions != 1) {
339 std::cout <<
"FAILURE" << std::endl
340 <<
"\tc_d=" << o.
c_d <<
", a_d=" << o.
a_d << std::endl
341 <<
"\t" << set_assign_name[val] << std::endl;
352#ifdef GECODE_HAS_FLOAT_VARS
360 const char* float_assign_name[] = {
367 const int n_float_assign =
368 sizeof(float_assign_name)/
sizeof(
const char*);
378 :
Base(
"Float::Assign::"+s), arity(
a), dom(d) {
384 FloatTestSpace* root =
new FloatTestSpace(
arity,
dom);
385 post(*root, root->x);
386 (void) root->status();
388 for (
int val = n_float_assign; val--; ) {
389 FloatTestSpace* clone =
static_cast<FloatTestSpace*
>(root->clone());
398 case 0: fa = FLOAT_ASSIGN_MIN();
break;
399 case 1: fa = FLOAT_ASSIGN_MAX();
break;
400 case 2: fa = FLOAT_ASSIGN_RND(
r);
break;
401 case 3: fa = FLOAT_ASSIGN(&
float_val);
break;
405 assign(*clone, clone->x, fa);
411 while (
Space* s = e_s.next()) {
412 delete s; solutions++;
414 if (solutions != 1) {
415 std::cout <<
"FAILURE" << std::endl
416 <<
"\tc_d=" << o.
c_d <<
", a_d=" << o.
a_d << std::endl
417 <<
"\t" << float_assign_name[val] << std::endl;
int n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Node * x
Pointer to corresponding Boolean expression node.
Which values to select for assignment.
Boolean integer variables.
Depth-first search engine.
Which values to select for assignment.
Value description class for branching.
bool l
Whether to try the lower or upper half first.
FloatNum n
The middle value for branching.
Which values to select for assignment.
unsigned int c_d
Create a clone after every c_d commits (commit distance)
unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance)
Which value to select for assignment.
Iterator for the unknown ranges of a set variable.
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
Space for executing Boolean tests.
BoolTestSpace(int n)
Initialize test space.
virtual Gecode::Space * copy(void)
Copy space during cloning.
Gecode::BoolVarArray x
Variables to be tested.
BoolTestSpace(BoolTestSpace &s)
Constructor for cloning s.
int bool_val(const Gecode::Space &, Gecode::BoolVar x, int)
Test function for branch value function.
virtual bool run(void)
Perform test.
BoolTest(const std::string &s, int a)
Construct and register test.
int arity
Number of variables.
virtual void post(Gecode::Space &home, Gecode::BoolVarArray &x)=0
Post assignment on variables x.
Space for executing Boolean tests.
Gecode::FloatNumBranch float_val(const Gecode::Space &, Gecode::FloatVar x, int)
Test function for branch value function.
Gecode::FloatVarArray x
Variables to be tested.
virtual Gecode::Space * copy(void)
Copy space during cloning.
FloatTestSpace(FloatTestSpace &s)
Constructor for cloning s.
FloatTestSpace(int n, const Gecode::FloatVal &d)
Initialize test space.
FloatTest(const std::string &s, int a, const Gecode::FloatVal &d)
Construct and register test.
Gecode::FloatVal dom
Domain of variables.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)=0
Post assignment on variables x.
int arity
Number of variables.
virtual bool run(void)
Perform test.
Space for executing integer tests.
virtual Gecode::Space * copy(void)
Copy space during cloning.
IntTestSpace(int n, Gecode::IntSet &d)
Initialize test space.
IntTestSpace(IntTestSpace &s)
Constructor for cloning s.
int int_val(const Gecode::Space &, Gecode::IntVar x, int)
Test function for branch value function.
Gecode::IntVarArray x
Variables to be tested.
virtual bool run(void)
Perform test.
IntTest(const std::string &s, int a, const Gecode::IntSet &d)
Construct and register test.
Gecode::IntSet dom
Domain of variables.
int arity
Number of variables.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)=0
Post assignment on variables x.
Space for executing Boolean tests.
SetTestSpace(int n, const Gecode::IntSet &d)
Initialize test space.
int set_val(const Gecode::Space &, Gecode::SetVar x, int)
Test function for branch value function.
Gecode::SetVarArray x
Variables to be tested.
SetTestSpace(SetTestSpace &s)
Constructor for cloning s.
virtual Gecode::Space * copy(void)
Copy space during cloning.
int arity
Number of variables.
Gecode::IntSet dom
Upper bound of variable domains.
virtual bool run(void)
Perform test.
virtual void post(Gecode::Space &home, Gecode::SetVarArray &x)=0
Post assignment on variables x.
SetTest(const std::string &s, int a, const Gecode::IntSet &d)
Construct and register test.
Base class for all tests to be run
static Gecode::Support::RandomGenerator rand
Random number generator.
void assign(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatAssign vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Assign all x with variable selection vars and value selection vals.
Space(void)
Default constructor.
const bool clone
Whether engines create a clone when being initialized.
Gecode toplevel namespace
BoolAssign BOOL_ASSIGN_MAX(void)
Select largest value.
BoolAssign BOOL_ASSIGN_RND(Rnd r)
Select random value.
BoolAssign BOOL_ASSIGN(BoolBranchVal v, BoolBranchCommit c=nullptr)
Select value as defined by the value function v and commit function c.
BoolAssign BOOL_ASSIGN_MIN(void)
Select smallest value.
int solutions(TestSpace *c, Gecode::Search::Options &o, int maxNbSol=-1)
Find number of solutions.
#define GECODE_NEVER
Assert that this command is never executed.