Class: Gecode::Constraints::Set::Cardinality::SizeExpressionStub
- Inherits:
-
CompositeStub
- Object
- ExpressionStub
- CompositeStub
- CompositeStub
- Gecode::Constraints::Set::Cardinality::SizeExpressionStub
- Defined in:
- lib/gecoder/interface/constraints/set/cardinality.rb
Overview
Describes a CompositeStub for the cardianlity constraint which constrains the cardianlity (size) of a set.
Example
# The size of +set+ must be within 1..17
set.size.must_be.in 1..17
# The size must equal the integer variable +size+.
set.size.must == size
# The size must not be larger than 17
set.size.must_not > 17
# We reify the above with a boolean variable called +is_not_large+ and
# select the strength +domain+.
set.size.must_not_be.larger_than(17, :reify => is_not_large,
:strength => :domain)
Instance Method Summary collapse
Methods inherited from CompositeStub
Methods inherited from CompositeStub
Methods included from LeftHandSideMethods
Methods inherited from ExpressionStub
Constructor Details
This class inherits a constructor from Gecode::Constraints::Set::Cardinality::CompositeStub
Instance Method Details
#constrain_equal(variable, params, constrain) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/gecoder/interface/constraints/set/cardinality.rb', line 65 def constrain_equal(variable, params, constrain) lhs = @params[:lhs] if constrain variable.must_be.in lhs.lower_bound.size..lhs.upper_bound.size end Gecode::Raw::cardinality(@model.active_space, lhs.bind, variable.bind) end |