class Gecode::SetEnum::SetEnumConstraintReceiver
SetEnumConstraintReceiver contains all constraints that can be placed on a SetEnumOperand.
Constraints are placed by calling Gecode::Operand#must (or any other of the variations defined in Operand), which produces a SetEnumConstraintReceiver from which the desired constraint can be used.
Examples ¶ ↑
Constrains set_enum
to channel int_enum
by using
#channel:
set_enum.must.channel set_enum
Constrains each pair of set operands in set_enum
to at most
share one element. Also constrains each set to have size 17. Uses #at_most_share_one_element.
set_enum.must.at_most_share_one_element(:size => 17)
Public Instance Methods
Constrains this set enum to channel int_enum_operand
. The i:th
set in the enumeration of set operands is constrained to include the value
of the j:th integer operand.
Neither reification nor negation is supported.
Examples ¶ ↑
# +set_enum+ is constrained to channel +int_enum+. int_enum.must.channel set_enum # This is another way of writing the above. set_enum.must.channel int_enum
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/set_enum/channel.rb, line 16 def channel(enum, options = {}) unless enum.respond_to? :to_int_enum raise TypeError, "Expected integer enum, for #{enum.class}." end if @params[:negate] raise Gecode::MissingConstraintError, 'A negated channel constraint ' + 'is not implemented.' end if options.has_key? :reify raise ArgumentError, 'The channel constraints does not support the ' + 'reification option.' end @params.update(Gecode::Set::Util.decode_options(options)) @params.update(:rhs => enum) @model.add_constraint Channel::IntEnumChannelConstraint.new(@model, @params) end
Public Class Methods
Raises TypeError unless the left hand side is a set enum operand.
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/set_enum_constraints.rb, line 71 def initialize(model, params) super unless params[:lhs].respond_to? :to_set_enum raise TypeError, 'Must have set enum operand as left hand side.' end end