Class: Opt::Variable

Inherits:
Expression show all
Defined in:
lib/opt/variable.rb

Direct Known Subclasses

Integer, SemiContinuous, SemiInteger

Instance Attribute Summary collapse

Attributes inherited from Expression

#parts

Instance Method Summary collapse

Methods inherited from Expression

#*, #+, #-, #-@, #<, #<=, #==, #>, #>=, #coerce, to_expression

Constructor Details

#initialize(bounds, name = nil) ⇒ Variable

Returns a new instance of Variable.



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

def initialize(bounds, name = nil)
  @bounds = bounds
  @name = name || "x#{object_id}"
end

Instance Attribute Details

#boundsObject (readonly)

Returns the value of attribute bounds.



3
4
5
# File 'lib/opt/variable.rb', line 3

def bounds
  @bounds
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/opt/variable.rb', line 3

def name
  @name
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#inspectObject



11
12
13
# File 'lib/opt/variable.rb', line 11

def inspect
  @name
end

#varsObject



15
16
17
# File 'lib/opt/variable.rb', line 15

def vars
  @vars ||= [self]
end