class Gecode::SelectedSet::SelectedSetConstraintReceiver

SelectedSetConstraintReceiver contains all constraints that can be placed on a SelectedSetOperand.

Constraints are placed by calling Gecode::Operand#must (or any other of the variations defined in Operand), which produces a SelectedSetConstraintReceiver from which the desired constraint can be used.

Examples

Constrains the sets in set_enum that are selected by set_operand to be disjoint. This uses SetEnumOperand#[] and #disjoint.

set_enum[set_operand].must_be.disjoint

Public Instance Methods

disjoint(options = {}) click to toggle source

Constrains the selected sets to be pairwise disjoint.

Examples

# Constrains all sets selected by +set_enum[set]+ to be pairwise
# disjoint.
set_enum[set].must_be.disjoint
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/selected_set/select.rb, line 51
def disjoint(options = {})
  if @params[:negate]
    raise Gecode::MissingConstraintError, 'A negated disjoint constraint ' + 
      'is not implemented.'
  end
  if options.has_key? :reify
    raise ArgumentError, 'The disjoint constraint does not support the ' + 
      'reification option.'
  end

  @params.update Gecode::Set::Util.decode_options(options)
  @model.add_constraint Element::DisjointConstraint.new(@model, @params)
end

Public Class Methods

new(model, params) click to toggle source

Raises TypeError unless the left hand side is a selected set operand.

Calls superclass method Gecode::ConstraintReceiver.new
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/selected_set_constraints.rb, line 65
def initialize(model, params) 
  super

  unless params[:lhs].respond_to? :to_selected_set
    raise TypeError, 'Must have selected set operand as left hand side.'
  end
end