Class: Amor::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/amor/variable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#indexObject (readonly)

Returns the value of attribute index.



4
5
6
# File 'lib/amor/variable.rb', line 4

def index
  @index
end

#lbObject 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

#modelObject (readonly)

Returns the value of attribute model.



4
5
6
# File 'lib/amor/variable.rb', line 4

def model
  @model
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/amor/variable.rb', line 6

def type
  @type
end

#ubObject 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

#valueObject

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_indexObject



31
32
33
# File 'lib/amor/variable.rb', line 31

def internal_index
  @model.internal_index(self.index)
end

#to_sObject



47
48
49
# File 'lib/amor/variable.rb', line 47

def to_s
  "x(#{index})"
end