Class: Gecode::Constraints::SetEnum::Selection::SelectExpressionStub

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

Overview

Describes a CompositeStub for the set select constraint, which constrains the set in a position specified by an integer variable in an enumeration of set variable.

Examples

# The set at the position described by the integer variable 
# +singleton_zero_position+ in the enumeration +sets+ of set variables 
# must equal [0].
sets[singleton_zero_position].must == 0

# The set at the position described by the integer variable +position+ in 
# the enumeration +sets+ of set variables must be a subset of +set+.
sets[position].must_be.subset_of set

# The same as above, but reified with the boolean variable +bool+.
sets[position].must_be.subset_of(set, :reify => bool)

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



106
107
108
109
110
111
112
113
114
# File 'lib/gecoder/interface/constraints/set_enum/selection.rb', line 106

def constrain_equal(variable, params, constrain)
  enum, index = @params.values_at(:lhs, :index)
  if constrain
    variable.must_be.subset_of enum.upper_bound_range
  end

  Gecode::Raw::selectSet(@model.active_space, enum.to_set_var_array, 
    index.bind, variable.bind)
end