class Gecode::Int::ShortCircuitEqualityOperand
An operand that short circuits integer equality.
Attributes
model[R]
Public Instance Methods
construct_receiver(params)
click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int_var_constraints.rb, line 73 def construct_receiver(params) params.update(:lhs => self) receiver = IntConstraintReceiver.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_int_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_int_var()
click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int_var_constraints.rb, line 100 def to_int_var variable = model.int_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/int_var_constraints.rb, line 69 def initialize(model) @model = model end