module Gecode::FixnumEnum::FixnumEnumOperand

A FixnumEnumOperand is a enumeration of Fixnum on which the constraints defined in FixnumEnumConstraintReceiver can be placed. They typically service as constant arrays or constant sets.

The fixnum enumeration operands are created by wrapping an enumeration of fixnum Gecode::Mixin#wrap_enum. The enumerations created that way all respond to the properties defined by FixnumEnumOperand.

Examples

Uses Gecode::Mixin#wrap_enum inside a problem formulation to create a FixnumEnumOperand from an existing enumeration of Fixnum:

fixnum_enum = wrap_enum([3, 5, 7])

Public Instance Methods

disjoint_union(set_operand) click to toggle source

Produces a new SetOperand representing the disjoint union between this operand, interpreted as a constant set, and set_operand. The disjoint union is the union of the disjoint parts of the sets.

Examples

# The disjoint union between +fixnum_enum+ and +set+.
fixnum_enum.disjoint_union set
# File lib/gecoder/interface/constraints/fixnum_enum/operation.rb, line 23
def disjoint_union(set_operand)
  set_operation(:disjoint_union, set_operand)
end
intersection(set_operand) click to toggle source

Produces a new SetOperand representing the intersection between this operand, interpreted as a constant set, and set_operand.

Examples

# The intersection between +fixnum_enum+ and +set+.
fixnum_enum.intersection set
# File lib/gecoder/interface/constraints/fixnum_enum/operation.rb, line 35
def intersection(set_operand)
  set_operation(:intersection, set_operand)
end
minus(set_operand) click to toggle source

Produces a new SetOperand representing this operand, interpreted as a constant set, minus set_operand.

Examples

# +fixnum_enum+ minus +set+.
fixnum_enum.minus set
# File lib/gecoder/interface/constraints/fixnum_enum/operation.rb, line 46
def minus(set_operand)
  set_operation(:minus, set_operand)
end
union(set_operand) click to toggle source

Produces a new SetOperand representing the union between this operand, interpreted as a constant set, and set_operand.

Examples

# The union between +fixnum_enum+ and +set+.
fixnum_enum.union set
# File lib/gecoder/interface/constraints/fixnum_enum/operation.rb, line 10
def union(set_operand)
  set_operation(:union, set_operand)
end

Public Class Methods

[](*vars) click to toggle source

Produces an IntOperand representing the i:th constant integer in the enumeration, where i is the value of the integer operand used as index. Think of it as array access in the world of constraint programming.

Examples

# The price of +selected_item+ as described by +prices+ .
prices = wrap_enum([500, 24, 4711, 412, 24])
prices[selected_item]
# File lib/gecoder/interface/constraints/fixnum_enum/element.rb, line 28
def [](*vars)
  if vars.first.respond_to? :to_int_var
    return Element::ElementIntOperand.new(
      self, vars.first, model)
  else
    pre_element_access(*vars) if respond_to? :pre_element_access
  end
end