lib/gecoder/interface/constraints/set_enum/distinct.rb in gecoder-0.7.0 vs lib/gecoder/interface/constraints/set_enum/distinct.rb in gecoder-0.7.1

- old
+ new

@@ -39,19 +39,38 @@ @model, @params.update(options)) end end # A module that gathers the classes and modules used in distinct constraints. - module Distinct - # Describes a set distinct constraint. + module Distinct #:nodoc: + # Describes a set distinct constraint, which constrains all set variables + # in the enumeration to be distinct and of a specified size. Providing a + # size is not optional. + # + # Neither negation nor reification is supported. + # + # == Examples + # + # # All set variables in +sets+ must have cardinality 4 and be different. + # sets.must_be.distinct(:size => 4) class DistinctConstraint < Gecode::Constraints::Constraint def post sets, size = @params.values_at(:lhs, :size) Gecode::Raw::distinct(@model.active_space, sets.to_set_var_array, size) end end - # Describes an at most one set constraint. + # Describes an at most one constraint, which constrains all pairs of set + # variables in the enumeration to at most have one element in common and be + # of a specified size. Providing a size is not optional. + # + # Neither negation nor reification is supported. + # + # == Examples + # + # # All set variables in +sets+ must have cardinality 17 and no pair may + # # have more than one element in common. + # sets.must.at_most_share_one_element(:size => 17) class AtMostOneConstraint < Gecode::Constraints::Constraint def post sets, size = @params.values_at(:lhs, :size) Gecode::Raw::atmostOne(@model.active_space, sets.to_set_var_array, size) end \ No newline at end of file