class Gecode::Int::Arithmetic::IntSquareRootOperand

Public Instance Methods

constrain_equal(int_operand, constrain, propagation_options) click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/arithmetic.rb, line 124
def constrain_equal(int_operand, constrain, propagation_options)
  int_op = @int.to_int_var
  if constrain
    max = int_op.max
    if max < 0
      # The left hand side does not have a real valued square root.
      upper_bound = 0
    else
      upper_bound = Math.sqrt(max).floor;
    end
    
    min = int_op.min
    if min < 0
      lower_bound = 0
    else
      lower_bound = Math.sqrt(min).floor;
    end
    
    int_operand.must_be.in lower_bound..upper_bound
  end

  Gecode::Raw::sqrt(@model.active_space, int_op.to_int_var.bind, 
    int_operand.to_int_var.bind, *propagation_options)
end

Public Class Methods

new(model, int_op) click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int/arithmetic.rb, line 119
def initialize(model, int_op)
  super model
  @int = int_op
end