module Gecode::Bool::BoolOperand

A BoolOperand is a combination of variables on which the constraints defined in BoolConstraintReceiver can be placed.

Boolean operands can be created either by using Gecode::Mixin#bool_var et al, or by using properties that produce boolean operands. The operands, no matter how they were created, all respond to the properties defined by BoolOperand.

Examples ¶ ↑

Produces a single boolean operand (more specifically a BoolVar) inside a problem formulation, using Gecode::Mixin#bool_var:

```bool_operand = bool_var
```

Uses the BoolOperand#& property to produce a new boolean operand representing `bool_operand1` AND `bool_operand2`:

```new_bool_operand = bool_operand1 & bool_operand2
```

Uses the BoolEnumOperand#conjunction property to produce a new boolean operand representing the conjunction of all boolean operands in the enumeration `bool_enum`:

```new_bool_operand = bool_enum.conjunction
```

Public Instance Methods

&(bool_op) click to toggle source

Produces a new BoolOperand representing this operand AND `bool_op`.

Examples ¶ ↑

```# (+b1+ and +b2+) or +b3+
(b1 & b1) | b3
```
```# File lib/gecoder/interface/constraints/bool/boolean.rb, line 19
def &(bool_op)
bool_expression_operation(:&, bool_op)
end```
*(fixnum) click to toggle source

Produces an IntOperand representing the value of this boolean operand (0 or 1) times a constant.

Examples ¶ ↑

```# +bool+ times 17
bool * 17
```
```# File lib/gecoder/interface/constraints/bool/linear.rb, line 80
def *(fixnum)
if fixnum.kind_of? Fixnum
bool_linear_expression_operation(:*, fixnum)
else
raise TypeError, "Expected fixnum, got #{fixnum.class}."
end
end```
+(op2) click to toggle source

Produces an IntOperand representing the value of this boolean operand (0 or 1) plus `op2`.

Examples ¶ ↑

```# +bool1+ plus +bool2+
bool1 + bool2
```
```# File lib/gecoder/interface/constraints/bool/linear.rb, line 69
def +(op2)
bool_linear_expression_operation(:+, op2)
end```
-(op2) click to toggle source

Produces an IntOperand representing the value of this boolean operand (0 or 1) minus `op2`.

Examples ¶ ↑

```# +bool1+ minus +bool2+
bool1 - bool2
```
```# File lib/gecoder/interface/constraints/bool/linear.rb, line 95
def -(op2)
bool_linear_expression_operation(:-, op2)
end```
^(bool_op) click to toggle source

Produces a new BoolOperand representing this operand XOR `bool_op`.

Examples ¶ ↑

```# (+b1+ and +b2+) or (+b3+ exclusive or +b1+)
(b1 & b2) | (b3 ^ b1)
```
```# File lib/gecoder/interface/constraints/bool/boolean.rb, line 29
def ^(bool_op)
bool_expression_operation(:^, bool_op)
end```
implies(bool_op) click to toggle source

Produces a new BoolOperand representing that this operand implies `bool_op`.

Examples ¶ ↑

```# (+b1+ implies +b2+) and (+b3+ implies +b2+)
(b1.implies b2) & (b3.implies b2)
```
```# File lib/gecoder/interface/constraints/bool/boolean.rb, line 40
def implies(bool_op)
bool_expression_operation(:implies, bool_op)
end```
|(bool_op) click to toggle source

Produces a new BoolOperand representing this operand OR `bool_op`.

Examples ¶ ↑

```# +b1+ and +b2+
b1 & b2
```
```# File lib/gecoder/interface/constraints/bool/boolean.rb, line 9
def |(bool_op)
bool_expression_operation(:|, bool_op)
end```