class Gecode::SelectedSet::SelectedSetOperand
A SelectedSetOperand is an uncommon operand that results from calling SetEnumOperand#[] with a SetOperand. It facilitates placing the constraints defined in SelectedSetConstraintReceiver
Examples ¶ ↑
Producing a SelectedSetOperand from
set_enum
and set_operand
:
set_enum[set_operand]
Public Instance Methods
intersection(options = {})
click to toggle source
Produces a SetOperand representing the selected sets’ intersection. The option :with can be used to enumerate the elements in the universe.
Examples ¶ ↑
# The intersection of all sets selected by +set_enum[set]+. set_enum[set].intersection # The same intersection as above, but with [3,5,7] as universe. set_enum[set].intersection(:with => [3,5,7])
# File lib/gecoder/interface/constraints/selected_set/select.rb, line 24 def intersection(options = {}) universe = nil unless options.empty? unless options.size == 1 and options.has_key?(:with) raise ArgumentError, "Expected option key :with, got #{options.keys}." else universe = options[:with] unless universe.kind_of?(Enumerable) and universe.all?{ |element| element.kind_of? Fixnum } raise TypeError, "Expected the universe to be specified as " + "an enumeration of fixnum, got #{universe.class}." end end end Element::SelectedSetIntersectionOperand.new(model, self, universe) end
union()
click to toggle source