Class: Gecode::Constraints::SetEnum::Distinct::AtMostOneConstraint

Inherits:
Constraint
  • Object
show all
Defined in:
lib/gecoder/interface/constraints/set_enum/distinct.rb

Overview

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)

Instance Method Summary collapse

Methods inherited from Constraint

#initialize

Constructor Details

This class inherits a constructor from Gecode::Constraints::Constraint

Instance Method Details

#postObject



74
75
76
77
# File 'lib/gecoder/interface/constraints/set_enum/distinct.rb', line 74

def post
  sets, size = @params.values_at(:lhs, :size)
  Gecode::Raw::atmostOne(@model.active_space, sets.to_set_var_array, size)
end