42 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST) 44 #if QT_VERSION >= 0x050000 73 const int n = q.
size();
74 switch (
opt.propagation()) {
76 for (
int i = 0;
i<
n;
i++)
77 for (
int j =
i+1; j<
n; j++) {
78 rel(*
this, q[
i] != q[j]);
79 rel(*
this, q[
i]+
i != q[j]+j);
80 rel(*
this, q[
i]-
i != q[j]-j);
84 for (
int i = 0;
i<
n;
i++)
85 for (
int j =
i+1; j<
n; j++) {
86 rel(*
this, q[
i]+
i != q[j]+j);
87 rel(*
this, q[
i]-
i != q[j]-j);
108 return new Queens(share,*
this);
115 for (
int i = 0;
i < q.
size();
i++) {
118 os << std::endl <<
"\t";
124 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST) 129 QGraphicsScene* scene;
133 static const int unit = 20;
136 QueensInspector(
void) : scene(NULL), mw(NULL) {}
138 virtual void inspect(
const Space& s) {
143 QList <QGraphicsItem*> itemList = scene->items();
144 foreach (QGraphicsItem*
i, scene->items()) {
145 scene->removeItem(
i);
150 for (
int j=0; j<q.
q.
size(); j++) {
151 scene->addRect(
i*unit,j*unit,unit,unit);
156 scene->addEllipse(QRectF(
i*unit+unit/4,xv.val()*unit+unit/4,
157 unit/2,unit/2),
p,
b);
164 void initialize(
void) {
165 mw =
new QMainWindow();
166 scene =
new QGraphicsScene();
167 QGraphicsView* view =
new QGraphicsView(scene);
168 view->setRenderHints(QPainter::Antialiasing);
169 mw->setCentralWidget(view);
170 mw->setAttribute(Qt::WA_QuitOnClose,
false);
171 mw->setAttribute(Qt::WA_DeleteOnClose,
false);
172 QAction* closeWindow =
new QAction(
"Close window", mw);
173 closeWindow->setShortcut(QKeySequence(
"Ctrl+W"));
174 mw->connect(closeWindow, SIGNAL(triggered()),
176 mw->addAction(closeWindow);
180 virtual std::string name(
void) {
return "Board"; }
182 virtual void finalize(
void) {
200 "only binary disequality constraints");
202 "single distinct and binary disequality constraints");
204 "three distinct constraints");
206 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST) 212 Script::run<Queens,DFS,SizeOptions>(
opt);
Value iterator for integer variables.
static IntArgs create(int n, int start, int inc=1)
Allocate array with n elements such that for all .
Options for scripts with additional size parameter
Use single distinct and binary disequality constraints.
void 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.
int size(void) const
Return size of array (number of elements)
void propagation(int v)
Set default propagation value.
bool assigned(void) const
Test if all variables are assigned.
IntVarArray q
Position of queens on boards.
class Gecode::Options::_I inspect
Abstract base class for inspectors.
Parametric base-class for scripts.
void iterations(unsigned int i)
Set default number of iterations.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
unsigned int size(I &i)
Size of all ranges of range iterator i.
void click(Gist::Inspector *i)
Add inspector that reacts on node double clicks.
int main(int argc, char *argv[])
Main-function.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl)
Post propagator for for all .
virtual void print(std::ostream &os) const
Print solution.
virtual Space * copy(bool share)
Perform copying during cloning.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
Queens(bool share, Queens &s)
Constructor for cloning s.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Queens(const SizeOptions &opt)
The actual problem.
Use three distinct constraints.
Gecode toplevel namespace
Use only binary disequality constraints.