Class: Gecode::Constraints::SetEnum::Selection::IntersectionExpressionStub
- Inherits:
-
Gecode::Constraints::Set::CompositeStub
- Object
- ExpressionStub
- CompositeStub
- Gecode::Constraints::Set::CompositeStub
- Gecode::Constraints::SetEnum::Selection::IntersectionExpressionStub
- Defined in:
- lib/gecoder/interface/constraints/set_enum/selection.rb
Overview
Describes a CompositeStub for the set intersection selection constraint, which constrains the intersection of sets located at the positions specified by a set variable in an enumeration of set variables.
Optionally a universe may also be specified.
Examples
# The sets in the enumeration set variable +sets+ located at the positions
# described by the set variable +selected_sets+ must have an intersection
# that's a superset of [0,4,17].
sets[selected_sets].intersection.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 an intersection
# that's disjoint with the set variable +set+.
sets[selected_sets].intersection.must_be.disjoint_with set
# The sets in the enumeration set variable +sets+ located at the positions
# described by the set variable +selected_sets+ must have an intersection
# that's disjoint with the set variable +set+ inside the universe 0..17.
sets[selected_sets].intersection(:with => 0..17).must_be.disjoint_with set
# The sets in the enumeration set variable +sets+ located at the positions
# described by the set variable +selected_sets+ must have an intersection
# that's disjoint with the set variable +set+ inside the universe
# described by the set variable +universe+.
sets[selected_sets].intersection(:with => universe).must_be.disjoint_with set
# The same as above but reified with the boolean variable
# +intersection_is_disjoint+.
sets[selected_sets].intersection(:with => universe).must_be.disjoint_with(
set, :reifty => intersection_is_disjoin)
Instance Method Summary collapse
Methods inherited from Gecode::Constraints::Set::CompositeStub
Methods inherited from CompositeStub
Methods included from LeftHandSideMethods
Methods inherited from ExpressionStub
Constructor Details
This class inherits a constructor from Gecode::Constraints::Set::CompositeStub
Instance Method Details
#constrain_equal(variable, params, constrain) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/gecoder/interface/constraints/set_enum/selection.rb', line 184 def constrain_equal(variable, params, constrain) enum, indices, universe = @params.values_at(:lhs, :indices, :universe) # We can't do any useful constraining here since the empty intersection # is the universe. if universe.nil? Gecode::Raw::selectInter(@model.active_space, enum.to_set_var_array, indices.bind, variable.bind) else Gecode::Raw::selectInterIn(@model.active_space, enum.to_set_var_array, indices.bind, variable.bind, Gecode::Constraints::Util.constant_set_to_int_set(universe)) end end |