4.2.2. Annotations¶
These annotations control evaluation and solving behaviour.
4.2.2.1. General annotations¶
Parameters¶
Declare that the annotated variable should be added to the output of the model. This annotation only has an effect when the model does not have an output item.
Marks a constraint as a recorded domain changing constraint (when mzn2fzn called with -g flag
Declare the annotated variable as being functionally defined. This annotation is introduced into FlatZinc code by the compiler.
Declare that the annotated expression is used to map an expression back from FlatZinc to MiniZinc.
Declare that expression may have undefined result (to avoid warnings)
With debug build of mzn2fzn, call MiniZinc::mzn_break_here when flattening this expression to make debugging easier. This annotation is ignored by the release build.
Declare that the annotated variable is required for checking solutions.
Used internally by the compiler
Declare that the annotated variable should be only used for output. This annotation can be used to define variables that are required for solution checkers, or that are necessary for the output item. The annotated variable must be par.
Declare that the annotated variable should be printed by the solver. This annotation is introduced into FlatZinc code by the compiler.
Declare function as total, i.e. it does not put any constraints on its arguments.
Declare a variable as being introduced by the compiler.
Functions and Predicates¶
Used to attach a name s
to a constraint and its decomposition. String
annotations on constraint keywords are re-written as constraint_name annotations
Declare variable: c
as being functionally defined
by the annotated constraint. This annotation is introduced into FlatZinc code by the compiler.
Document the function or variable declaration item with
the string s
.
Used to attach a name s
to an expression, this should also propagate to
any sub-expressions or decomposition of the annotated expression. String annotations on expressions
are re-written as expression_name annotations
Declare that the annotated variable is required for checking solutions and has an enum type.
Declare a name for the annotated constraint.
State that a function is deprecated.
Declare a name for the annotated expression.
Representation of the call-stack when the annotated item
was introduced, as a string s
. Can be used to uniquely identify variables and constraints across different
compilations of a model that may have different names. This annotations is introduced into
FlatZinc code by the compiler and is retained if –keep-paths argument is used.
Declare that the annotated array should be printed by
the solver with the given index sets a
. This annotation is introduced into FlatZinc code by
the compiler.
4.2.2.2. Propagation strength annotations¶
Annotate a constraint to use bounds propagation
Annotate a constraint to use domain propagation
4.2.2.3. Search annotations¶
Variable selection annotations¶
Choose the variable with the largest domain
Choose the variable with largest domain, divided by the number of attached constraints weighted by how often they have caused failure
Choose the variable with the smallest domain
Choose the variable with the highest impact so far during the search
Search variables in the given order
Choose the variable with the largest value in its domain
Choose the variable with largest difference between the two smallest values in its domain
Choose the variable with the smallest domain, breaking ties using the number of attached constraints
Choose the variable with the largest number of attached constraints
Choose the variable with the smallest value in its domain
Value choice annotations¶
Assign values in ascending order
If the domain consists of several contiguous intervals, reduce the domain to the first interval. Otherwise bisect the domain.
Assign the largest value in the domain
Assign the middle value in the domain
Assign the value in the domain closest to the mean of its current bounds
Assign the smallest value in the domain
Assign a random value from the domain
Bisect the domain, excluding the lower half first
Bisect the domain, excluding the upper half first
Bisect the domain, randomly selecting which half to exclude first
Exclude the largest value from the domain
Exclude the middle value from the domain
Exclude the smallest value from the domain
Exclude a random value from the domain
Restart annotations¶
Functions and Predicates¶
Restart after constant number of nodes scale
Restart with geometric sequence with parameters base
and scale
Restart with linear sequence scaled by scale
Restart with Luby sequence scaled by scale
Other declarations¶
Specify search on variables x
, with variable selection
strategy select
, value choice strategy choice
, and exploration strategy
explore
.
If x
is a multi-dimensional array, it is coerced to one-dimensional
in row-major order (as with the array1d function).
Specify search on variables x
, with variable selection
strategy select
, and value choice strategy choice
.
If x
is a multi-dimensional array, it is coerced to one-dimensional
in row-major order (as with the array1d function).
Specify search on variables x
,
with precision prec
, variable selection
strategy select
, value choice strategy choice
, and exploration strategy
explore
.
If x
is a multi-dimensional array, it is coerced to one-dimensional
in row-major order (as with the array1d function).
Specify search on variables x
,
with precision prec
, variable selection
strategy select
, and value choice strategy choice
.
If x
is a multi-dimensional array, it is coerced to one-dimensional
in row-major order (as with the array1d function).
Specify search on variables x
, with variable selection
strategy select
, value choice strategy choice
, and exploration strategy
explore
. If x
is a multi-dimensional array, it is coerced to one-dimensional
in row-major order (as with the array1d function).
Specify search on variables x
, with variable selection
strategy select
, and value choice strategy choice
.
If x
is a multi-dimensional array, it is coerced to one-dimensional
in row-major order (as with the array1d function).
Sequentially perform the searches specified in array s
Specify search on variables x
, with variable selection
strategy select
, value choice strategy choice
, and exploration strategy
explore
.
If x
is a multi-dimensional array, it is coerced to one-dimensional
in row-major order (as with the array1d function).
Specify search on variables x
, with variable selection
strategy select
, and value choice strategy choice
.
If x
is a multi-dimensional array, it is coerced to one-dimensional
in row-major order (as with the array1d function).
4.2.2.4. Warm start annotations¶
To be put on the solve item, similar to search annotations. A variable can be mentioned several times and in different annotations but only one of the values is taken
Warm start annotations with optional values¶
The value arrays can contain <> elements (absent values). The following decompositions eliminate those elements because FlatZinc 1.6 does not support optionals.
Specify warm start values v
for an array of booleans x
Specify warm start values v
for an array of integers x
Specify warm start values v
for an array of floats x
Specify warm start values v
for an array of sets x
Other declarations¶
Specify warm start values v
for an array of booleans x
Specify warm start values v
for an array of integers x
Specify warm start values v
for an array of floats x
Specify warm start values v
for an array of sets x
Specify an array w
of warm_start annotations
or other warm_start_array annotations. Can be useful to keep the annotation
order in FlatZinc for manual updating.
Note: if you have search annotations as well, put warm_starts into seq_search in order to have precedence between both, which may matter.