Class: Gecode::Bool::Linear::ExpressionNode
- Inherits:
-
Object
- Object
- Gecode::Bool::Linear::ExpressionNode
- Defined in:
- lib/gecoder/interface/constraints/bool/linear.rb
Overview
Describes a single node in a linear expression.
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#initialize(value, model = nil) ⇒ ExpressionNode
constructor
A new instance of ExpressionNode.
-
#to_minimodel_lin_exp ⇒ Object
Converts the linear expression to an instance of Gecode::Raw::MiniModel::LinExpr.
Constructor Details
#initialize(value, model = nil) ⇒ ExpressionNode
Returns a new instance of ExpressionNode.
180 181 182 183 184 185 186 187 |
# File 'lib/gecoder/interface/constraints/bool/linear.rb', line 180 def initialize(value, model = nil) unless value.respond_to?(:to_bool_var) or value.kind_of?(Fixnum) raise TypeError, 'Expected bool operand or ' + "fixnum, got #{value.class}." end @value = value @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
:nodoc:
178 179 180 |
# File 'lib/gecoder/interface/constraints/bool/linear.rb', line 178 def model @model end |
Instance Method Details
#to_minimodel_lin_exp ⇒ Object
Converts the linear expression to an instance of Gecode::Raw::MiniModel::LinExpr
191 192 193 194 195 196 197 |
# File 'lib/gecoder/interface/constraints/bool/linear.rb', line 191 def to_minimodel_lin_exp expression = @value if expression.respond_to? :to_bool_var expression = expression.to_bool_var.bind * 1 end expression end |