Class: Gecode::Set::ShortCircuitEqualityOperand
- Inherits:
-
Object
- Object
- Gecode::Set::ShortCircuitEqualityOperand
- Includes:
- SetOperand
- Defined in:
- lib/gecoder/interface/constraints/set_var_constraints.rb
Overview
An operand that short circuits set equality.
Direct Known Subclasses
Gecode::SelectedSet::Element::SelectedSetIntersectionOperand, Gecode::SelectedSet::Element::SelectedSetUnionOperand, Gecode::SetEnum::Element::ElementSetOperand, Gecode::SetEnum::Operation::OperationSetOperand
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #construct_receiver(params) ⇒ Object
-
#initialize(model) ⇒ ShortCircuitEqualityOperand
constructor
A new instance of ShortCircuitEqualityOperand.
- #to_set_var ⇒ Object
Methods included from SetOperand
#disjoint_union, #elements, #intersection, #method_missing, #minus, #size, #union
Methods included from Operand
Constructor Details
#initialize(model) ⇒ ShortCircuitEqualityOperand
Returns a new instance of ShortCircuitEqualityOperand.
64 65 66 |
# File 'lib/gecoder/interface/constraints/set_var_constraints.rb', line 64 def initialize(model) @model = model end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Gecode::Set::SetOperand
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
62 63 64 |
# File 'lib/gecoder/interface/constraints/set_var_constraints.rb', line 62 def model @model end |
Instance Method Details
#construct_receiver(params) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/gecoder/interface/constraints/set_var_constraints.rb', line 68 def construct_receiver(params) params.update(:lhs => self) receiver = SetConstraintReceiver.new(@model, params) op = self receiver.instance_eval{ @short_circuit = op } class <<receiver alias_method :equality_without_short_circuit, :== def ==(operand, = {}) if !@params[:negate] and !.has_key?(:reify) and operand.respond_to? :to_set_var # Short circuit the constraint. @params.update Gecode::Util.() @model.add_constraint(Gecode::BlockConstraint.new( @model, @params) do @short_circuit.constrain_equal(operand, false, @params.values_at(:strength, :kind)) end) else equality_without_short_circuit(operand, ) end end alias_comparison_methods end return receiver end |
#to_set_var ⇒ Object
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/gecoder/interface/constraints/set_var_constraints.rb', line 95 def to_set_var variable = model.set_var = Gecode::Set::Util.( {}).values_at(:strength, :kind) model.add_interaction do constrain_equal(variable, true, ) end return variable end |