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
- #*(mult) ⇒ Object
- #+(vars) ⇒ Object
- #-(vars) ⇒ Object
- #-@ ⇒ Object
- #<=(vars) ⇒ Object
- #==(vars) ⇒ Object
- #>=(vars) ⇒ 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
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.shuffle[0,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
#*(mult) ⇒ Object
38 39 40 |
# File 'lib/ruby-cbc/ilp/var.rb', line 38 def *(mult) Ilp::Term.new(self) * mult end |
#+(vars) ⇒ Object
26 27 28 |
# File 'lib/ruby-cbc/ilp/var.rb', line 26 def +(vars) Ilp::Term.new(self) + vars end |
#-(vars) ⇒ Object
30 31 32 |
# File 'lib/ruby-cbc/ilp/var.rb', line 30 def -(vars) Ilp::Term.new(self) - vars end |
#-@ ⇒ Object
34 35 36 |
# File 'lib/ruby-cbc/ilp/var.rb', line 34 def -@ Ilp::Term.new(self, -1) end |
#<=(vars) ⇒ Object
46 47 48 |
# File 'lib/ruby-cbc/ilp/var.rb', line 46 def <=(vars) Ilp::Term.new(self) <= vars end |
#==(vars) ⇒ Object
42 43 44 |
# File 'lib/ruby-cbc/ilp/var.rb', line 42 def ==(vars) Ilp::Term.new(self) == vars end |
#>=(vars) ⇒ Object
50 51 52 |
# File 'lib/ruby-cbc/ilp/var.rb', line 50 def >=(vars) Ilp::Term.new(self) >= vars 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 end |