4.2.2. Annotations

These annotations control evaluation and solving behaviour.

4.2.2.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 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 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_constraint_name(string)

Declare a name for the annotated constraint.

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

annotation bounds

Annotate a constraint to use bounds propagation

annotation domain

Annotate a constraint to use domain propagation

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

Other declarations

annotation bool_search(array [int] 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 .

annotation float_search(array [int] 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 .

annotation int_search(array [int] 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 .

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

Sequentially perform the searches specified in array s

annotation set_search(array [int] 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 .

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.

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.