Module: Gecode::SetEnumMethods
- Defined in:
- lib/gecoder/interface/enum_wrapper.rb
Overview
A module containing the methods needed by enumerations containing set operands. Requires that it’s included in an enumerable.
Instance Attribute Summary
Attributes included from EnumMethods
Instance Method Summary collapse
-
#bind_array ⇒ Object
Returns a set variable array with all the bound variables.
-
#to_set_enum ⇒ Object
Returns the receiver.
-
#upper_bound_range ⇒ Object
Returns the range of the union of the contained sets’ upper bounds.
Methods included from VariableEnumMethods
Methods included from EnumMethods
Methods included from Gecode::SetEnum::SetEnumOperand
#disjoint_union, included, #intersection, #method_missing, #union
Methods included from Operand
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Gecode::SetEnum::SetEnumOperand
Instance Method Details
#bind_array ⇒ Object
Returns a set variable array with all the bound variables.
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/gecoder/interface/enum_wrapper.rb', line 145 def bind_array space = @model.active_space unless @bound_space == space elements = to_a @bound_arr = Gecode::Raw::SetVarArray.new(active_space, elements.size) elements.each_with_index{ |var, index| @bound_arr[index] = var.bind } @bound_space = space end return @bound_arr end |
#to_set_enum ⇒ Object
Returns the receiver.
157 158 159 |
# File 'lib/gecoder/interface/enum_wrapper.rb', line 157 def to_set_enum self end |
#upper_bound_range ⇒ Object
Returns the range of the union of the contained sets’ upper bounds.
162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/gecoder/interface/enum_wrapper.rb', line 162 def upper_bound_range inject(nil) do |range, var| upper_bound = var.upper_bound min = upper_bound.min max = upper_bound.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 |