class Gecode::IntVar

Describes an integer variable.

An integer variable can take the value of any integer in its domain, which is specified upon constructing the variable and further constrained by placing constraints on the variable. An integer variable is said to be assigned once the domain only contains a single element, at which point value can be used to retrieve the value.

Integer variables are integer operands and hence respond to everything that Gecode::Int::IntOperand responds to. Any constraint found in Gecode::Int::IntConstraintReceiver can thereby be placed on integer variables.

Attributes

model[R]

Public Instance Methods

domain() click to toggle source

Returns an enumeration corresponding to the domain.

# File lib/gecoder/interface/variables.rb, line 120
def domain
  if range?
    min..max
  else
    (min..max).select do |i|
      include? i
    end
  end
end
to_int_var() click to toggle source

Returns the receiver.

# File lib/gecoder/interface/variables.rb, line 115
def to_int_var
  self
end
value() click to toggle source

Gets the value of the assigned integer variable (a Fixnum). The variable must be assigned, if it isn’t then a RuntimeError is raised.

# File lib/gecoder/interface/variables.rb, line 109
def value
  raise 'No value is assigned.' unless assigned?
  send_bound(:val)
end