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

# <ConsistencyModule:> 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

Low
  Non-negative integer
High
  Positive integer
K
  Positive integer
ZeroOnes
  A collection of 0/1 domain) variables or integers

## Description

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

ConsistencyModule is the optional module specification to give the consistency level for the propagation for this constraint: gfd_gac for generalised arc consistency (domain consistency),

The more general version of this constraint, sequence/5, where the values being checked is not limited to 1 is known as among_seq in the global constraint catalog, and this constraint is also implemented via the more general Gecode sequence() constraint by limiting the value set to 1. This version is provided here for compatibility with IC and FD, where the more general sequence/5 constraint is implemented on top of this more restrictive sequence/4.

## Examples

    [eclipse 20]: sequence(2,3,3,[1,0,1,1,0,1]).    % Succeed

    [eclipse 21]: sequence(2,3,3,[1,0,1,1,0,0,1]).  % Fail

## See Also

sequence / 5, fd_global_gac : sequence / 4, ic_global_gac : sequence / 4