38 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST) 40 #if QT_VERSION >= 0x050000 69 const int n = q.
size();
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);
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"; }
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) 207 opt.
parse(argc,argv);
208 Script::run<Queens,DFS,SizeOptions>(
opt);
Value iterator for integer variables.
void size(unsigned int s)
Set default size.
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
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.
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
bool assigned(void) const
Test if all variables are assigned.
virtual Space * copy(void)
Perform copying during cloning.
IntVarArray q
Position of queens on boards.
class Gecode::Options::_I inspect
void ipl(IntPropLevel i)
Set default integer propagation level.
Use only binary disequality constraints.
Abstract base class for inspectors.
Parametric base-class for scripts.
void iterations(unsigned int i)
Set default number of iterations.
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
Gecode::IntArgs i({1, 2, 3, 4})
IntValBranch INT_VAL_MIN(void)
Select smallest value.
struct Gecode::@593::NNF::@62::@63 b
For binary nodes (and, or, eqv)
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.
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl)
Post propagator for for all .
virtual void print(std::ostream &os) const
Print solution.
Use three distinct constraints.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
Use single distinct and binary disequality constraints.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Queens(Queens &s)
Constructor for cloning s.
Queens(const SizeOptions &opt)
The actual problem.
Gecode toplevel namespace