Class: Gecode::Constraints::SetEnum::Selection::UnionExpressionStub

Inherits:
Gecode::Constraints::Set::CompositeStub show all
Defined in:
lib/gecoder/interface/constraints/set_enum/selection.rb

Overview

Describes a CompositeStub for the set union selection constraint, which constrains the union of sets located at the positions specified by a set variable in an enumeration of set variables.

Examples

# The sets in the enumeration set variable +sets+ located at the positions
# described by the set variable +selected_sets+ must have a union that's
# a superset of [0,4,17]. 
sets[selected_sets].union.must_be.superset_of [0,4,17]

# The sets in the enumeration set variable +sets+ located at the positions
# described by the set variable +selected_sets+ must have a union that's
# disjoint with the set variable +set+.
sets[selected_sets].union.must_be.disjoint_with set

# The same as above but reified with the boolean variable 
# +union_is_disjoint+.
sets[selected_sets].union.must_be.disjoint_with(set, 
  :reify => union_is_disjoin)

Instance Method Summary collapse

Methods inherited from Gecode::Constraints::Set::CompositeStub

#initialize

Methods inherited from CompositeStub

#initialize

Methods included from LeftHandSideMethods

#must, #must_not

Methods inherited from ExpressionStub

#initialize

Constructor Details

This class inherits a constructor from Gecode::Constraints::Set::CompositeStub

Instance Method Details

#constrain_equal(variable, params, constrain) ⇒ Object



138
139
140
141
142
143
144
145
146
# File 'lib/gecoder/interface/constraints/set_enum/selection.rb', line 138

def constrain_equal(variable, params, constrain)
  enum, indices = @params.values_at(:lhs, :indices)
  if constrain
    variable.must_be.subset_of enum.upper_bound_range
  end
  
  Gecode::Raw::selectUnion(@model.active_space, enum.to_set_var_array,
    indices.bind, variable.bind)
end