Module: Gecode::IntEnumMethods
- Defined in:
- lib/gecoder/interface/enum_wrapper.rb
Overview
A module containing the methods needed by enumerations containing int operands. Requires that it’s included in an enumerable.
Instance Attribute Summary
Attributes included from EnumMethods
Instance Method Summary collapse
-
#bind_array ⇒ Object
Returns an int variable array with all the bound variables.
-
#domain_range ⇒ Object
Returns the smallest range that contains the domains of all integer variables involved.
-
#to_int_enum ⇒ Object
Returns the receiver.
Methods included from VariableEnumMethods
Methods included from EnumMethods
Methods included from Gecode::IntEnum::IntEnumOperand
#count, included, #max, #method_missing, #min
Methods included from Operand
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Gecode::IntEnum::IntEnumOperand
Instance Method Details
#bind_array ⇒ Object
Returns an int variable array with all the bound variables.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/gecoder/interface/enum_wrapper.rb', line 71 def bind_array space = @model.active_space unless @bound_space == space elements = to_a @bound_arr = Gecode::Raw::IntVarArray.new(active_space, elements.size) elements.each_with_index{ |var, index| @bound_arr[index] = var.bind } @bound_space = space end return @bound_arr end |
#domain_range ⇒ Object
Returns the smallest range that contains the domains of all integer variables involved.
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/gecoder/interface/enum_wrapper.rb', line 89 def domain_range inject(nil) do |range, var| min = var.min max = var.max next min..max if range.nil? range = min..range.last if min < range.first range = range.first..max if max > range.last range end end |
#to_int_enum ⇒ Object
Returns the receiver.
83 84 85 |
# File 'lib/gecoder/interface/enum_wrapper.rb', line 83 def to_int_enum self end |