38 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
40 #if QT_VERSION >= 0x050000
45 using namespace Gecode;
69 const int n = q.
size();
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) {}
134 virtual void inspect(
const Space& s) {
139 QList <QGraphicsItem*> itemList = scene->items();
140 foreach (QGraphicsItem*
i, scene->items()) {
141 scene->removeItem(
i);
146 for (
int j=0; j<q.
q.
size(); j++) {
147 scene->addRect(
i*unit,j*unit,unit,unit);
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"; }
178 virtual void finalize(
void) {
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)
208 Script::run<Queens,DFS,SizeOptions>(
opt);
struct Gecode::@602::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.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
Parametric base-class for scripts.
Abstract base class for inspectors.
static IntArgs create(int n, int start, int inc=1)
Allocate array with n elements such that for all .
Value iterator for integer variables.
void click(Gist::Inspector *i)
Add inspector that reacts on node double clicks.
void propagation(int v)
Set default propagation value.
void iterations(unsigned int i)
Set default number of iterations.
class Gecode::Options::_I inspect
Script mode to run.
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.
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.
virtual Space * copy(void)
Perform copying during cloning.
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl)
Post propagator for for all .
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
IntValBranch INT_VAL_MIN(void)
Select smallest value.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Gecode::IntArgs i({1, 2, 3, 4})