class Ilp::Constraint

Constants

EQUALS
GREATER_OR_EQ
LESS_OR_EQ
SIGN_TO_STRING

Attributes

bound[RW]
function_name[RW]
terms[RW]
type[RW]

Public Class Methods

new(terms, type, bound) click to toggle source
# File lib/ruby-cbc/ilp/constraint.rb, line 9
def initialize(terms, type, bound)
  @terms = terms - bound
  @terms.normalize!
  @bound = -1 * @terms.send(:pop_constant)
  @type = type
end

Public Instance Methods

to_function_s() click to toggle source
# File lib/ruby-cbc/ilp/constraint.rb, line 20
def to_function_s
  "#{function_name || 'constraint'}(#{vars.map!(&:name).join(', ')})"
end
to_s() click to toggle source
# File lib/ruby-cbc/ilp/constraint.rb, line 30
def to_s
  sign = SIGN_TO_STRING[@type] || "??"
  "#{@terms} #{sign} #{@bound}"
end
vars() click to toggle source
# File lib/ruby-cbc/ilp/constraint.rb, line 16
def vars
  terms.vars
end