4.2.1. Annotations

These annotations control evaluation and solving behaviour.

4.2.1.1. General annotations

Parameters

annotation add_to_output

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.

annotation domain_change_constraint

Marks a constraint as a recorded domain changing constraint (when mzn2fzn called with -g flag

annotation is_defined_var

Declare the annotated variable as being functionally defined. This annotation is introduced into FlatZinc code by the compiler.

annotation is_reverse_map

Declare that the annotated expression is used to map an expression back from FlatZinc to MiniZinc.

annotation maybe_partial

Declare that expression may have undefined result (to avoid warnings)

annotation mzn_break_here

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.

annotation mzn_check_var

Declare that the annotated variable is required for checking solutions.

annotation mzn_rhs_from_assignment

Used internally by the compiler

annotation output_only

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.

annotation output_var

Declare that the annotated variable should be printed by the solver. This annotation is introduced into FlatZinc code by the compiler.

annotation promise_total

Declare function as total, i.e. it does not put any constraints on its arguments.

annotation var_is_introduced

Declare a variable as being introduced by the compiler.

Functions and Predicates

annotation constraint_name(string: s)

Used to attach a name s to a constraint and its decomposition. String annotations on constraint keywords are re-written as constraint_name annotations

annotation defines_var(var $t: c)

Declare variable: c as being functionally defined by the annotated constraint. This annotation is introduced into FlatZinc code by the compiler.

annotation doc_comment(string: s)

Document the function or variable declaration item with the string s .

annotation expression_name(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

annotation mzn_check_enum_var(set of int)

Declare that the annotated variable is required for checking solutions and has an enum type.

annotation mzn_constraint_name(string)

Declare a name for the annotated constraint.

annotation mzn_deprecated(string: version, string: explanation)

State that a function is deprecated.

annotation mzn_expression_name(string)

Declare a name for the annotated expression.

annotation mzn_path(string: s)

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.

annotation output_array(array [$u] of set of int: a)

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.1.2. Propagation strength annotations

annotation bounds

Annotate a constraint to use bounds propagation

annotation domain

Annotate a constraint to use domain propagation

4.2.1.3. Search annotations

Variable selection annotations

annotation anti_first_fail

Choose the variable with the largest domain

annotation dom_w_deg

Choose the variable with largest domain, divided by the number of attached constraints weighted by how often they have caused failure

annotation first_fail

Choose the variable with the smallest domain

annotation impact

Choose the variable with the highest impact so far during the search

annotation input_order

Search variables in the given order

annotation largest

Choose the variable with the largest value in its domain

annotation max_regret

Choose the variable with largest difference between the two smallest values in its domain

annotation most_constrained

Choose the variable with the smallest domain, breaking ties using the number of attached constraints

annotation occurrence

Choose the variable with the largest number of attached constraints

annotation smallest

Choose the variable with the smallest value in its domain

Value choice annotations

annotation indomain

Assign values in ascending order

annotation indomain_interval

If the domain consists of several contiguous intervals, reduce the domain to the first interval. Otherwise bisect the domain.

annotation indomain_max

Assign the largest value in the domain

annotation indomain_median

Assign the middle value in the domain

annotation indomain_middle

Assign the value in the domain closest to the mean of its current bounds

annotation indomain_min

Assign the smallest value in the domain

annotation indomain_random

Assign a random value from the domain

annotation indomain_reverse_split

Bisect the domain, excluding the lower half first

annotation indomain_split

Bisect the domain, excluding the upper half first

annotation indomain_split_random

Bisect the domain, randomly selecting which half to exclude first

annotation outdomain_max

Exclude the largest value from the domain

annotation outdomain_median

Exclude the middle value from the domain

annotation outdomain_min

Exclude the smallest value from the domain

annotation outdomain_random

Exclude a random value from the domain

Exploration strategy annotations

annotation complete

Perform a complete search

Restart annotations

Parameters

annotation restart_none

Do not restart

Functions and Predicates

annotation restart_constant(int: scale)

Restart after constant number of nodes scale

annotation restart_geometric(float: base, int: scale)

Restart with geometric sequence with parameters base and scale

annotation restart_linear(int: scale)

Restart with linear sequence scaled by scale

annotation restart_luby(int: scale)

Restart with Luby sequence scaled by scale

Other declarations

annotation bool_search(array [$X] of var bool: x,
                       ann: select,
                       ann: choice,
                       ann: explore)

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).

annotation bool_search(array [$X] of var bool: x,
                       ann: select,
                       ann: choice)

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).

More…

annotation float_search(array [$X] of var float: x,
                        float: prec,
                        ann: select,
                        ann: choice,
                        ann: explore)

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).

annotation float_search(array [$X] of var float: x,
                        float: prec,
                        ann: select,
                        ann: choice)

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).

More…

annotation int_search(array [$X] of var int: x,
                      ann: select,
                      ann: choice,
                      ann: explore)

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).

annotation int_search(array [$X] of var int: x,
                      ann: select,
                      ann: choice)

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).

More…

annotation seq_search(array [int] of ann: s)

Sequentially perform the searches specified in array s

annotation set_search(array [$X] of var set of int: x,
                      ann: select,
                      ann: choice,
                      ann: explore)

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).

annotation set_search(array [$X] of var set of int: x,
                      ann: select,
                      ann: choice)

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).

More…

4.2.1.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.

annotation warm_start(array [int] of var bool: x,
                      array [int] of opt bool: v)

Specify warm start values v for an array of booleans x

More…

annotation warm_start(array [int] of var int: x,
                      array [int] of opt int: v)

Specify warm start values v for an array of integers x

More…

annotation warm_start(array [int] of var float: x,
                      array [int] of opt float: v)

Specify warm start values v for an array of floats x

More…

annotation warm_start(array [int] of var set of int: x,
                      array [int] of opt set of int: v)

Specify warm start values v for an array of sets x

More…

Other declarations

annotation warm_start(array [int] of var bool: x,
                      array [int] of bool: v)

Specify warm start values v for an array of booleans x

annotation warm_start(array [int] of var int: x, array [int] of int: v)

Specify warm start values v for an array of integers x

annotation warm_start(array [int] of var float: x,
                      array [int] of float: v)

Specify warm start values v for an array of floats x

annotation warm_start(array [int] of var set of int: x,
                      array [int] of set of int: v)

Specify warm start values v for an array of sets x

annotation warm_start_array(array [int] of ann: w)

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.