class RAMS::Variable

A Variable has bounds and a type. Names are created automatically.

RAMS::Variable.new                     # continuous, >= 0
RAMS::Variable.new low: nil            # continuous, unbounded
RAMS::Variable.new low: 1, high: 2.5   # continuous, >= 1, <= 2.5
RAMS::Variable.new type: :binary       # binary variable
RAMS::Variable.new type: :integer      # integer variable, >= 0

Attributes

high[R]
id[R]
low[R]
type[R]

Public Class Methods

new(low: 0.0, high: nil, type: :continuous) click to toggle source
Calls superclass method RAMS::Expression::new
# File lib/rams/variable.rb, line 15
def initialize(low: 0.0, high: nil, type: :continuous)
  @id = Variable.next_id

  @low = low
  @high = high
  @type = type

  super({ self => 1.0 })
end
next_id() click to toggle source
# File lib/rams/variable.rb, line 31
def self.next_id
  @next_id += 1
end

Public Instance Methods

name() click to toggle source
# File lib/rams/variable.rb, line 25
def name
  "v#{id}"
end