+1
.latexmkrc
+1
.latexmkrc
+39
assets/glossary.tex
+39
assets/glossary.tex
···
14
14
description={},
15
15
}
16
16
17
+
\newglossaryentry{array}{
18
+
name={array},
19
+
description={},
20
+
}
21
+
17
22
\newglossaryentry{gls-cbls}{
18
23
name={constraint-based local search},
19
24
description={},
20
25
}
21
26
27
+
\newglossaryentry{comprehension}{
28
+
name={comprehension},
29
+
description={},
30
+
}
31
+
32
+
\newglossaryentry{conditional}{
33
+
name={conditional},
34
+
description={},
35
+
}
22
36
23
37
\newglossaryentry{constraint}{
24
38
name={constraint},
···
70
84
description={},
71
85
}
72
86
87
+
\newglossaryentry{generator}{
88
+
name={generator},
89
+
description={},
90
+
}
91
+
73
92
\newglossaryentry{global}{
74
93
name={global constraint},
75
94
description={},
···
80
99
description={},
81
100
}
82
101
102
+
\newglossaryentry{let}{
103
+
name={let expression},
104
+
description={},
105
+
}
106
+
83
107
\newglossaryentry{linear-programming}{
84
108
name={linear programming},
85
109
description={},
···
131
155
description={},
132
156
}
133
157
158
+
\newglossaryentry{operator}{
159
+
name={operators},
160
+
description={},
161
+
}
162
+
163
+
\newglossaryentry{optional}{
164
+
name={optional},
165
+
description={},
166
+
}
167
+
134
168
\newglossaryentry{restart}{
135
169
name={restart},
136
170
description={},
···
165
199
name={term rewriting},
166
200
description={},
167
201
}
202
+
203
+
\newglossaryentry{zinc}{
204
+
name={Zinc},
205
+
description={},
206
+
}
+1
assets/shorthands.tex
+1
assets/shorthands.tex
···
5
5
\newcommand{\minisearch}{\gls{minisearch}\xspace{}}
6
6
\newcommand{\minizinc}{\gls{minizinc}\xspace{}}
7
7
\newcommand{\nanozinc}{\gls{nanozinc}\xspace{}}
8
+
\newcommand{\zinc}{\gls{zinc}\xspace{}}
8
9
\newcommand{\cml}{\gls{constraint-modelling} language\xspace{}}
9
10
\newcommand{\cmls}{\gls{constraint-modelling} languages\xspace{}}
10
11
+255
-43
chapters/2_background.tex
+255
-43
chapters/2_background.tex
···
20
20
In a constraint model, instead of specifying the manner in which we can find the
21
21
solution, we give a concise description of the problem. We describe what we
22
22
already know, the \glspl{parameter}, what we wish to know, the \glspl{variable},
23
-
and the relationships that should exists between them, the \glspl{constraint}.
23
+
and the relationships that should exist between them, the \glspl{constraint}.
24
24
25
25
This type of combinatorial problem is typically called a \gls{csp}. Many \cmls\
26
26
also support the modelling of \gls{cop}, where a \gls{csp} is augmented with an
···
119
119
\autocite{nethercote-2007-minizinc}. Its expressive language and extensive
120
120
library of constraints allow users to easily model complex problems.
121
121
122
-
Let us introduce the language by modelling the problem from
123
-
\cref{ex:back-knapsack}. A \minizinc\ model encoding this problem is shown in
124
-
\cref{lst:back-mzn-knapsack}.
125
-
126
122
\begin{listing}
127
123
\mznfile{assets/mzn/back_knapsack.mzn}
128
124
\caption{\label{lst:back-mzn-knapsack} A \minizinc\ model describing a 0-1 knapsack
129
125
problem}
130
126
\end{listing}
131
127
132
-
The model starts with the declaration of the \glspl{parameter}.
133
-
\Lref{line:back:knap:toys} declares an enumerated type that represents all
134
-
possible toys, \(T\) in the mathematical model in the example.
135
-
\Lref{line:back:knap:joy,line:back:knap:space} declare arrays mapping from toys
136
-
to integer values, these represent the functional mappings \(joy\) and
137
-
\(space\). Finally, \lref{line:back:knap:left} declares an integer
138
-
\gls{parameter} to represent the car capacity as an equivalent to \(C\).
128
+
\begin{example}%
129
+
\label{ex:back-mzn-knapsack}
139
130
140
-
The model then declares its \glspl{variable}. \Lref{line:back:knap:sel} declares
141
-
the main \gls{variable} \mzninline{selection}, which represents the selection of
142
-
toys to be packed. \(S\) in our earlier model. We also declare the variable
143
-
\mzninline{total_joy}, on \lref{line:back:knap:tj}, which is functionally
144
-
defined to be the summation of all the joy for the toy picked in our selection.
131
+
Let us introduce the language by modelling the problem from
132
+
\cref{ex:back-knapsack}. A \minizinc\ model encoding this problem is shown in
133
+
\cref{lst:back-mzn-knapsack}.
134
+
135
+
The model starts with the declaration of the \glspl{parameter}.
136
+
\Lref{line:back:knap:toys} declares an enumerated type that represents all
137
+
possible toys, \(T\) in the mathematical model in the example.
138
+
\Lref{line:back:knap:joy,line:back:knap:space} declare arrays mapping from
139
+
toys to integer values, these represent the functional mappings \(joy\) and
140
+
\(space\). Finally, \lref{line:back:knap:left} declares an integer
141
+
\gls{parameter} to represent the car capacity as an equivalent to \(C\).
142
+
143
+
The model then declares its \glspl{variable}. \Lref{line:back:knap:sel}
144
+
declares the main \gls{variable} \mzninline{selection}, which represents the
145
+
selection of toys to be packed. \(S\) in our earlier model. We also declare
146
+
the variable \mzninline{total_joy}, on \lref{line:back:knap:tj}, which is
147
+
functionally defined to be the summation of all the joy for the toy picked in
148
+
our selection.
145
149
146
-
Finally, the model contains a constraint, on \lref{line:back:knap:con}, to
147
-
ensure we do not exceed the given capacity and states the goal for the solver:
148
-
to maximise the value of the variable \mzninline{total_joy}.
150
+
Finally, the model contains a constraint, on \lref{line:back:knap:con}, to
151
+
ensure we do not exceed the given capacity and states the goal for the solver:
152
+
to maximise the value of the variable \mzninline{total_joy}.
153
+
\end{example}
149
154
150
155
One might note that, although more textual and explicit, the \minizinc\ model
151
156
definition is very similar to our earlier mathematical definition.
···
194
199
\glspl{parameter} and as \glspl{variable}. \minizinc\ is allows all these
195
200
types to be contained in arrays. Unlike other languages, arrays can have a
196
201
user defined index set. Although the index can start at any value the set is
197
-
forced to be a range. \minizinc\ also has an annotation type, annotations can be either a declared name or a function call. These annotations can be attached to \minizinc\ expressions, declarations, or constraints. }
202
+
forced to be a range. \minizinc\ also has an annotation type, annotations can
203
+
be either a declared name or a function call. These annotations can be
204
+
attached to \minizinc\ expressions, declarations, or constraints. }
205
+
206
+
\jip{This should explain array types}
198
207
199
208
\subsection{MiniZinc Expressions}%
200
209
\label{subsec:back-mzn-expr}
201
210
211
+
One of the powers of the \minizinc\ language is the extensive expression
212
+
language that it offers to help modellers create models that are intuitive to
213
+
read, but are transformed to fit the structure best suited to the chosen
214
+
\gls{solver}. We will now briefly discussed the most important \minizinc\
215
+
expressions and the general methods employed when flattening them. For a
216
+
detailed overview of all \minizinc\ you can consult the full syntactic structure
217
+
of the \minizinc\ expressions in \minizinc\ 2.5.5 can be found in
218
+
\cref{sec:mzn-grammar-expressions}. Nethercote et al.\ and Mariott et al.\ offer
219
+
a detailed discussion of the expression language of \minizinc\ and its
220
+
predecessor \zinc\ respectively
221
+
\autocite*{nethercote-2007-minizinc,marriott-2008-zinc}.
202
222
203
-
\paragraph{Global Constraints}
204
-
\paragraph{Operators}
205
-
\paragraph{Conditional Expressions}
206
-
\paragraph{Array Operations}
207
-
\paragraph{Set Operations}
208
-
\paragraph{Generator Expressions}
209
-
\paragraph{Let Expressions}
223
+
\Glspl{global} are the basic building blocks in the \minizinc\ language. These
224
+
expressions capture common (complex) relations between variables. \Glspl{global}
225
+
in the \minizinc\ language are used as function calls. An example of a
226
+
\gls{global} is
227
+
228
+
\begin{mzn}
229
+
predicate knapsack(
230
+
array [int] of int: w,
231
+
array [int] of int: p,
232
+
array [int] of var int: x,
233
+
var int: W,
234
+
var int: P,
235
+
);
236
+
\end{mzn}
237
+
238
+
This \gls{global} expresses the knapsack relationship, where the
239
+
\glspl{parameter} \mzninline{w} are the weights of the items, \mzninline{p} are
240
+
the profit for each items, the \glspl{variable} in \mzninline{x} represent the
241
+
amount of time the items are present in the knapsack, and \mzninline{W} and
242
+
\mzninline{P}, repectively, represent the weight and profit of the knapsack.
243
+
244
+
Note that the usage of this \gls{global} might have simplified the \minizinc\
245
+
model in \cref{ex:back-mzn-knapsack}:
246
+
247
+
\begin{mzn}
248
+
constraint knapsack(toy_space, toy_joy, set2bool(selection), total_joy, space);
249
+
\end{mzn}
250
+
251
+
The usage of this \gls{global} has the additional benefit that the knapsack
252
+
structure of the problem is then known to the \gls{solver} which might implement
253
+
special handling of the relationship.
254
+
255
+
Although \minizinc\ contains a extensive library of \glspl{global}, many
256
+
problems contain constraints that aren't covered by a \gls{global}. There are
257
+
many other expression forms in \minizinc\ that can help modellers express a
258
+
constraint.
210
259
260
+
\Gls{operator} symbols in \minizinc\ are used as short hands for \minizinc\
261
+
functions that can be used to transform or combine other expressions. For
262
+
example the constraint
263
+
264
+
\begin{mzn}
265
+
constraint not (a + b < c);
266
+
\end{mzn}
267
+
268
+
contains the infix \glspl{operator} \mzninline{+} and \mzninline{<}, and the
269
+
prefix \gls{operator} \mzninline{not}.
270
+
271
+
These \glspl{operator} will be evaluated using the addition, less-than
272
+
comparison, and Boolean negation functions respectively. Although the
273
+
\gls{operator} syntax for \glspl{variable} and \glspl{parameter} is the same,
274
+
different (overloaded) versions of these functions will be used during
275
+
flattening. For \glspl{parameter} types the result of the function can be
276
+
directly computed, but when flattening these functions with \glspl{variable}
277
+
types a new variable for its result must be introduced and a constraints
278
+
enforcing the functional relationship.
279
+
280
+
The choice between different expressions can often be expressed using a
281
+
\gls{conditional} expression, sometimes better known as an ``if-then-else''
282
+
expressions. You could, for example, force that the absolute value of
283
+
\mzninline{a} is bigger than \mzninline{b} using the constraint
284
+
285
+
\begin{mzn}
286
+
constraint if b >= 0 then a > b else b < a endif;
287
+
\end{mzn}
288
+
289
+
In \minizinc\ the result of an \gls{conditional} expression is, however, not
290
+
contained to Boolean types. The condition in the expression, the ``if'', must be
291
+
of a Boolean type, but as long as the different sides of the \gls{conditional}
292
+
expression are the same type it is a valid conditional expression. This can be
293
+
used to, for example, define an absolute value function for integer
294
+
\gls{parameter}:
295
+
296
+
\begin{mzn}
297
+
function int: abs(int: a) =
298
+
if a >= 0 then a else -a endif;
299
+
\end{mzn}
300
+
301
+
When the condition does not contain any \glspl{variable}, then the flattening of
302
+
a \gls{conditional} expression will result in one of the side of the
303
+
expressions. If, however, the condition does contain a \glspl{variable}, then
304
+
the result of the condition cannot be defined during the flattening. Instead,
305
+
the expression will introduce a new variable for the result of the expression
306
+
and a constraint to enforce the functional relationship. In \minizinc\ special
307
+
\mzninline{if_then_else} \glspl{global} are available to implement this
308
+
relationship.
309
+
310
+
For the selection of an element from an \gls{array}, instead of between
311
+
different expressions, the \minizinc\ language uses an \gls{array} access syntax
312
+
similar to most other languages. The expression \mzninline{a[i]} selects the
313
+
element with index \mzninline{i} from the array \mzninline{a}. Note this is not
314
+
necessarily the \(\mzninline{i}^{\text{th}}\) element because \minizinc\ allows
315
+
modellers to provide a custom index set.
316
+
317
+
Like the previous expressions, the selector \mzninline{i} can be both a
318
+
\gls{parameter} or a \gls{variable}. If the expression is a \gls{variable}, then
319
+
the expression is flattened as being an \mzninline{element} function. Otherwise,
320
+
the flattening will replace the \gls{array} access expression by the element
321
+
referenced by expression.
322
+
323
+
\Gls{array} \glspl{comprehension} are expressions can be used to compose
324
+
\gls{array} objects. This allows modellers to create \glspl{array} that are not
325
+
given directly as input to the model or are a declared collection of variables.
326
+
327
+
\Gls{generator} expressions, \mzninline{[E | G where F]}, consist of three
328
+
parts:
329
+
330
+
\begin{description}
331
+
\item[\mzninline{G}] The generator expression which assigns the values of
332
+
collections to identifiers,
333
+
\item[\mzninline{F}] an optional filtering condition, which has to evaluate to
334
+
\mzninline{true} for the iteration to be included in the array,
335
+
\item[\mzninline{E}] and the expression that is evaluation for each iteration
336
+
when the filtering condition succeeds.
337
+
\end{description}
338
+
339
+
The following example composes a array that contains the doubled even values of
340
+
an \gls{array} \mzninline{x}.
341
+
342
+
\begin{minizinc}
343
+
[ xi * 2 | xi in x where x mod 2 == 0]
344
+
\end{minizinc}
345
+
346
+
The evaluated expression will be added to the new array. This means that the
347
+
type of the array will primarily depend on the type of the expression. However,
348
+
in recent versions of \minizinc\ both the collections over which we iterate and
349
+
the filtering condition could have a \gls{variable} type. Since we then cannot
350
+
decise during flattening if an element is present in the array, the elements
351
+
will be made of an \gls{optional} type. This means that the solver still will
352
+
decide if the element is present in the array or if it takes a special
353
+
``absent'' value (\mzninline{<>}).
354
+
355
+
Finally, \glspl{let} are the primary scoping mechanism in the \minizinc\
356
+
language, together with function definitions. A \gls{let} allows a modeller to
357
+
provide a list of definitions, flattened in order, that can be used in its
358
+
resulting definition. There are three main purposes for \glspl{let}:
359
+
360
+
\begin{enumerate}
361
+
\item To name an intermediate expression so it can be used multiple times (or
362
+
to simplify the expression). For example, the constraint
363
+
364
+
\begin{mzn}
365
+
constraint let { var int: tmp = x div 2; } in tmp mod 2 == 0 \/ tmp = 0;
366
+
\end{mzn}
367
+
368
+
constrains that half of \mzninline{x} is even or zero.
369
+
370
+
\item To introduce a scoped \gls{variable}. For example, the constraint
371
+
372
+
\begin{mzn}
373
+
let {var -2..2: slack;} in x + slack = y;
374
+
\end{mzn}
375
+
376
+
constrains that \mzninline{x} and \mzninline{y} are at most two apart.
377
+
378
+
\item To constrain the resulting expression. For example, the following function
379
+
380
+
\begin{mzn}
381
+
function var int: int_times(var int: x, var int: y) =
382
+
let {
383
+
var int: z;
384
+
constraint pred_int_times(x, y, z);
385
+
} in z;
386
+
\end{mzn}
387
+
388
+
returns a new \gls{variable} \mzninline{z} that is constrained to be the
389
+
multiplication of \mzninline{x} and \mzninline{y} by the relational
390
+
multiplication constraint \mzninline{pred_int_times}.
391
+
\end{enumerate}
392
+
393
+
An important detail in flattening \glspl{let} is that any variables that are
394
+
introduced might need to be renamed in the resulting solver level model.
395
+
Different from top-level definitions, the variables declared in \glspl{let} can
396
+
be flattened multiple times when used in loops, function definitions (that are
397
+
called multiple times), and \gls{array} \glspl{comprehension}. In these cases the
398
+
flattener must assign any variables in the \gls{let} a new name and use this
399
+
name in any subsequent definitions and in the resulting expression.
211
400
212
401
\subsection{Handling Undefined Expressions}%
213
402
\label{subsec:back-mzn-partial}
214
403
215
-
Some expressions in the \cmls\ do not always have a well defined result.
404
+
Some expressions in the \cmls\ do not always have a well-defined result.
216
405
Examples of such expressions in \minizinc\ are:
217
406
218
407
\begin{itemize}
219
408
\item Division (or modulus) when the divisor is zero: \\ \mzninline{x div 0 =
220
-
@??@}
409
+
@??@}
221
410
222
411
\item Array access when the index is outside of the given index set: \\
223
-
\mzninline{array1d(1..3, [1,2,3])[0] = @??@}
412
+
\mzninline{array1d(1..3, [1,2,3])[0] = @??@}
224
413
225
-
\item Finding the minimum or maximum or an empty set: \\ \mzninline{min({}) =
226
-
@??@}
414
+
\item Finding the minimum or maximum or an empty set: \\ \mzninline{min({})
415
+
=@??@}
227
416
228
-
\item Computing the square root of a negative value: \\ \mzninline{sqrt(-1) = @??@}
417
+
\item Computing the square root of a negative value: \\ \mzninline{sqrt(-1) =
418
+
@??@}
229
419
230
420
\end{itemize}
231
421
232
422
The existence of undefined expressions can cause confusion in \cmls. There is
233
-
both the question what happens when a undefined expressions is evaluated and at
234
-
what point during the process undefined values will be resolved, during
423
+
both the question of what happens when an undefined expression is evaluated and
424
+
at what point during the process undefined values will be resolved, during
235
425
flattening or at solving time.
236
426
237
427
Frisch and Stuckey define three semantic models to deal with the undefinedness
···
239
429
240
430
\begin{description}
241
431
242
-
\item[Strict] \cmls\ employing a ``strict'' undefinedness semantic do not allow any undefined behaviour during the evaluation of the constraint model. If during the flattening or solving process an expression is found to be undefined, then any expressions in which it is used is also marked as undefined. In the end, this means that the occurrence of a single undefined expression will mark the full model as undefined.
432
+
\item[Strict] \cmls\ employing a ``strict'' undefinedness semantic do not
433
+
allow any undefined behaviour during the evaluation of the constraint model.
434
+
If during the flattening or solving process an expression is found to be
435
+
undefined, then any expressions in which it is used is also marked as
436
+
undefined. In the end, this means that the occurrence of a single undefined
437
+
expression will mark the full model as undefined.
243
438
244
-
\item[Kleene] The ``Kleene'' semantic treat undefined expressions as expressions for which not enough information is available. This if a expressions contains undefined sub-expression, it will only be marked as undefined if the value of the subexpression is required to compute its result. Take for example the expression \mzninline{false -> E}. Here, when \mzninline{E} is undefined the result of the expression can still be said to be \mzninline{true}, since the value of \mzninline{E} does not influence the result of the expression. However, if we take the expression \mzninline{true /\ E}, then when \mzninline{E} is undefined the overall expression is also undefined since the value of the expression cannot be determined.
439
+
\item[Kleene] The ``Kleene'' semantic treat undefined expressions as
440
+
expressions for which not enough information is available. This if an
441
+
expression contains undefined sub-expression, it will only be marked as
442
+
undefined if the value of the sub-expression is required to compute its
443
+
result. Take for example the expression \mzninline{false -> E}. Here, when
444
+
\mzninline{E} is undefined the result of the expression can still be said to
445
+
be \mzninline{true}, since the value of \mzninline{E} does not influence the
446
+
result of the expression. However, if we take the expression \mzninline{true
447
+
/\ E}, then when \mzninline{E} is undefined the overall expression is also
448
+
undefined since the value of the expression cannot be determined.
245
449
246
-
\item[Relational] The ``relational'' semantic follows from the fact that all expressions in \cmls\ will eventually become part of a relational constraint. So even though a (functional) expression in itself might not have a well-defined result, we can still decide whether its surrounding relationship holds. For example, the expression \mzninline{x div 0} is undefined, but the relationship \mzninline{int_div(x,0,y)} can be said to be \mzninline{false}. It can be said that the relational semantic will make the closest relational expression that contains an undefined expression \mzninline{false}.
450
+
\item[Relational] The ``relational'' semantic follows from the fact that all
451
+
expressions in \cmls\ will eventually become part of a relational
452
+
constraint. So even though a (functional) expression in itself might not
453
+
have a well-defined result, we can still decide whether its surrounding
454
+
relationship holds. For example, the expression \mzninline{x div 0} is
455
+
undefined, but the relationship \mzninline{int_div(x,0,y)} can be said to be
456
+
\mzninline{false}. It can be said that the relational semantic will make the
457
+
closest relational expression that contains an undefined expression
458
+
\mzninline{false}.
247
459
248
460
\end{description}
249
461
···
252
464
the users of constraint modelling languages. This is why the \minizinc\ uses
253
465
relational semantics during its evaluation.
254
466
255
-
For example, one might might deal with a zero divisor using a disjunction:
467
+
For example, one might deal with a zero divisor using a disjunction:
256
468
257
469
\begin{mzn}
258
470
constraint d == 0 \/ a div d < 3;
···
260
472
261
473
In this case we expect the undefinedness of the division to be contained within
262
474
the second part of the disjunction. This corresponds to ``relational''
263
-
semantics. \jip{TODO:\@ This also corresponds to Kleene semantics, maybe I should
264
-
use a different example}
475
+
semantics. \jip{TODO:\@ This also corresponds to Kleene semantics, maybe I
476
+
should use a different example}
265
477
266
478
Frisch and Stuckey also show that different \glspl{solver} often employ
267
-
different semantical models \autocite*{frisch-2009-undefinedness}. It is
479
+
different semantics \autocite*{frisch-2009-undefinedness}. It is
268
480
therefore important that, during the flattening process, any potentially
269
481
undefined expression gets replaced by an equivalent model that is still valid
270
482
under a strict semantic. Essentially eliminating the existence of undefined
+23
-23
chapters/3_rewriting.tex
+23
-23
chapters/3_rewriting.tex
···
22
22
23
23
In this chapter, we revisit the rewriting of high-level \cmls\ into solver-level
24
24
constraint models. We describe a new \textbf{systematic view of the execution of
25
-
\minizinc{}} and build on this to propose a new tool chain. We show how this
25
+
\minizinc{}} and build on this to propose a new tool chain. We show how this
26
26
tool chain allows us to:
27
27
28
28
\begin{itemize}
···
975
975
be \emph{reified} into a Boolean variable. Reification means that a variable
976
976
\mzninline{b} is constrained to be true if and only if a corresponding
977
977
constraint \mzninline{c(...)} holds. We have already seen reification in
978
-
\cref{ex:4-absreif}: the truth of constraint \mzninline{abs(x) > y} was
979
-
bound to a Boolean variable \mzninline{b1}, which was then used in a
980
-
disjunction. We say that the same constraint can be used in \emph{root context}
981
-
as well as in a \emph{reified context}. In \minizinc, almost all constraints
982
-
can be used in both contexts. However, reified constraints are often defined in
983
-
the library in terms of complicated decompositions into simpler constraints, or
984
-
require specialised algorithms in the target solvers. In either case, it can be
985
-
very beneficial for the efficiency of the generated \nanozinc\ program if we can
986
-
detect that a reified constraint is in fact not required.
978
+
\cref{ex:4-absreif}: the truth of constraint \mzninline{abs(x) > y} was bound to
979
+
a Boolean variable \mzninline{b1}, which was then used in a disjunction. We say
980
+
that the same constraint can be used in \emph{root context} as well as in a
981
+
\emph{reified context}. In \minizinc, almost all constraints can be used in both
982
+
contexts. However, reified constraints are often defined in the library in terms
983
+
of complicated decompositions into simpler constraints, or require specialised
984
+
algorithms in the target solvers. In either case, it can be very beneficial for
985
+
the efficiency of the generated \nanozinc\ program if we can detect that a
986
+
reified constraint is in fact not required.
987
987
988
988
If a constraint is present in the root context, it means that it must hold
989
989
globally. If the same constraint is used in a reified context, it can therefore
···
1032
1032
variables that represent intermediate results. This is in particular true for
1033
1033
linear and boolean equations that are generally written using \minizinc\
1034
1034
operators. For example the evaluation of the linear constraint \mzninline{x +
1035
-
2*y <= z} will result in the following \nanozinc:
1035
+
2*y <= z} will result in the following \nanozinc:
1036
1036
1037
1037
\begin{nzn}
1038
1038
var int: x;
···
1053
1053
additional burden to have intermediate values that have to be given a value in
1054
1054
the solution.
1055
1055
1056
-
This can be resolved using the \gls{aggregation} of constraints. When we aggregate
1057
-
constraints we combine constraints connected through functional definitions into
1058
-
one or multiple constraints eliminating the need for intermediate variables. For
1059
-
example, the arithmetic definitions can be combined into linear constraints,
1060
-
Boolean logic can be combined into clauses, and counting constraints can be
1061
-
combined into global cardinality constraints.
1056
+
This can be resolved using the \gls{aggregation} of constraints. When we
1057
+
aggregate constraints we combine constraints connected through functional
1058
+
definitions into one or multiple constraints eliminating the need for
1059
+
intermediate variables. For example, the arithmetic definitions can be combined
1060
+
into linear constraints, Boolean logic can be combined into clauses, and
1061
+
counting constraints can be combined into global cardinality constraints.
1062
1062
1063
1063
In \nanozinc, we are able to aggregate constraints during partial evaluation. To
1064
1064
aggregate a certain kind of constraint, the solver must the constraint as a
1065
1065
solver-level primitive. These constraints will now be kept as temporary
1066
1066
functional definitions in the \nanozinc\ program. Once a top-level (relational)
1067
1067
constraint is posted that uses the temporary functional definitions as one of
1068
-
its arguments, the interpreter will employ dedicated \gls{aggregation} logic to visit
1069
-
the functional definitions and combine their constraints. The top-level
1068
+
its arguments, the interpreter will employ dedicated \gls{aggregation} logic to
1069
+
visit the functional definitions and combine their constraints. The top-level
1070
1070
constraint constraint is then replaced by the combined constraint. When the
1071
1071
intermediate variables become unused, they will be removed using the normal
1072
1072
mechanisms.
···
1166
1166
available. \Gls{cse}, our next optimisation technique, ensures that we do not
1167
1167
create or evaluate the same constraint or function twice and reuse variables
1168
1168
where possible. Finally, the last optimisation technique we discuss is the use
1169
-
of constraint \gls{aggregation}. The use of \gls{aggregation} ensures that individual
1170
-
functional constraints can be collected and combined into an aggregated form.
1171
-
This allows us to avoid the existence of intermediate variables in some cases.
1172
-
This optimisation is very important for \gls{mip} solvers.
1169
+
of constraint \gls{aggregation}. The use of \gls{aggregation} ensures that
1170
+
individual functional constraints can be collected and combined into an
1171
+
aggregated form. This allows us to avoid the existence of intermediate variables
1172
+
in some cases. This optimisation is very important for \gls{mip} solvers.
1173
1173
1174
1174
Finally, we test the described system using a experimental implementation. We
1175
1175
compare this experimental implementation against the current \minizinc\