Class: Gecode::Int::Arithmetic::IntSquaredOperand
- Inherits:
-
ShortCircuitEqualityOperand
- Object
- ShortCircuitEqualityOperand
- Gecode::Int::Arithmetic::IntSquaredOperand
- 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) ⇒ IntSquaredOperand
constructor
A new instance of IntSquaredOperand.
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) ⇒ IntSquaredOperand
Returns a new instance of IntSquaredOperand.
100 101 102 103 |
# File 'lib/gecoder/interface/constraints/int/arithmetic.rb', line 100 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
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/gecoder/interface/constraints/int/arithmetic.rb', line 105 def constrain_equal(int_operand, constrain, ) int_op = @int.to_int_var if constrain min = int_op.min; max = int_op.max products = [min*max, min*min, max*max] int_operand.must_be.in products.min..products.max end Gecode::Raw::sqr(@model.active_space, int_op.to_int_var.bind, int_operand.to_int_var.bind, *) end |