38#if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
40#if QT_VERSION >= 0x050000
68 :
Script(opt),
q(*this,opt.size(),0,opt.size()-1) {
70 switch (opt.propagation()) {
72 for (int i = 0; i<n; i++)
73 for (int j = i+1; j<n; j++) {
74 rel(*this, q[i] != q[j]);
75 rel(*this, q[i]+i != q[j]+j);
76 rel(*this, q[i]-i != q[j]-j);
80 for (
int i = 0; i<
n; i++)
81 for (
int j = i+1; j<
n; j++) {
82 rel(*
this,
q[i]+i !=
q[j]+j);
83 rel(*
this,
q[i]-i !=
q[j]-j);
111 for (
int i = 0; i < q.
size(); i++) {
114 os << std::endl <<
"\t";
120#if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
125 QGraphicsScene* scene;
129 static const int unit = 20;
132 QueensInspector(
void) : scene(NULL), mw(NULL) {}
139 QList <QGraphicsItem*> itemList = scene->items();
140 foreach (QGraphicsItem* i, scene->items()) {
141 scene->removeItem(i);
145 for (
int i=0;
i<q.
q.
size();
i++) {
146 for (
int j=0; j<q.
q.
size(); j++) {
147 scene->addRect(i*unit,j*unit,unit,unit);
149 QBrush
b(q.
q[i].
assigned() ? Qt::black : Qt::red);
150 QPen
p(q.
q[i].
assigned() ? Qt::black : Qt::white);
152 scene->addEllipse(QRectF(i*unit+unit/4,xv.val()*unit+unit/4,
153 unit/2,unit/2),
p,
b);
160 void initialize(
void) {
161 mw =
new QMainWindow();
162 scene =
new QGraphicsScene();
163 QGraphicsView* view =
new QGraphicsView(scene);
164 view->setRenderHints(QPainter::Antialiasing);
165 mw->setCentralWidget(view);
166 mw->setAttribute(Qt::WA_QuitOnClose,
false);
167 mw->setAttribute(Qt::WA_DeleteOnClose,
false);
168 QAction* closeWindow =
new QAction(
"Close window", mw);
169 closeWindow->setShortcut(QKeySequence(
"Ctrl+W"));
170 mw->connect(closeWindow, SIGNAL(triggered()),
172 mw->addAction(closeWindow);
176 virtual std::string
name(
void) {
return "Board"; }
196 "only binary disequality constraints");
198 "single distinct and binary disequality constraints");
200 "three distinct constraints");
202#if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
204 opt.inspect.click(&ki);
207 opt.
parse(argc,argv);
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
Parametric base-class for scripts.
static void run(const Options &opt, Script *s=NULL)
Abstract base class for inspectors.
virtual void inspect(const Space &s)=0
Call-back function.
virtual void finalize(void)
Clean up when Gist exits.
virtual std::string name(void)
Name of the inspector.
static IntArgs create(int n, int start, int inc=1)
Allocate array with n elements such that for all .
Value iterator for integer variables.
Options for scripts with additional size parameter
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.
virtual Space * copy(void)
Perform copying during cloning.
int main(int argc, char *argv[])
Main-function.
@ PROP_DISTINCT
Use three distinct constraints.
@ PROP_BINARY
Use only binary disequality constraints.
@ PROP_MIXED
Use single distinct and binary disequality constraints.
Queens(const SizeOptions &opt)
The actual problem.
Queens(Queens &s)
Constructor for cloning s.
virtual void print(std::ostream &os) const
Print solution.
IntVarArray q
Position of queens on boards.
void parse(int argc, char *argv[])
Parse commandline arguments.
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 .
Gecode toplevel namespace
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl=IPL_DEF)
Post propagator for for all .
IntValBranch INT_VAL_MIN(void)
Select smallest value.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl=nullptr)
Select variable with smallest domain size.
Gecode::IntArgs i({1, 2, 3, 4})