Class: MIPPeR::Constraint

Inherits:
Object
  • Object
show all
Defined in:
lib/mipper/constraint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expr, sense, rhs, name = nil) ⇒ Constraint

Returns a new instance of Constraint.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mipper/constraint.rb', line 6

def initialize(expr, sense, rhs, name = nil)
  @expression = expr
  @sense = sense
  @rhs = rhs
  @name = name

  # Store this constraint for each associated variable
  @expression.terms.each_key do |var|
    var.constraints << self
  end
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



4
5
6
# File 'lib/mipper/constraint.rb', line 4

def expression
  @expression
end

#indexObject

Returns the value of attribute index.



3
4
5
# File 'lib/mipper/constraint.rb', line 3

def index
  @index
end

#modelObject

Returns the value of attribute model.



3
4
5
# File 'lib/mipper/constraint.rb', line 3

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/mipper/constraint.rb', line 4

def name
  @name
end

#rhsObject (readonly)

Returns the value of attribute rhs.



4
5
6
# File 'lib/mipper/constraint.rb', line 4

def rhs
  @rhs
end

#senseObject (readonly)

Returns the value of attribute sense.



4
5
6
# File 'lib/mipper/constraint.rb', line 4

def sense
  @sense
end

Instance Method Details

#inspectObject



18
19
20
# File 'lib/mipper/constraint.rb', line 18

def inspect
  "#{@expression.inspect} #{sense.to_s} #{rhs}"
end