Boolean Enumeration Operands

A boolean enumeration operand is an enumeration of boolean operands.

Examples of Boolean Enumeration Operands

Enumerations of boolean operands are commonly created using Gecode::Mixin#bool_var_array and Gecode::Mixin#bool_var_matrix.

# Creates an array of five boolean operands.
bool_enum = bool_var_array(5)

A less common way to create the operands is by using Gecode::Mixin#wrap_enum to wrap an existing enumeration that contains boolean operands.

bool_enum = wrap_enum([bool_operand1, bool_operand2])

Constraints

Generated from BoolEnumConstraintReceiver.

channel

channel(integer_operand, options = {})

Constrains this enumeration to “channel” integer_operand. This constrains the integer operand to take value i exactly when the operand at index i in the boolean enumeration is true and the others are false.

Beyond the common options the channel constraint can also take the following option:

:offset
Specifies an offset for the integer operand. If the offset is set to k then the integer operand takes value i+k exactly when the operand at index i in the boolean enumeration is true and the rest are false.

Neither reification nor negation is supported. The int operand and the enumeration can be interchanged.

Examples
# Constrains the enumeration called +option_is_selected+ to be false
# in the first four positions and have exactly one true operand in
# the other.
option_is_selected.must.channel selected_option_index
selected_option_index.must_be > 3

# Constrains the enumeration called +option_is_selected+ to be false
# in the first five positions and have exactly one true operand in
# the other.
selected_option_index.must.channel(option_is_selected, :offset => 1)
selected_option_index.must_be > 3

in

in(tuples, options = {})

Constrains all the operands in this enumeration to be equal to one of the specified tuples. Neither negation nor reification is supported.

Examples
# Constrains the three boolean operands in +bools+ to either
# be true, false, true, or false, false, true.
bools.must_be.in [[true, false, true], [false, false, true]]

# The same as above, but preferring speed over low memory usage.
bools.must_be.in([[true, false, true], [false, false, true]],
  :kind => :speed)

match

match(regexp, options = {})

Constrains the sequence of operands in this enumeration to match a specified regexp in the boolean domain. Neither negation nor reification is supported.

The regular expressions are specified as described in IntEnumConstraintReceiver#match but true and false can be used instead of integers.

Examples
# Constrains the two boolean operands in +bools+ to be false
# and true respectively.
bools.must.match [false, true]

# Constrains the boolean operands in +bools+ to be false,
# except for three consecutive operands which should be true
# followed by false followed by true.
bools.must.match [repeat(false), true, false, true, repeat(false)]]

Properties

Generated from BoolEnumOperand.

conjunction

conjunction()

Produces a BoolOperand that represents the conjunction (AND) of all boolean operands in this enumeration.

Examples
# Conjunction of all elements in +bool_enum+.
bool_enum.conjunction

disjunction

disjunction()

Produces a BoolOperand that represents the disjunction (OR) of all boolean operands in this enumeration.

Examples
# Disjunction of all elements in +bool_enum+.
bool_enum.disjunction