Class: Amor::Variable
- Inherits:
-
Object
- Object
- Amor::Variable
- Defined in:
- lib/amor/variable.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#lb ⇒ Object
(also: #lower_bound)
Returns the value of attribute lb.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#type ⇒ Object
Returns the value of attribute type.
-
#ub ⇒ Object
(also: #upper_bound)
Returns the value of attribute ub.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #*(scalar) ⇒ Object
- #+(value) ⇒ Object
- #-(value) ⇒ Object
- #-@ ⇒ Object
- #<=(value) ⇒ Object
- #==(value) ⇒ Object
- #>=(value) ⇒ Object
-
#initialize(model, index) ⇒ Variable
constructor
A new instance of Variable.
- #internal_index ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(model, index) ⇒ Variable
Returns a new instance of Variable.
10 11 12 13 |
# File 'lib/amor/variable.rb', line 10 def initialize(model, index) @model = model @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
4 5 6 |
# File 'lib/amor/variable.rb', line 4 def index @index end |
#lb ⇒ Object Also known as: lower_bound
Returns the value of attribute lb.
6 7 8 |
# File 'lib/amor/variable.rb', line 6 def lb @lb end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/amor/variable.rb', line 4 def model @model end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/amor/variable.rb', line 6 def type @type end |
#ub ⇒ Object Also known as: upper_bound
Returns the value of attribute ub.
6 7 8 |
# File 'lib/amor/variable.rb', line 6 def ub @ub end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/amor/variable.rb', line 6 def value @value end |
Instance Method Details
#*(scalar) ⇒ Object
15 16 17 |
# File 'lib/amor/variable.rb', line 15 def *(scalar) Expression.new([[scalar, self]]) end |
#+(value) ⇒ Object
19 20 21 |
# File 'lib/amor/variable.rb', line 19 def +(value) Expression.new(self) + Expression.new(value) end |
#-(value) ⇒ Object
23 24 25 |
# File 'lib/amor/variable.rb', line 23 def -(value) self + -value end |
#-@ ⇒ Object
27 28 29 |
# File 'lib/amor/variable.rb', line 27 def -@ Expression.new([[-1, self]]) end |
#<=(value) ⇒ Object
39 40 41 |
# File 'lib/amor/variable.rb', line 39 def <= value Constraint.new(self, :lesser_equal, value) end |
#==(value) ⇒ Object
35 36 37 |
# File 'lib/amor/variable.rb', line 35 def == value Constraint.new(self, :equal, value) end |
#>=(value) ⇒ Object
43 44 45 |
# File 'lib/amor/variable.rb', line 43 def >= value Constraint.new(self, :greater_equal, value) end |
#internal_index ⇒ Object
31 32 33 |
# File 'lib/amor/variable.rb', line 31 def internal_index @model.internal_index(self.index) end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/amor/variable.rb', line 47 def to_s "x(#{index})" end |