Go to the documentation of this file.
38 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
40 #if QT_VERSION >= 0x050000
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) {
135 const Queens& q = static_cast<const Queens&>(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)
void propagation(int v)
Set default propagation value.
static IntArgs create(int n, int start, int inc=1)
Allocate array with n elements such that for all .
virtual void print(std::ostream &os) const
Print solution.
void click(Gist::Inspector *i)
Add inspector that reacts on node double clicks.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Use single distinct and binary disequality constraints.
Value iterator for integer variables.
class Gecode::Options::_I inspect
Script mode to run.
Queens(Queens &s)
Constructor for cloning s.
Abstract base class for inspectors.
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.
void iterations(unsigned int i)
Set default number of iterations.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Queens(const SizeOptions &opt)
The actual problem.
int size(void) const
Return size of array (number of elements)
bool assigned(void) const
Test if all variables are assigned.
Use three distinct constraints.
Gecode toplevel namespace
Parametric base-class for scripts.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
virtual Space * copy(void)
Perform copying during cloning.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
int main(int argc, char *argv[])
Main-function.
IntVarArray q
Position of queens on boards.
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl)
Post propagator for for all .
int n
Number of negative literals for node type.
Gecode::IntArgs i({1, 2, 3, 4})
int p
Number of positive literals for node type.
Use only binary disequality constraints.
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
Options for scripts with additional size parameter