Module: Gecode::Set::SetOperand
- Includes:
- Operand
- Defined in:
- lib/gecoder/interface/constraints/set_var_constraints.rb,
lib/gecoder/interface/constraints/set/operation.rb,
lib/gecoder/interface/constraints/set/cardinality.rb,
lib/gecoder/interface/constraints/set_elements_constraints.rb
Overview
A SetOperand is a combination of operands on which the constraints defined in SetConstraintReceiver can be placed.
Set operands can be created either by using Gecode::Mixin#set_var et al, or by using properties that produce set operands. The operands, no matter how they were created, all respond to the properties defined by SetOperand.
Examples
Produces a single set operand (more specifically a SetVar), with greatest lower bound 0 and least upper bound 1, 2, inside a problem formulation, using Gecode::Mixin#set_var:
set_operand = set_var(0, 0..2)
Uses the SetOperand#union property to produce a new set operand representing the union between set_operand1
and set_operand2
:
new_set_operand = set_operand1.union(set_operand2)
Uses the SetEnumOperand#union property to produce a new set operand representing the union of the set operands in the enumeration set_enum
:
new_set_operand = set_enum.union
Uses the SetEnumOperand#[] property to produce a new set operand representing the set operand at the index decided by int_operand
(which can change during search) in the enumeration set_enum
:
new_set_operand = set_enum[int_operand]
– Classes that mix in SetOperand must define #model and #to_set_var .
Instance Method Summary collapse
-
#disjoint_union(set_operand_or_constant_set) ⇒ Object
Produces a new SetOperand representing the disjoint union between this operand and
set_operand_or_constant_set
. -
#elements ⇒ Object
Produces a SetElementsOperand on which relation constraints can be placed that constrain all elements in the set.
-
#intersection(set_operand_or_constant_set) ⇒ Object
Produces a new SetOperand representing the intersection between this operand and
set_operand_or_constant_set
. -
#method_missing(method, *args) ⇒ Object
:nodoc:.
-
#minus(set_operand_or_constant_set) ⇒ Object
Produces a new SetOperand representing this operand minus
set_operand_or_constant_set
. -
#size ⇒ Object
Produces an IntOperand representing the size of the set.
-
#union(set_operand_or_constant_set) ⇒ Object
Produces a new SetOperand representing the union between this operand and
set_operand_or_constant_set
.
Methods included from Operand
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
:nodoc:
43 44 45 46 47 48 49 50 |
# File 'lib/gecoder/interface/constraints/set_var_constraints.rb', line 43 def method_missing(method, *args) #:nodoc: if Gecode::SetVar.instance_methods.include? method.to_s # Delegate to the set var. to_set_var.method(method).call(*args) else super end end |
Instance Method Details
#disjoint_union(set_operand_or_constant_set) ⇒ Object
Produces a new SetOperand representing the disjoint union between this operand and set_operand_or_constant_set
. The disjoint union is the union of the disjoint parts of the sets.
Examples
# The disjoint union between +set1+ and +set2+.
set1.disjoint_union set2
# The disjoint union between +set+ and {1, 3, 5}.
set.disjoint_union [1,3,5]
28 29 30 |
# File 'lib/gecoder/interface/constraints/set/operation.rb', line 28 def disjoint_union(set_operand_or_constant_set) set_operation(:disjoint_union, set_operand_or_constant_set) end |
#elements ⇒ Object
Produces a SetElementsOperand on which relation constraints can be placed that constrain all elements in the set.
Examples
# The elements of +set+.
set.elements
91 92 93 |
# File 'lib/gecoder/interface/constraints/set_elements_constraints.rb', line 91 def elements Gecode::SetElements::SetElementsOperand.new(self) end |
#intersection(set_operand_or_constant_set) ⇒ Object
Produces a new SetOperand representing the intersection between this operand and set_operand_or_constant_set
.
Examples
# The intersection between +set1+ and +set2+.
set1.intersection set2
# The intersection between +set+ and {1, 3, 5}.
set.intersection [1,3,5]
42 43 44 |
# File 'lib/gecoder/interface/constraints/set/operation.rb', line 42 def intersection(set_operand_or_constant_set) set_operation(:intersection, set_operand_or_constant_set) end |
#minus(set_operand_or_constant_set) ⇒ Object
Produces a new SetOperand representing this operand minus set_operand_or_constant_set
.
Examples
# +set1+ minus +set2+.
set1.minus set2
# +set+ minus {1, 3, 5}.
set.minus [1,3,5]
56 57 58 |
# File 'lib/gecoder/interface/constraints/set/operation.rb', line 56 def minus(set_operand_or_constant_set) set_operation(:minus, set_operand_or_constant_set) end |
#size ⇒ Object
Produces an IntOperand representing the size of the set.
Examples
# The size of +set+.
set.size
9 10 11 |
# File 'lib/gecoder/interface/constraints/set/cardinality.rb', line 9 def size Cardinality::SetSizeOperand.new(@model, self) end |
#union(set_operand_or_constant_set) ⇒ Object
Produces a new SetOperand representing the union between this operand and set_operand_or_constant_set
.
Examples
# The union between +set1+ and +set2+.
set1.union set2
# The union between +set+ and {1, 3, 5}.
set.union [1,3,5]
13 14 15 |
# File 'lib/gecoder/interface/constraints/set/operation.rb', line 13 def union(set_operand_or_constant_set) set_operation(:union, set_operand_or_constant_set) end |