module Gecode::IntEnumMethods

A module containing the methods needed by enumerations containing int operands. Requires that it’s included in an enumerable.

Public Instance Methods

bind_array() click to toggle source

Returns an int variable array with all the bound variables.

# File doc/tmp/rdoc_dev/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() click to toggle source

Returns the smallest range that contains the domains of all integer variables involved.

# File doc/tmp/rdoc_dev/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() click to toggle source

Returns the receiver.

# File doc/tmp/rdoc_dev/gecoder/interface/enum_wrapper.rb, line 83
def to_int_enum
  self
end