[ library(fd_global_gac) | Reference Manual | Alphabetic Index ]

sequence(+Low, +High, +K, +ZeroOnes)

The number of occurrences of the value 1 is between Low and High for all sequences of K variables in ZeroOnes
Non-negative integer
Positive integer
Postive integer
A collection of 0/1 variables or integers


This constraint ensures that the number of occurrences of the value 1 is at least Low and at most High for all sequences of K consecutive variables/values in ZeroOnes. ZeroOnes are 0/1 variables (or itnegers), i.e. they have the domain [0,1].

The ZeroOnes can be interpreted as the fulfillment of various conditions if the variables are linked to these conditions. For example, sequence/5 is implemented by linking the N ZeroOnes variables to a matching collection of N finite domain `original' variables using element/3 constraints to constrain the ZeroOnes to be 1 if the corresponding original value takes one of the specified values. The ZeroOnes can then be used in further constraint reasoning.

Note: this constraint is different from sequence/4 in lib(fd).

This is currently a prototype -- the constraint has not been tested very extensively and little effort has been spent to optimise performance. We welcome any feedback on using this constraint.

See Also

sequence / 5, fd : element / 3, fd_global : sequence_total / 6, fd_global : sequence_total / 7