Class: Gecode::IntVar
- Inherits:
-
Object
- Object
- Gecode::IntVar
- Includes:
- Gecode::Int::IntOperand
- Defined in:
- lib/gecoder/interface/variables.rb
Overview
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.
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#domain ⇒ Object
Returns an enumeration corresponding to the domain.
-
#to_int_var ⇒ Object
Returns the receiver.
-
#value ⇒ Object
Gets the value of the assigned integer variable (a Fixnum).
Methods included from Gecode::Int::IntOperand
#*, #+, #-, #abs, #method_missing, #pre_arith_mult, #square_root, #squared
Methods included from Operand
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Gecode::Int::IntOperand
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
84 85 86 |
# File 'lib/gecoder/interface/variables.rb', line 84 def model @model end |
Instance Method Details
#domain ⇒ Object
Returns an enumeration corresponding to the domain.
120 121 122 123 124 125 126 127 128 |
# 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 ⇒ Object
Returns the receiver.
115 116 117 |
# File 'lib/gecoder/interface/variables.rb', line 115 def to_int_var self end |
#value ⇒ Object
Gets the value of the assigned integer variable (a Fixnum). The variable must be assigned, if it isn’t then a RuntimeError is raised.
109 110 111 112 |
# File 'lib/gecoder/interface/variables.rb', line 109 def value raise 'No value is assigned.' unless assigned? send_bound(:val) end |