Module: Gecode::BoolEnum::BoolEnumOperand

Includes:
Operand
Included in:
Dummy, Gecode::BoolEnumMethods
Defined in:
lib/gecoder/interface/constraints/bool_enum_constraints.rb,
lib/gecoder/interface/constraints/bool_enum/relation.rb

Overview

A BoolEnumOperand is a enumeration of BoolOperand on which the constraints defined in BoolEnumConstraintReceiver can be placed.

Enumerations of boolean operands can be created either by using Gecode::Mixin#bool_var_array and Gecode::Mixin#bool_var_matrix, or by wrapping an existing enumeration containing BoolOperand using Gecode::Mixin#wrap_enum. The enumerations, no matter how they were created, all respond to the properties defined by BoolEnumOperand.

Examples

Produces an array of five boolean operands inside a problem formulation using Gecode::Mixin#bool_var_array:

bool_enum = bool_var_array(5)

Uses Gecode::Mixin#wrap_enum inside a problem formulation to create a BoolEnumOperand from an existing enumeration containing the boolean operands bool_operand1 and bool_operand2:

bool_enum = wrap_enum([bool_operand1, bool_operand2])

– Classes that mix in BoolEnumOperand must define #model and #to_bool_enum .

Instance Method Summary collapse

Methods included from Operand

#model, #must, #must_not

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

:nodoc:



32
33
34
35
36
37
38
39
# File 'lib/gecoder/interface/constraints/bool_enum_constraints.rb', line 32

def method_missing(method, *args) #:nodoc:
  if Gecode::BoolEnum::Dummy.instance_methods.include? method.to_s
    # Delegate to the bool enum.
    to_bool_enum.method(method).call(*args)
  else
    super
  end
end

Instance Method Details

#conjunctionObject

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


10
11
12
# File 'lib/gecoder/interface/constraints/bool_enum/relation.rb', line 10

def conjunction
  Relation::BoolEnumConjunctionOperand.new(@model, self)
end

#disjunctionObject

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


21
22
23
# File 'lib/gecoder/interface/constraints/bool_enum/relation.rb', line 21

def disjunction
  Relation::BoolEnumDisjunctionOperand.new(@model, self)
end