91 width(spec[0]), height(spec[1]),
92 x(*this, (width+1)*height, 0, 28) {
96 IntArgs board((width+1)*height);
97 for (
int i=0;
i<width;
i++)
98 for (
int j=0; j<height; j++)
99 board[j*(width+1)+
i] = spec[j*width+
i];
102 for (
int i=0;
i<height;
i++) {
103 board[
i*(width+1)+8] = -1;
104 rel(*
this,
x[
i*(width+1)+8]==28);
109 IntVarArgs p1(*
this, 28, 0, (width+1)*height-1);
110 IntVarArgs p2(*
this, 28, 0, (width+1)*height-1);
116 int possibleDiffsA[] = {1, width+1};
117 IntSet possibleDiffs(possibleDiffsA, 2);
119 for (
int i=0;
i<=6;
i++)
120 for (
int j=
i; j<=6; j++) {
127 IntVar diff(*
this, possibleDiffs);
128 abs(*
this,
expr(*
this, p1[dominoCount]-p2[dominoCount]),
133 rel(*
this, p1[dominoCount],
IRT_LE, p2[dominoCount]);
136 element(*
this, board, p1[dominoCount],
i);
137 element(*
this, board, p2[dominoCount], j);
141 element(*
this,
x, p1[dominoCount], dominoCount);
142 element(*
this,
x, p2[dominoCount], dominoCount);
148 for (
int i=0;
i<=6;
i++)
149 for (
int j=
i; j<=6; j++) {
155 for (
int pos = 0;
pos < (width+1)*height; ++
pos) {
156 if ((
pos+1) % (width+1) != 0) {
157 if (board[
pos] ==
i && board[
pos+1] == j)
159 if (board[
pos] == j && board[
pos+1] ==
i &&
i != j)
162 if (
pos/(width+1) < height-1) {
163 if (board[
pos] ==
i && board[
pos+width+1] == j)
165 if (board[
pos] == j && board[
pos+width+1] ==
i &&
i != j)
175 element(*
this,
x, p1[dominoCount], dominoCount);
176 element(*
this,
x, p2[dominoCount], dominoCount);
183 for (
int i=0;
i<28;
i++) {
194 for (
int h = 0; h < height; ++h) {
196 for (
int w = 0; w < width; ++w) {
197 int val =
x[h*(width+1)+w].
min();
198 char c = val < 10 ?
'0'+val :
'A' + (val-10);
207 Script(s), spec(s.spec), width(s.width), height(s.height) {
208 x.update(*
this, s.x);
231 std::cerr <<
"Error: size must be between 0 and "
235 Script::run<Domino,DFS,SizeOptions>(
opt);
Node * x
Pointer to corresponding Boolean expression node.
const unsigned int n_examples
The number of examples.
Example: Solitaire domino
int main(int argc, char *argv[])
Main-function.
virtual Space * copy(void)
Copy space during cloning.
const unsigned int n_examples
Number of board specifications.
Domino(Domino &s)
Constructor for cloning s.
const int domino1[]
Example 1
const int domino3[]
Example 3
const int domino0[]
Example 0
virtual void print(std::ostream &os) const
Print solution.
@ PROP_EXTENSIONAL
Use extensional constraints.
@ PROP_ELEMENT
Use element constraints.
const int domino5[]
Example 5
const int domino2[]
Example 2
const int domino4[]
Example 4
Domino(const SizeOptions &opt)
Actual model.
const int * specs[]
Board specifications.
Parametric base-class for scripts.
Passing integer arguments.
Passing integer variables.
Regular expressions over integer values.
Options for scripts with additional size parameter
void parse(int argc, char *argv[])
Parse commandline arguments.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
void extensional(Home home, const IntVarArgs &x, DFA d, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for extensional constraint described by a DFA.
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
bool pos(const View &x)
Test whether x is postive.
const FloatNum min
Smallest allowed float value.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Gecode toplevel namespace
IntVar expr(Home home, const LinIntExpr &e, const IntPropLevels &ipls=IntPropLevels::def)
Post linear expression and return its value.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
void element(Home home, IntSharedArray n, IntVar x0, IntVar x1, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for .
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i({1, 2, 3, 4})