Class: Ilp::Var
- Inherits:
-
Object
- Object
- Ilp::Var
- Defined in:
- lib/ruby-cbc/ilp/var.rb
Constant Summary collapse
- BINARY_KIND =
:binary- INTEGER_KIND =
:integer- CONTINUOUS_KIND =
:continuous
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#lower_bound ⇒ Object
Returns the value of attribute lower_bound.
-
#name ⇒ Object
Returns the value of attribute name.
-
#upper_bound ⇒ Object
Returns the value of attribute upper_bound.
Instance Method Summary collapse
- #*(other) ⇒ Object
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #-@ ⇒ Object
- #<=(other) ⇒ Object
- #==(other) ⇒ Object
- #>=(other) ⇒ Object
- #bounds ⇒ Object
- #bounds=(range) ⇒ Object
- #coerce(num) ⇒ Object
-
#initialize(name: nil, kind: INTEGER_KIND, lower_bound: nil, upper_bound: nil) ⇒ Var
constructor
A new instance of Var.
- #to_s ⇒ Object
Constructor Details
#initialize(name: nil, kind: INTEGER_KIND, lower_bound: nil, upper_bound: nil) ⇒ Var
Returns a new instance of Var.
9 10 11 12 13 14 15 |
# File 'lib/ruby-cbc/ilp/var.rb', line 9 def initialize(name: nil, kind: INTEGER_KIND, lower_bound: nil, upper_bound: nil) @kind = kind @name = name @name = ("a".."z").to_a.sample(8).join if name.nil? @lower_bound = lower_bound @upper_bound = upper_bound end |
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
3 4 5 |
# File 'lib/ruby-cbc/ilp/var.rb', line 3 def kind @kind end |
#lower_bound ⇒ Object
Returns the value of attribute lower_bound.
3 4 5 |
# File 'lib/ruby-cbc/ilp/var.rb', line 3 def lower_bound @lower_bound end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/ruby-cbc/ilp/var.rb', line 3 def name @name end |
#upper_bound ⇒ Object
Returns the value of attribute upper_bound.
3 4 5 |
# File 'lib/ruby-cbc/ilp/var.rb', line 3 def upper_bound @upper_bound end |
Instance Method Details
#*(other) ⇒ Object
38 39 40 |
# File 'lib/ruby-cbc/ilp/var.rb', line 38 def *(other) Ilp::Term.new(self) * other end |
#+(other) ⇒ Object
26 27 28 |
# File 'lib/ruby-cbc/ilp/var.rb', line 26 def +(other) Ilp::Term.new(self) + other end |
#-(other) ⇒ Object
30 31 32 |
# File 'lib/ruby-cbc/ilp/var.rb', line 30 def -(other) Ilp::Term.new(self) - other end |
#-@ ⇒ Object
34 35 36 |
# File 'lib/ruby-cbc/ilp/var.rb', line 34 def -@ Ilp::Term.new(self, -1) end |
#<=(other) ⇒ Object
46 47 48 |
# File 'lib/ruby-cbc/ilp/var.rb', line 46 def <=(other) Ilp::Term.new(self) <= other end |
#==(other) ⇒ Object
42 43 44 |
# File 'lib/ruby-cbc/ilp/var.rb', line 42 def ==(other) Ilp::Term.new(self) == other end |
#>=(other) ⇒ Object
50 51 52 |
# File 'lib/ruby-cbc/ilp/var.rb', line 50 def >=(other) Ilp::Term.new(self) >= other end |
#bounds ⇒ Object
22 23 24 |
# File 'lib/ruby-cbc/ilp/var.rb', line 22 def bounds @lower_bound..@upper_bound end |
#bounds=(range) ⇒ Object
17 18 19 20 |
# File 'lib/ruby-cbc/ilp/var.rb', line 17 def bounds=(range) @lower_bound = range.min @upper_bound = range.max end |
#coerce(num) ⇒ Object
54 55 56 |
# File 'lib/ruby-cbc/ilp/var.rb', line 54 def coerce(num) [Ilp::Term.new(self), num] end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/ruby-cbc/ilp/var.rb', line 58 def to_s name.to_s end |