class Gecode::Int::Linear::ExpressionTree

Describes a binary tree of expression nodes which together form a linear expression.

Attributes

model[R]

Public Instance Methods

relation_constraint(relation, int_operand_or_fix, params) click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/linear.rb, line 100
def relation_constraint(relation, int_operand_or_fix, params)
  unless params[:negate]
    relation_type = 
      Gecode::Util::RELATION_TYPES[relation]
  else
    relation_type = 
      Gecode::Util::NEGATED_RELATION_TYPES[relation]
  end

  unless int_operand_or_fix.respond_to? :to_minimodel_lin_exp
    int_operand_or_fix = Linear::ExpressionNode.new(int_operand_or_fix);
  end

  params.update(:lhs => self, :rhs => int_operand_or_fix, 
    :relation_type => relation_type)
  LinearRelationConstraint.new(model, params)
end
to_minimodel_lin_exp() click to toggle source

Converts the linear expression to an instance of Gecode::Raw::MiniModel::LinExpr

# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/linear.rb, line 96
def to_minimodel_lin_exp
  @left.to_minimodel_lin_exp.send(@operation, @right.to_minimodel_lin_exp)
end

Public Class Methods

new(left_node, right_node, operation) click to toggle source

Constructs a new expression with the specified operands.

# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/linear.rb, line 86
def initialize(left_node, right_node, operation)
  super(left_node.model || right_node.model)
  @left = left_node
  @right = right_node
  @operation = operation
  @model = @left.model || @right.model
end