Class: Cassowary::Variable
Instance Attribute Summary collapse
#name
Instance Method Summary
collapse
Methods included from Equalities
#cn_equal, #cn_geq, #cn_leq
#dummy?
Constructor Details
#initialize(hash) ⇒ Variable
Returns a new instance of Variable.
9
10
11
12
|
# File 'lib/variables/variable.rb', line 9
def initialize(hash)
super
self.value = hash[:value]
end
|
Instance Attribute Details
Returns the value of attribute value.
7
8
9
|
# File 'lib/variables/variable.rb', line 7
def value
@value
end
|
Instance Method Details
14
15
16
|
# File 'lib/variables/variable.rb', line 14
def *(expr)
self.as_linear_expression * expr
end
|
18
19
20
|
# File 'lib/variables/variable.rb', line 18
def +(expr)
self.as_linear_expression + expr
end
|
22
23
24
|
# File 'lib/variables/variable.rb', line 22
def -(expr)
self.as_linear_expression - expr
end
|
48
49
50
|
# File 'lib/variables/variable.rb', line 48
def -@
-1.0.as_linear_expression * self
end
|
26
27
28
|
# File 'lib/variables/variable.rb', line 26
def /(expr)
self.as_linear_expression / expr
end
|
#as_linear_expression ⇒ Object
30
31
32
33
34
|
# File 'lib/variables/variable.rb', line 30
def as_linear_expression
expr = LinearExpression.new
expr.terms[self] = 1.0
expr
end
|
#external? ⇒ Boolean
36
37
38
|
# File 'lib/variables/variable.rb', line 36
def external?
true
end
|
52
53
54
|
# File 'lib/variables/variable.rb', line 52
def inspect
"#{super}[#{value.inspect}]"
end
|
#pivotable? ⇒ Boolean
40
41
42
|
# File 'lib/variables/variable.rb', line 40
def pivotable?
false
end
|
#restricted? ⇒ Boolean
44
45
46
|
# File 'lib/variables/variable.rb', line 44
def restricted?
false
end
|