62 const static int n = 18;
76 for (
int i=0;
i<n/2;
i++) {
77 q1[
i] = q[
i]; q2[
i] = q[n/2 +
i];
94 return new Queens(share,*
this);
99 if (q[
i].val() != s.
q[
i].val())
108 static std::string
name(
void) {
126 #ifdef GECODE_HAS_SET_VARS
131 static const int size = 16;
133 static const int distance = 4;
135 static const int bits = 8;
141 x(*this,size,
IntSet::empty,1,bits) {
143 for (
int i=x.
size();
i--;)
144 cx[
i] =
expr(*
this, -x[
i]);
146 for (
int i=0; i<x.
size(); i++)
147 for (
int j=i+1; j<x.
size(); j++)
157 for (
int i=0; i<size/2; i++) {
158 x1[
i] = x[
i]; x2[
i] = x[size/2 +
i];
171 x.
update(*
this, share, s.x);
175 return new Hamming(share,*
this);
179 for (
int i=0;
i<x.
size();
i++) {
191 static std::string
name(
void) {
209 template<
class Model,
class ValBranch>
222 static std::string
str(
unsigned int i) {
229 :
Base(
"NoGoods::"+Model::name()+
"::"+Model::val(vb0)+
"::"+str(t0)+
230 "::"+(a0 ?
"+" :
"-")+
"::"+(n0 ?
"+" :
"-")),
231 vb(vb0), t(t0), a(a0), n(n0) {}
234 Model* m =
new Model(vb,a,n);
236 Model* s_plain =
dfs(m);
256 Model* s_nogoods =
dfs(m);
258 bool ok = ((s_nogoods != NULL) &&
259 ((t != 1) || s_plain->same(*s_nogoods)));
279 for (
unsigned int t = 1;
t<=4;
t++) {
286 #ifdef GECODE_HAS_SET_VARS
Which values to select for branching first.
static IntArgs create(int n, int start, int inc=1)
Allocate array with n elements such that for all .
bool same(const Hamming &s) const
Check whether two solutions are the same.
unsigned int nogoods_limit
Depth limit for extraction of no-goods.
unsigned int t
Number of threads to use.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
Select all values starting from smallest.
Help class to create and register tests.
unsigned long int limit(void) const
Return current limit.
bool a
Whether to also assign some variables.
SetVarBranch SET_VAR_NONE(void)
Select first unassigned variable.
static std::string val(SetValBranch svb)
Return name for branching.
Stop-object based on number of nodes
NoGoods(ValBranch vb0, unsigned int t0, bool a0, bool n0)
Initialize test.
static std::string str(unsigned int i)
Map unsigned integer to string.
ValBranch vb
How to branch.
Select values greater than mean of smallest and largest value.
void dummy(Space &home)
A dummy function for branching.
Which values to select for branching first.
Value propagation or consistency (naive)
Select all values starting from largest.
SetValBranch SET_VAL_MIN_INC(void)
Include smallest element.
bool equal(I &i, J &j)
Check whether range iterators i and j are equal.
Select select(void) const
Return selection strategy.
Select values not greater than mean of smallest and largest value.
Select select(void) const
Return selection strategy.
Hamming(bool share, Hamming &s)
Constructor for copying s.
Example for testing set no-goods.
virtual bool run(void)
Run test.
Include smallest element.
Example for testing integer no-goods.
static std::string val(IntValBranch ivb)
Return name for branching.
virtual Space * copy(bool share)
Copy during cloning.
Hamming(SetValBranch svb, bool assign, bool null)
Actual model.
IntAssign INT_ASSIGN_MIN(void)
Select smallest value.
virtual void post(Space &home) const
Post no-goods.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
static std::string name(void)
Return name.
Create(void)
Perform creation and registration.
double threads
Number of threads to use.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
int dfs(Space *root, const Gist::Options &opt)
Create a new stand-alone Gist for root.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
unsigned int size(I &i)
Size of all ranges of range iterator i.
IntValBranch INT_VAL_SPLIT_MAX(void)
Select values greater than mean of smallest and largest value.
Base class for all tests to be run
SetValBranch SET_VAL_MAX_EXC(void)
Exclude largest element.
Iterator for the greatest lower bound ranges of a set variable.
Queens(bool share, Queens &s)
Constructor for cloning s.
SetValBranch SET_VAL_MAX_INC(void)
Include largest element.
Queens(IntValBranch ivb, bool assign, bool null)
The actual problem.
IntVarArray q
Position of queens on boards.
Passing integer variables.
SetValBranch SET_VAL_MIN_EXC(void)
Exclude smallest element.
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
bool stopped(void) const
Check whether engine has been stopped.
IntValBranch INT_VAL_MAX(void)
Select largest value.
Exclude smallest element.
Value branching information.
BoolVar expr(Home home, const BoolExpr &e, IntConLevel icl)
Post Boolean expression and return its value.
IntValBranch INT_VALUES_MIN(void)
Try all values starting from smallest.
BrancherHandle assign(Home home, const FloatVarArgs &x, FloatAssign fa, FloatBranchFilter bf, FloatVarValPrint vvp)
Assign all x with value selection vals.
Node * x
Pointer to corresponding Boolean expression node.
No-goods recorded from restarts.
IntValBranch INT_VALUES_MAX(void)
Try all values starting from largest.
T * next(void)
Return next solution (NULL, if none exists or search has been stopped)
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
static unsigned int nodeinc(void)
Return increment for node stop.
void distinct(Home home, const IntVarArgs &x, IntConLevel icl)
Post propagator for for all .
static unsigned int nodeinc(void)
Return increment for node stop.
Stop * stop
Stop object for stopping search.
IntValBranch INT_VAL_SPLIT_MIN(void)
Select values not greater than mean of smallest and largest value.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
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.
NoGoods & nogoods(void)
Return no-goods.
int size(void) const
Return size of array (number of elements)
#define GECODE_NEVER
Assert that this command is never executed.
bool n
Whether to also create branchers without no-good literals.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
Depth-first search engine.
static std::string name(void)
Return name.
bool same(const Queens &s) const
Check whether two solutions are the same.
Example: Generating Hamming codes
virtual Space * copy(bool share)
Perform copying during cloning.