Class: LV
Overview
An LP Variable. Used as arguments in LP Expressions. The subtypes BV and IV represent Binary and Integer variables. These are constructed dynamically by using the special Capitalised variable declaration syntax.
Direct Known Subclasses
BV, IV
Constant Summary
Rulp::Bounds::DIRS, Rulp::Bounds::DIRS_REVERSED
Instance Attribute Summary collapse
Attributes included from Rulp::Bounds
#const
Class Method Summary
collapse
Instance Method Summary
collapse
included, #initialize, #to_s
#<, #<=, #==, #>, #>=, #bounds, #coerce, #coerced?, #nocoerce, #relative_constraint
Instance Attribute Details
Returns the value of attribute args.
7
8
9
|
# File 'lib/rulp/lv.rb', line 7
def args
@args
end
|
Returns the value of attribute gt.
8
9
10
|
# File 'lib/rulp/lv.rb', line 8
def gt
@gt
end
|
Returns the value of attribute gte.
8
9
10
|
# File 'lib/rulp/lv.rb', line 8
def gte
@gte
end
|
Returns the value of attribute lt.
8
9
10
|
# File 'lib/rulp/lv.rb', line 8
def lt
@lt
end
|
Returns the value of attribute lte.
8
9
10
|
# File 'lib/rulp/lv.rb', line 8
def lte
@lte
end
|
Returns the value of attribute name.
7
8
9
|
# File 'lib/rulp/lv.rb', line 7
def name
@name
end
|
Returns the value of attribute value.
8
9
10
|
# File 'lib/rulp/lv.rb', line 8
def value
@value
end
|
Class Method Details
.const_missing(name) ⇒ Object
28
29
30
|
# File 'lib/rulp/lv.rb', line 28
def self.const_missing(name)
return self.definition(name)
end
|
.definition(name, args) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/rulp/lv.rb', line 32
def self.definition(name, args)
identifier = "#{name}#{args.join("_")}"
self.class.send(:define_method, identifier){|index=nil|
if index
self.definition(name, index)
else
defined = LV::names_table["#{identifier}"]
if defined && defined.class != self
raise StandardError.new("ERROR:\n#{name} was already defined as a variable of type #{defined.class}."+
"You are trying to redefine it as a variable of type #{self}")
elsif(!defined)
self.new(name, args)
else
defined
end
end
}
return self.send(identifier) || self.new(name, args)
end
|
.method_missing(name, *args) ⇒ Object
24
25
26
|
# File 'lib/rulp/lv.rb', line 24
def self.method_missing(name, *args)
return self.definition(name, args)
end
|
Instance Method Details
61
62
63
|
# File 'lib/rulp/lv.rb', line 61
def -(other)
self + (-other)
end
|
57
58
59
|
# File 'lib/rulp/lv.rb', line 57
def -@
return self * -1
end
|
80
81
82
|
# File 'lib/rulp/lv.rb', line 80
def inspect
"#{name}#{args.join("-")}(#{suffix})[#{value || 'undefined'}]"
end
|
16
17
18
|
# File 'lib/rulp/lv.rb', line 16
def meth
"#{self.name}_#{self.suffix}"
end
|
20
21
22
|
# File 'lib/rulp/lv.rb', line 20
def suffix
"f"
end
|
12
13
14
|
# File 'lib/rulp/lv.rb', line 12
def to_proc
->(index){ send(self.meth, index) }
end
|