Class: Gecode::Int::Arithmetic::IntSquareRootOperand
- Inherits:
-
ShortCircuitEqualityOperand
- Object
- ShortCircuitEqualityOperand
- Gecode::Int::Arithmetic::IntSquareRootOperand
- Defined in:
- lib/gecoder/interface/constraints/int/arithmetic.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from ShortCircuitEqualityOperand
Instance Method Summary collapse
- #constrain_equal(int_operand, constrain, propagation_options) ⇒ Object
-
#initialize(model, int_op) ⇒ IntSquareRootOperand
constructor
A new instance of IntSquareRootOperand.
Methods inherited from ShortCircuitEqualityOperand
#construct_receiver, #to_int_var
Methods included from IntOperand
#*, #+, #-, #abs, #method_missing, #pre_arith_mult, #square_root, #squared
Methods included from Operand
Constructor Details
#initialize(model, int_op) ⇒ IntSquareRootOperand
Returns a new instance of IntSquareRootOperand.
119 120 121 122 |
# File 'lib/gecoder/interface/constraints/int/arithmetic.rb', line 119 def initialize(model, int_op) super model @int = int_op end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Gecode::Int::IntOperand
Instance Method Details
#constrain_equal(int_operand, constrain, propagation_options) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/gecoder/interface/constraints/int/arithmetic.rb', line 124 def constrain_equal(int_operand, constrain, ) 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, *) end |