Class: ORTools::SumArray
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from LinearExpr
#*, #+, #-, #-@, #/, #<=, #==, #>=, #coeffs, #inspect, #solution_value
Constructor Details
#initialize(array) ⇒ SumArray
5
6
7
|
# File 'lib/or_tools/sum_array.rb', line 5
def initialize(array)
@array = array.map { |v| cast_to_lin_exp(v) }
end
|
Instance Attribute Details
#array ⇒ Object
Returns the value of attribute array.
3
4
5
|
# File 'lib/or_tools/sum_array.rb', line 3
def array
@array
end
|
Instance Method Details
#add_self_to_coeff_map_or_stack(coeffs, multiplier, stack) ⇒ Object
9
10
11
12
13
|
# File 'lib/or_tools/sum_array.rb', line 9
def add_self_to_coeff_map_or_stack(coeffs, multiplier, stack)
@array.reverse.each do |arg|
stack << [multiplier, arg]
end
end
|
#cast_to_lin_exp(v) ⇒ Object
15
16
17
|
# File 'lib/or_tools/sum_array.rb', line 15
def cast_to_lin_exp(v)
v.is_a?(Numeric) ? Constant.new(v) : v
end
|
#to_s ⇒ Object
19
20
21
|
# File 'lib/or_tools/sum_array.rb', line 19
def to_s
"(#{@array.map(&:to_s).join(" + ")})"
end
|