class Gecode::Set::ShortCircuitRelationsOperand
An operand that short circuits set non-negated and non-reified versions of the relation constraints.
Attributes
model[R]
Public Instance Methods
construct_receiver(params)
click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/set_var_constraints.rb, line 127 def construct_receiver(params) params.update(:lhs => self) receiver = SetConstraintReceiver.new(@model, params) op = self receiver.instance_eval{ @short_circuit = op } class <<receiver Gecode::Util::SET_RELATION_TYPES.keys.each do |comp| eval <<-end_code alias_method :alias_#{comp.to_i}_without_short_circuit, :#{comp} def #{comp}(operand, options = {}) if !@params[:negate] && !options.has_key?(:reify) && (operand.respond_to?(:to_set_var) or Gecode::Util::constant_set?(operand)) # Short circuit the constraint. @params.update Gecode::Set::Util.decode_options(options) @model.add_constraint( @short_circuit.relation_constraint( :#{comp}, operand, @params)) else alias_#{comp.to_i}_without_short_circuit(operand, options) end end end_code end alias_comparison_methods end return receiver end
relation_constraint(relation, set_operand_or_constant_set, params)
click to toggle source
Returns a constraint that constrains this operand to have relation
relation
to set_operand_or_constant_set
, which is
either a set operand or a constant set, given the specified hash
params
of parameters. The constraints are never negated nor
reified.
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/set_var_constraints.rb, line 169 def relation_constraint(relation, set_operand_or_constant_set, params) raise NotImplementedError, 'Abstract method has not been implemented.' end
to_set_var()
click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/set_var_constraints.rb, line 157 def to_set_var variable = model.set_var params = {:lhs => self} params.update Gecode::Set::Util.decode_options({}) model.add_constraint relation_constraint(:==, variable, params) return variable end
Public Class Methods
new(model)
click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/set_var_constraints.rb, line 123 def initialize(model) @model = model end