module Gecode::SetEnum::SetEnumOperand
A SetEnumOperand is a enumeration of SetOperand on which the constraints defined in SetEnumConstraintReceiver can be placed.
Enumerations of set operands can be created either by using Gecode::Mixin#set_var_array and Gecode::Mixin#set_var_matrix, or by wrapping an existing enumeration containing SetOperand using Gecode::Mixin#wrap_enum. The enumerations, no matter how they were created, all respond to the properties defined by SetEnumOperand.
Examples ¶ ↑
Produces an array of five set operands, with greatest lower bound {0} and least upper bound {0, 1, 2}, inside a problem formulation using Gecode::Mixin#set_var_array:
set_enum = set_var_array(5, 0, 1..2)
Uses Gecode::Mixin#wrap_enum
inside a problem formulation to create a SetEnumOperand from an existing enumeration
containing the set operands set_operand1
and
set_operand2
:
set_enum = wrap_enum([set_operand1, set_operand2])
Public Instance Methods
Public Class Methods
Produces a SetOperand representing the i:th set operand in the enumeration, where i is the value of the int operand used as index.
A set can also be used as index, in which case a SelectedSetOperand is produced.
Examples ¶ ↑
# The set operand at the +x+:th position in +set_enum+, # where +x+ is a int operand. set_enum[x] # The SelectedSetOperand representing sets at positions # included in the value of +set+ in +set_enum+, set_enum[set]
# File lib/gecoder/interface/constraints/set_enum/element.rb, line 37 def [](*vars) # Hook in an element constraint if a operand is used for array # access. if vars.first.respond_to? :to_int_var Element::ElementSetOperand.new( model, self, vars.first) elsif vars.first.respond_to? :to_set_var Gecode::SelectedSet::SelectedSetOperand.new( self, vars.first) else if respond_to? :pre_set_element_access pre_set_element_access(*vars) end end end