class Gecode::Bool::ShortCircuitEqualityOperand
An operand that short circuits boolean equality.
Attributes
model[R]
Public Instance Methods
construct_receiver(params)
click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/bool_var_constraints.rb, line 104 def construct_receiver(params) params.update(:lhs => self) receiver = BoolConstraintReceiver.new(@model, params) op = self receiver.instance_eval{ @short_circuit = op } class <<receiver alias_method :equality_without_short_circuit, :== def ==(operand, options = {}) if !@params[:negate] and options[:reify].nil? and operand.respond_to? :to_bool_var # Short circuit the constraint. @params.update Gecode::Util.decode_options(options) @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, options) end end alias_comparison_methods end return receiver end
to_bool_var()
click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/bool_var_constraints.rb, line 131 def to_bool_var variable = model.bool_var options = Gecode::Util.decode_options({}).values_at(:strength, :kind) model.add_interaction do constrain_equal(variable, true, options) end return variable end
Public Class Methods
new(model)
click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/bool_var_constraints.rb, line 100 def initialize(model) @model = model end