Class: Gecode::Set::Cardinality::SetSizeOperand
- Inherits:
-
Int::ShortCircuitEqualityOperand
- Object
- Int::ShortCircuitEqualityOperand
- Gecode::Set::Cardinality::SetSizeOperand
- Defined in:
- lib/gecoder/interface/constraints/set/cardinality.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from Int::ShortCircuitEqualityOperand
Instance Method Summary collapse
- #constrain_equal(int_operand, constrain, propagation_options) ⇒ Object
- #construct_receiver(params) ⇒ Object
-
#initialize(model, set_op) ⇒ SetSizeOperand
constructor
A new instance of SetSizeOperand.
- #pre_cardinality_construct_receiver ⇒ Object
Methods inherited from Int::ShortCircuitEqualityOperand
Methods included from Int::IntOperand
#*, #+, #-, #abs, #method_missing, #pre_arith_mult, #square_root, #squared
Methods included from Operand
Constructor Details
#initialize(model, set_op) ⇒ SetSizeOperand
Returns a new instance of SetSizeOperand.
29 30 31 32 |
# File 'lib/gecoder/interface/constraints/set/cardinality.rb', line 29 def initialize(model, set_op) super model @set = set_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
34 35 36 37 38 39 40 41 42 |
# File 'lib/gecoder/interface/constraints/set/cardinality.rb', line 34 def constrain_equal(int_operand, constrain, ) set = @set.to_set_var if constrain int_operand.must_be.in set.lower_bound.size..set.upper_bound.size end Gecode::Raw::cardinality(@model.active_space, set.bind, int_operand.to_int_var.bind) end |
#construct_receiver(params) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gecoder/interface/constraints/set/cardinality.rb', line 45 def construct_receiver(params) receiver = pre_cardinality_construct_receiver(params) set = @set receiver.instance_eval{ @set = set } class <<receiver alias_method :in_without_short_circuit, :in def in(range, = {}) if range.kind_of?(Range) and !@params[:negate] and !.has_key?(:reify) @params.update(:lhs => @set, :range => range) @model.add_constraint CardinalityConstraint.new(@model, @params) else in_without_short_circuit(range, ) end end end return receiver end |
#pre_cardinality_construct_receiver ⇒ Object
44 |
# File 'lib/gecoder/interface/constraints/set/cardinality.rb', line 44 alias_method :pre_cardinality_construct_receiver, :construct_receiver |